Implement volumeEncryption feature flag

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia 2024-11-11 16:05:27 +01:00
parent 780106f32a
commit 48a93f6c9c
No known key found for this signature in database
GPG Key ID: E6D011B7415D4393
9 changed files with 75 additions and 46 deletions

View File

@ -29,10 +29,12 @@ export default {
}, },
async fetch() { async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore; if (this.value.volumeEncryptionFeatureEnabled) {
const inStore = this.$store.getters['currentProduct'].inStore;
this.secrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET }); this.secrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
this.images = await this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.IMAGE }); this.images = await this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.IMAGE });
}
}, },
data() { data() {
@ -104,6 +106,7 @@ export default {
return this.value.encryptionSecret; return this.value.encryptionSecret;
}, },
secretLink() { secretLink() {
return this.secrets.find((sc) => sc.id === this.value.encryptionSecret)?.detailLocation; return this.secrets.find((sc) => sc.id === this.value.encryptionSecret)?.detailLocation;
}, },
@ -198,7 +201,7 @@ export default {
</div> </div>
<div <div
v-if="value.isEncrypted" v-if="value.volumeEncryptionFeatureEnabled && value.isEncrypted"
class="row mb-20" class="row mb-20"
> >
<div class="col span-12"> <div class="col span-12">
@ -224,7 +227,7 @@ export default {
</div> </div>
<div <div
v-if="isEncryptedOrDecrypted" v-if="value.volumeEncryptionFeatureEnabled && isEncryptedOrDecrypted"
class="row mb-20" class="row mb-20"
> >
<div class="col span-12"> <div class="col span-12">

View File

@ -126,16 +126,19 @@ export default {
const hash = { const hash = {
namespaces: this.$store.dispatch(`${ inStore }/findAll`, { type: NAMESPACE }), namespaces: this.$store.dispatch(`${ inStore }/findAll`, { type: NAMESPACE }),
secrets: this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET }),
storages: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }), storages: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
longhornNodes: this.$store.dispatch(`${ inStore }/findAll`, { type: LONGHORN.NODES }), longhornNodes: this.$store.dispatch(`${ inStore }/findAll`, { type: LONGHORN.NODES }),
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }) csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER })
}; };
if (this.longhornV2LVMSupport) { if (this.value.longhornV2LVMSupport) {
hash.longhornV2DataEngine = this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }); hash.longhornV2DataEngine = this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE });
} }
if (this.value.volumeEncryptionFeatureEnabled) {
hash.secrets = this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
}
await allHash(hash); await allHash(hash);
}, },
@ -150,10 +153,6 @@ export default {
return this.isCreate ? _CREATE : _VIEW; return this.isCreate ? _CREATE : _VIEW;
}, },
longhornV2LVMSupport() {
return this.$store.getters['harvester-common/getFeatureEnabled']('longhornV2LVMSupport');
},
provisioners() { provisioners() {
const out = []; const out = [];

View File

@ -311,37 +311,39 @@ export default {
</LabeledSelect> </LabeledSelect>
</div> </div>
</div> </div>
<div class="row mt-20"> <template v-if="value.volumeEncryptionFeatureEnabled">
<RadioGroup <div class="row mt-20">
v-model:value="value.parameters.migratable" <RadioGroup
name="layer3NetworkMode" v-model:value="value.parameters.migratable"
:label="t('harvester.storage.parameters.migratable.label')" name="layer3NetworkMode"
:mode="mode" :label="t('harvester.storage.parameters.migratable.label')"
:options="migratableOptions"
/>
</div>
<div class="row mt-20">
<RadioGroup
v-model:value="volumeEncryption"
name="volumeEncryption"
:label="t('harvester.storage.volumeEncryption')"
:mode="mode"
:options="volumeEncryptionOptions"
/>
</div>
<div
v-if="value.parameters.encrypted === 'true'"
class="row mt-20"
>
<div class="col span-6">
<LabeledSelect
v-model:value="secret"
:label="t('harvester.storage.secret')"
:options="secretOptions"
:mode="mode" :mode="mode"
:options="migratableOptions"
/> />
</div> </div>
</div> <div class="row mt-20">
<RadioGroup
v-model:value="volumeEncryption"
name="volumeEncryption"
:label="t('harvester.storage.volumeEncryption')"
:mode="mode"
:options="volumeEncryptionOptions"
/>
</div>
<div
v-if="value.parameters.encrypted === 'true'"
class="row mt-20"
>
<div class="col span-6">
<LabeledSelect
v-model:value="secret"
:label="t('harvester.storage.secret')"
:options="secretOptions"
:mode="mode"
/>
</div>
</div>
</template>
<KeyValue <KeyValue
v-model:value="parameters" v-model:value="parameters"
:add-label="t('storageClass.longhorn.addLabel')" :add-label="t('storageClass.longhorn.addLabel')"

View File

@ -127,14 +127,23 @@ export default {
showEditAsYaml() { showEditAsYaml() {
return this.value.spec.sourceType === DOWNLOAD || this.value.spec.sourceType === CLONE; return this.value.spec.sourceType === DOWNLOAD || this.value.spec.sourceType === CLONE;
}, },
radioGroupOptions() { radioGroupOptions() {
if (this.value.volumeEncryptionFeatureEnabled) {
return [
DOWNLOAD,
UPLOAD,
ENCRYPT,
DECRYPT
];
}
return [ return [
DOWNLOAD, DOWNLOAD,
UPLOAD, UPLOAD
ENCRYPT,
DECRYPT
]; ];
}, },
storageClassOptions() { storageClassOptions() {
const inStore = this.$store.getters['currentProduct'].inStore; const inStore = this.$store.getters['currentProduct'].inStore;
const storages = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS); const storages = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS);

View File

@ -315,7 +315,7 @@ export default {
</InputOrDisplay> </InputOrDisplay>
</div> </div>
<div <div
v-if="isView" v-if="value.volumeEncryptionFeatureEnabled && isView"
class="col span-3" class="col span-3"
> >
<LabelValue <LabelValue

View File

@ -284,7 +284,7 @@ export default {
</InputOrDisplay> </InputOrDisplay>
</div> </div>
<div <div
v-if="isView" v-if="value.volumeEncryptionFeatureEnabled && isView"
class="col span-6" class="col span-6"
> >
<LabelValue <LabelValue

View File

@ -61,4 +61,12 @@ export default class HciStorageClass extends StorageClass {
get isLonghornV2() { get isLonghornV2() {
return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === DATA_ENGINE_V2; return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === DATA_ENGINE_V2;
} }
get longhornV2LVMSupport() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('longhornV2LVMSupport');
}
get volumeEncryptionFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('volumeEncryption');
}
} }

View File

@ -59,14 +59,14 @@ export default class HciVmImage extends HarvesterResource {
}, },
{ {
action: 'encryptImage', action: 'encryptImage',
enabled: !this.isEncrypted, enabled: this.volumeEncryptionFeatureEnabled && !this.isEncrypted,
icon: 'icon icon-lock', icon: 'icon icon-lock',
label: this.t('harvester.action.encryptImage'), label: this.t('harvester.action.encryptImage'),
disabled: !this.isReady, disabled: !this.isReady,
}, },
{ {
action: 'decryptImage', action: 'decryptImage',
enabled: this.isEncrypted, enabled: this.volumeEncryptionFeatureEnabled && this.isEncrypted,
icon: 'icon icon-unlock', icon: 'icon icon-unlock',
label: this.t('harvester.action.decryptImage'), label: this.t('harvester.action.decryptImage'),
disabled: !this.isReady, disabled: !this.isReady,
@ -381,6 +381,10 @@ export default class HciVmImage extends HarvesterResource {
]; ];
} }
get volumeEncryptionFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('volumeEncryption');
}
download() { download() {
window.location.href = this.links.download; window.location.href = this.links.download;
} }

View File

@ -1151,6 +1151,10 @@ export default class VirtVm extends HarvesterResource {
return this.$rootGetters['harvester-common/getFeatureEnabled']('schedulingVMBackup'); return this.$rootGetters['harvester-common/getFeatureEnabled']('schedulingVMBackup');
} }
get volumeEncryptionFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('volumeEncryption');
}
setInstanceLabels(val) { setInstanceLabels(val) {
if ( !this.spec?.template?.metadata?.labels ) { if ( !this.spec?.template?.metadata?.labels ) {
set(this, 'spec.template.metadata.labels', {}); set(this, 'spec.template.metadata.labels', {});