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

View File

@ -126,16 +126,19 @@ export default {
const hash = {
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 }),
longhornNodes: this.$store.dispatch(`${ inStore }/findAll`, { type: LONGHORN.NODES }),
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 });
}
if (this.value.volumeEncryptionFeatureEnabled) {
hash.secrets = this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
}
await allHash(hash);
},
@ -150,10 +153,6 @@ export default {
return this.isCreate ? _CREATE : _VIEW;
},
longhornV2LVMSupport() {
return this.$store.getters['harvester-common/getFeatureEnabled']('longhornV2LVMSupport');
},
provisioners() {
const out = [];

View File

@ -311,37 +311,39 @@ export default {
</LabeledSelect>
</div>
</div>
<div class="row mt-20">
<RadioGroup
v-model:value="value.parameters.migratable"
name="layer3NetworkMode"
:label="t('harvester.storage.parameters.migratable.label')"
:mode="mode"
: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"
<template v-if="value.volumeEncryptionFeatureEnabled">
<div class="row mt-20">
<RadioGroup
v-model:value="value.parameters.migratable"
name="layer3NetworkMode"
:label="t('harvester.storage.parameters.migratable.label')"
:mode="mode"
:options="migratableOptions"
/>
</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
v-model:value="parameters"
:add-label="t('storageClass.longhorn.addLabel')"

View File

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

View File

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

View File

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

View File

@ -61,4 +61,12 @@ export default class HciStorageClass extends StorageClass {
get isLonghornV2() {
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',
enabled: !this.isEncrypted,
enabled: this.volumeEncryptionFeatureEnabled && !this.isEncrypted,
icon: 'icon icon-lock',
label: this.t('harvester.action.encryptImage'),
disabled: !this.isReady,
},
{
action: 'decryptImage',
enabled: this.isEncrypted,
enabled: this.volumeEncryptionFeatureEnabled && this.isEncrypted,
icon: 'icon icon-unlock',
label: this.t('harvester.action.decryptImage'),
disabled: !this.isReady,
@ -381,6 +381,10 @@ export default class HciVmImage extends HarvesterResource {
];
}
get volumeEncryptionFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('volumeEncryption');
}
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');
}
get volumeEncryptionFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('volumeEncryption');
}
setInstanceLabels(val) {
if ( !this.spec?.template?.metadata?.labels ) {
set(this, 'spec.template.metadata.labels', {});