Skip to content

Commit

Permalink
rebase | use k8spatch
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Schuler <jschuler@redhat.com>
  • Loading branch information
jschuler committed Jan 10, 2025
2 parents 86620ef + cc62d29 commit 90cb409
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 158 deletions.
18 changes: 9 additions & 9 deletions .tekton/forklift-console-plugin-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ spec:
- name: name
value: init
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:60063fefe88e111d129cb59caff97c912722927c8a0f750253553d4c527a2396
value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:90dda596d44b3f861889da2fba161dff34c6116fe76c3989e3f84262ea0f29cd
- name: kind
value: task
resolver: bundles
Expand All @@ -157,7 +157,7 @@ spec:
- name: name
value: git-clone-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-git-clone-oci-ta:0.1@sha256:8ab0c7a7ac4a4c59740a24304e17cc64fe8745376d19396c4660fc0e1a957a1b
value: quay.io/konflux-ci/tekton-catalog/task-git-clone-oci-ta:0.1@sha256:f72fcca6732516339d55ac5f01660e287968e64e857a40a8608db27e298b5126
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -186,7 +186,7 @@ spec:
- name: name
value: prefetch-dependencies-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-prefetch-dependencies-oci-ta:0.1@sha256:3e51d7c477ba00bd0c7de2d8f89269131646d2582e631b9aee91fb4b022d4555
value: quay.io/konflux-ci/tekton-catalog/task-prefetch-dependencies-oci-ta:0.1@sha256:994f816e36ac832f4020647afd69223a015c84c503f925013c573fed52f05420
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -227,7 +227,7 @@ spec:
- name: name
value: buildah-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:e0f1ec1ec43ba0f9533dd70fe76a3c24ac3ca14ddd83036099c8073c94dc8258
value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:c2e4e492c5f069c02ef2555514ceff65c75d4325657fd33727de68df7cca5f69
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -256,7 +256,7 @@ spec:
- name: name
value: build-image-index
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:37328a4b2fc686435531ba423c26c2051822a4e70b06088c4d8eaf0e8fa6d65b
value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:479775c8655d815fb515aeb97efc0e64284a8520c452754981970900b937a393
- name: kind
value: task
resolver: bundles
Expand All @@ -280,7 +280,7 @@ spec:
- name: name
value: source-build-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-source-build-oci-ta:0.1@sha256:26278e5373a726594975a9ec2f177a67e3674bbf905d7d317b9ea60ca7993978
value: quay.io/konflux-ci/tekton-catalog/task-source-build-oci-ta:0.1@sha256:75e882bf1619dd45a4043060ce42a6ad3ce781264ade5b7f66a1d994ee159126
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -416,7 +416,7 @@ spec:
- name: name
value: apply-tags
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:0767c115d4ba4854d106c9cdfabdc1f1298bc2742a3fea4fefbac4b9c5873d6e
value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:2c2d88c07623b2d25163994ded6e9f29205ea5bbab090f4c86379739940028b9
- name: kind
value: task
resolver: bundles
Expand All @@ -439,7 +439,7 @@ spec:
- name: name
value: push-dockerfile-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-push-dockerfile-oci-ta:0.1@sha256:08ef41d6a98608bd5f1de75d77f015f520911a278d1875e174b88b9d04db2441
value: quay.io/konflux-ci/tekton-catalog/task-push-dockerfile-oci-ta:0.1@sha256:98ccae6ac132ab837fc51a70514be5fca656e09d6d4ad93230bd10f0119258aa
- name: kind
value: task
resolver: bundles
Expand All @@ -456,7 +456,7 @@ spec:
- name: name
value: rpms-signature-scan
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:ec536e55a039052823ba74e07db3175554fb046649671d1fefd776ca064d00ac
value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:39cd56ffa26ff5edfd5bf9b61e902cae35a345c078cd9dcbc0737d30f3ce5ef1
- name: kind
value: task
resolver: bundles
Expand Down
18 changes: 9 additions & 9 deletions .tekton/forklift-console-plugin-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ spec:
- name: name
value: init
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:60063fefe88e111d129cb59caff97c912722927c8a0f750253553d4c527a2396
value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:90dda596d44b3f861889da2fba161dff34c6116fe76c3989e3f84262ea0f29cd
- name: kind
value: task
resolver: bundles
Expand All @@ -156,7 +156,7 @@ spec:
- name: name
value: git-clone-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-git-clone-oci-ta:0.1@sha256:8ab0c7a7ac4a4c59740a24304e17cc64fe8745376d19396c4660fc0e1a957a1b
value: quay.io/konflux-ci/tekton-catalog/task-git-clone-oci-ta:0.1@sha256:f72fcca6732516339d55ac5f01660e287968e64e857a40a8608db27e298b5126
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -185,7 +185,7 @@ spec:
- name: name
value: prefetch-dependencies-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-prefetch-dependencies-oci-ta:0.1@sha256:3e51d7c477ba00bd0c7de2d8f89269131646d2582e631b9aee91fb4b022d4555
value: quay.io/konflux-ci/tekton-catalog/task-prefetch-dependencies-oci-ta:0.1@sha256:994f816e36ac832f4020647afd69223a015c84c503f925013c573fed52f05420
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -226,7 +226,7 @@ spec:
- name: name
value: buildah-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:e0f1ec1ec43ba0f9533dd70fe76a3c24ac3ca14ddd83036099c8073c94dc8258
value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:c2e4e492c5f069c02ef2555514ceff65c75d4325657fd33727de68df7cca5f69
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -255,7 +255,7 @@ spec:
- name: name
value: build-image-index
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:37328a4b2fc686435531ba423c26c2051822a4e70b06088c4d8eaf0e8fa6d65b
value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:479775c8655d815fb515aeb97efc0e64284a8520c452754981970900b937a393
- name: kind
value: task
resolver: bundles
Expand All @@ -279,7 +279,7 @@ spec:
- name: name
value: source-build-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-source-build-oci-ta:0.1@sha256:26278e5373a726594975a9ec2f177a67e3674bbf905d7d317b9ea60ca7993978
value: quay.io/konflux-ci/tekton-catalog/task-source-build-oci-ta:0.1@sha256:75e882bf1619dd45a4043060ce42a6ad3ce781264ade5b7f66a1d994ee159126
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -415,7 +415,7 @@ spec:
- name: name
value: apply-tags
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:0767c115d4ba4854d106c9cdfabdc1f1298bc2742a3fea4fefbac4b9c5873d6e
value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:2c2d88c07623b2d25163994ded6e9f29205ea5bbab090f4c86379739940028b9
- name: kind
value: task
resolver: bundles
Expand All @@ -438,7 +438,7 @@ spec:
- name: name
value: push-dockerfile-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-push-dockerfile-oci-ta:0.1@sha256:08ef41d6a98608bd5f1de75d77f015f520911a278d1875e174b88b9d04db2441
value: quay.io/konflux-ci/tekton-catalog/task-push-dockerfile-oci-ta:0.1@sha256:98ccae6ac132ab837fc51a70514be5fca656e09d6d4ad93230bd10f0119258aa
- name: kind
value: task
resolver: bundles
Expand All @@ -455,7 +455,7 @@ spec:
- name: name
value: rpms-signature-scan
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:ec536e55a039052823ba74e07db3175554fb046649671d1fefd776ca064d00ac
value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:39cd56ffa26ff5edfd5bf9b61e902cae35a345c078cd9dcbc0737d30f3ce5ef1
- name: kind
value: task
resolver: bundles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
"Edit migration plan transfer network": "Edit migration plan transfer network",
"Edit NetworkMap": "Edit NetworkMap",
"Edit Plan": "Edit Plan",
"Edit plan name": "Edit plan name",
"Edit Precopy interval (minutes)": "Edit Precopy interval (minutes)",
"Edit Provider": "Edit Provider",
"Edit Provider Credentials": "Edit Provider Credentials",
Expand Down Expand Up @@ -268,6 +269,7 @@
"Multiple NICs on the same network": "Multiple NICs on the same network",
"Name": "Name",
"Name is primarily intended for creation idempotence and configuration definition. Cannot be updated.": "Name is primarily intended for creation idempotence and configuration definition. Cannot be updated.",
"Name is required and must be a unique within a namespace and valid Kubernetes name.": "Name is required and must be a unique within a namespace and valid Kubernetes name.",
"Namespace": "Namespace",
"Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.": "Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.",
"Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace -\n the value of this field for those objects will be empty.": "Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace -\n the value of this field for those objects will be empty.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const PlanCreatePage: React.FC<{ namespace: string }> = ({ namespace }) =
!emptyContext &&
!(
!!state?.flow?.apiError ||
Object.values(state?.validation || []).some((validation) => validation === 'error')
Object.values(state?.validation || []).some((validation) => validation === 'error') ||
state?.validation?.planName === 'default'
),
canJumpTo: filterState?.selectedVMs?.length > 0,
nextButtonText: 'Create migration plan',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { VmData } from 'src/modules/Providers/views';
import { useCreateVmMigrationData } from 'src/modules/Providers/views/migrate';
import {
PageAction,
setPlanName,
setProjectName as setProjectNameAction,
} from 'src/modules/Providers/views/migrate/reducer/actions';
import { CreateVmMigrationPageState } from 'src/modules/Providers/views/migrate/types';
Expand All @@ -20,7 +19,6 @@ import { PlanCreatePageState } from '../states';
import { ChipsToolbarProviders } from './ChipsToolbarProviders';
import { createProviderCardItems } from './createProviderCardItems';
import { FiltersToolbarProviders } from './FiltersToolbarProviders';
import { PlanNameTextField } from './PlanNameTextField';
import { ProjectNameSelect } from './ProjectNameSelect';

export type PlanCreateFormProps = {
Expand All @@ -42,7 +40,6 @@ export type PlanCreateFormProps = {
export const PlanCreateForm: React.FC<PlanCreateFormProps> = ({
providers,
filterState,
state,
projectName,
filterDispatch,
dispatch,
Expand All @@ -61,17 +58,6 @@ export const PlanCreateForm: React.FC<PlanCreateFormProps> = ({
return (
<div className="forklift-create-provider-edit-section">
<Form isWidthLimited className="forklift-section-secret-edit">
<PlanNameTextField
isRequired
value={state.underConstruction.plan.metadata.name}
validated={state.validation.planName}
isDisabled={state.flow.editingDone}
onChange={(_, value) => {
dispatch(setPlanName(value?.trim() ?? ''));
setData({ ...data, planName: value });
}}
/>

<ProjectNameSelect
value={projectName}
options={providerNamespaces.map((namespace) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import React from 'react';
import { useForkliftTranslation } from 'src/utils';

import { FormGroupWithHelpText, TypeaheadSelect, TypeaheadSelectOption } from '@kubev2v/common';
import {
K8sResourceKind,
useFlag,
useK8sWatchResource,
} from '@openshift-console/dynamic-plugin-sdk';
import { Popover } from '@patternfly/react-core';
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';

Expand Down Expand Up @@ -46,3 +51,20 @@ export const ProjectNameSelect: React.FC<ProjectNameSelectProps> = ({
</FormGroupWithHelpText>
);
};

export const useProjectNameSelectOptions = (defaultProject: string): TypeaheadSelectOption[] => {
const isUseProjects = useFlag('OPENSHIFT'); // OCP or Kind installations

const [projects, projectsLoaded, projectsLoadError] = useK8sWatchResource<K8sResourceKind[]>({
kind: isUseProjects ? 'Project' : 'Namespace',
isList: true,
});

return projects.length === 0 || !projectsLoaded || projectsLoadError
? // In case of an error or an empty list, returns the active namespace
[{ value: defaultProject, content: defaultProject }]
: projects.map((project) => ({
value: project.metadata?.name,
content: project.metadata?.name,
}));
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect, useReducer } from 'react';
import { useHistory } from 'react-router';
import { PlanEditAction } from 'src/modules/Plans/utils/types/PlanEditAction';
import {
planMappingsSectionReducer,
Expand Down Expand Up @@ -28,7 +27,7 @@ export const PlanEditPage: React.FC<{
sourceProvider: V1beta1Provider;
targetProvider: V1beta1Provider;
projectName: string;
onClose?: () => void;
onClose: () => void;
selectedVMs?: VmData[];
editAction: PlanEditAction;
planNetworkMaps: V1beta1NetworkMap;
Expand All @@ -46,7 +45,6 @@ export const PlanEditPage: React.FC<{
planStorageMaps,
}) => {
const { t } = useForkliftTranslation();
const history = useHistory();
const startAtStep = 1;

// Init Select source provider form state
Expand Down Expand Up @@ -96,7 +94,7 @@ export const PlanEditPage: React.FC<{
}
}, [planNetworkMaps, planStorageMaps]);

useUpdateEffect(state, dispatch, planMappingsState);
useUpdateEffect(state, dispatch, planMappingsState, onClose);

const steps = [
{
Expand Down Expand Up @@ -142,7 +140,6 @@ export const PlanEditPage: React.FC<{
},
];

const goBack = () => history.goBack();
const title = 'Plans wizard';
return (
<>
Expand All @@ -159,7 +156,7 @@ export const PlanEditPage: React.FC<{
mainAriaLabel={`${title} content`}
steps={steps}
onSave={() => dispatch(startUpdate())}
onClose={onClose || goBack}
onClose={onClose}
startAtStep={startAtStep}
/>
</PageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const CertificateUpload: FC<CertificateUploadProps> = ({
<FetchCertificateModal
url={url}
handleSave={(v) => onTextChange(null, v)}
existingCert={String(value)}
existingCert={value ? String(value) : undefined}
/>,
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ProvidersCreatePage: React.FC<{
const [activeNamespace, setActiveNamespace] = useActiveNamespace();
const [providerNames] = useK8sWatchProviderNames({ namespace });
const defaultNamespace = process?.env?.DEFAULT_NAMESPACE || 'default';
const projectName = activeNamespace === '#ALL_NS#' ? 'openshift-mtv' : activeNamespace;
const projectName = activeNamespace === '#ALL_NS#' ? defaultNamespace : activeNamespace;
const initialNamespace = namespace || projectName || defaultNamespace;

const initialState: ProvidersCreatePageState = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import React, { useReducer } from 'react';
import { Base64 } from 'js-base64';
import { ProjectNameSelect } from 'src/modules/Plans/views/create/components/ProjectNameSelect';
import {
ProjectNameSelect,
useProjectNameSelectOptions,
} from 'src/modules/Plans/views/create/components/ProjectNameSelect';
import { ModalHOC } from 'src/modules/Providers/modals';
import { validateK8sName, ValidationMsg } from 'src/modules/Providers/utils';
import { SelectableCard } from 'src/modules/Providers/utils/components/Gallery/SelectableCard';
import { SelectableGallery } from 'src/modules/Providers/utils/components/Gallery/SelectableGallery';
import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n';

import { FormGroupWithHelpText } from '@kubev2v/common';
import {
IoK8sApiCoreV1Secret,
K8sResourceCommon,
ProviderType,
V1beta1Provider,
} from '@kubev2v/types';
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
import { IoK8sApiCoreV1Secret, ProviderType, V1beta1Provider } from '@kubev2v/types';
import {
Flex,
FlexItem,
Expand Down Expand Up @@ -50,14 +47,7 @@ export const ProvidersCreateForm: React.FC<ProvidersCreateFormProps> = ({
}) => {
const { t } = useForkliftTranslation();

const [projects, projectsLoaded] = useK8sWatchResource<K8sResourceCommon[]>({
groupVersionKind: {
version: 'v1',
group: 'project.openshift.io',
kind: 'Project',
},
isList: true,
});
const projects = useProjectNameSelectOptions(projectName);

const initialState = {
validation: {
Expand Down Expand Up @@ -126,11 +116,7 @@ export const ProvidersCreateForm: React.FC<ProvidersCreateFormProps> = ({
<Form isWidthLimited className="forklift-section-secret-edit">
<ProjectNameSelect
value={projectName}
options={projects.map((project) => ({
value: project.metadata?.name,
content: project.metadata?.name,
}))}
isDisabled={!projectsLoaded || !projects.length}
options={projects}
onSelect={onProjectNameChange}
popoverHelpContent={
<ForkliftTrans>The project that your provider will be created in.</ForkliftTrans>
Expand Down
Loading

0 comments on commit 90cb409

Please sign in to comment.