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

Hack 'n Hustle: command line tool to update a DevWorkspace #990

Closed
l0rd opened this issue Dec 2, 2022 · 6 comments
Closed

Hack 'n Hustle: command line tool to update a DevWorkspace #990

l0rd opened this issue Dec 2, 2022 · 6 comments
Assignees

Comments

@l0rd
Copy link
Collaborator

l0rd commented Dec 2, 2022

The goal is to create a small command line utility that takes as input the path to a devfile.yaml file and the path to a devworkspace.yaml file. As a result it prints to stdout a DevWorkspace object, identical to the original one, but with the template replaced by the Devfile content (with a few gotchas).

$ dw-update --help
Takes as input the path to a devfile.yaml file and the path to a devworkspace.yaml file and prints to stdout a DevWorkspace object, identical to the original one, but with the template replaced by the Devfile content (with a few gotchas).

Usage:
  dw-update [options]

Options:
  -d, --devfile=[]:
    The file that contains the new devfile that is going to be applied.
  -w, --devworkspace=[]:
    The file that contains the original DevWorksapce object, in YAML format.

The gotchas:

  1. The original DevWorkspace spec.template.projects is not replaced (needed until Add project in DevWorkspace CRD spec and deprecate projects from the devfile spec eclipse-che/che#21188)
  2. An existing controller.devfile.io/merge-contribution: true attribute in the original DevWorkspace spec.template.components should be kept even if not present in the devfile (needed until Implicitly set merge-contribution:true on first template component #993).
@AObuchow AObuchow self-assigned this Dec 2, 2022
@AObuchow
Copy link
Collaborator

AObuchow commented Dec 8, 2022

@l0rd I wanted to clarify about gotcha #2

  1. An existing controller.devfile.io/merge-contribution: true attribute in the original DevWorkspace spec.template.components should be kept even if not present in the devfile.

Should only the attribute be kept? Or the entire component?

For example, do we want the following behaviour?

Given this devworkspace:

Kind: Devworkspace
Spec:
  Template:
    Components:
      - name: componentA
        attributes:
          controller.devfile.io/merge-contribution: true
      - name: componentB
        attributes:
          controller.devfile.io/merge-contribution: true

And this devfile:

Kind: Devfile
Spec:
  Components:
     - name: ComponentB

The resulting devworkspace:

Kind: Devworkspace
Spec:
  Template:
    Components:
      - name: componentB
        attributes:
          controller.devfile.io/merge-contribution: true

Or do we want this behaviour:

Given this devworkspace:

Kind: Devworkspace
Spec:
  Template:
    Components:
      - name: componentA
        attributes:
          controller.devfile.io/merge-contribution: true
      - name: componentB
        attributes:
          controller.devfile.io/merge-contribution: true

And this devfile:

Kind: Devfile
Spec:
  Components:
     - name: ComponentB

The resulting devworkspace (componentA is kept because it has the controller.devfile.io/merge-contribution: true attribute):

Kind: Devworkspace
Spec:
  Template:
    Components:
      - name: componentA
        attributes:
          controller.devfile.io/merge-contribution: true
      - name: componentB
        attributes:
          controller.devfile.io/merge-contribution: true

@l0rd
Copy link
Collaborator Author

l0rd commented Dec 8, 2022

You should support DevWorkspaces with only one attribute controller.devfile.io/merge-contribution: true. You can return error if there are more than one.

@l0rd
Copy link
Collaborator Author

l0rd commented Dec 9, 2022

@AObuchow I have updated the description: as we discussed dw-update should take 2 YAML files as input (a devfile and a devworkspace) and prints the resulting devworkspace YAML to stdout. I have changed my mind about extra features as "getting a devworkspace from stdin" or "making devworkspace optional": let's keep this script as simple as possible. It would be cool if you could add a test that runs with go test though.

@l0rd l0rd changed the title Hack 'n Hustle: command line that DW Hack 'n Hustle: command line tool to update a DevWorkspace Dec 10, 2022
@l0rd
Copy link
Collaborator Author

l0rd commented Dec 12, 2022

Added in the description the reference to 2 issues that will simplify the devworkspace update:

@AObuchow
Copy link
Collaborator

For future reference, this is the repo that came out of this task: https://github.com/AObuchow/DW-update

@AObuchow
Copy link
Collaborator

Closing this issue as I was able to create a POC, and ultimately the devworkspace-generator was created for this purpose.

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

2 participants