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

Validate commands in devworkspaces using devfile validation package #1336

Open
AObuchow opened this issue Oct 30, 2024 · 0 comments
Open

Validate commands in devworkspaces using devfile validation package #1336

AObuchow opened this issue Oct 30, 2024 · 0 comments

Comments

@AObuchow
Copy link
Collaborator

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).

@AObuchow AObuchow changed the title Valid commands in devworkspaces using devfile validation package Validate commands in devworkspaces using devfile validation package Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant