Skip to content
This repository was archived by the owner on Jun 18, 2025. It is now read-only.

Commit d776e24

Browse files
feat: remove deployment environment from register repository page (#231)
This change updates the Register Repository Page removing the deployment environment selection when the repository content type is set to deployments.
1 parent f3df559 commit d776e24

File tree

3 files changed

+0
-134
lines changed

3 files changed

+0
-134
lines changed

plugins/cad/src/components/RegisterRepositoryPage/RegisterRepositoryPage.tsx

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ import { Secret } from '../../types/Secret';
4040
import { allowFunctionRepositoryRegistration } from '../../utils/featureFlags';
4141
import {
4242
ContentSummary,
43-
DeploymentEnvironment,
44-
DeploymentEnvironmentDetails,
4543
getRepositoryGitDetails,
4644
getRepositoryOciDetails,
4745
getRepositoryResource,
@@ -138,7 +136,6 @@ export const RegisterRepositoryPage = () => {
138136

139137
let gitDetails: RepositoryGitDetails | undefined = undefined;
140138
let ociDetails: RepositoryOciDetails | undefined = undefined;
141-
let deploymentEnvironment: DeploymentEnvironment | undefined = undefined;
142139

143140
if (state.type === RepositoryType.GIT) {
144141
const createBranch = true;
@@ -159,19 +156,13 @@ export const RegisterRepositoryPage = () => {
159156
const contentSummary = state.contentSummary as ContentSummary;
160157
const repositoryAccess = state.repositoryAccess as RepositoryAccess;
161158

162-
if (contentSummary === ContentSummary.DEPLOYMENT) {
163-
deploymentEnvironment =
164-
state.deploymentEnvironment as DeploymentEnvironment;
165-
}
166-
167159
const resource = getRepositoryResource(
168160
state.name,
169161
state.description,
170162
contentSummary,
171163
repositoryAccess,
172164
gitDetails,
173165
ociDetails,
174-
deploymentEnvironment,
175166
);
176167

177168
return resource;
@@ -248,14 +239,6 @@ export const RegisterRepositoryPage = () => {
248239
}
249240
}
250241

251-
for (const [environment, details] of Object.entries(
252-
DeploymentEnvironmentDetails,
253-
)) {
254-
if (repositoryUrl.includes(details.shortName)) {
255-
toSet.deploymentEnvironment = environment;
256-
}
257-
}
258-
259242
const suggestedName = kebabCase(
260243
repositoryUrl
261244
.split('/')
@@ -311,16 +294,6 @@ export const RegisterRepositoryPage = () => {
311294
return selectItems;
312295
}, []);
313296

314-
const deploymentEnvironmentRadioOptions = useMemo(
315-
() =>
316-
Object.keys(DeploymentEnvironmentDetails).map(env => ({
317-
label: env,
318-
value: env,
319-
description: DeploymentEnvironmentDetails[env].description,
320-
})),
321-
[],
322-
);
323-
324297
return (
325298
<div>
326299
<Breadcrumbs>
@@ -498,22 +471,6 @@ export const RegisterRepositoryPage = () => {
498471
</div>
499472
</SimpleStepperStep>
500473

501-
{state.contentSummary === ContentSummary.DEPLOYMENT && (
502-
<SimpleStepperStep title="Deployment Environment">
503-
<div className={classes.stepContent}>
504-
<RadioGroup
505-
label="Development Environment"
506-
onChange={value =>
507-
updateStateValue('deploymentEnvironment', value)
508-
}
509-
value={state.deploymentEnvironment}
510-
options={deploymentEnvironmentRadioOptions}
511-
helperText="Select the environment that maps to your repository."
512-
/>
513-
</div>
514-
</SimpleStepperStep>
515-
)}
516-
517474
<SimpleStepperStep
518475
title="Confirm"
519476
actions={{ nextText: 'Register Repository', onNext: registerRepo }}

plugins/cad/src/components/RepositoryPage/components/RepositoryDetails.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import React from 'react';
1919
import { Repository } from '../../../types/Repository';
2020
import { RepositorySummary } from '../../../types/RepositorySummary';
2121
import {
22-
getDeploymentEnvironment,
2322
getPackageDescriptor,
24-
isDeploymentRepository,
2523
isReadOnlyRepository,
2624
} from '../../../utils/repository';
2725

@@ -90,16 +88,11 @@ const getRepositoryMetadata = (repository: Repository): Metadata => {
9088
name: repository.metadata.name,
9189
description: repository.spec.description ?? '',
9290
content: `${getPackageDescriptor(repository)}s`,
93-
deploymentEnvironment: getDeploymentEnvironment(repository),
9491
repositoryAccess: isReadOnly ? 'read-only access' : 'write access',
9592
...getRepositoryStoreMetadata(repository),
9693
...getRepositoryStatusConditions(repository),
9794
};
9895

99-
if (!isDeploymentRepository(repository)) {
100-
delete metadata.deploymentEnvironment;
101-
}
102-
10396
return metadata;
10497
};
10598

plugins/cad/src/utils/repository.ts

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,7 @@ type ContentCloneToDetail = {
4646
message?: string;
4747
};
4848

49-
type EnvironmentDetails = {
50-
[key: string]: EnvironmentDetail;
51-
};
52-
53-
type EnvironmentDetail = {
54-
shortName: string;
55-
description: string;
56-
repositoryEnvironmentLabelValue?: string;
57-
notDeploymentEnvironment?: DeploymentEnvironment[];
58-
};
59-
6049
const REPOSITORY_CONTENT_LABEL = 'kpt.dev/repository-content';
61-
const REPOSITORY_DEPLOYMENT_ENVIRONMENT_LABEL =
62-
'kpt.dev/deployment-environment';
6350
const REPOSITORY_ACCESS_LABEL = 'kpt.dev/repository-access';
6451

6552
export enum ContentSummary {
@@ -70,12 +57,6 @@ export enum ContentSummary {
7057
FUNCTION = 'Function',
7158
}
7259

73-
export enum DeploymentEnvironment {
74-
DEVELOPMENT = 'Development',
75-
STAGING = 'Staging',
76-
PRODUCTION = 'Production',
77-
}
78-
7960
export enum RepositoryAccess {
8061
FULL = 'full',
8162
READ_ONLY = 'read-only',
@@ -180,30 +161,6 @@ export const RepositoryContentDetails: ContentDetailsLookup = {
180161
},
181162
};
182163

183-
export const DeploymentEnvironmentDetails: EnvironmentDetails = {
184-
[DeploymentEnvironment.DEVELOPMENT]: {
185-
shortName: 'dev',
186-
description:
187-
'The development environment is the environment your team uses for day-to-day development. A Team Blueprint package is expected to be cloned to this environment first.',
188-
notDeploymentEnvironment: [
189-
DeploymentEnvironment.STAGING,
190-
DeploymentEnvironment.PRODUCTION,
191-
],
192-
},
193-
[DeploymentEnvironment.STAGING]: {
194-
shortName: 'staging',
195-
description:
196-
'The staging environment is similar to the production environment, except it does not receive live traffic. A Team Blueprint package is expected to be cloned to this environment after it is cloned, published, and tested in the development environment.',
197-
repositoryEnvironmentLabelValue: 'staging',
198-
},
199-
[DeploymentEnvironment.PRODUCTION]: {
200-
shortName: 'prod',
201-
description:
202-
'The production environment receives live traffic. A Team Blueprint package is expected to be cloned to this environment after it is cloned, published, and tested in the staging environment.',
203-
repositoryEnvironmentLabelValue: 'production',
204-
},
205-
};
206-
207164
const isRepositoryContent = (
208165
repository: Repository,
209166
contentType: ContentSummary,
@@ -280,36 +237,6 @@ export const getPackageDescriptor = (repository: Repository): string => {
280237
return 'Unknown';
281238
};
282239

283-
const isDeploymentEnviroment = (
284-
repository: Repository,
285-
environment: DeploymentEnvironment,
286-
): boolean => {
287-
const environmentDetails = DeploymentEnvironmentDetails[environment];
288-
289-
const isLabelMatch =
290-
!environmentDetails.repositoryEnvironmentLabelValue ||
291-
repository.metadata.labels?.[REPOSITORY_DEPLOYMENT_ENVIRONMENT_LABEL] ===
292-
environmentDetails.repositoryEnvironmentLabelValue;
293-
294-
const isDeployment = isDeploymentRepository(repository);
295-
const notContent = environmentDetails.notDeploymentEnvironment ?? [];
296-
const noDisqualifiers = !notContent
297-
.map(env => isDeploymentEnviroment(repository, env))
298-
.includes(true);
299-
300-
return isDeployment && isLabelMatch && noDisqualifiers;
301-
};
302-
303-
export const getDeploymentEnvironment = (repository: Repository): string => {
304-
for (const env of Object.keys(DeploymentEnvironmentDetails)) {
305-
if (isDeploymentEnviroment(repository, env as DeploymentEnvironment)) {
306-
return env;
307-
}
308-
}
309-
310-
return 'Unknown';
311-
};
312-
313240
export const getRepository = (
314241
allRepositories: Repository[],
315242
repositoryName: string,
@@ -361,7 +288,6 @@ export const getRepositoryResource = (
361288
repositoryAccess: RepositoryAccess,
362289
git?: RepositoryGitDetails,
363290
oci?: RepositoryOciDetails,
364-
deploymentEnvironment?: DeploymentEnvironment,
365291
): Repository => {
366292
const contentDetails = RepositoryContentDetails[contentSummary];
367293

@@ -377,16 +303,6 @@ export const getRepositoryResource = (
377303
contentDetails.repositoryContentLabelValue;
378304
}
379305

380-
if (contentSummary === ContentSummary.DEPLOYMENT && deploymentEnvironment) {
381-
const environmentDetails =
382-
DeploymentEnvironmentDetails[deploymentEnvironment];
383-
384-
if (environmentDetails.repositoryEnvironmentLabelValue) {
385-
labels[REPOSITORY_DEPLOYMENT_ENVIRONMENT_LABEL] =
386-
environmentDetails.repositoryEnvironmentLabelValue;
387-
}
388-
}
389-
390306
if (repositoryAccess === RepositoryAccess.READ_ONLY) {
391307
labels[REPOSITORY_ACCESS_LABEL] = RepositoryAccess.READ_ONLY;
392308
}

0 commit comments

Comments
 (0)