Skip to content

Commit b17d7fb

Browse files
authored
Merge pull request #339 from lswith/master
treat sub paths correctly
2 parents 64fdb8d + d78e77f commit b17d7fb

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

examples/remoteBuild.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ test 3 == \
1616
echo $?
1717
```
1818

19+
Overlays can be remote as well:
20+
21+
<!-- @remoteOverlayBuild @test -->
22+
23+
```
24+
target=github.com/kubernetes-sigs/kustomize//examples/multibases/dev/?ref=v1.0.6
25+
test 1 == \
26+
$(kustomize build $target | grep cluster-a-dev-myapp-pod | wc -l); \
27+
echo $?
28+
```
29+
1930
A base can also be specified as a URL:
2031

2132
<!-- @createOverlay @test -->
@@ -55,4 +66,4 @@ Here are some example urls pointing to Github repos following this convention.
5566
`github.com/Liujingfang1/kustomize//examples/helloWorld?ref=repoUrl2`
5667
- a subdirectory in a repo on commit `7050a45134e9848fca214ad7e7007e96e5042c03`
5768

58-
`github.com/Liujingfang1/kustomize//examples/helloWorld?ref=7050a45134e9848fca214ad7e7007e96e5042c03`
69+
`github.com/Liujingfang1/kustomize//examples/helloWorld?ref=7050a45134e9848fca214ad7e7007e96e5042c03`

pkg/loader/githubloader.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ import (
2929

3030
// githubLoader loads files from a checkout github repo
3131
type githubLoader struct {
32-
repo string
32+
repo string
33+
// target is the directory which is to be built
34+
targetDir string
35+
// checkoutDir is for the whole repository
3336
checkoutDir string
3437
loader *fileLoader
3538
}
3639

3740
// Root returns the root location for this Loader.
3841
func (l *githubLoader) Root() string {
39-
return l.checkoutDir
42+
return l.targetDir
4043
}
4144

4245
// New delegates to fileLoader.New
@@ -60,15 +63,18 @@ func newGithubLoader(repoUrl string, fs fs.FileSystem) (*githubLoader, error) {
6063
if err != nil {
6164
return nil, err
6265
}
63-
target := filepath.Join(dir, "repo")
64-
err = checkout(repoUrl, target)
66+
repodir := filepath.Join(dir, "repo")
67+
src, subdir := getter.SourceDirSubdir(repoUrl)
68+
err = checkout(src, repodir)
6569
if err != nil {
6670
return nil, err
6771
}
72+
target := filepath.Join(repodir, subdir)
6873
l := newFileLoaderAtRoot(target, fs)
6974
return &githubLoader{
7075
repo: repoUrl,
71-
checkoutDir: dir,
76+
targetDir: target,
77+
checkoutDir: repodir,
7278
loader: l,
7379
}, nil
7480
}

0 commit comments

Comments
 (0)