Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions shell/edit/persistentvolume/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import InfoBox from '@shell/components/InfoBox';
import { mapFeature, UNSUPPORTED_STORAGE_DRIVERS } from '@shell/store/features';
import ResourceManager from '@shell/mixins/resource-manager';

const DEFAULT_ACCESS_MODES = ['ReadWriteOnce'];

export default {
name: 'PersistentVolume',
inheritAttrs: false,
Expand Down Expand Up @@ -64,36 +66,42 @@ export default {
},

data() {
const NONE_OPTION = {
label: this.t('generic.none'),
value: ''
return {
secondaryResourceData: this.secondaryResourceDataConfig(),
storageClassOptions: [],
currentClaim: null,
plugin: '',
initialNodeAffinity: null,
NODE,
};
const defaultAccessModes = ['ReadWriteOnce'];
},

created() {
this.value['spec'] = this.value.spec || {};
this.value.spec['accessModes'] = this.value.spec.accessModes || defaultAccessModes;
this.value.spec['accessModes'] = this.value.spec.accessModes || DEFAULT_ACCESS_MODES;
this.value.spec['capacity'] = this.value.spec.capacity || {};
this.value.spec.capacity['storage'] = this.value.spec.capacity.storage || '10Gi';
this.value.spec['storageClassName'] = this.value.spec.storageClassName || NONE_OPTION.value;
this.value.spec['storageClassName'] = this.value.spec.storageClassName || this.noneOption.value;

const foundPlugin = this.value.isLonghorn ? LONGHORN_PLUGIN : VOLUME_PLUGINS.find((plugin) => this.value.spec[plugin.value]);
const plugin = (foundPlugin || VOLUME_PLUGINS[0]).value;

return {
secondaryResourceData: this.secondaryResourceDataConfig(),
storageClassOptions: [],
currentClaim: null,
plugin,
NONE_OPTION,
NODE,
initialNodeAffinity: clone(this.value.spec.nodeAffinity),
};
this.plugin = (foundPlugin || VOLUME_PLUGINS[0]).value;
this.initialNodeAffinity = clone(this.value.spec.nodeAffinity);

this.registerBeforeHook(this.willSave, 'willSave');
},

computed: {
showUnsupportedStorage: mapFeature(UNSUPPORTED_STORAGE_DRIVERS),
...mapGetters(['currentProduct', 'currentCluster']),

noneOption() {
return {
label: this.t('generic.none'),
value: ''
};
},

readWriteOnce: {
get() {
return this.value.spec.accessModes.includes('ReadWriteOnce');
Expand Down Expand Up @@ -149,10 +157,6 @@ export default {
}
},

created() {
this.registerBeforeHook(this.willSave, 'willSave');
},

methods: {
secondaryResourceDataConfig() {
return {
Expand All @@ -168,7 +172,7 @@ export default {
value: s.metadata.name
}));

storageClassOptions.unshift(this.NONE_OPTION);
storageClassOptions.unshift(this.noneOption);

return storageClassOptions;
}
Expand All @@ -194,7 +198,7 @@ export default {
return require(`./plugins/${ name }`).default;
},
willSave() {
if (this.value.spec.storageClassName === this.NONE_OPTION.value) {
if (this.value.spec.storageClassName === this.noneOption.value) {
this.value.spec['storageClassName'] = null;
}

Expand Down
27 changes: 13 additions & 14 deletions shell/edit/persistentvolume/plugins/awsElasticBlockStore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ export default {
required: true,
},
},
data() {
created() {
this.value.spec['awsElasticBlockStore'] = this.value.spec.awsElasticBlockStore || {};
this.value.spec.awsElasticBlockStore['readOnly'] = this.value.spec.awsElasticBlockStore.readOnly || false;
this.value.spec.awsElasticBlockStore['partition'] = this.value.spec.awsElasticBlockStore.partition || 0;

const readOnlyOptions = [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];

return { readOnlyOptions };
},
computed: {
readOnlyOptions() {
return [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];
},
partition: {
get() {
return this.value.spec.awsElasticBlockStore.partition;
Expand Down
97 changes: 49 additions & 48 deletions shell/edit/persistentvolume/plugins/azureDisk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,58 @@ export default {
required: true,
},
},
data() {
const readOnlyOptions = [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];

const kindOptions = [
{
label: this.t('persistentVolume.azureDisk.kind.dedicated'),
value: 'Dedicated'
},
{
label: this.t('persistentVolume.azureDisk.kind.managed'),
value: 'Managed'
},
{
label: this.t('persistentVolume.azureDisk.kind.shared'),
value: 'Shared'
}
];

const cachingModeOptions = [
{
label: this.t('persistentVolume.azureDisk.cachingMode.none'),
value: 'None'
},
{
label: this.t('persistentVolume.azureDisk.cachingMode.readOnly'),
value: 'ReadOnly'
},
{
label: this.t('persistentVolume.azureDisk.cachingMode.readWrite'),
value: 'ReadWrite'
}
];

created() {
this.value.spec['azureDisk'] = this.value.spec.azureDisk || {};
this.value.spec.azureDisk['readOnly'] = this.value.spec.azureDisk.readOnly || false;
this.value.spec.azureDisk['cachingMode'] = this.value.spec.azureDisk.cachingMode || cachingModeOptions[0].value;
this.value.spec.azureDisk['kind'] = this.value.spec.azureDisk.kind || kindOptions[2].value;

return {
kindOptions, readOnlyOptions, cachingModeOptions
};
this.value.spec.azureDisk['cachingMode'] = this.value.spec.azureDisk.cachingMode || this.cachingModeOptions[0].value;
this.value.spec.azureDisk['kind'] = this.value.spec.azureDisk.kind || this.kindOptions[2].value;
},
computed: {
readOnlyOptions() {
return [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];
},
kindOptions() {
return [
{
label: this.t('persistentVolume.azureDisk.kind.dedicated'),
value: 'Dedicated'
},
{
label: this.t('persistentVolume.azureDisk.kind.managed'),
value: 'Managed'
},
{
label: this.t('persistentVolume.azureDisk.kind.shared'),
value: 'Shared'
}
];
},
cachingModeOptions() {
return [
{
label: this.t('persistentVolume.azureDisk.cachingMode.none'),
value: 'None'
},
{
label: this.t('persistentVolume.azureDisk.cachingMode.readOnly'),
value: 'ReadOnly'
},
{
label: this.t('persistentVolume.azureDisk.cachingMode.readWrite'),
value: 'ReadWrite'
}
];
}
}
};
</script>

Expand Down
29 changes: 15 additions & 14 deletions shell/edit/persistentvolume/plugins/azureFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ export default {
required: true,
},
},
data() {
created() {
this.value.spec['azureFile'] = this.value.spec.azureFile || {};
this.value.spec.azureFile['readOnly'] = this.value.spec.azureFile.readOnly || false;

const readOnlyOptions = [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];

return { readOnlyOptions };
},
computed: {
readOnlyOptions() {
return [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];
}
}
};
</script>

Expand Down
29 changes: 15 additions & 14 deletions shell/edit/persistentvolume/plugins/cephfs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@ export default {
required: true,
},
},
data() {
const readOnlyOptions = [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];

created() {
this.value.spec['cephfs'] = this.value.spec.cephfs || {};
this.value.spec.cephfs['readOnly'] = this.value.spec.cephfs.readOnly || false;
this.value.spec.cephfs['secretRef'] = this.value.spec.cephfs.secretRef || {};

return { readOnlyOptions };
},
computed: {
readOnlyOptions() {
return [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];
}
}
};
</script>

Expand Down
29 changes: 15 additions & 14 deletions shell/edit/persistentvolume/plugins/cinder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@ export default {
required: true,
},
},
data() {
const readOnlyOptions = [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];

created() {
this.value.spec['cinder'] = this.value.spec.cinder || {};
this.value.spec.cinder['readOnly'] = this.value.spec.cinder.readOnly || false;
this.value.spec.cinder['secretRef'] = this.value.spec.cinder.secretRef || {};

return { readOnlyOptions };
},
computed: {
readOnlyOptions() {
return [
{
label: this.t('generic.yes'),
value: true
},
{
label: this.t('generic.no'),
value: false
}
];
}
}
};
</script>

Expand Down
Loading