Skip to content

Commit

Permalink
Merge pull request #1556 from avivtur/rename-it-vm-rootdisk
Browse files Browse the repository at this point in the history
CNV-32995: Align volume name 'rootdisk' convention
  • Loading branch information
openshift-merge-robot authored Sep 20, 2023
2 parents 97117fe + 6c9f22c commit d14a5da
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/utils/components/CloneTemplateModal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
V1beta1DataVolumeSourcePVC,
V1beta1DataVolumeSpec,
} from '@kubevirt-ui/kubevirt-api/kubevirt';
import { ROOTDISK } from '@kubevirt-utils/constants/constants';
import { getTemplateVirtualMachineObject } from '@kubevirt-utils/resources/template';
import { getDataVolumeTemplates, getVolumes } from '@kubevirt-utils/resources/vm';
import { k8sCreate } from '@openshift-console/dynamic-plugin-sdk';

const getBootSourceDataVolumeTemplate = (template: V1Template) => {
const vm = getTemplateVirtualMachineObject(template);
const rootVolume = getVolumes(vm)?.find((volume) => volume.name === 'rootdisk');
const rootVolume = getVolumes(vm)?.find((volume) => volume.name === ROOTDISK);

if (rootVolume?.dataVolume?.name)
return getDataVolumeTemplates(vm)?.find(
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export const OPENSHIFT_SRIOV_NETWORK_OPERATOR_NS = 'openshift-sriov-network-oper
export const OPENSHIFT_MULTUS_NS = 'openshift-multus';

export const VENDOR_LABEL = 'instancetype.kubevirt.io/vendor';

export const ROOTDISK = 'rootdisk';
5 changes: 3 additions & 2 deletions src/views/catalog/CreateFromInstanceTypes/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt';
import { convertUserDataObjectToYAML } from '@kubevirt-utils/components/CloudinitModal/utils/cloudinit-utils';
import { ACTIVATION_KEY } from '@kubevirt-utils/components/CloudinitModal/utils/consts';
import { addSecretToVM } from '@kubevirt-utils/components/SSHSecretSection/utils/utils';
import { ROOTDISK } from '@kubevirt-utils/constants/constants';
import { RHELAutomaticSubscriptionData } from '@kubevirt-utils/hooks/useRHELAutomaticSubscription/utils/types';
import { isBootableVolumePVCKind } from '@kubevirt-utils/resources/bootableresources/helpers';
import { getName, getNamespace } from '@kubevirt-utils/resources/shared';
Expand Down Expand Up @@ -122,7 +123,7 @@ export const generateVM = (
disk: {
bus: 'virtio',
},
name: `${virtualmachineName}-disk`,
name: ROOTDISK,
},
{
disk: {
Expand All @@ -136,7 +137,7 @@ export const generateVM = (
volumes: [
{
dataVolume: { name: `${virtualmachineName}-volume` },
name: `${virtualmachineName}-disk`,
name: ROOTDISK,
},
{
cloudInitConfigDrive: {
Expand Down
10 changes: 6 additions & 4 deletions src/views/catalog/templatescatalog/tests/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ROOTDISK } from '@kubevirt-utils/constants/constants';

export const containerTemplateMock = {
apiVersion: 'template.openshift.io/v1',
kind: 'Template',
Expand Down Expand Up @@ -43,7 +45,7 @@ export const containerTemplateMock = {
disk: {
bus: 'virtio',
},
name: 'rootdisk',
name: ROOTDISK,
},
],
interfaces: [
Expand Down Expand Up @@ -72,7 +74,7 @@ export const containerTemplateMock = {
containerDisk: {
image: 'fooContainer',
},
name: 'rootdisk',
name: ROOTDISK,
},
],
},
Expand Down Expand Up @@ -130,7 +132,7 @@ export const urlTemplateMock = {
disk: {
bus: 'virtio',
},
name: 'rootdisk',
name: ROOTDISK,
},
],
interfaces: [
Expand Down Expand Up @@ -160,7 +162,7 @@ export const urlTemplateMock = {
// eslint-disable-next-line no-template-curly-in-string
name: 'url-template-rootdisk',
},
name: 'rootdisk',
name: ROOTDISK,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/views/templates/actions/editBootSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
V1beta1DataVolumeSpec,
V1DataVolumeTemplateSpec,
} from '@kubevirt-ui/kubevirt-api/kubevirt';
import { DEFAULT_NAMESPACE } from '@kubevirt-utils/constants/constants';
import { DEFAULT_NAMESPACE, ROOTDISK } from '@kubevirt-utils/constants/constants';
import {
getTemplateVirtualMachineObject,
poorManProcess,
Expand Down Expand Up @@ -64,7 +64,7 @@ const getRootDiskDataVolumeTemplate = (
): undefined | V1DataVolumeTemplateSpec => {
const vm = getTemplateVirtualMachineObject(template);

const rootVolume = getVolumes(vm)?.find((volume) => volume.name === 'rootdisk');
const rootVolume = getVolumes(vm)?.find((volume) => volume.name === ROOTDISK);

return vm?.spec?.dataVolumeTemplates?.find(
(dataVolumeTemplate) => rootVolume?.dataVolume?.name === dataVolumeTemplate?.metadata?.name,
Expand Down

0 comments on commit d14a5da

Please sign in to comment.