diff --git a/src/components/IntegrationTest/IntegrationTestForm/const.ts b/src/components/IntegrationTest/IntegrationTestForm/const.ts index 88423a5bb..2703bb796 100644 --- a/src/components/IntegrationTest/IntegrationTestForm/const.ts +++ b/src/components/IntegrationTest/IntegrationTestForm/const.ts @@ -1,3 +1,4 @@ export const EC_INTEGRATION_TEST_URL = 'https://github.com/redhat-appstudio/build-definitions'; export const EC_INTEGRATION_TEST_REVISION = 'main'; export const EC_INTEGRATION_TEST_PATH = 'pipelines/enterprise-contract.yaml'; +export const EC_INTEGRATION_TEST_KIND = 'enterprise-contract'; diff --git a/src/components/IntegrationTest/IntegrationTestForm/types.ts b/src/components/IntegrationTest/IntegrationTestForm/types.ts index 368837023..be7d1159f 100644 --- a/src/components/IntegrationTest/IntegrationTestForm/types.ts +++ b/src/components/IntegrationTest/IntegrationTestForm/types.ts @@ -16,6 +16,7 @@ export type IntegrationTestFormValues = { export enum IntegrationTestAnnotations { DISPLAY_NAME = 'app.kubernetes.io/display-name', + KIND = 'test.appstudio.openshift.io/kind', } export enum IntegrationTestLabels { diff --git a/src/components/IntegrationTest/IntegrationTestForm/utils/__tests__/create-utils.spec.ts b/src/components/IntegrationTest/IntegrationTestForm/utils/__tests__/create-utils.spec.ts index 21b2d16f1..e2d3b72ef 100644 --- a/src/components/IntegrationTest/IntegrationTestForm/utils/__tests__/create-utils.spec.ts +++ b/src/components/IntegrationTest/IntegrationTestForm/utils/__tests__/create-utils.spec.ts @@ -1,7 +1,13 @@ import { k8sCreateResource } from '@openshift/dynamic-plugin-sdk-utils'; import { IntegrationTestScenarioModel } from '../../../../../models'; import { MockIntegrationTestsWithGit } from '../../../IntegrationTestsListView/__data__/mock-integration-tests'; -import { IntegrationTestLabels } from '../../types'; +import { + EC_INTEGRATION_TEST_KIND, + EC_INTEGRATION_TEST_PATH, + EC_INTEGRATION_TEST_REVISION, + EC_INTEGRATION_TEST_URL, +} from '../../const'; +import { IntegrationTestAnnotations, IntegrationTestLabels } from '../../types'; import { ResolverRefParams, createIntegrationTest, @@ -190,6 +196,24 @@ describe('Create Utils', () => { 'https://github.com/redhat-appstudio/integration-examples/tree/main/pipelines/integration_pipeline_pass.yaml', ); }); + + it('Should set EC kind annotation', async () => { + createResourceMock.mockImplementation(({ resource }) => resource); + const resource = await createIntegrationTest( + { + name: 'app-enterprise-contract', + revision: EC_INTEGRATION_TEST_REVISION, + url: EC_INTEGRATION_TEST_URL, + path: EC_INTEGRATION_TEST_PATH, + optional: false, + }, + 'Test Application', + 'test-ns', + ); + expect(resource.metadata.annotations).toStrictEqual({ + [IntegrationTestAnnotations.KIND]: EC_INTEGRATION_TEST_KIND, + }); + }); }); describe('Create Utils formatParams', () => { diff --git a/src/components/IntegrationTest/IntegrationTestForm/utils/create-utils.ts b/src/components/IntegrationTest/IntegrationTestForm/utils/create-utils.ts index 486b8d8c9..679d400bb 100644 --- a/src/components/IntegrationTest/IntegrationTestForm/utils/create-utils.ts +++ b/src/components/IntegrationTest/IntegrationTestForm/utils/create-utils.ts @@ -10,9 +10,16 @@ import { ResolverParam, ResolverType, } from '../../../../types/coreBuildService'; +import { + EC_INTEGRATION_TEST_KIND, + EC_INTEGRATION_TEST_PATH, + EC_INTEGRATION_TEST_REVISION, + EC_INTEGRATION_TEST_URL, +} from '../const'; import { ENVIRONMENTS, FormValues, + IntegrationTestAnnotations, IntegrationTestFormValues, IntegrationTestLabels, } from '../types'; @@ -110,6 +117,10 @@ export const createIntegrationTest = ( ): Promise => { const { name, url, revision, path, optional, environmentName, environmentType, params } = integrationTestValues; + const isEC = + url === EC_INTEGRATION_TEST_URL && + revision === EC_INTEGRATION_TEST_REVISION && + path === EC_INTEGRATION_TEST_PATH; const integrationTestResource: IntegrationTestScenarioKind = { apiVersion: `${IntegrationTestScenarioGroupVersionKind.group}/${IntegrationTestScenarioGroupVersionKind.version}`, kind: IntegrationTestScenarioGroupVersionKind.kind, @@ -117,6 +128,7 @@ export const createIntegrationTest = ( name, namespace, ...(optional && { labels: { [IntegrationTestLabels.OPTIONAL]: optional.toString() } }), + ...(isEC && { annotations: { [IntegrationTestAnnotations.KIND]: EC_INTEGRATION_TEST_KIND } }), }, spec: { application,