Open
Description
Description
The devfile API provides a validation package that can be used to validate devfile commands.
We should use this to validate the commands present in a devworkspace during the devworkspace reconciliation. We should also use this validation in the validating webhook.
Not only would this catch invalid devfile's provided by users, but it would prevent any errors when DWO injects invalid commands into the devworkspace, as was mentioned in #1329 (comment) where commands with the same ID were being injected into the devworkspace.
Currently, the following devworkspace will be start, despite having 2 commands with the same ID:
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: code-latest-duplicate-commands
spec:
started: true
template:
attributes:
controller.devfile.io/storage-type: ephemeral
projects:
- name: web-nodejs-sample
git:
remotes:
origin: "https://github.com/che-samples/web-nodejs-sample.git"
commands:
- id: say-hello
exec:
component: che-code-runtime-description
commandLine: echo "Hello from $(pwd)"
workingDir: ${PROJECT_SOURCE}/app
- id: say-hello
exec:
component: che-code-runtime-description
commandLine: echo "Second hello from $(pwd)"
workingDir: ${PROJECT_SOURCE}/app
contributions:
- name: che-code
uri: https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/che-incubator/che-code/latest/devfile.yaml
components:
- name: che-code-runtime-description
container:
env:
- name: CODE_HOST
value: 0.0.0.0
I'd expect the above devworkspace to fail, citing commands with duplicate IDs (which is not permitted by the devfile API).
Metadata
Metadata
Assignees
Labels
No labels