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

If clonePath is set, sync to it #2747

Merged

Conversation

johnmcollier
Copy link
Member

Signed-off-by: John Collier John.J.Collier@ibm.com

What type of PR is this?

Uncomment only one /kind line, and delete the rest.
For example, > /kind bug would simply become: /kind bug

/kind bug

What does does this PR do / why we need it:
This PR updates the sync code to sync to the devfile's clonePath folder if it's set. Certain devfiles, such as the official Go devfile, rely on this field being set properly (see https://github.com/eclipse/che-devfile-registry/blob/5a41b4b0c85893a6ee99059fcceab35b8a71780c/devfiles/go/devfile.yaml#L46 for example)

Which issue(s) this PR fixes:

Fixes #2741

Signed-off-by: John Collier <John.J.Collier@ibm.com>
@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 23, 2020
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@johnmcollier
Copy link
Member Author

/retest

@codecov
Copy link

codecov bot commented Mar 23, 2020

Codecov Report

Merging #2747 into master will decrease coverage by 0.32%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2747      +/-   ##
==========================================
- Coverage   43.72%   43.39%   -0.33%     
==========================================
  Files          87       91       +4     
  Lines        8068     8233     +165     
==========================================
+ Hits         3528     3573      +45     
- Misses       4195     4309     +114     
- Partials      345      351       +6
Impacted Files Coverage Δ
...g/devfile/adapters/kubernetes/component/adapter.go 35.6% <80%> (+1.41%) ⬆️
pkg/kclient/deployments.go 34.66% <0%> (-54.99%) ⬇️
pkg/component/watch.go 67.33% <0%> (-6.67%) ⬇️
pkg/application/application.go 41.26% <0%> (-6.01%) ⬇️
pkg/occlient/occlient.go 52.69% <0%> (-0.1%) ⬇️
pkg/lclient/images.go 60% <0%> (ø)
pkg/lclient/fakeclient.go 42.62% <0%> (ø)
pkg/lclient/client.go 0% <0%> (ø)
pkg/lclient/containers.go 88.88% <0%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcd770f...e8bf177. Read the comment docs.

@amitkrout
Copy link
Contributor

@johnmcollier Can you please add steps for how to validate this change with an example. Later we can think upon the possibility of integration test script.

@johnmcollier
Copy link
Member Author

@amitkrout I've added instructions on how to validate.

How to validate:

  1. Download devfile with a project that uses the clonePath field (try https://raw.githubusercontent.com/eclipse/che-devfile-registry/5a41b4b0c85893a6ee99059fcceab35b8a71780c/devfiles/go/devfile.yaml)
  2. Pull down the project specified in the devfile and put in the same folder as the devfile (as Add ability to create application resource/template from stack #2582 hasn't been implemented)
  3. Build my branch
  4. Run odo push
  5. Verify the project gets synced to /projects/<clonePath> in the remote container

Copy link
Contributor

@rajivnathan rajivnathan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me, thanks! lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 26, 2020
// If the clonepath is set to a value, set it to be the sync folder
// As some devfiles rely on the code being synced to the folder in the clonepath
if project.ClonePath != nil {
return filepath.ToSlash(filepath.Join(kclient.OdoSourceVolumeMount, *project.ClonePath))
Copy link
Member

@kadel kadel Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a check to prevent escaping /projects or more precisely escaping from kclient.OdoSourceVolumeMount ( using ..
see: https://github.com/redhat-developer/devfile/blob/master/docs/devfile.md#clonepath

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good catch.

How should we handle that? Che throws an error if the clonePath starts with either / or .. (https://github.com/eclipse/che/blob/420d4ea34cf50e5835027016211f16b02eba8a54/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverter.java#L109). We should probably do the same.

Signed-off-by: John Collier <John.J.Collier@ibm.com>
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 26, 2020
@johnmcollier
Copy link
Member Author

@kadel Thanks for the review! I've updated the PR with changes to only allow relative clonePaths and to not allow .. in the clonePath.

projectNames := []string{"some-name", "another-name"}
projectRepos := []string{"https://github.com/some/repo.git", "https://github.com/another/repo.git"}
projectClonePath := "src/github.com/golang/example/"
invalidClonePaths := []string{"/var", "../var", "pkg/../../var"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kadel
Copy link
Member

kadel commented Mar 26, 2020

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Mar 26, 2020
Copy link
Contributor

@rajivnathan rajivnathan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding lgtm label back since Tomas' comments have been addressed.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 26, 2020
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

7 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

6 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 0e0886f into redhat-developer:master Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Projects are not synced to the devfile clonePath
7 participants