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

Add kustomize build {repoUrl} #260

Merged
merged 2 commits into from
Aug 15, 2018

Conversation

Liujingfang1
Copy link
Contributor

  • Add githubLoader which checks out a repo, saves to a temp dir and creates a fileLoader with root at the temp dir
  • Add NewLoader function to return either a fileLoader or githubLoader based on the input string
  • Use NewLoader in both build and diff
  • In fileLoader.New, if the input string is a repoUrl, return a githubLoader.

The accepted format of the repoUrl is
github.com/project/repo//subdir?ref=xxx

both subdir and ref are optional.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Liujingfang1

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 14, 2018
@Liujingfang1 Liujingfang1 changed the title WIP: Add kustomize build {repoUrl} Add kustomize build {repoUrl} Aug 14, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2018
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 14, 2018
@Liujingfang1
Copy link
Contributor Author

Following examples all work
kustomize build github.com/kubernetes-sigs/kustomize//examples/multibases?ref=v1.0.6
kustomize build github.com/Liujingfang1/mysql
kustomize build github.com/Liujingfang1/kustomize//examples/helloWorld?ref=repoUrl2

kustomize build also works for those links as bases:

bases:
- github.com/kubernetes-sigs/kustomize//examples/multibases?ref=v1.0.6
- github.com/Liujingfang1/mysql
- github.com/Liujingfang1/kustomize//examples/helloWorld?ref=repoUrl2

In order to make go vet and metalinter happy, I manually removed some file in go-getter library. I don't think this hacky workaround is sustainable. What about we create a branch in go-getter repo with our desired change? @monopole Then we can use our branch safely with dep ensure.

Copy link
Contributor

@monopole monopole left a comment

Choose a reason for hiding this comment

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

couple of quick questions

@@ -53,6 +53,9 @@ func (l *fileLoader) Root() string {
// Example: "/home/seans/project" or "/home/seans/project/"
// NOT "/home/seans/project/file.yaml".
func (l *fileLoader) New(newRoot string) (Loader, error) {
if isRepoUrl(newRoot) {
return newGithubLoader(newRoot, l.fSys)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

NewLoader does this (it doesn't look right here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is slight difference between New and NewLoader. New creates a new fileLoader whose root is a relative path in current fileloader. NewLoader is more like creating a root loader, where we don't have an existing fileloader.

repo string
checkoutDir string
fSys fs.FileSystem
loader *fileLoader
Copy link
Contributor

Choose a reason for hiding this comment

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

can this just mixin fileLoader (and use its fSys field)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can.

@monopole
Copy link
Contributor

go vet and metalinter should ignore the vendored stuff (else everything would already be blowing up).

So all the deps come in because they have an s3 getter that comes along for the ride (no option to just get a subset of the getters).

I guess we can just vendor the world for now, rather than hack around it. Perhaps file an issue with hashicorp and move on.

@Liujingfang1
Copy link
Contributor Author

So all the deps come in because they have an s3 getter that comes along for the ride (no option to just get a subset of the getters).

That's corret. The go-getter client contains several detectors for different kinds of repos(github, mecurial and so on), s3 is one of them. There is no option to get a subset of it.

I guess we can just vendor the world for now, rather than hack around it. Perhaps file an issue with hashicorp and move on.

I created a PR #262 on a different branch.

Copy link
Contributor

@monopole monopole left a comment

Choose a reason for hiding this comment

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

/lgtm

}

// isRepoUrl checks if a string is a repo Url
func isRepoUrl(s string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add test coverage for this

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 15, 2018
@k8s-ci-robot k8s-ci-robot merged commit 3b64f1e into kubernetes-sigs:master Aug 15, 2018
@Liujingfang1 Liujingfang1 deleted the repoUrl2 branch September 6, 2018 18:42
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants