fix: do not inherit template secret when creating new VM (#643)

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee 2025-12-10 17:12:56 +08:00 committed by GitHub
parent b03fffbc30
commit 6c27a46274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -96,7 +96,6 @@ export default {
templateVersionId: '',
namePrefix: '',
isSingle: true,
useTemplate: false,
isOpen: false,
hostname,
isRestartImmediately,

View File

@ -142,6 +142,7 @@ export default {
showYaml: false,
spec: null,
osType: 'linux',
useTemplate: false,
sshKey: [],
maintenanceStrategies,
maintenanceStrategy: 'Migrate',
@ -273,7 +274,7 @@ export default {
needNewSecret() {
// When creating a template it is always necessary to create a new secret.
return this.showYaml ? false : this.resourceType === HCI.VM_VERSION || this.isCreate;
return this.isCreate || this.showYaml ? false : this.resourceType === HCI.VM_VERSION;
},
defaultTerminationSetting() {
@ -1647,7 +1648,8 @@ export default {
secretRef: {
handler(secret) {
if (secret && this.resourceType !== HCI.BACKUP && this.resourceType !== HCI.VM) {
// we should not inherit the secret if it's from VM template.
if (secret && this.resourceType !== HCI.BACKUP && !this.useTemplate) {
this.secretName = secret?.metadata.name;
}
},