-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add codemie integration page (#315)
- Loading branch information
1 parent
8c5b694
commit f20494a
Showing
194 changed files
with
2,757 additions
and
397 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { KubeObjectConfig } from '../../../../types/configs/k8s'; | ||
|
||
export const CodemieKubeObjectConfig: KubeObjectConfig = { | ||
kind: 'Codemie', | ||
name: { | ||
singularForm: 'codemie', | ||
pluralForm: 'codemies', | ||
}, | ||
group: 'edp.epam.com', | ||
version: 'v1alpha1', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ApiProxy, K8s } from '@kinvolk/headlamp-plugin/lib'; | ||
import { CodemieKubeObjectConfig } from './config'; | ||
import { CodemieKubeObjectInterface } from './types'; | ||
|
||
const { | ||
name: { singularForm, pluralForm }, | ||
group, | ||
version, | ||
} = CodemieKubeObjectConfig; | ||
|
||
export class CodemieKubeObject extends K8s.cluster.makeKubeObject<CodemieKubeObjectInterface>(singularForm) { | ||
static apiEndpoint = ApiProxy.apiFactoryWithNamespace(group, version, pluralForm); | ||
|
||
static get className(): string { | ||
return singularForm; | ||
} | ||
|
||
get spec(): CodemieKubeObjectInterface['spec'] { | ||
return this.jsonData!.spec; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { KubeObjectInterface } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; | ||
|
||
export interface CodemieKubeObjectInterface extends KubeObjectInterface { | ||
spec: { | ||
oidc: { | ||
secretRef: { | ||
clientKey: string; | ||
secretKey: string; | ||
name: string; | ||
}; | ||
tokenEndpoint: string; | ||
}; | ||
url: string; | ||
}; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/k8s/groups/EDP/Codemie/utils/createCodemieInstance/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CODEMIE_FORM_NAMES } from '../../../../../../widgets/ManageCodeMie/names'; | ||
import { createCodemieInstance } from './index'; | ||
|
||
describe('testing createCodemieInstance', () => { | ||
it('should return valid kube object', () => { | ||
const object = createCodemieInstance(CODEMIE_FORM_NAMES, { | ||
name: 'codemie', | ||
tokenEndpoint: 'test-token-endpoint', | ||
apiUrl: 'test-api-url', | ||
}); | ||
|
||
expect(object).toMatchObject({ | ||
apiVersion: 'edp.epam.com/v1alpha1', | ||
kind: 'Codemie', | ||
metadata: { name: 'codemie' }, | ||
spec: { | ||
oidc: { | ||
secretRef: { | ||
name: 'codemie', | ||
clientKey: 'client_id', | ||
secretKey: 'client_secret', | ||
}, | ||
tokenEndpoint: 'test-token-endpoint', | ||
}, | ||
url: 'test-api-url', | ||
}, | ||
}); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
src/k8s/groups/EDP/Codemie/utils/createCodemieInstance/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { set } from 'lodash'; | ||
import { FormNameObject } from '../../../../../../types/forms'; | ||
import { DeepPartial } from '../../../../../../types/global'; | ||
import { CodemieFormValues } from '../../../../../../widgets/ManageCodeMie/types'; | ||
import { CodemieKubeObjectConfig } from '../../config'; | ||
import { CodemieKubeObjectInterface } from '../../types'; | ||
|
||
const { kind, group, version } = CodemieKubeObjectConfig; | ||
|
||
export const createCodemieInstance = ( | ||
names: { | ||
[key: string]: FormNameObject; | ||
}, | ||
formValues: CodemieFormValues | ||
): CodemieKubeObjectInterface => { | ||
const { name, ...restProps } = formValues; | ||
|
||
const base: DeepPartial<CodemieKubeObjectInterface> = { | ||
apiVersion: `${group}/${version}`, | ||
kind, | ||
metadata: { | ||
name: name, | ||
}, | ||
spec: { | ||
oidc: { | ||
secretRef: { | ||
name, | ||
clientKey: 'client_id', | ||
secretKey: 'client_secret', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
for (const [propKey, propValue] of Object.entries(restProps)) { | ||
const propPath = names[propKey].path; | ||
set(base, propPath, propValue); | ||
} | ||
|
||
return base as CodemieKubeObjectInterface; | ||
}; |
34 changes: 34 additions & 0 deletions
34
src/k8s/groups/EDP/Codemie/utils/createCodemieSecretInstance/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { CODEMIE_SECRET_FORM_NAMES } from '../../../../../../widgets/ManageCodeMie/names'; | ||
import { | ||
SECRET_LABEL_ASSOCIATED_KIND, | ||
SECRET_LABEL_SECRET_TYPE, | ||
} from '../../../../default/Secret/labels'; | ||
import { CodemieKubeObjectConfig } from '../../config'; | ||
import { createCodemieSecretInstance } from './index'; | ||
|
||
describe('testing createCodemieSecretInstance', () => { | ||
it('should return valid kube object', () => { | ||
const object = createCodemieSecretInstance(CODEMIE_SECRET_FORM_NAMES, { | ||
name: 'codemie', | ||
clientId: 'test-client-id', | ||
clientSecret: 'test-client-secret', | ||
}); | ||
|
||
expect(object).toMatchObject({ | ||
apiVersion: 'v1', | ||
kind: 'Secret', | ||
metadata: { | ||
name: 'codemie', | ||
labels: { | ||
[SECRET_LABEL_SECRET_TYPE]: 'codemie', | ||
[SECRET_LABEL_ASSOCIATED_KIND]: CodemieKubeObjectConfig.kind, | ||
}, | ||
}, | ||
type: 'Opaque', | ||
data: { | ||
client_id: 'dGVzdC1jbGllbnQtaWQ=', | ||
client_secret: 'dGVzdC1jbGllbnQtc2VjcmV0', | ||
}, | ||
}); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
src/k8s/groups/EDP/Codemie/utils/createCodemieSecretInstance/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { set } from 'lodash'; | ||
import { FormNameObject } from '../../../../../../types/forms'; | ||
import { DeepPartial } from '../../../../../../types/global'; | ||
import { EDPKubeObjectInterface } from '../../../../../../types/k8s'; | ||
import { safeEncode } from '../../../../../../utils/decodeEncode'; | ||
import { CodemieSecretFormValues } from '../../../../../../widgets/ManageCodeMie/types'; | ||
import { | ||
SECRET_LABEL_ASSOCIATED_KIND, | ||
SECRET_LABEL_SECRET_TYPE, | ||
} from '../../../../default/Secret/labels'; | ||
import { CodemieKubeObjectConfig } from '../../config'; | ||
|
||
export const createCodemieSecretInstance = ( | ||
names: { | ||
[key: string]: FormNameObject; | ||
}, | ||
formValues: CodemieSecretFormValues | ||
): DeepPartial<EDPKubeObjectInterface> => { | ||
const { clientId, clientSecret, name, ...restProps } = formValues; | ||
|
||
const base: DeepPartial<EDPKubeObjectInterface> = { | ||
apiVersion: 'v1', | ||
kind: 'Secret', | ||
metadata: { | ||
name, | ||
labels: { | ||
[SECRET_LABEL_SECRET_TYPE]: 'codemie', | ||
[SECRET_LABEL_ASSOCIATED_KIND]: CodemieKubeObjectConfig.kind, | ||
}, | ||
}, | ||
data: { | ||
client_id: safeEncode(clientId), | ||
client_secret: safeEncode(clientSecret), | ||
}, | ||
type: 'Opaque', | ||
}; | ||
|
||
for (const [propKey, propValue] of Object.entries(restProps)) { | ||
const propPath = names[propKey].path; | ||
set(base, propPath, propValue); | ||
} | ||
|
||
return base; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { KubeObjectConfig } from '../../../../types/configs/k8s'; | ||
|
||
export const CodemieProjectKubeObjectConfig: KubeObjectConfig = { | ||
kind: 'CodemieProject', | ||
name: { | ||
singularForm: 'codemieproject', | ||
pluralForm: 'codemieprojects', | ||
}, | ||
group: 'edp.epam.com', | ||
version: 'v1alpha1', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ApiProxy, K8s } from '@kinvolk/headlamp-plugin/lib'; | ||
import { CodemieProjectKubeObjectConfig } from './config'; | ||
import { CodemieProjectKubeObjectInterface } from './types'; | ||
|
||
const { | ||
name: { singularForm, pluralForm }, | ||
group, | ||
version, | ||
} = CodemieProjectKubeObjectConfig; | ||
|
||
export class CodemieProjectKubeObject extends K8s.cluster.makeKubeObject<CodemieProjectKubeObjectInterface>(singularForm) { | ||
static apiEndpoint = ApiProxy.apiFactoryWithNamespace(group, version, pluralForm); | ||
|
||
static get className(): string { | ||
return singularForm; | ||
} | ||
|
||
get spec(): CodemieProjectKubeObjectInterface['spec'] { | ||
return this.jsonData!.spec; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { KubeObjectInterface } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; | ||
|
||
export interface CodemieProjectKubeObjectInterface extends KubeObjectInterface { | ||
spec: { | ||
codemieRef: { | ||
kind: 'Codemie'; | ||
name: string; | ||
}; | ||
name: string; | ||
}; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/k8s/groups/EDP/CodemieProject/utils/createCodemieProjectInstance/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CODEMIE_PROJECT_FORM_NAMES } from '../../../../../../widgets/ManageCodeMie/names'; | ||
import { createCodemieProjectInstance } from './index'; | ||
|
||
describe('testing createCodemieProjectInstance', () => { | ||
it('should return valid kube object', () => { | ||
const object = createCodemieProjectInstance(CODEMIE_PROJECT_FORM_NAMES, { | ||
projectName: 'test-project-name', | ||
codemieRefName: 'codemie', | ||
}); | ||
|
||
expect(object).toMatchObject({ | ||
apiVersion: 'edp.epam.com/v1alpha1', | ||
kind: 'CodemieProject', | ||
metadata: { name: 'test-project-name' }, | ||
spec: { | ||
name: 'test-project-name', | ||
codemieRef: { kind: 'Codemie', name: 'codemie' }, | ||
}, | ||
}); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
src/k8s/groups/EDP/CodemieProject/utils/createCodemieProjectInstance/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { set } from 'lodash'; | ||
import { FormNameObject } from '../../../../../../types/forms'; | ||
import { DeepPartial } from '../../../../../../types/global'; | ||
import { CodemieProjectFormValues } from '../../../../../../widgets/ManageCodeMie/types'; | ||
import { CodemieProjectKubeObjectConfig } from '../../config'; | ||
import { CodemieProjectKubeObjectInterface } from '../../types'; | ||
|
||
const { kind, group, version } = CodemieProjectKubeObjectConfig; | ||
|
||
export const createCodemieProjectInstance = ( | ||
names: { | ||
[key: string]: FormNameObject; | ||
}, | ||
formValues: CodemieProjectFormValues | ||
): CodemieProjectKubeObjectInterface => { | ||
const { projectName, ...restProps } = formValues; | ||
|
||
const base: DeepPartial<CodemieProjectKubeObjectInterface> = { | ||
apiVersion: `${group}/${version}`, | ||
kind, | ||
metadata: { | ||
name: projectName, | ||
}, | ||
spec: { | ||
name: projectName, | ||
codemieRef: { | ||
kind: 'Codemie', | ||
}, | ||
}, | ||
}; | ||
|
||
for (const [propKey, propValue] of Object.entries(restProps)) { | ||
const propPath = names[propKey].path; | ||
set(base, propPath, propValue); | ||
} | ||
|
||
return base as CodemieProjectKubeObjectInterface; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { KubeObjectConfig } from '../../../../types/configs/k8s'; | ||
|
||
export const CodemieProjectSettingsKubeObjectConfig: KubeObjectConfig = { | ||
kind: 'CodemieProjectSettings', | ||
name: { | ||
singularForm: 'codemieprojectsettings', | ||
pluralForm: 'codemieprojectsettings', | ||
}, | ||
group: 'edp.epam.com', | ||
version: 'v1alpha1', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ApiProxy, K8s } from '@kinvolk/headlamp-plugin/lib'; | ||
import { CodemieProjectSettingsKubeObjectConfig } from './config'; | ||
import { CodemieProjectSettingsKubeObjectInterface } from './types'; | ||
|
||
const { | ||
name: { singularForm, pluralForm }, | ||
group, | ||
version, | ||
} = CodemieProjectSettingsKubeObjectConfig; | ||
|
||
export class CodemieProjectSettingsKubeObject extends K8s.cluster.makeKubeObject<CodemieProjectSettingsKubeObjectInterface>( | ||
singularForm | ||
) { | ||
static apiEndpoint = ApiProxy.apiFactoryWithNamespace(group, version, pluralForm); | ||
|
||
static get className(): string { | ||
return singularForm; | ||
} | ||
|
||
get spec(): CodemieProjectSettingsKubeObjectInterface['spec'] { | ||
return this.jsonData!.spec; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { KubeObjectInterface } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; | ||
|
||
export interface CodemieProjectSettingsKubeObjectInterface extends KubeObjectInterface { | ||
spec: { | ||
alias: string; | ||
codemieRef: { | ||
kind: string; | ||
name: string; | ||
}; | ||
gitCredential: { | ||
secretRef: { | ||
name: string; | ||
secretKey: string; | ||
}; | ||
tokenName: string; | ||
url: string; | ||
}; | ||
projectName: string; | ||
type: string; | ||
}; | ||
} |
Oops, something went wrong.