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

Parent Devfiles and workingDir vs clonePath issue #109

Closed
kadel opened this issue Aug 10, 2020 · 2 comments · Fixed by #116
Closed

Parent Devfiles and workingDir vs clonePath issue #109

kadel opened this issue Aug 10, 2020 · 2 comments · Fixed by #116

Comments

@kadel
Copy link
Member

kadel commented Aug 10, 2020

Currently clonePath defaults to the project name. This means that by default source code is cloned into /project/<project-name>. This is problematic for Stacks (Parent Devfiles) as they can't know where the project source code will be.

Example:

How should I set workingDir in my example devfile.yaml so It is generic enough that it can be used without everyone overriding workingDir for all commands?

# parent.yaml
schemaVersion: 2.0.0
metadata:
  name: java
components:
  - container:
      name: tools
      image: quay.io/eclipse/che-java11-maven:nightly
      mountSources: true
commands:
  - exec:
      id: mvn-package
      component: tools
      commandLine: "mvn package"
      # workingDir: ?????
      group:
        kind: build
        isDefault: true
  - exec:
      id: run
      component: tools
      commandLine: "java -jar target/*.jar"
      # workingDir: ?????
      group:
        kind: run
        isDefault: true

Now I want to use this in my local devfile.yaml

# devfile.yaml
schemaVersion: 2.0.0
metadata:
  name: myproject
projects:
  - name: myproject
      git:
        location: https://github.com/example/example
parent:
  uri: https://registry.example.com/java/parent.yaml

This won't work because commands in parent devfile don't specify workingDir so it will default to container working directory (in this case /project). But I can't set working dir in parent devfile, because I can't know what will be the project name.

@johnmcollier
Copy link
Member

johnmcollier commented Aug 10, 2020

A similar issue to this is when the user brings their own project, rather than using one of the ones defined in the devfile.

If the commands in a devfile assume the working directory is $PROJECTS_ROOT/clonePath, that'll cause issues for cases like in odo, where users can use their own project/code with the devfile (and so there isn't a clear value for clonePath)

@kadel
Copy link
Member Author

kadel commented Aug 11, 2020

After a lengthy discussion, we agreed to introduce a new variable $PROJECT_SOURCE that will be expanded to a directory with project source for single project Devfiles.

In other words:
$PROJECT_SOURCE = $PROJECT_ROOT/<project_name>

TODO @kadel: add more details and update documentation

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

Successfully merging a pull request may close this issue.

2 participants