Skip to content

Commit a7f4db7

Browse files
authored
Merge pull request #4030 from thatsmydoing/url-format
Update supported URLs in remoteBuild.md
2 parents 5d07624 + 54ae9ba commit a7f4db7

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

examples/remoteBuild.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
# remote targets
22

3-
`kustomize build` can be run on a URL.
3+
`kustomize build` can be run on a URL. Resources can also reference other
4+
kustomization directories via URLs too.
45

5-
A [lite version of go-getter module](https://github.com/yujunz/go-getter) is
6-
leveraged to get remote content, then running `kustomize build` against the
7-
desired directory in the local copy.
6+
The URL format is an HTTPS or SSH `git clone` URL with an optional directory and
7+
some query string parameters. The directory is specified by appending a `//`
8+
after the repo URL. The following query string parameters can also be specified:
9+
10+
* `ref` - a `git fetch`-able ref, typically a branch, tag, or full commit hash
11+
(short hashes are not supported)
12+
* `timeout` (default `27s`) - a number in seconds, or a go duration. specifies
13+
the timeout for fetching the resource
14+
* `submodules` (default `true`) - a boolean specifying whether to clone
15+
submodules or not
16+
17+
For example,
18+
`https://github.com/kubernetes-sigs/kustomize//examples/multibases/dev/?ref=v1.0.6`
19+
will essentially clone the git repo via HTTPS, checkout `v1.0.6` and run
20+
`kustomize build` inside the `examples/multibases/dev` directory.
21+
22+
SSH clones are also supported either with `[email protected]:owner/repo` or
23+
`ssh://[email protected]/owner/repo` URLs.
24+
25+
`file:///` clones are not supported.
26+
27+
# Examples
828

929
To try this immediately, run a build against the kustomization
1030
in the [multibases](multibases/README.md) example. There's
1131
one pod in the output:
1232

1333
<!-- @remoteOverlayBuild @testAgainstLatestRelease -->
1434
```
15-
target="github.com/kubernetes-sigs/kustomize/examples/multibases/dev/?ref=v1.0.6"
35+
target="https://github.com/kubernetes-sigs/kustomize//examples/multibases/dev/?ref=v1.0.6"
1636
test 1 == \
1737
$(kustomize build $target | grep dev-myapp-pod | wc -l); \
1838
echo $?
@@ -24,33 +44,21 @@ someone who wants to send them all at the same time):
2444

2545
<!-- @remoteBuild @testAgainstLatestRelease -->
2646
```
27-
target="https://github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6"
47+
target="https://github.com/kubernetes-sigs/kustomize//examples/multibases?ref=v1.0.6"
2848
test 3 == \
2949
$(kustomize build $target | grep cluster-a-.*-myapp-pod | wc -l); \
3050
echo $?
3151
```
3252

33-
The URL can be an archive
34-
35-
<!-- @remoteBuild -->
36-
```
37-
target="https://github.com/kustless/kustomize-examples/archive/master.zip//kustomize-examples-master"
38-
test 1 == \
39-
$(kustomize build $target | grep remote-cm | wc -l); \
40-
echo $?
41-
```
42-
43-
Note the kustomize root path inside archive must be appended after `//`.
44-
45-
A base can be a URL:
53+
A remote kustomization directory resource can also be a URL:
4654

4755
<!-- @createOverlay @testAgainstLatestRelease -->
4856
```
4957
DEMO_HOME=$(mktemp -d)
5058
5159
cat <<EOF >$DEMO_HOME/kustomization.yaml
5260
resources:
53-
- github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6
61+
- https://github.com/kubernetes-sigs/kustomize//examples/multibases?ref=v1.0.6
5462
namePrefix: remote-
5563
EOF
5664
```
@@ -65,18 +73,16 @@ test 3 == \
6573
echo $?
6674
```
6775

68-
## URL format
69-
70-
The url should follow
71-
[hashicorp/go-getter URL format](https://github.com/hashicorp/go-getter#url-format).
76+
## Legacy URL format
7277

73-
Note that using `//` in the url will only copy the directory specified by the path
74-
after `//`, which means some relative paths, like `../xxx`, may not work. Using `/` to copy
75-
entire repo. For more details please see [go-getter documentation](https://github.com/hashicorp/go-getter#subdirectories).
78+
Historically, kustomize has supported a modified [hashicorp/go-getter URL format](https://github.com/hashicorp/go-getter#url-format).
7679

77-
Note that S3 and GCS are NOT supported to avoid introducing massive dependency.
80+
This is still supported for backwards compatibility but is no longer recommended
81+
to be used as kustomize supports different query parameters and the semantics of
82+
what gets fetched in `go-getter` itself are different (particularly with
83+
subdirectories).
7884

79-
Here are some example urls
85+
Here are some examples of legacy urls
8086

8187
<!-- @createOverlay @testAgainstLatestRelease -->
8288
```
@@ -92,7 +98,5 @@ resources:
9298
- github.com/Liujingfang1/kustomize/examples/helloWorld?ref=repoUrl2
9399
# a subdirectory in a repo on commit `7050a45134e9848fca214ad7e7007e96e5042c03`
94100
- github.com/Liujingfang1/kustomize/examples/helloWorld?ref=7050a45134e9848fca214ad7e7007e96e5042c03
95-
# a subdirectory in a remote archive
96-
- https://github.com/kustless/kustomize-examples/archive/master.zip//kustomize-examples-master
97101
EOF
98102
```

examples/zh/remoteBuild.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<!-- @remoteOverlayBuild @test -->
1010

1111
```bash
12-
target="github.com/kubernetes-sigs/kustomize/examples/multibases/dev/?ref=v1.0.6"
12+
target="https://github.com/kubernetes-sigs/kustomize//examples/multibases/dev/?ref=v1.0.6"
1313
test 1 == \
1414
$(kustomize build $target | grep dev-myapp-pod | wc -l); \
1515
echo $?
@@ -19,7 +19,7 @@ test 1 == \
1919

2020
<!-- @remoteBuild @test -->
2121
```bash
22-
target="https://github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6"
22+
target="https://github.com/kubernetes-sigs/kustomize//examples/multibases?ref=v1.0.6"
2323
test 3 == \
2424
$(kustomize build $target | grep cluster-a-.*-myapp-pod | wc -l); \
2525
echo $?
@@ -33,7 +33,7 @@ DEMO_HOME=$(mktemp -d)
3333

3434
cat <<EOF >$DEMO_HOME/kustomization.yaml
3535
resources:
36-
- github.com/kubernetes-sigs/kustomize/examples/multibases?ref=v1.0.6
36+
- https://github.com/kubernetes-sigs/kustomize//examples/multibases?ref=v1.0.6
3737
namePrefix: remote-
3838
EOF
3939
```
@@ -47,7 +47,7 @@ test 3 == \
4747
echo $?
4848
```
4949

50-
## URL format
50+
## Legacy URL format
5151

5252
URL 需要遵循 [hashicorp/go-getter URL 格式](https://github.com/hashicorp/go-getter#url-format) 。下面是一些遵循此约定的 Github repos 示例url。
5353

0 commit comments

Comments
 (0)