Skip to content

Commit

Permalink
Rebase driver.longhorn.io
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Sep 24, 2024
1 parent 281633a commit 0cecf90
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { clone } from '@shell/utils/object';
import { uniq } from '@shell/utils/array';
import { ENGINE_VERSION_V1 } from '../index.vue';
// UI components for Longhorn storage class parameters
const DEFAULT_PARAMETERS = [
'numberOfReplicas',
'staleReplicaTimeout',
'diskSelector',
'nodeSelector',
'migratable',
'encrypted',
'engineVersion',
];
Expand All @@ -29,7 +31,7 @@ const {
} = CSI_SECRETS;
export default {
name: 'DriverLonghornIO',
name: 'DriverLonghornIOV1',
components: {
KeyValue,
Expand Down Expand Up @@ -70,12 +72,13 @@ export default {
staleReplicaTimeout: '30',
diskSelector: null,
nodeSelector: null,
encrypted: 'false',
migratable: 'true',
engineVersion: ENGINE_VERSION_V1
});
}
return {};
return { secrets: [] };
},
computed: {
longhornNodes() {
Expand Down Expand Up @@ -327,7 +330,6 @@ export default {
:label="t('harvester.storage.secret')"
:options="secretOptions"
:mode="mode"
:options="migratableOptions"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,36 @@ import KeyValue from '@shell/components/form/KeyValue';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { LabeledInput } from '@components/Form/LabeledInput';
import RadioGroup from '@components/Form/Radio/RadioGroup';
import { SECRET, NAMESPACE, LONGHORN } from '@shell/config/types';
import { _CREATE, _VIEW } from '@shell/config/query-params';
import { LONGHORN } from '@shell/config/types';
import { CSI_SECRETS } from '@pkg/harvester/config/harvester-map';
import { clone } from '@shell/utils/object';
import { uniq } from '@shell/utils/array';
import { ENGINE_VERSION_V2 } from '../index.vue';
// UI components for Longhorn storage class parameters
const DEFAULT_PARAMETERS = [
'numberOfReplicas',
'staleReplicaTimeout',
'diskSelector',
'nodeSelector',
'migratable',
'encrypted',
'engineVersion',
];
const {
CSI_PROVISIONER_SECRET_NAME,
CSI_PROVISIONER_SECRET_NAMESPACE,
CSI_NODE_PUBLISH_SECRET_NAME,
CSI_NODE_PUBLISH_SECRET_NAMESPACE,
CSI_NODE_STAGE_SECRET_NAME,
CSI_NODE_STAGE_SECRET_NAMESPACE
} = CSI_SECRETS;
export default {
name: 'DriverLonghornIOV2',
components: {
KeyValue,
LabeledSelect,
Expand All @@ -42,21 +55,31 @@ export default {
},
},
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
await this.$store.dispatch(`${ inStore }/findAll`, { type: NAMESPACE });
const allSecrets = await this.$store.dispatch(`${ inStore }/findAll`, { type: SECRET });
// only show non-system secret to user to select
this.secrets = allSecrets.filter(secret => secret.isSystem === false);
},
data() {
if (this.realMode === _CREATE) {
this.$set(this.value, 'parameters', {
numberOfReplicas: '3',
staleReplicaTimeout: '30',
diskSelector: null,
nodeSelector: null,
encrypted: 'false',
migratable: 'false',
engineVersion: ENGINE_VERSION_V2
});
}
return {};
return { secrets: [] };
},
computed: {
longhornNodes() {
const inStore = this.$store.getters['currentProduct'].inStore;
Expand Down Expand Up @@ -100,11 +123,29 @@ export default {
}];
},
secretOptions() {
return this.secrets.map(secret => secret.id);
},
volumeEncryptionOptions() {
return [{
label: this.t('generic.yes'),
value: 'true'
}, {
label: this.t('generic.no'),
value: 'false'
}];
},
parameters: {
get() {
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];
});
Expand All @@ -116,6 +157,46 @@ export default {
}
},
volumeEncryption: {
set(neu) {
this.$set(this.value, 'parameters', {
...this.value.parameters,
encrypted: neu
});
},
get() {
return this.value?.parameters?.encrypted || 'false';
}
},
secret: {
get() {
const selectedNs = this.value.parameters[CSI_PROVISIONER_SECRET_NAMESPACE];
const selectedName = this.value.parameters[CSI_PROVISIONER_SECRET_NAME];
if (selectedNs && selectedName) {
return `${ selectedNs }/${ selectedName }`;
}
return '';
},
set(selectedSecret) {
const [namespace, name] = selectedSecret.split('/');
this.$set(this.value, 'parameters', {
...this.value.parameters,
[CSI_PROVISIONER_SECRET_NAME]: name,
[CSI_NODE_PUBLISH_SECRET_NAME]: name,
[CSI_NODE_STAGE_SECRET_NAME]: name,
[CSI_PROVISIONER_SECRET_NAMESPACE]: namespace,
[CSI_NODE_PUBLISH_SECRET_NAMESPACE]: namespace,
[CSI_NODE_STAGE_SECRET_NAMESPACE]: namespace
});
}
},
nodeSelector: {
get() {
const nodeSelector = this.value?.parameters?.nodeSelector;
Expand Down Expand Up @@ -224,15 +305,32 @@ export default {
</LabeledSelect>
</div>
</div>
<div class="row mt-10">
<div class="row mt-20">
<RadioGroup
v-model="value.parameters.migratable"
name="layer3NetworkMode"
:label="t('harvester.storage.parameters.migratable.label')"
:mode="mode"
:options="migratableOptions"
:disabled="true"
/>
</div>
<div class="row mt-20">
<RadioGroup
v-model="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">
<RadioGroup
v-model="value.parameters.migratable"
name="layer3NetworkMode"
:label="t('harvester.storage.parameters.migratable.label')"
<LabeledSelect
v-model="secret"
:label="t('harvester.storage.secret')"
:options="secretOptions"
:mode="mode"
:options="migratableOptions"
:disabled="true"
/>
</div>
</div>
Expand Down

0 comments on commit 0cecf90

Please sign in to comment.