Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Longhorn CSI storage driver to be selected #12682

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions cypress/e2e/po/components/workloads/pod-storage.po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import ComponentPo from '@/cypress/e2e/po/components/component.po';
import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po';
import ButtonDropdownPo from '@/cypress/e2e/po/components/button-dropdown.po';
import SelectPo from '@/cypress/e2e/po/components/select.po';

class WorkloadVolumePo extends ComponentPo {
yamlEditor(): CodeMirrorPo {
Expand All @@ -15,4 +17,12 @@ export default class WorkloadPodStoragePo extends ComponentPo {
nthVolumeComponent(n: number) {
return new WorkloadVolumePo(`[data-testid="volume-component-${ n }"]`);
}

addVolumeButton() : ButtonDropdownPo {
return new ButtonDropdownPo('[data-testid="dropdown-button-storage-volume"]');
}

driverInput(): SelectPo {
return new SelectPo('[data-testid="workload-storage-driver"]');
}
}
25 changes: 24 additions & 1 deletion cypress/e2e/tests/pages/explorer2/workloads/deployments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Cluster Explorer', () => {
deploymentEditConfigPage.horizontalTabs().clickTabWithSelector('li#pod');

// open the pod storage tab
deploymentEditConfigPage.podTabs().clickTabWithSelector('li#storage');
deploymentEditConfigPage.podTabs().clickTabWithSelector('li#storage-pod');

// check that there is a component rendered for each workload volume and that that component has rendered some information about the volume
deploymentEditConfigPage.podStorage().nthVolumeComponent(0).yamlEditor().value()
Expand Down Expand Up @@ -151,6 +151,29 @@ describe('Cluster Explorer', () => {
expect(response.body.spec.template.spec.containers[0].volumeMounts).to.eq(undefined);
});
});

it('should be able to select Pod CSI storage option', () => {
deploymentsCreatePage.goTo();
deploymentsCreatePage.waitForPage();

// open the pod tab
deploymentsCreatePage.horizontalTabs().clickTabWithSelector('li#pod');

// open the pod storage tab
deploymentsCreatePage.podTabs().clickTabWithSelector('li#storage-pod');

deploymentsCreatePage.podStorage().addVolumeButton().toggle();
deploymentsCreatePage.podStorage().addVolumeButton().getOptions().should('contain', 'CSI');

deploymentsCreatePage.podStorage().addVolumeButton().clickOptionWithLabel('CSI');

// open the driver input
deploymentsCreatePage.podStorage().driverInput().toggle();
deploymentsCreatePage.podStorage().driverInput().getOptions().should('contain', 'Longhorn');

// select the Longhorn option from the driver input
deploymentsCreatePage.podStorage().driverInput().clickOptionWithLabel('Longhorn');
});
});

describe('List: Deployments', () => {
Expand Down
2 changes: 1 addition & 1 deletion shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6548,7 +6548,7 @@ workload:
managed: Managed
shared: Shared
drivers:
driver.longhorn.io: Longhorn
driver-longhorn-io: Longhorn
fsType: Filesystem Type
shareName: Share Name
secretName: Secret Name
Expand Down
2 changes: 1 addition & 1 deletion shell/edit/workload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export default {
>
<Tab
:label="t('workload.storage.title')"
name="storage"
name="storage-pod"
:weight="tabWeightMap['storage']"
@active="$refs.storage.refresh()"
>
Expand Down
30 changes: 29 additions & 1 deletion shell/edit/workload/storage/csi/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ export default {

...mapGetters({ t: 'i18n/t' })
},

methods: {
/**
* Retrieves the label for a given option
* @param option The option for which to retrieve the label. option can be
* either a string or an object. If it is an object, is should have a `label`
* property associated with it.
*/
getOptionLabel(option) {
if (typeof option === 'string') {
return this.getOptionLabelString(option);
}

const { label } = option;

return this.getOptionLabelString(label);
},
/**
* Translates a given key into a localized string.
* @param key The key to be translated.
*/
getOptionLabelString(key) {
// Periods are replaced with `-` to prevent conflict with the default key
// separator.
return this.t(`workload.storage.csi.drivers.'${ key.replaceAll('.', '-') }'`);
}
}
};
</script>

Expand Down Expand Up @@ -71,10 +98,11 @@ export default {
<div class="col span-6">
<LabeledSelect
v-model:value="value.csi.driver"
data-testid="workload-storage-driver"
:mode="mode"
:label="t('workload.storage.driver')"
:options="driverOpts"
:get-option-label="opt=>t(`workload.storage.csi.drivers.'${opt}'`)"
:get-option-label="getOptionLabel"
:required="true"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions shell/edit/workload/storage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export default {
:button-label="t('workload.storage.addVolume')"
:dropdown-options="volumeTypeOptions"
size="sm"
data-testid="dropdown-button-storage-volume"
@click-action="e=>addVolume(e.value)"
/>
</template>
Expand Down
Loading