refactor: fallback to longhorn if not default storage class

Signed-off-by: andy.lee <andy.lee@suse.com>
(cherry picked from commit 6e9350e63d1d90ec82cedca885a932380fe249d0)
This commit is contained in:
andy.lee 2025-01-17 14:57:39 +08:00 committed by Mergify
parent 3a5ead3c2c
commit fb8a81fd0f

View File

@ -61,7 +61,6 @@ export default {
images: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.IMAGE }), images: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.IMAGE }),
storageClasses: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }), storageClasses: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
}); });
this['storageClassName'] = this.storageClassName || this.defaultStorageClassName(); this['storageClassName'] = this.storageClassName || this.defaultStorageClassName();
this.images = this.$store.getters[`${ inStore }/all`](HCI.IMAGE); this.images = this.$store.getters[`${ inStore }/all`](HCI.IMAGE);
@ -253,7 +252,7 @@ export default {
}, },
'value.spec.securityParameters.cryptoOperation'() { 'value.spec.securityParameters.cryptoOperation'() {
if (this.value.spec?.securityParameters?.cryptoOperation === ENCRYPT) { if (this.value.spec?.securityParameters?.cryptoOperation === ENCRYPT) {
this.storageClassName = this.encryptedStorageClasses[0]?.name || LONGHORN; this.storageClassName = this.encryptedStorageClasses[0]?.name || '';
} else { // URL / FILE / DECRYPT should use default storage class } else { // URL / FILE / DECRYPT should use default storage class
this.storageClassName = this.defaultStorageClassName(); this.storageClassName = this.defaultStorageClassName();
} }
@ -410,6 +409,10 @@ export default {
const inStore = this.$store.getters['currentProduct'].inStore; const inStore = this.$store.getters['currentProduct'].inStore;
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find((s) => s.isDefault); const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find((s) => s.isDefault);
if (!defaultStorage) {
return LONGHORN;
}
// if default sc is encrypted, use longhorn as default // if default sc is encrypted, use longhorn as default
return defaultStorage.isEncrypted ? LONGHORN : defaultStorage?.metadata?.name; return defaultStorage.isEncrypted ? LONGHORN : defaultStorage?.metadata?.name;
} }