-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new workspace creation URL parameter (#1037)
* feat: Add a new workspace creation URL parameter named editor-image Signed-off-by: Oleksii Orel <[email protected]>
- Loading branch information
Showing
17 changed files
with
424 additions
and
19 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ This file lists dependencies that do not need CQs or auto-detection does not wor | |
| Packages | Resolved CQs | | ||
| --- | --- | | ||
| `@fastify/[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@fastify/cors/8.4.1) | | ||
| `@fastify/reply-from@^9.6.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@fastify/reply-from/9.6.0) | | ||
| `@patternfly/[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@patternfly/react-core/4.278.0) | | ||
| `@patternfly/[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@patternfly/react-table/4.113.6) | | ||
| `@patternfly/[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@patternfly/react-icons/4.93.7) | | ||
|
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
| [`@fastify/[email protected]`](git+https://github.com/fastify/fast-json-stringify-compiler.git) | MIT | clearlydefined | | ||
| [`@fastify/[email protected]`](git+https://github.com/fastify/fastify-http-proxy.git) | MIT | clearlydefined | | ||
| [`@fastify/[email protected]`](git+https://github.com/fastify/fastify-oauth2.git) | MIT | clearlydefined | | ||
| [`@fastify/reply-from@9.4.0`](git+https://github.com/fastify/fastify-reply-from.git) | MIT | clearlydefined | | ||
| [`@fastify/reply-from@9.6.0`](git+https://github.com/fastify/fastify-reply-from.git) | MIT | clearlydefined | | ||
| [`@fastify/[email protected]`](git+https://github.com/fastify/send.git) | MIT | clearlydefined | | ||
| [`@fastify/[email protected]`](https://github.com/fastify/fastify-static.git) | MIT | clearlydefined | | ||
| [`@fastify/[email protected]`](git+https://github.com/fastify/fastify-swagger-ui.git) | MIT | clearlydefined | | ||
|
@@ -170,7 +170,7 @@ | |
| [`[email protected]`](https://github.com/react-dropzone/file-selector.git) | MIT | [CQ22350](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=22350) | | ||
| [`[email protected]`](git+https://github.com/delvedor/find-my-way.git) | MIT | clearlydefined | | ||
| [`[email protected]`](git+https://github.com/focus-trap/focus-trap.git) | MIT | clearlydefined | | ||
| [`[email protected].3`]([email protected]:follow-redirects/follow-redirects.git) | MIT | #10782 | | ||
| [`[email protected].4`]([email protected]:follow-redirects/follow-redirects.git) | MIT | #10782 | | ||
| [`[email protected]`](https://github.com/mikeal/forever-agent) | Apache-2.0 | clearlydefined | | ||
| [`[email protected]`](git://github.com/form-data/form-data.git) | MIT | clearlydefined | | ||
| [`[email protected]`](https://github.com/jshttp/forwarded.git) | MIT | clearlydefined | | ||
|
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
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 |
---|---|---|
|
@@ -32,6 +32,15 @@ describe('test buildFactoryLoaderPath()', () => { | |
); | ||
}); | ||
|
||
test('editor-image parameter', () => { | ||
const result = buildFactoryLoaderPath( | ||
'[email protected]:eclipse-che/che-dashboard.git?editor-image=quay.io/mloriedo/che-code:copilot-builtin', | ||
); | ||
expect(result).toEqual( | ||
'/f?editor-image=quay.io%2Fmloriedo%2Fche-code%3Acopilot-builtin&url=git%40github.com%3Aeclipse-che%2Fche-dashboard.git', | ||
); | ||
}); | ||
|
||
test('devfilePath parameter', () => { | ||
const result = buildFactoryLoaderPath( | ||
'[email protected]:eclipse-che/che-dashboard.git?devfilePath=devfilev2.yaml', | ||
|
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
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
175 changes: 175 additions & 0 deletions
175
packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/__tests__/editorImage.spec.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,175 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import common from '@eclipse-che/common'; | ||
import fs from 'fs'; | ||
import { dump, load } from 'js-yaml'; | ||
|
||
import devfileApi from '@/services/devfileApi'; | ||
import { DevWorkspaceBuilder } from '@/store/__mocks__/devWorkspaceBuilder'; | ||
import { | ||
getEditorImage, | ||
updateDevWorkspaceTemplate, | ||
updateEditorDevfile, | ||
} from '@/store/Workspaces/devWorkspaces/editorImage'; | ||
|
||
describe('Update editor image', () => { | ||
describe('devfile source annotation', () => { | ||
it('should return undefined without devfile-source', () => { | ||
const devWorkspace = new DevWorkspaceBuilder() | ||
.withTemplateAttributes({ | ||
'dw.metadata.annotations': {}, | ||
}) | ||
.build(); | ||
|
||
const editorImageParam = getEditorImage(devWorkspace); | ||
|
||
expect(editorImageParam).toBeUndefined(); | ||
}); | ||
|
||
it('should return undefined without factory params', () => { | ||
const devWorkspace = new DevWorkspaceBuilder() | ||
.withTemplateAttributes({ | ||
'dw.metadata.annotations': { | ||
'che.eclipse.org/devfile-source': dump({ | ||
factory: {}, | ||
}), | ||
}, | ||
}) | ||
.build(); | ||
|
||
const editorImageParam = getEditorImage(devWorkspace); | ||
|
||
expect(editorImageParam).toBeUndefined(); | ||
}); | ||
|
||
it('should return the editor image param', () => { | ||
const devWorkspace = new DevWorkspaceBuilder() | ||
.withTemplateAttributes({ | ||
'dw.metadata.annotations': { | ||
'che.eclipse.org/devfile-source': dump({ | ||
factory: { | ||
params: | ||
'editor-image=test-images/che-code:tag&url=https://github.com/eclipse-che/che-dashboard', | ||
}, | ||
}), | ||
}, | ||
}) | ||
.build(); | ||
|
||
const editorImageParam = getEditorImage(devWorkspace); | ||
|
||
expect(editorImageParam).toStrictEqual('test-images/che-code:tag'); | ||
}); | ||
}); | ||
|
||
describe('editor devfile', () => { | ||
it('should throw an error if editorContent is not defined', () => { | ||
const customEditorImage = 'test-images/che-code:tag'; | ||
|
||
const editorContent = ''; | ||
|
||
let errorMessage: string | undefined; | ||
try { | ||
updateEditorDevfile(editorContent, customEditorImage); | ||
} catch (err) { | ||
errorMessage = common.helpers.errors.getMessage(err); | ||
} | ||
|
||
expect(errorMessage).toEqual('Editor content is empty.'); | ||
}); | ||
|
||
it('should throw an error if editor components are not defined', () => { | ||
const customEditorImage = 'test-images/che-code:tag'; | ||
|
||
const editorContent = fs.readFileSync( | ||
__dirname + '/fixtures/test-devfile-without-components.yaml', | ||
'utf-8', | ||
); | ||
|
||
let errorMessage: string | undefined; | ||
try { | ||
updateEditorDevfile(editorContent, customEditorImage); | ||
} catch (err) { | ||
errorMessage = common.helpers.errors.getMessage(err); | ||
} | ||
|
||
expect(errorMessage).toEqual( | ||
'Failed to update editor image. Editor components is not defined.', | ||
); | ||
}); | ||
|
||
it('should update the target image', () => { | ||
const customEditorImage = 'test-images/che-code:tag'; | ||
|
||
const editorContent = fs.readFileSync( | ||
__dirname + '/fixtures/test-editor-devfile.yaml', | ||
'utf-8', | ||
); | ||
|
||
const customEditorContent = updateEditorDevfile(editorContent, customEditorImage); | ||
|
||
const output = fs.readFileSync( | ||
__dirname + '/fixtures/test-editor-devfile-with-custom-image.yaml', | ||
'utf-8', | ||
); | ||
|
||
expect(customEditorContent).toStrictEqual(output); | ||
}); | ||
}); | ||
|
||
describe('devWorkspace template', () => { | ||
it('should throw an error if editor components are not defined', () => { | ||
const customEditorImage = 'test-images/che-code:tag'; | ||
|
||
const devWorkspaceTemplate = load( | ||
fs.readFileSync( | ||
__dirname + '/fixtures/test-devworkspace-template-without-components.yaml', | ||
'utf-8', | ||
), | ||
) as devfileApi.DevWorkspaceTemplate; | ||
|
||
let errorMessage: string | undefined; | ||
try { | ||
updateDevWorkspaceTemplate(devWorkspaceTemplate, customEditorImage); | ||
} catch (err) { | ||
errorMessage = common.helpers.errors.getMessage(err); | ||
} | ||
|
||
expect(errorMessage).toEqual( | ||
'Failed to update editor image. Editor components is not defined.', | ||
); | ||
}); | ||
|
||
it('should update the target image', () => { | ||
const customEditorImage = 'test-images/che-code:tag'; | ||
|
||
const devWorkspaceTemplate = load( | ||
fs.readFileSync(__dirname + '/fixtures/test-devworkspace-template.yaml', 'utf-8'), | ||
) as devfileApi.DevWorkspaceTemplate; | ||
|
||
const customEditorContent = updateDevWorkspaceTemplate( | ||
devWorkspaceTemplate, | ||
customEditorImage, | ||
); | ||
|
||
const output = load( | ||
fs.readFileSync( | ||
__dirname + '/fixtures/test-devworkspace-template-with-custom-image.yaml', | ||
'utf-8', | ||
), | ||
); | ||
|
||
expect(customEditorContent).toStrictEqual(output); | ||
}); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...rc/store/Workspaces/devWorkspaces/__tests__/fixtures/test-devfile-without-components.yaml
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,3 @@ | ||
schemaVersion: 2.2.0 | ||
metadata: | ||
name: che-test |
18 changes: 18 additions & 0 deletions
18
...spaces/devWorkspaces/__tests__/fixtures/test-devworkspace-template-with-custom-image.yaml
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,18 @@ | ||
apiVersion: workspace.devfile.io/v1alpha2 | ||
kind: DevWorkspaceTemplate | ||
metadata: | ||
annotations: | ||
che.eclipse.org/components-update-policy: manual | ||
name: che-code | ||
spec: | ||
components: | ||
- attributes: | ||
controller.devfile.io/container-contribution: true | ||
container: | ||
image: test-images/che-code:tag | ||
name: che-code-runtime-description | ||
- name: checode | ||
volume: {} | ||
- container: | ||
image: quay.io/che-incubator/che-code:next | ||
name: che-code-injector |
7 changes: 7 additions & 0 deletions
7
...paces/devWorkspaces/__tests__/fixtures/test-devworkspace-template-without-components.yaml
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,7 @@ | ||
apiVersion: workspace.devfile.io/v1alpha2 | ||
kind: DevWorkspaceTemplate | ||
metadata: | ||
annotations: | ||
che.eclipse.org/components-update-policy: managed | ||
name: che-code | ||
spec: {} |
18 changes: 18 additions & 0 deletions
18
...end/src/store/Workspaces/devWorkspaces/__tests__/fixtures/test-devworkspace-template.yaml
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,18 @@ | ||
apiVersion: workspace.devfile.io/v1alpha2 | ||
kind: DevWorkspaceTemplate | ||
metadata: | ||
annotations: | ||
che.eclipse.org/components-update-policy: managed | ||
name: che-code | ||
spec: | ||
components: | ||
- attributes: | ||
controller.devfile.io/container-contribution: true | ||
container: | ||
image: quay.io/devfile/universal-developer-image:next | ||
name: che-code-runtime-description | ||
- name: checode | ||
volume: {} | ||
- container: | ||
image: quay.io/che-incubator/che-code:next | ||
name: che-code-injector |
14 changes: 14 additions & 0 deletions
14
...re/Workspaces/devWorkspaces/__tests__/fixtures/test-editor-devfile-with-custom-image.yaml
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,14 @@ | ||
schemaVersion: 2.2.0 | ||
metadata: | ||
name: che-code | ||
components: | ||
- name: che-code-runtime-description | ||
container: | ||
image: test-images/che-code:tag | ||
attributes: | ||
controller.devfile.io/container-contribution: true | ||
- name: checode | ||
volume: {} | ||
- name: che-code-injector | ||
container: | ||
image: quay.io/che-incubator/che-code:next |
14 changes: 14 additions & 0 deletions
14
...d-frontend/src/store/Workspaces/devWorkspaces/__tests__/fixtures/test-editor-devfile.yaml
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,14 @@ | ||
schemaVersion: 2.2.0 | ||
metadata: | ||
name: che-code | ||
components: | ||
- name: che-code-runtime-description | ||
container: | ||
image: quay.io/devfile/universal-developer-image:next | ||
attributes: | ||
controller.devfile.io/container-contribution: true | ||
- name: checode | ||
volume: {} | ||
- name: che-code-injector | ||
container: | ||
image: quay.io/che-incubator/che-code:next |
Oops, something went wrong.