fix(k8s/configurations): fix an issue with configuration ownership

pull/4214/head
Anthony Lapenna 2020-08-15 12:42:04 +12:00
parent 7ad06b3be5
commit 46762f3e67
3 changed files with 8 additions and 4 deletions

View File

@ -52,6 +52,7 @@ class KubernetesConfigMapConverter {
res.metadata.uid = data.Id;
res.metadata.name = data.Name;
res.metadata.namespace = data.Namespace;
res.metadata.labels[KubernetesPortainerConfigurationOwnerLabel] = data.ConfigurationOwner;
res.data = data.Data;
return res;
}

View File

@ -87,21 +87,24 @@ class KubernetesConfigurationService {
/**
* UPDATE
*/
async updateAsync(formValues) {
async updateAsync(formValues, configuration) {
try {
if (formValues.Type === KubernetesConfigurationTypes.CONFIGMAP) {
const configMap = KubernetesConfigMapConverter.configurationFormValuesToConfigMap(formValues);
configMap.ConfigurationOwner = configuration.ConfigurationOwner;
await this.KubernetesConfigMapService.update(configMap);
} else {
const secret = KubernetesSecretConverter.configurationFormValuesToSecret(formValues);
secret.ConfigurationOwner = configuration.ConfigurationOwner;
await this.KubernetesSecretService.update(secret);
}
} catch (err) {
throw err;
}
}
update(config) {
return this.$async(this.updateAsync, config);
update(formValues, configuration) {
return this.$async(this.updateAsync, formValues, configuration);
}
/**

View File

@ -94,7 +94,7 @@ class KubernetesConfigurationController {
{ reload: true }
);
} else {
await this.KubernetesConfigurationService.update(this.formValues);
await this.KubernetesConfigurationService.update(this.formValues, this.configuration);
this.Notifications.success('Configuration succesfully updated');
this.$state.reload();
}