Skip to content

Commit

Permalink
Merge pull request #1018 from yaacov/add-namespace-to-ocp-vm-plan
Browse files Browse the repository at this point in the history
🐞 Add namepsace to vm when source is OCP
  • Loading branch information
yaacov authored Mar 25, 2024
2 parents afb2984 + 5023567 commit c9a6229
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import { Td } from '@kubev2v/common';
import { OVirtVM } from '@kubev2v/types';

import { PowerStateCellRenderer } from './components/PowerStateCellRenderer';
import { VMCellProps, VMConcernsCellRenderer, VMNameCellRenderer } from './components';

export interface VmData {
vm: OVirtVM;
name: string;
concerns: string;
}
import { VMCellProps, VMConcernsCellRenderer, VmData, VMNameCellRenderer } from './components';

const renderTd = ({ resourceData, resourceFieldId, resourceFields }: RenderTdProps) => {
const fieldId = resourceFieldId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import { ResourceField, RowProps } from '@kubev2v/common';
import { Td } from '@kubev2v/common';
import { OvaVM } from '@kubev2v/types';

import { VMCellProps, VMConcernsCellRenderer, VMNameCellRenderer } from './components';

export interface VmData {
vm: OvaVM;
name: string;
concerns: string;
}
import { VMCellProps, VMConcernsCellRenderer, VmData, VMNameCellRenderer } from './components';

const renderTd = ({ resourceData, resourceFieldId, resourceFields }: RenderTdProps) => {
const fieldId = resourceFieldId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ import {
PowerStateCellRenderer,
VMCellProps,
VMConcernsCellRenderer,
VmData,
VMNameCellRenderer,
} from './components';

export interface VmData {
vm: VSphereVM;
name: string;
concerns: string;
}

const renderTd = ({ resourceData, resourceFieldId, resourceFields }: RenderTdProps) => {
const fieldId = resourceFieldId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ProviderVirtualMachine } from '@kubev2v/types';
export interface VmData {
vm: ProviderVirtualMachine;
name: string;
namespace: string;
isProviderLocalOpenshift?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useProviderInventory, UseProviderInventoryParams } from 'src/modules/Providers/hooks';
import { ProviderData } from 'src/modules/Providers/utils';
import { isProviderLocalOpenshift } from 'src/utils/resources';
import { isProviderLocalOpenshift, isProviderOpenshift } from 'src/utils/resources';

import { ProviderVirtualMachine } from '@kubev2v/types';
import { OpenshiftVM, ProviderVirtualMachine } from '@kubev2v/types';

import { VmData } from '../components';

Expand Down Expand Up @@ -45,6 +45,7 @@ export const useInventoryVms = (
providerType: provider?.spec?.type,
} as ProviderVirtualMachine,
name: vm.name,
namespace: isProviderOpenshift(validProvider) ? (vm as OpenshiftVM).namespace : undefined,
isProviderLocalOpenshift: isProviderLocalOpenshift(validProvider),
}))
: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export const createInitialState = ({
destination: undefined,
},
targetNamespace: undefined,
vms: selectedVms.map((data) => ({ name: data.name, id: toId(data) })),
vms: selectedVms.map((data) => ({
name: data.name,
namespace: data.namespace,
id: toId(data),
})),
},
},
netMap: {
Expand Down
8 changes: 7 additions & 1 deletion packages/forklift-console-plugin/src/utils/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ export const referenceForObj = (obj: K8sResourceCommon) => {
};

/**
* Can this provider be considered a local target provider?
* Can this provider be considered a local openshift provider?
*/
export const isProviderLocalOpenshift = (provider: V1beta1Provider): boolean =>
provider?.spec?.type === 'openshift' && (!provider?.spec?.url || provider?.spec?.url === '');

/**
* Is this provider an openshift provider?
*/
export const isProviderOpenshift = (provider: V1beta1Provider): boolean =>
provider?.spec?.type === 'openshift';

0 comments on commit c9a6229

Please sign in to comment.