Skip to content

Commit

Permalink
fixup! feat: added implementation of devfileSchema API
Browse files Browse the repository at this point in the history
  • Loading branch information
olexii4 committed Nov 21, 2022
1 parent 63b4552 commit f9755d8
Show file tree
Hide file tree
Showing 6 changed files with 2,873 additions and 284 deletions.
810 changes: 533 additions & 277 deletions packages/dashboard-backend/src/devfileSchemas/2.2.0/devfile.json

Large diffs are not rendered by default.

2,304 changes: 2,304 additions & 0 deletions packages/dashboard-backend/src/devfileSchemas/2.2.1-alpha/devfile.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/dashboard-backend/src/routes/api/devfileSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as devfileSchemaV100 from '../../devfileSchemas/1.0.0/devfile.json';
import * as devfileSchemaV200 from '../../devfileSchemas/2.0.0/devfile.json';
import * as devfileSchemaV210 from '../../devfileSchemas/2.1.0/devfile.json';
import * as devfileSchemaV220 from '../../devfileSchemas/2.2.0/devfile.json';
import * as devfileSchemaV221Alpha from '../../devfileSchemas/2.2.1-alpha/devfile.json';
import { JSONSchema7 } from 'json-schema';

const tags = ['Devfile'];
Expand All @@ -43,6 +44,8 @@ export function registerDevfileSchemaRoute(server: FastifyInstance) {
return devfileSchemaV210;
case '2.2.0':
return devfileSchemaV220;
case '2.2.1-alpha':
return devfileSchemaV221Alpha;
}
reply.code(204);
},
Expand Down
1 change: 0 additions & 1 deletion packages/dashboard-backend/src/typings/models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import { IDevWorkspaceTemplate } from '../devworkspaceClient';
import { V1alpha2DevWorkspace } from '@devfile/api';
import { devfileVersionSchema } from '../constants/schemas';

declare namespace restParams {
export interface INamespacedParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ describe('Devfile registries', () => {
const schemaV200 = getSchemaV200();
const schemaV210 = getSchemaV210();
const schemaV220 = getSchemaV220();
const schemav221alpha = getSchemaV221Alpha();
(mockAxios.get as jest.Mock).mockResolvedValueOnce({
data: schemaV1,
});
Expand All @@ -215,6 +216,9 @@ describe('Devfile registries', () => {
(mockAxios.get as jest.Mock).mockResolvedValueOnce({
data: schemaV220,
});
(mockAxios.get as jest.Mock).mockResolvedValueOnce({
data: schemav221alpha,
});

const store = new FakeStoreBuilder()
.withWorkspacesSettings({
Expand All @@ -236,7 +240,13 @@ describe('Devfile registries', () => {
{
type: devfileRegistriesStore.Type.RECEIVE_SCHEMA,
schema: {
oneOf: expect.arrayContaining([schemaV1, schemaV200, schemaV210, schemaV220]),
oneOf: expect.arrayContaining([
schemaV1,
schemaV200,
schemaV210,
schemaV220,
schemav221alpha,
]),
},
},
];
Expand Down Expand Up @@ -645,7 +655,26 @@ function getSchemaV220() {
description:
'Devfile describes the structure of a cloud-native devworkspace and development environment.',
type: 'object',
title: 'Devfile schema - Version 2.2.0-alpha',
title: 'Devfile schema - Version 2.2.0',
required: ['schemaVersion'],
properties: {
schemaVersion: {
description: 'Devfile schema version',
type: 'string',
pattern:
'^([2-9])\\.([0-9]+)\\.([0-9]+)(\\-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$',
},
},
additionalProperties: false,
};
}

function getSchemaV221Alpha() {
return {
description:
'Devfile describes the structure of a cloud-native devworkspace and development environment.',
type: 'object',
title: 'Devfile schema - Version 2.2.1-alpha',
required: ['schemaVersion'],
properties: {
schemaVersion: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import common from '@eclipse-che/common';
import { AppThunk } from '..';
import { fetchRegistryMetadata, fetchDevfile } from '../../services/registry/devfiles';
import { createObject } from '../helpers';
import { container } from '../../inversify.config';
import { CheWorkspaceClient } from '../../services/workspace-client/cheworkspace/cheWorkspaceClient';
import { selectPlugins } from '../Plugins/chePlugins/selectors';
import { isDevworkspacesEnabled } from '../../services/helpers/devworkspace';
import fetchAndUpdateDevfileSchema from './fetchAndUpdateDevfileSchema';
import devfileApi from '../../services/devfileApi';
import { fetchResources, loadResourcesContent } from '../../services/registry/resources';
import { getDevfileSchema } from '../../services/dashboard-backend-client/devWorkspaceApi';

const WorkspaceClient = container.get(CheWorkspaceClient);
export const DEFAULT_REGISTRY = '/dashboard/devfile-registry/';

export type DevWorkspaceResources = [devfileApi.DevWorkspace, devfileApi.DevWorkspaceTemplate];
Expand Down Expand Up @@ -327,9 +324,10 @@ export const actionCreators: ActionCreators = {
const schemav200 = await fetchAndUpdateDevfileSchema('2.0.0');
const schemav210 = await fetchAndUpdateDevfileSchema('2.1.0');
const schemav220 = await fetchAndUpdateDevfileSchema('2.2.0');
const schemav221alpha = await fetchAndUpdateDevfileSchema('2.2.1-alpha');

schema = {
oneOf: [parsedSchemaV1, schemav200, schemav210, schemav220],
oneOf: [parsedSchemaV1, schemav200, schemav210, schemav220, schemav221alpha],
};
}

Expand Down

0 comments on commit f9755d8

Please sign in to comment.