clean secret name if change namespace

This commit is contained in:
andy.lee 2024-09-13 21:55:38 +08:00 committed by Francesco Torchia
parent 7f72fdf2c5
commit d06f0ec989
No known key found for this signature in database
GPG Key ID: E6D011B7415D4393

View File

@ -9,6 +9,7 @@ import { CSI_SECRETS } from '@pkg/harvester/config/harvester-map';
import { clone } from '@shell/utils/object'; import { clone } from '@shell/utils/object';
import { uniq } from '@shell/utils/array'; import { uniq } from '@shell/utils/array';
// UI components for Longhorn storage class parameters
const DEFAULT_PARAMETERS = [ const DEFAULT_PARAMETERS = [
'numberOfReplicas', 'numberOfReplicas',
'staleReplicaTimeout', 'staleReplicaTimeout',
@ -28,6 +29,8 @@ const {
} = CSI_SECRETS; } = CSI_SECRETS;
export default { export default {
name: 'DriverLonghornIO',
components: { components: {
KeyValue, KeyValue,
LabeledSelect, LabeledSelect,
@ -57,7 +60,6 @@ export default {
this.secrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET }); this.secrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
this.namespaces = allNamespaces.filter(ns => ns.isSystem === false).map(ns => ns.id); // only show non-system namespaces to user to select this.namespaces = allNamespaces.filter(ns => ns.isSystem === false).map(ns => ns.id); // only show non-system namespaces to user to select
}, },
data() { data() {
if (this.realMode === _CREATE) { if (this.realMode === _CREATE) {
this.value['parameters'] = { this.value['parameters'] = {
@ -75,7 +77,16 @@ export default {
namespaces: [], namespaces: [],
}; };
}, },
watch: {
secretNamespace() {
this.$set(this.value, 'parameters', {
...this.value.parameters,
[CSI_PROVISIONER_SECRET_NAME]: '',
[CSI_NODE_PUBLISH_SECRET_NAME]: '',
[CSI_NODE_STAGE_SECRET_NAME]: ''
});
}
},
computed: { computed: {
longhornNodes() { longhornNodes() {
const inStore = this.$store.getters['currentProduct'].inStore; const inStore = this.$store.getters['currentProduct'].inStore;
@ -143,7 +154,11 @@ export default {
get() { get() {
const parameters = clone(this.value?.parameters) || {}; const parameters = clone(this.value?.parameters) || {};
DEFAULT_PARAMETERS.map((key) => { DEFAULT_PARAMETERS.forEach((key) => {
delete parameters[key];
});
Object.values(CSI_SECRETS).forEach((key) => {
delete parameters[key]; delete parameters[key];
}); });