Skip to content

Commit

Permalink
Merge pull request #828 from zregvart/issue/HACBS-2547
Browse files Browse the repository at this point in the history
feat: add kind annotation to EC ITS
  • Loading branch information
openshift-ci[bot] authored Oct 10, 2023
2 parents d2b4bd1 + 214367f commit c111901
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -110,13 +117,18 @@ export const createIntegrationTest = (
): Promise<IntegrationTestScenarioKind> => {
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,
metadata: {
name,
namespace,
...(optional && { labels: { [IntegrationTestLabels.OPTIONAL]: optional.toString() } }),
...(isEC && { annotations: { [IntegrationTestAnnotations.KIND]: EC_INTEGRATION_TEST_KIND } }),
},
spec: {
application,
Expand Down

0 comments on commit c111901

Please sign in to comment.