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.uid = data.Id;
res.metadata.name = data.Name; res.metadata.name = data.Name;
res.metadata.namespace = data.Namespace; res.metadata.namespace = data.Namespace;
res.metadata.labels[KubernetesPortainerConfigurationOwnerLabel] = data.ConfigurationOwner;
res.data = data.Data; res.data = data.Data;
return res; return res;
} }

View File

@ -87,21 +87,24 @@ class KubernetesConfigurationService {
/** /**
* UPDATE * UPDATE
*/ */
async updateAsync(formValues) { async updateAsync(formValues, configuration) {
try { try {
if (formValues.Type === KubernetesConfigurationTypes.CONFIGMAP) { if (formValues.Type === KubernetesConfigurationTypes.CONFIGMAP) {
const configMap = KubernetesConfigMapConverter.configurationFormValuesToConfigMap(formValues); const configMap = KubernetesConfigMapConverter.configurationFormValuesToConfigMap(formValues);
configMap.ConfigurationOwner = configuration.ConfigurationOwner;
await this.KubernetesConfigMapService.update(configMap); await this.KubernetesConfigMapService.update(configMap);
} else { } else {
const secret = KubernetesSecretConverter.configurationFormValuesToSecret(formValues); const secret = KubernetesSecretConverter.configurationFormValuesToSecret(formValues);
secret.ConfigurationOwner = configuration.ConfigurationOwner;
await this.KubernetesSecretService.update(secret); await this.KubernetesSecretService.update(secret);
} }
} catch (err) { } catch (err) {
throw 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 } { reload: true }
); );
} else { } else {
await this.KubernetesConfigurationService.update(this.formValues); await this.KubernetesConfigurationService.update(this.formValues, this.configuration);
this.Notifications.success('Configuration succesfully updated'); this.Notifications.success('Configuration succesfully updated');
this.$state.reload(); this.$state.reload();
} }