Skip to content

Commit 75281f3

Browse files
shivanand-harnessHarness
authored andcommitted
feat: [AH-1881]: support conda package type for enterprise only (#4664)
* 5e5959 feat: [AH-1881]: resolve PR comments * f99aec feat: [AH-1881]: update icon and conda package metadata mapping * 84a2ee feat: [AH-1881]: support conda package type for enterprise only
1 parent 44634a1 commit 75281f3

26 files changed

+740
-20
lines changed

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"@codemirror/state": "^6.2.0",
5151
"@codemirror/view": "^6.9.6",
5252
"@harnessio/design-system": "^2.1.1",
53-
"@harnessio/icons": "^2.1.13",
54-
"@harnessio/react-har-service-client": "^0.29.0",
53+
"@harnessio/icons": "^2.1.14",
54+
"@harnessio/react-har-service-client": "^0.30.0",
5555
"@harnessio/react-ng-manager-client": "^1.40.0",
5656
"@harnessio/react-ssca-manager-client": "^0.65.0",
5757
"@harnessio/uicore": "^4.3.4",

web/src/ar/MFEAppTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,6 @@ export enum FeatureFlags {
153153
HAR_CUSTOM_METADATA_ENABLED = 'HAR_CUSTOM_METADATA_ENABLED',
154154
HAR_ARTIFACT_QUARANTINE_ENABLED = 'HAR_ARTIFACT_QUARANTINE_ENABLED',
155155
HAR_ENABLE_UNTAGGED_IMAGES_SUPPORT = 'HAR_ENABLE_UNTAGGED_IMAGES_SUPPORT',
156-
HAR_SUPPORT_LOCAL_REGISTRY_AS_UPSTREAM_PROXY = 'HAR_SUPPORT_LOCAL_REGISTRY_AS_UPSTREAM_PROXY'
156+
HAR_SUPPORT_LOCAL_REGISTRY_AS_UPSTREAM_PROXY = 'HAR_SUPPORT_LOCAL_REGISTRY_AS_UPSTREAM_PROXY',
157+
HAR_CONDA_PACKAGE_TYPE = 'HAR_CONDA_PACKAGE_TYPE'
157158
}

web/src/ar/common/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export enum RepositoryPackageType {
6464
DEBIAN = 'DEBIAN',
6565
CARGO = 'CARGO',
6666
ALPINE = 'ALPINE',
67-
HUGGINGFACE = 'HUGGINGFACE'
67+
HUGGINGFACE = 'HUGGINGFACE',
68+
CONDA = 'CONDA'
6869
}
6970

7071
export enum RepositoryConfigType {

web/src/ar/hooks/useGetRepositoryTypes.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
*/
1616

1717
import type { IconName } from '@harnessio/icons'
18-
import type { FeatureFlags } from '@ar/MFEAppTypes'
18+
19+
import { FeatureFlags } from '@ar/MFEAppTypes'
1920
import type { StringsMap } from '@ar/frameworks/strings'
20-
import { RepositoryPackageType } from '@ar/common/types'
21+
import { Parent, RepositoryPackageType } from '@ar/common/types'
2122
import { ThumbnailTagEnum } from '@ar/components/Tag/ThumbnailTags'
23+
24+
import { useAppStore } from './useAppStore'
2225
import { useFeatureFlags } from './useFeatureFlag'
2326

2427
export interface RepositoryTypeListItem {
@@ -29,10 +32,12 @@ export interface RepositoryTypeListItem {
2932
tooltip?: string
3033
featureFlag?: FeatureFlags
3134
tag?: ThumbnailTagEnum
35+
parent?: Parent
3236
}
3337

3438
export const useGetRepositoryTypes = (): RepositoryTypeListItem[] => {
3539
const featureFlags = useFeatureFlags()
40+
const { parent } = useAppStore()
3641

3742
return RepositoryTypes.map(repo => {
3843
if (repo.disabled && repo.featureFlag && featureFlags[repo.featureFlag]) {
@@ -44,7 +49,7 @@ export const useGetRepositoryTypes = (): RepositoryTypeListItem[] => {
4449
}
4550
}
4651
return repo
47-
})
52+
}).filter(each => (each.parent ? each.parent === parent : true))
4853
}
4954

5055
const RepositoryTypes: RepositoryTypeListItem[] = [
@@ -106,6 +111,16 @@ const RepositoryTypes: RepositoryTypeListItem[] = [
106111
icon: 'huggingface',
107112
tag: ThumbnailTagEnum.Beta
108113
},
114+
{
115+
label: 'repositoryTypes.conda',
116+
value: RepositoryPackageType.CONDA,
117+
icon: 'conda-icon',
118+
tooltip: 'Coming Soon!',
119+
disabled: true,
120+
tag: ThumbnailTagEnum.ComingSoon,
121+
featureFlag: FeatureFlags.HAR_CONDA_PACKAGE_TYPE,
122+
parent: Parent.Enterprise
123+
},
109124
{
110125
label: 'repositoryTypes.debian',
111126
value: RepositoryPackageType.DEBIAN,

web/src/ar/hooks/useGetUpstreamRepositoryPackageTypes.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
import type { IconName } from '@harnessio/icons'
1818

19-
import type { FeatureFlags } from '@ar/MFEAppTypes'
19+
import { Parent } from '@ar/common/types'
20+
import { FeatureFlags } from '@ar/MFEAppTypes'
2021
import type { StringsMap } from '@ar/frameworks/strings'
2122
import { ThumbnailTagEnum } from '@ar/components/Tag/ThumbnailTags'
2223
import { UpstreamProxyPackageType } from '@ar/pages/upstream-proxy-details/types'
2324

25+
import { useAppStore } from './useAppStore'
2426
import { useFeatureFlags } from './useFeatureFlag'
2527

2628
export interface UpstreamRepositoryPackageTypeListItem {
@@ -31,10 +33,12 @@ export interface UpstreamRepositoryPackageTypeListItem {
3133
tooltip?: string
3234
featureFlag?: FeatureFlags
3335
tag?: ThumbnailTagEnum
36+
parent?: Parent
3437
}
3538

3639
export const useGetUpstreamRepositoryPackageTypes = (): UpstreamRepositoryPackageTypeListItem[] => {
3740
const featureFlags = useFeatureFlags()
41+
const { parent } = useAppStore()
3842

3943
return UpstreamProxyPackageTypeList.map(repo => {
4044
if (repo.disabled && repo.featureFlag && featureFlags[repo.featureFlag]) {
@@ -46,7 +50,7 @@ export const useGetUpstreamRepositoryPackageTypes = (): UpstreamRepositoryPackag
4650
}
4751
}
4852
return repo
49-
})
53+
}).filter(each => (each.parent ? each.parent === parent : true))
5054
}
5155

5256
export const UpstreamProxyPackageTypeList: UpstreamRepositoryPackageTypeListItem[] = [
@@ -109,6 +113,16 @@ export const UpstreamProxyPackageTypeList: UpstreamRepositoryPackageTypeListItem
109113
icon: 'huggingface',
110114
tag: ThumbnailTagEnum.Beta
111115
},
116+
{
117+
label: 'repositoryTypes.conda',
118+
value: UpstreamProxyPackageType.CONDA,
119+
icon: 'conda-icon',
120+
tooltip: 'Coming Soon!',
121+
disabled: true,
122+
tag: ThumbnailTagEnum.ComingSoon,
123+
featureFlag: FeatureFlags.HAR_CONDA_PACKAGE_TYPE,
124+
parent: Parent.Enterprise
125+
},
112126
{
113127
label: 'repositoryTypes.debian',
114128
value: UpstreamProxyPackageType.DEBIAN,
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright 2024 Harness, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import React from 'react'
18+
import type { IconName } from '@harnessio/icons'
19+
20+
import { RepositoryConfigType, RepositoryPackageType } from '@ar/common/types'
21+
import UpstreamProxyActions from '@ar/pages/upstream-proxy-details/components/UpstreamProxyActions/UpstreamProxyActions'
22+
import UpstreamProxyConfigurationForm from '@ar/pages/upstream-proxy-details/components/Forms/UpstreamProxyConfigurationForm'
23+
import UpstreamProxyCreateFormContent from '@ar/pages/upstream-proxy-details/components/FormContent/UpstreamProxyCreateFormContent'
24+
import UpstreamProxyDetailsHeader from '@ar/pages/upstream-proxy-details/components/UpstreamProxyDetailsHeader/UpstreamProxyDetailsHeader'
25+
import {
26+
type CreateRepositoryFormProps,
27+
type RepositoryActionsProps,
28+
type RepositoryConfigurationFormProps,
29+
type RepositoryDetailsHeaderProps,
30+
RepositoryStep,
31+
type RepositoryTreeNodeProps,
32+
type RepositoySetupClientProps
33+
} from '@ar/frameworks/RepositoryStep/Repository'
34+
import {
35+
UpstreamProxyAuthenticationMode,
36+
type UpstreamRegistryRequest,
37+
UpstreamRepositoryURLInputSource
38+
} from '@ar/pages/upstream-proxy-details/types'
39+
40+
import RepositoryDetails from '../RepositoryDetails'
41+
import type { Repository, VirtualRegistryRequest } from '../types'
42+
import RepositoryActions from '../components/Actions/RepositoryActions'
43+
import RedirectPageView from '../components/RedirectPageView/RedirectPageView'
44+
import SetupClientContent from '../components/SetupClientContent/SetupClientContent'
45+
import RepositoryTreeNode from '../components/RepositoryTreeNode/RepositoryTreeNode'
46+
import RepositoryConfigurationForm from '../components/Forms/RepositoryConfigurationForm'
47+
import RepositoryCreateFormContent from '../components/FormContent/RepositoryCreateFormContent'
48+
import RepositoryDetailsHeader from '../components/RepositoryDetailsHeader/RepositoryDetailsHeader'
49+
50+
export class CondaRepositoryType extends RepositoryStep<VirtualRegistryRequest> {
51+
protected packageType = RepositoryPackageType.CONDA
52+
protected repositoryName = 'Conda Repository'
53+
protected repositoryIcon: IconName = 'conda-icon'
54+
protected supportedScanners = []
55+
protected supportsUpstreamProxy = true
56+
protected supportedUpstreamURLSources = [
57+
UpstreamRepositoryURLInputSource.Anaconda,
58+
UpstreamRepositoryURLInputSource.Custom
59+
]
60+
61+
protected defaultValues: VirtualRegistryRequest = {
62+
packageType: RepositoryPackageType.CONDA,
63+
identifier: '',
64+
config: {
65+
type: RepositoryConfigType.VIRTUAL
66+
},
67+
scanners: [],
68+
isPublic: false
69+
}
70+
71+
protected defaultUpstreamProxyValues: UpstreamRegistryRequest = {
72+
packageType: RepositoryPackageType.CONDA,
73+
identifier: '',
74+
config: {
75+
type: RepositoryConfigType.UPSTREAM,
76+
source: UpstreamRepositoryURLInputSource.Anaconda,
77+
authType: UpstreamProxyAuthenticationMode.ANONYMOUS,
78+
url: ''
79+
},
80+
cleanupPolicy: [],
81+
scanners: [],
82+
isPublic: false
83+
}
84+
85+
renderCreateForm(props: CreateRepositoryFormProps): JSX.Element {
86+
const { type } = props
87+
if (type === RepositoryConfigType.VIRTUAL) {
88+
return <RepositoryCreateFormContent isEdit={false} />
89+
} else {
90+
return <UpstreamProxyCreateFormContent isEdit={false} readonly={false} />
91+
}
92+
}
93+
94+
renderCofigurationForm(props: RepositoryConfigurationFormProps<Repository>): JSX.Element {
95+
const { type } = props
96+
if (type === RepositoryConfigType.VIRTUAL) {
97+
return <RepositoryConfigurationForm ref={props.formikRef} readonly={props.readonly} />
98+
} else {
99+
return <UpstreamProxyConfigurationForm ref={props.formikRef} readonly={props.readonly} />
100+
}
101+
}
102+
103+
renderActions(props: RepositoryActionsProps<Repository>): JSX.Element {
104+
if (props.type === RepositoryConfigType.VIRTUAL) {
105+
return <RepositoryActions data={props.data} readonly={props.readonly} pageType={props.pageType} />
106+
}
107+
return <UpstreamProxyActions data={props.data} readonly={props.readonly} pageType={props.pageType} />
108+
}
109+
110+
renderSetupClient(props: RepositoySetupClientProps): JSX.Element {
111+
const { repoKey, onClose, artifactKey, versionKey } = props
112+
return (
113+
<SetupClientContent
114+
repoKey={repoKey}
115+
artifactKey={artifactKey}
116+
versionKey={versionKey}
117+
onClose={onClose}
118+
packageType={RepositoryPackageType.CONDA}
119+
/>
120+
)
121+
}
122+
123+
renderRepositoryDetailsHeader(props: RepositoryDetailsHeaderProps<Repository>): JSX.Element {
124+
const { type } = props
125+
if (type === RepositoryConfigType.VIRTUAL) {
126+
return <RepositoryDetailsHeader data={props.data} />
127+
} else {
128+
return <UpstreamProxyDetailsHeader data={props.data} />
129+
}
130+
}
131+
132+
renderRedirectPage(): JSX.Element {
133+
return <RedirectPageView />
134+
}
135+
136+
renderTreeNodeView(props: RepositoryTreeNodeProps): JSX.Element {
137+
return <RepositoryTreeNode {...props} icon={this.repositoryIcon} />
138+
}
139+
140+
renderTreeNodeDetails(): JSX.Element {
141+
return <RepositoryDetails />
142+
}
143+
}

web/src/ar/pages/repository-details/RepositoryFactory.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { RPMRepositoryType } from './RPMRepository/RPMRepositoryType'
2626
import { CargoRepositoryType } from './CargoRepository/CargoRepositoryType'
2727
import { GoRepositoryType } from './GoRepository/GoRepositoryType'
2828
import { HuggingfaceRepositoryType } from './HuggingfaceRepositoryType/HuggingfaceRepositoryType'
29+
import { CondaRepositoryType } from './CondaRepository/CondaRepositoryType'
2930

3031
repositoryFactory.registerStep(new DockerRepositoryType())
3132
repositoryFactory.registerStep(new HelmRepositoryType())
@@ -38,3 +39,4 @@ repositoryFactory.registerStep(new RPMRepositoryType())
3839
repositoryFactory.registerStep(new CargoRepositoryType())
3940
repositoryFactory.registerStep(new GoRepositoryType())
4041
repositoryFactory.registerStep(new HuggingfaceRepositoryType())
42+
repositoryFactory.registerStep(new CondaRepositoryType())

web/src/ar/pages/upstream-proxy-details/components/AuthenticationFormInput/constants.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,9 @@ export const URLSourceToSupportedAuthTypesMapping: Record<
8282
[UpstreamRepositoryURLInputSource.HuggingFace]: [
8383
UpstreamProxyAuthenticationMode.USER_NAME_AND_PASSWORD,
8484
UpstreamProxyAuthenticationMode.ANONYMOUS
85+
],
86+
[UpstreamRepositoryURLInputSource.Anaconda]: [
87+
UpstreamProxyAuthenticationMode.USER_NAME_AND_PASSWORD,
88+
UpstreamProxyAuthenticationMode.ANONYMOUS
8589
]
8690
}

web/src/ar/pages/upstream-proxy-details/components/Forms/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export function getFormattedFormDataForAuthType(
125125
UpstreamRepositoryURLInputSource.NpmJS,
126126
UpstreamRepositoryURLInputSource.NugetOrg,
127127
UpstreamRepositoryURLInputSource.PyPi,
128-
UpstreamRepositoryURLInputSource.GoProxy
128+
UpstreamRepositoryURLInputSource.GoProxy,
129+
UpstreamRepositoryURLInputSource.Anaconda
129130
].includes(draft.config.source as UpstreamRepositoryURLInputSource)
130131
) {
131132
set(draft, 'config.url', '')

web/src/ar/pages/upstream-proxy-details/components/RepositoryUrlInput/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,9 @@ export const UpstreamURLSourceConfig: Record<UpstreamRepositoryURLInputSource, R
6161
[UpstreamRepositoryURLInputSource.HuggingFace]: {
6262
label: 'upstreamProxyDetails.createForm.source.huggingface',
6363
value: UpstreamRepositoryURLInputSource.HuggingFace
64+
},
65+
[UpstreamRepositoryURLInputSource.Anaconda]: {
66+
label: 'upstreamProxyDetails.createForm.source.anaconda',
67+
value: UpstreamRepositoryURLInputSource.Anaconda
6468
}
6569
}

0 commit comments

Comments
 (0)