Skip to content

Commit

Permalink
fix:rename configmapName
Browse files Browse the repository at this point in the history
  • Loading branch information
dyx1234 committed Oct 23, 2024
1 parent 79ae56a commit 9252a93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,8 @@ void setConfigMapKey(String cluster, String namespace) {
configMapKey = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).join(cluster, namespace);
}

public String getConfigMapKey() {
return configMapKey;
}

public String getConfigMapName() {
return configMapName;
}

void setConfigMapName(String appId, boolean syncImmediately) {
//configMapName = ConfigConsts.APOLLO_CONFIG_CACHE + appId;
configMapName = appId;
configMapName = ConfigConsts.APOLLO_CONFIG_CACHE + appId;
// 初始化configmap
this.checkConfigMapName(configMapName);
if (syncImmediately) {
Expand Down Expand Up @@ -274,8 +265,8 @@ public void onRepositoryChange(String namespace, Properties newProperties) {

public void persistConfigMap(Properties properties) {
Transaction transaction = Tracer.newTransaction("Apollo.ConfigService", "persistK8sConfigMap");
transaction.addData("configMapName", configUtil.getAppId());
transaction.addData("k8sNamespace", configUtil.getK8sNamespace());
transaction.addData("configMapName", configMapName);
transaction.addData("k8sNamespace", k8sNamespace);
try {
// Convert properties to a JSON string using Gson
Gson gson = new Gson();
Expand All @@ -284,7 +275,7 @@ public void persistConfigMap(Properties properties) {
data.put(configMapKey, jsonConfig);

// update configmap
kubernetesManager.updateConfigMap(configUtil.getK8sNamespace(), configUtil.getAppId(), data);
kubernetesManager.updateConfigMap(k8sNamespace, configMapName, data);
transaction.setStatus(Transaction.SUCCESS);
} catch (Exception ex) {
ApolloConfigException exception =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ public void tearDown() throws Exception {
// assertEquals(someCluster +"-"+ someNamespace, configmapRepo.getConfigMapKey());
// }
//
// @Test
// public void testSetConfigMapName() {
// K8sConfigMapConfigRepository repo = new K8sConfigMapConfigRepository(someNamespace);
// repo.setConfigMapName(someAppId, false);
// assertEquals(someAppId, repo.getConfigMapName());
// }

@Test(expected = IllegalArgumentException.class)
public void testSetConfigMapNameWithNullAppId() {
Expand Down

0 comments on commit 9252a93

Please sign in to comment.