Skip to content

Commit f81060b

Browse files
committed
feat: Add GHCR as Container Registry option flow (#238)
1 parent 7e45dee commit f81060b

File tree

21 files changed

+2697
-173
lines changed

21 files changed

+2697
-173
lines changed

src/configs/icon-mappings/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ export const REGISTRY_TYPE_ICON_MAPPING = {
8181
[CONTAINER_REGISTRY_TYPE.DOCKER_HUB]: RESOURCE_ICON_NAMES.DOCKER,
8282
[CONTAINER_REGISTRY_TYPE.OPENSHIFT_REGISTRY]: RESOURCE_ICON_NAMES.OPENSHIFT,
8383
[CONTAINER_REGISTRY_TYPE.NEXUS]: RESOURCE_ICON_NAMES.NEXUS,
84+
[CONTAINER_REGISTRY_TYPE.GHCR]: RESOURCE_ICON_NAMES.GITHUB,
8485
} as const;

src/icons/iconify-icons-mapping.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export enum ICONS {
1010
INFINITY = 'ion:infinite-outline',
1111
APPLICATION = 'fluent:app-generic-24-regular',
1212
BUCKET = 'mdi:delete',
13-
CHECK_CIRCLE = 'bi:check-circle',
14-
CHECK_CIRCLE_FILLED = 'heroicons:check-circle-solid',
15-
CROSS_CIRCLE = 'uiw:circle-close-o',
13+
CHECK_CIRCLE = 'material-symbols:check-circle-outline',
14+
CHECK_CIRCLE_FILLED = 'material-symbols:check-circle',
15+
CROSS_CIRCLE = 'bx:x-circle',
1616
CIRCLE_NOTCH = 'fa-solid:circle-notch',
1717
LOADER_CIRCLE = 'lucide:loader-2',
1818
INFO_CIRCLE = 'ant-design:info-circle-outlined',

src/k8s/ConfigMap/constants.ts

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const CONTAINER_REGISTRY_TYPE = {
1111
HARBOR: 'harbor',
1212
OPENSHIFT_REGISTRY: 'openshift',
1313
NEXUS: 'nexus',
14+
GHCR: 'ghcr',
1415
} as const;
1516

1617
export const CONTAINER_REGISTRY_TYPE_LABEL_MAP = {
@@ -19,6 +20,7 @@ export const CONTAINER_REGISTRY_TYPE_LABEL_MAP = {
1920
[CONTAINER_REGISTRY_TYPE.HARBOR]: 'Harbor',
2021
[CONTAINER_REGISTRY_TYPE.OPENSHIFT_REGISTRY]: 'OpenShift',
2122
[CONTAINER_REGISTRY_TYPE.NEXUS]: 'Nexus',
23+
[CONTAINER_REGISTRY_TYPE.GHCR]: 'GHCR',
2224
};
2325

2426
export const CONTAINER_REGISTRY_TYPE_BY_PLATFORM = {
@@ -27,12 +29,14 @@ export const CONTAINER_REGISTRY_TYPE_BY_PLATFORM = {
2729
CONTAINER_REGISTRY_TYPE.DOCKER_HUB,
2830
CONTAINER_REGISTRY_TYPE.HARBOR,
2931
CONTAINER_REGISTRY_TYPE.NEXUS,
32+
CONTAINER_REGISTRY_TYPE.GHCR,
3033
],
3134
[CONTAINER_REGISTRY_PLATFORM.OPENSHIFT]: [
3235
CONTAINER_REGISTRY_TYPE.ECR,
3336
CONTAINER_REGISTRY_TYPE.DOCKER_HUB,
3437
CONTAINER_REGISTRY_TYPE.HARBOR,
3538
CONTAINER_REGISTRY_TYPE.OPENSHIFT_REGISTRY,
3639
CONTAINER_REGISTRY_TYPE.NEXUS,
40+
CONTAINER_REGISTRY_TYPE.GHCR,
3741
],
3842
};

src/pages/edp-pipeline-details/components/PipelineRunDetails/components/TaskRunStep/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export const TaskRunStep = ({ taskRun, step }) => {
1919
const completionTime = step?.terminated?.finishedAt || new Date().toISOString();
2020
const startTime = step?.terminated?.startedAt;
2121

22-
console.log(completionTime, startTime, step);
23-
2422
const duration = humanize(new Date(completionTime).getTime() - new Date(startTime).getTime(), {
2523
language: 'en-mini',
2624
spacer: '',

src/pages/edp-pipelines/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
PIPELINE_RUN_LABEL_SELECTOR_PIPELINE_TYPE,
55
} from '../../k8s/PipelineRun/labels';
66
import { PipelineRunKubeObjectInterface } from '../../k8s/PipelineRun/types';
7-
import { MatchFunctions } from '../edp-overview-list/types';
7+
import { MatchFunctions } from './types';
88

99
export const FILTER_CONTROLS = {
1010
CODEBASES: 'codebases',

src/pages/edp-stage-details/components/Applications/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Grid, Stack } from '@mui/material';
1+
import { Grid } from '@mui/material';
22
import React from 'react';
33
import { useFormContext } from 'react-hook-form';
44
import { Table } from '../../../../components/Table';
@@ -396,7 +396,6 @@ export const Applications = ({
396396
isSelected={(row) => selected.indexOf(row.application.metadata.name) !== -1}
397397
/>
398398
</Grid>
399-
<Stack>asd</Stack>
400399
</Grid>
401400
</>
402401
);

src/providers/MultiForm/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export const MultiFormContextProvider = <FormName extends string>({
4949
const isFormDirty =
5050
form.formState.dirtyFields && Object.keys(form.formState.dirtyFields).length > 0;
5151

52-
console.log('isFormDirty', isFormDirty, formName, form.formState.dirtyFields, onlyDirty);
53-
5452
if (isFormDirty || !onlyDirty) {
5553
await formItem.onSubmit();
5654
formItem.form.reset({}, { keepDirty: false, keepValues: true });

src/widgets/ManageArgoCD/hooks/useQuickLinkEditForm.ts

-4
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ export const useQuickLinkEditForm = ({
3333

3434
const handleSubmit = React.useCallback(
3535
async (values: QuickLinkFormValues) => {
36-
console.log('values', values);
37-
console.log('quickLink', quickLink);
38-
3936
const newQuickLinkData = editResource(QUICK_LINK_FORM_NAMES, quickLink, values);
40-
console.log('newQuickLinkData', newQuickLinkData);
4137

4238
await editQuickLink({
4339
QuickLinkData: newQuickLinkData,

src/widgets/ManageRegistry/__snapshots__/index.edit.test.tsx.snap

+2,553-149
Large diffs are not rendered by default.

src/widgets/ManageRegistry/components/ConfigMap/fields/Type/index.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { FormRadioGroup } from '../../../../../../providers/Form/components/FormRadioGroup';
1313
import { FieldEvent, FORM_MODES } from '../../../../../../types/forms';
1414
import { ValueOf } from '../../../../../../types/global';
15-
import { DOCKER_HUB_REGISTRY_ENDPOINT } from '../../../../constants';
15+
import { DOCKER_HUB_REGISTRY_ENDPOINT, GHCR_ENDPOINT } from '../../../../constants';
1616
import { useRegistryFormsContext } from '../../../../hooks/useRegistryFormsContext';
1717
import {
1818
CONFIG_MAP_FORM_NAMES,
@@ -75,6 +75,18 @@ export const Type = () => {
7575
}
7676
);
7777
break;
78+
case CONTAINER_REGISTRY_TYPE.GHCR:
79+
configMap.form.setValue(
80+
CONFIG_MAP_FORM_NAMES.registryEndpoint.name,
81+
GHCR_ENDPOINT,
82+
{
83+
shouldDirty: false,
84+
}
85+
);
86+
sharedForm.setValue(SHARED_FORM_NAMES.registryEndpoint.name, GHCR_ENDPOINT, {
87+
shouldDirty: false,
88+
});
89+
break;
7890
case CONTAINER_REGISTRY_TYPE.ECR:
7991
pushAccount.form.setValue(PUSH_ACCOUNT_FORM_NAMES.pushAccountPassword.name, '', {
8092
shouldDirty: true,

src/widgets/ManageRegistry/constants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ export const FORM_NAMES = {
88

99
export const DOCKER_HUB_REGISTRY_ENDPOINT = 'docker.io';
1010
export const DOCKER_HUB_REGISTRY_ENDPOINT_VALUE = 'https://index.docker.io/v1/';
11+
12+
export const GHCR_ENDPOINT = 'ghcr.io';
13+
export const GHCR_ENDPOINT_VALUE = 'https://ghcr.io';

src/widgets/ManageRegistry/hooks/useConfigMapEditForm.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { editResource } from '../../../k8s/common/editResource';
44
import { CONTAINER_REGISTRY_TYPE } from '../../../k8s/ConfigMap/constants';
55
import { useConfigMapCRUD } from '../../../k8s/ConfigMap/hooks/useConfigMapCRUD';
66
import { ConfigMapKubeObjectInterface } from '../../../k8s/ConfigMap/types';
7-
import { DOCKER_HUB_REGISTRY_ENDPOINT } from '../constants';
7+
import { DOCKER_HUB_REGISTRY_ENDPOINT, GHCR_ENDPOINT } from '../constants';
88
import { CONFIG_MAP_FORM_NAMES } from '../names';
99
import { ConfigMapFormValues } from '../types';
1010

@@ -40,6 +40,14 @@ export const useConfigMapEditForm = ({
4040
[CONFIG_MAP_FORM_NAMES.registrySpace.name]:
4141
EDPConfigMap?.data.container_registry_space || '',
4242
};
43+
case CONTAINER_REGISTRY_TYPE.GHCR:
44+
return {
45+
[CONFIG_MAP_FORM_NAMES.registryEndpoint.name]: GHCR_ENDPOINT,
46+
[CONFIG_MAP_FORM_NAMES.registryType.name]:
47+
EDPConfigMap?.data.container_registry_type || '',
48+
[CONFIG_MAP_FORM_NAMES.registrySpace.name]:
49+
EDPConfigMap?.data.container_registry_space || '',
50+
};
4351
default:
4452
return {
4553
[CONFIG_MAP_FORM_NAMES.registryEndpoint.name]:
@@ -76,6 +84,12 @@ export const useConfigMapEditForm = ({
7684
[CONFIG_MAP_FORM_NAMES.registrySpace.name]: values.registrySpace,
7785
[CONFIG_MAP_FORM_NAMES.registryType.name]: values.registryType,
7886
});
87+
case CONTAINER_REGISTRY_TYPE.GHCR:
88+
return editResource(CONFIG_MAP_FORM_NAMES, EDPConfigMap, {
89+
[CONFIG_MAP_FORM_NAMES.registryEndpoint.name]: GHCR_ENDPOINT,
90+
[CONFIG_MAP_FORM_NAMES.registrySpace.name]: values.registrySpace,
91+
[CONFIG_MAP_FORM_NAMES.registryType.name]: values.registryType,
92+
});
7993
case CONTAINER_REGISTRY_TYPE.HARBOR:
8094
case CONTAINER_REGISTRY_TYPE.NEXUS:
8195
case CONTAINER_REGISTRY_TYPE.OPENSHIFT_REGISTRY:

src/widgets/ManageRegistry/hooks/usePullAccountCreateForm.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { REGISTRY_SECRET_NAMES } from '../../../k8s/Secret/constants';
55
import { useSecretCRUD } from '../../../k8s/Secret/hooks/useSecretCRUD';
66
import { SecretKubeObjectInterface } from '../../../k8s/Secret/types';
77
import { createRegistrySecretInstance } from '../../../k8s/Secret/utils/createRegistrySecretInstance';
8-
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE } from '../constants';
8+
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE, GHCR_ENDPOINT_VALUE } from '../constants';
99
import { PULL_ACCOUNT_FORM_NAMES } from '../names';
1010
import { PullAccountFormValues, SharedFormValues } from '../types';
1111
import { getUsernameAndPassword } from '../utils';
@@ -62,6 +62,16 @@ export const usePullAccountCreateForm = ({
6262
}),
6363
});
6464
break;
65+
case CONTAINER_REGISTRY_TYPE.GHCR:
66+
await createSecret({
67+
secretData: createRegistrySecretInstance({
68+
name: REGISTRY_SECRET_NAMES.REGCRED,
69+
registryEndpoint: GHCR_ENDPOINT_VALUE,
70+
user: values.pullAccountUser,
71+
password: values.pullAccountPassword,
72+
}),
73+
});
74+
break;
6575
case CONTAINER_REGISTRY_TYPE.HARBOR:
6676
case CONTAINER_REGISTRY_TYPE.NEXUS:
6777
await createSecret({

src/widgets/ManageRegistry/hooks/usePullAccountEditForm.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { REGISTRY_SECRET_NAMES } from '../../../k8s/Secret/constants';
55
import { useSecretCRUD } from '../../../k8s/Secret/hooks/useSecretCRUD';
66
import { SecretKubeObjectInterface } from '../../../k8s/Secret/types';
77
import { createRegistrySecretInstance } from '../../../k8s/Secret/utils/createRegistrySecretInstance';
8-
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE } from '../constants';
8+
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE, GHCR_ENDPOINT_VALUE } from '../constants';
99
import { PULL_ACCOUNT_FORM_NAMES } from '../names';
1010
import { PullAccountFormValues, SharedFormValues } from '../types';
1111
import { getUsernameAndPassword } from '../utils';
@@ -54,6 +54,16 @@ export const usePullAccountEditForm = ({
5454
}),
5555
});
5656
break;
57+
case CONTAINER_REGISTRY_TYPE.GHCR:
58+
await editSecret({
59+
secretData: createRegistrySecretInstance({
60+
name: REGISTRY_SECRET_NAMES.REGCRED,
61+
registryEndpoint: GHCR_ENDPOINT_VALUE,
62+
user: values.pullAccountUser,
63+
password: values.pullAccountPassword,
64+
}),
65+
});
66+
break;
5767
case CONTAINER_REGISTRY_TYPE.HARBOR:
5868
case CONTAINER_REGISTRY_TYPE.NEXUS:
5969
await editSecret({

src/widgets/ManageRegistry/hooks/usePushAccountCreateForm.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
createOpenshiftPushSecretInstance,
1010
createRegistrySecretInstance,
1111
} from '../../../k8s/Secret/utils/createRegistrySecretInstance';
12-
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE } from '../constants';
12+
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE, GHCR_ENDPOINT_VALUE } from '../constants';
1313
import { PUSH_ACCOUNT_FORM_NAMES } from '../names';
1414
import { PushAccountFormValues, SharedFormValues } from '../types';
1515
import { getAuth, getUsernameAndPassword } from '../utils';
@@ -82,6 +82,16 @@ export const usePushAccountCreateForm = ({
8282
}),
8383
});
8484
break;
85+
case CONTAINER_REGISTRY_TYPE.GHCR:
86+
await createSecret({
87+
secretData: createRegistrySecretInstance({
88+
name: REGISTRY_SECRET_NAMES.KANIKO_DOCKER_CONFIG,
89+
registryEndpoint: GHCR_ENDPOINT_VALUE,
90+
user: values.pushAccountUser,
91+
password: values.pushAccountPassword,
92+
}),
93+
});
94+
break;
8595
case CONTAINER_REGISTRY_TYPE.HARBOR:
8696
case CONTAINER_REGISTRY_TYPE.NEXUS:
8797
await createSecret({

src/widgets/ManageRegistry/hooks/usePushAccountEditForm.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
createOpenshiftPushSecretInstance,
1010
createRegistrySecretInstance,
1111
} from '../../../k8s/Secret/utils/createRegistrySecretInstance';
12-
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE } from '../constants';
12+
import { DOCKER_HUB_REGISTRY_ENDPOINT_VALUE, GHCR_ENDPOINT_VALUE } from '../constants';
1313
import { PUSH_ACCOUNT_FORM_NAMES } from '../names';
1414
import { PushAccountFormValues, SharedFormValues } from '../types';
1515
import { getAuth, getUsernameAndPassword } from '../utils';
@@ -77,6 +77,16 @@ export const usePushAccountEditForm = ({
7777
}),
7878
});
7979
break;
80+
case CONTAINER_REGISTRY_TYPE.GHCR:
81+
await editSecret({
82+
secretData: createRegistrySecretInstance({
83+
name: REGISTRY_SECRET_NAMES.KANIKO_DOCKER_CONFIG,
84+
registryEndpoint: GHCR_ENDPOINT_VALUE,
85+
user: values.pushAccountUser,
86+
password: values.pushAccountPassword,
87+
}),
88+
});
89+
break;
8090
case CONTAINER_REGISTRY_TYPE.HARBOR:
8191
case CONTAINER_REGISTRY_TYPE.NEXUS:
8292
await editSecret({

src/widgets/ManageRegistry/hooks/useResetRegistry.ts

+16
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ export const useResetRegistry = ({
8282
await editConfigMap({ configMapData: newEDPConfigMap });
8383
};
8484

85+
const resetGHCR = async () => {
86+
const newEDPConfigMap = editResource(CONFIG_MAP_FORM_NAMES, EDPConfigMap, {
87+
[CONFIG_MAP_FORM_NAMES.registryEndpoint.name]: '',
88+
[CONFIG_MAP_FORM_NAMES.registrySpace.name]: '',
89+
[CONFIG_MAP_FORM_NAMES.registryType.name]: '',
90+
});
91+
92+
for (const secret of secretsArray) {
93+
await deleteSecret({ secretData: secret });
94+
}
95+
await editConfigMap({ configMapData: newEDPConfigMap });
96+
};
97+
8598
const resetHarborOrNexus = async () => {
8699
const newEDPConfigMap = editResource(CONFIG_MAP_FORM_NAMES, EDPConfigMap, {
87100
[CONFIG_MAP_FORM_NAMES.registryEndpoint.name]: '',
@@ -114,6 +127,9 @@ export const useResetRegistry = ({
114127
case CONTAINER_REGISTRY_TYPE.DOCKER_HUB:
115128
await resetDockerHub();
116129
break;
130+
case CONTAINER_REGISTRY_TYPE.GHCR:
131+
await resetGHCR();
132+
break;
117133
case CONTAINER_REGISTRY_TYPE.HARBOR:
118134
case CONTAINER_REGISTRY_TYPE.NEXUS:
119135
await resetHarborOrNexus();

src/widgets/ManageRegistry/index.edit.test.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,27 @@ describe('testing ManageRegistry Edit', () => {
8989
expect(dialog).toMatchSnapshot();
9090
});
9191

92+
test('renders ManageRegistry component with GHCR EDPConfig map', () => {
93+
render(
94+
<TestWrapper>
95+
<ManageRegistry
96+
EDPConfigMap={
97+
createEdpConfigMapMock(
98+
CONTAINER_REGISTRY_TYPE.GHCR,
99+
CONTAINER_REGISTRY_PLATFORM.KUBERNETES
100+
) as unknown as ConfigMapKubeObjectInterface
101+
}
102+
pushAccountSecret={undefined}
103+
pullAccountSecret={undefined}
104+
tektonServiceAccount={undefined}
105+
/>
106+
</TestWrapper>
107+
);
108+
109+
const dialog = screen.getByTestId('form');
110+
expect(dialog).toMatchSnapshot();
111+
});
112+
92113
test('renders ManageRegistry component with Openshift registry EDPConfig map', () => {
93114
render(
94115
<TestWrapper>

src/widgets/ManageRegistry/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const ManageRegistry = ({
161161
CONTAINER_REGISTRY_TYPE.NEXUS,
162162
CONTAINER_REGISTRY_TYPE.OPENSHIFT_REGISTRY,
163163
CONTAINER_REGISTRY_TYPE.DOCKER_HUB,
164+
CONTAINER_REGISTRY_TYPE.GHCR,
164165
]) && (
165166
<Grid item xs={12}>
166167
<PushAccountForm />
@@ -170,6 +171,7 @@ export const ManageRegistry = ({
170171
CONTAINER_REGISTRY_TYPE.HARBOR,
171172
CONTAINER_REGISTRY_TYPE.NEXUS,
172173
CONTAINER_REGISTRY_TYPE.DOCKER_HUB,
174+
CONTAINER_REGISTRY_TYPE.GHCR,
173175
]) && (
174176
<Grid item xs={12}>
175177
<UseSameAccount />
@@ -179,6 +181,7 @@ export const ManageRegistry = ({
179181
CONTAINER_REGISTRY_TYPE.HARBOR,
180182
CONTAINER_REGISTRY_TYPE.NEXUS,
181183
CONTAINER_REGISTRY_TYPE.DOCKER_HUB,
184+
CONTAINER_REGISTRY_TYPE.GHCR,
182185
]) && (
183186
<Grid item xs={12}>
184187
<PullAccountForm />

src/widgets/PipelineRunGraph/hooks/usePipelineRunGraphData.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,28 @@ export const usePipelineRunGraphData = (
1616
taskRunListByNameMap,
1717
} = usePipelineRunData(taskRuns, pipelineRun);
1818

19+
console.log(
20+
pipelineRunTasks,
21+
pipelineRunFinallyTasksMap,
22+
pipelineRunMainTasksMap,
23+
taskRunListByNameMap
24+
);
25+
1926
const isLoading = taskRuns === null || pipelineRun === null;
2027

2128
const noTasks = React.useMemo(() => {
22-
return pipelineRunTasks.allTasks.length === 0;
23-
}, [pipelineRunTasks.allTasks.length]);
29+
return (
30+
pipelineRunTasks.allTasks.length === 0 ||
31+
!pipelineRunMainTasksMap ||
32+
!pipelineRunFinallyTasksMap ||
33+
!taskRunListByNameMap
34+
);
35+
}, [
36+
pipelineRunFinallyTasksMap,
37+
pipelineRunMainTasksMap,
38+
pipelineRunTasks.allTasks.length,
39+
taskRunListByNameMap,
40+
]);
2441

2542
const nodes = React.useMemo(() => {
2643
if (noTasks || isLoading) {

0 commit comments

Comments
 (0)