Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add kind annotation to EC ITS #828

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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