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

Exec command should make component required #152

Closed
maysunfaisal opened this issue Oct 5, 2020 · 13 comments · Fixed by #161
Closed

Exec command should make component required #152

maysunfaisal opened this issue Oct 5, 2020 · 13 comments · Fixed by #161
Assignees
Labels
area/api Enhancement or issue related to the api/devfile specification
Milestone

Comments

@maysunfaisal
Copy link
Member

Currently the spec does not define the component in an exec as required. I am wondering if that's the case, what is the point in have an exec command at all? If the there is an exec command in a devfile, it is to be executed in a container; which is to be represented by the component property.

https://github.com/devfile/api/blob/master/pkg/apis/workspaces/v1alpha2/commands.go#L125

@davidfestal
Copy link
Collaborator

@l0rd wdyt about this one ? It seems we should make the component mandatory right ?

@elsony
Copy link
Contributor

elsony commented Oct 6, 2020

I don't see much usage on a command without a component. Without the component info, the tools using the devfile won't know where are they going to execute the command.

@l0rd
Copy link
Contributor

l0rd commented Oct 6, 2020

Agreed. The component should be mandatory for exec commands. On the other hand apply commands should not require that.

@elsony elsony added the area/api Enhancement or issue related to the api/devfile specification label Oct 6, 2020
@mmulholla
Copy link
Contributor

So this:

// Describes component to which given action relates
// +optional
Component string `json:"component,omitempty"`

Becomes:

// Describes component to which given action relates
// 
Component string `json:"component"`

?????

@davidfestal
Copy link
Collaborator

Yes, exactly.

@elsony elsony added this to the 2.0 milestone Oct 6, 2020
@johnmcollier
Copy link
Member

johnmcollier commented Oct 6, 2020

So, I think this is a good idea. But one thing I'm wondering is, will this cause issues for overriding parent commands in devfiles?

E.g.

schemaVersion: 2.0.0
metadata:
  name: nodejs
  version: 1.0.0
parent:
  uri: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml
  commands:
    - id: install
      exec:
        commandLine: npm install && echo hi

Is currently valid, and changes the commandLine for the install command. We don't specify the component of the overridden command since we're not changing it. Will this still be valid if we make component required?

@mmulholla
Copy link
Contributor

For example, https://github.com/devfile/api/blob/master/samples/devfiles/simple-devfile.yaml#L30 includes:

  • id: helloWorld
    exec:
    env:
    - name: "USER"
    value: "John Doe"
    commandLine: 'echo "Hello ${USER}"'

This example would now be invalid. Is this acceptable?

@maysunfaisal
Copy link
Member Author

@mmulholla yes, that would become invalid because the exec command has no component to execute itself.

@mmulholla
Copy link
Contributor

So given this and what John pointed out do we still want this change?

@davidfestal
Copy link
Collaborator

davidfestal commented Oct 7, 2020

For example, https://github.com/devfile/api/blob/master/samples/devfiles/simple-devfile.yaml#L30 includes:

  • id: helloWorld
    exec:
    env:
    • name: "USER"
      value: "John Doe"
      commandLine: 'echo "Hello ${USER}"'

This example would now be invalid. Is this acceptable?

@mmulholla @maysunfaisal

Yes, it seems this is an error in this example file, that was not reported because of the fact that component is optional for now.
IMO this should not prevent us from doing the change proposed in this issue.

@davidfestal
Copy link
Collaborator

So, I think this is a good idea. But one thing I'm wondering is, will this cause issues for overriding parent commands in devfiles?

E.g.

schemaVersion: 2.0.0
metadata:
  name: nodejs
  version: 1.0.0
parent:
  uri: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml
  commands:
    - id: install
      exec:
        commandLine: npm install && echo hi

Is currently valid, and changes the commandLine for the install command. We don't specify the component of the overridden command since we're not changing it. Will this still be valid if we make component required?

In fact that won't be a problem since the override generator takes care of that when generating the Override Structs. It makes all the fields optional, apart from those that are strictly required because they are used as merge keys in a list.

So even with the change proposed here to implement this issue, the command override described by @johnmcollier and quoted above will still be valid.

@davidfestal
Copy link
Collaborator

Agreed. The component should be mandatory for exec commands. On the other hand apply commands should not require that.

@l0rd Do you mean that Apply command should not require a mandatory component ? What would an Apply command without a component field mean ?

@l0rd
Copy link
Contributor

l0rd commented Oct 7, 2020

Agreed. The component should be mandatory for exec commands. On the other hand apply commands should not require that.

@l0rd Do you mean that Apply command should not require a mandatory component ? What would an Apply command without a component field mean ?

@davidfestal you are right. It should be mandatory for apply commands as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Enhancement or issue related to the api/devfile specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants