mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-18 18:18:36 +00:00
Compare commits
185 Commits
monopole-p
...
prowBadge
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee110a8e02 | ||
|
|
826da4b19e | ||
|
|
630ac1b318 | ||
|
|
23589cc2af | ||
|
|
b349351e6e | ||
|
|
7bddd14419 | ||
|
|
894e21acbf | ||
|
|
524d672307 | ||
|
|
d051588789 | ||
|
|
ea807fcdcc | ||
|
|
a7f0af939b | ||
|
|
4f926df7cf | ||
|
|
1dad3f0975 | ||
|
|
885a9db52e | ||
|
|
8d40ead9b7 | ||
|
|
86bcb47b7d | ||
|
|
f08594cc22 | ||
|
|
56b6fa90b3 | ||
|
|
292d950465 | ||
|
|
ee431f755c | ||
|
|
e00d0b98de | ||
|
|
a8b9741866 | ||
|
|
7855031ecc | ||
|
|
e12d57e6f2 | ||
|
|
0d2ae19c80 | ||
|
|
804cf6d71c | ||
|
|
e342b68f0a | ||
|
|
022805b56b | ||
|
|
eb57d4b510 | ||
|
|
a5a51ba76a | ||
|
|
32efef71f4 | ||
|
|
98c08b2b66 | ||
|
|
5ea34b2efb | ||
|
|
0f3d5c80e4 | ||
|
|
cabaccb9fd | ||
|
|
4d1fe6678f | ||
|
|
04af0e6648 | ||
|
|
7a696ef616 | ||
|
|
691c11d520 | ||
|
|
109ffdaec5 | ||
|
|
aac1b7dc24 | ||
|
|
96782d9584 | ||
|
|
b17ea88bf7 | ||
|
|
091964c2c4 | ||
|
|
38973a80c3 | ||
|
|
4a7b22cf23 | ||
|
|
21a544f188 | ||
|
|
43f44b88ce | ||
|
|
0086470fe1 | ||
|
|
6a3eaf8ba0 | ||
|
|
26e801d2f2 | ||
|
|
d5d908610d | ||
|
|
8a22efb213 | ||
|
|
8bd989abb1 | ||
|
|
a3f59f2f4f | ||
|
|
a4ee1c2e72 | ||
|
|
39fe903498 | ||
|
|
78abd4193a | ||
|
|
96926fecce | ||
|
|
7d852c7bab | ||
|
|
d36a5a9c2f | ||
|
|
f81cc75925 | ||
|
|
ab39586960 | ||
|
|
17503ae9d8 | ||
|
|
24988df444 | ||
|
|
11ce0128ad | ||
|
|
4c0ab89c87 | ||
|
|
50cc1968e4 | ||
|
|
51ba40d39b | ||
|
|
20184e9835 | ||
|
|
8e3b7b195e | ||
|
|
ba48f615e8 | ||
|
|
2be48ca96a | ||
|
|
85e9127071 | ||
|
|
06e70f74c2 | ||
|
|
5184872cb5 | ||
|
|
f39f28d38f | ||
|
|
114e676cb1 | ||
|
|
2826dddc32 | ||
|
|
7164e55831 | ||
|
|
39629ed3e7 | ||
|
|
002993379a | ||
|
|
63622dbf2f | ||
|
|
85e9779bd6 | ||
|
|
81bbd2f2e3 | ||
|
|
d41df982c5 | ||
|
|
7629a03dd6 | ||
|
|
3def13d479 | ||
|
|
51a79d554c | ||
|
|
6c2adc48dd | ||
|
|
efdd812cc1 | ||
|
|
cd6614a93b | ||
|
|
04bec8ed2e | ||
|
|
51b29d7023 | ||
|
|
3a2635bd2d | ||
|
|
443fa792c3 | ||
|
|
064f0641ba | ||
|
|
a36d5b76be | ||
|
|
5c0fbf9a7f | ||
|
|
9a9bdee605 | ||
|
|
11ef1f3921 | ||
|
|
ce2e685619 | ||
|
|
aa46b6ec44 | ||
|
|
c4d949333d | ||
|
|
702b10d524 | ||
|
|
7840b7f949 | ||
|
|
2cf5dc16cb | ||
|
|
036b93c8d0 | ||
|
|
cad69ae415 | ||
|
|
5b774d09e1 | ||
|
|
9cbabe9135 | ||
|
|
7e8f8a649c | ||
|
|
68a9389bfe | ||
|
|
5364b2198a | ||
|
|
63ff34ffe2 | ||
|
|
6944cea234 | ||
|
|
370502ed4b | ||
|
|
711bab85ae | ||
|
|
0b1ad031a9 | ||
|
|
300dd108d5 | ||
|
|
65522b9e9f | ||
|
|
270f832b07 | ||
|
|
f2dddf48ae | ||
|
|
37bab58095 | ||
|
|
76e72ada16 | ||
|
|
0571f13da1 | ||
|
|
b33d0f86f0 | ||
|
|
d43fc9979c | ||
|
|
735cefa456 | ||
|
|
a24bf6aece | ||
|
|
fae66446a8 | ||
|
|
6c2c08c4df | ||
|
|
fcfe798b75 | ||
|
|
a484bd2efd | ||
|
|
c8602cf9b6 | ||
|
|
caa8fdc3cd | ||
|
|
f0ae77abd5 | ||
|
|
5d1a0346b5 | ||
|
|
55284dc290 | ||
|
|
382425d974 | ||
|
|
ff6250cdb4 | ||
|
|
2a8a17e3af | ||
|
|
70ac18f720 | ||
|
|
bb6677f80a | ||
|
|
3408c3e4c6 | ||
|
|
f6ad78650e | ||
|
|
a3800701f1 | ||
|
|
6c4370cd0d | ||
|
|
052deacbb2 | ||
|
|
523ab2e35f | ||
|
|
9a015ca8d5 | ||
|
|
a24cc4d305 | ||
|
|
ef76575ab6 | ||
|
|
39094f2aeb | ||
|
|
49ebb3f155 | ||
|
|
fa507f782f | ||
|
|
da548f65ea | ||
|
|
8991b193c6 | ||
|
|
3c776b3435 | ||
|
|
cf61a360e0 | ||
|
|
a588f498ea | ||
|
|
1503b4c834 | ||
|
|
573d7b7234 | ||
|
|
1d94ee86df | ||
|
|
275bf05ae2 | ||
|
|
aec264d2b5 | ||
|
|
62f21cbe69 | ||
|
|
d70f3a7958 | ||
|
|
5707962df5 | ||
|
|
63c06eeaf1 | ||
|
|
b3ce3a7882 | ||
|
|
a8b5ec2c61 | ||
|
|
d190e1c18a | ||
|
|
1d988a0fd8 | ||
|
|
6f176b1507 | ||
|
|
bfb1b44b15 | ||
|
|
9ebee1e247 | ||
|
|
87b680e1c0 | ||
|
|
59ce165355 | ||
|
|
a7201a38e4 | ||
|
|
80633137a9 | ||
|
|
2a28b37b3c | ||
|
|
866303a0d7 | ||
|
|
bce9cb5710 | ||
|
|
a9d35cc598 |
43
.travis.yml
43
.travis.yml
@@ -1,43 +0,0 @@
|
|||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
# TODO: Speed up the slowness of the osx travis runs
|
|
||||||
# Maybe cache brew installs?
|
|
||||||
#
|
|
||||||
# TODO: Uncomment when some gets the tests running on Windows.
|
|
||||||
# - windows
|
|
||||||
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- tree
|
|
||||||
homebrew:
|
|
||||||
packages:
|
|
||||||
- tree
|
|
||||||
update: true
|
|
||||||
|
|
||||||
# Only clone the most recent commit.
|
|
||||||
git:
|
|
||||||
depth: 1
|
|
||||||
|
|
||||||
language: go
|
|
||||||
|
|
||||||
go:
|
|
||||||
- "1.13"
|
|
||||||
|
|
||||||
go_import_path: sigs.k8s.io/kustomize
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- source ./travis/consider-early-travis-exit.sh
|
|
||||||
|
|
||||||
# Skip the install process; let pre-commit.sh do it.
|
|
||||||
install: true
|
|
||||||
|
|
||||||
script:
|
|
||||||
- make verify-kustomize
|
|
||||||
- ./travis/kyaml-pre-commit.sh
|
|
||||||
- ./travis/check-go-mod.sh
|
|
||||||
|
|
||||||
# TBD. Suppressing for now.
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
16
Makefile
16
Makefile
@@ -22,7 +22,9 @@ verify-kustomize: \
|
|||||||
.PHONY: prow-presubmit-check
|
.PHONY: prow-presubmit-check
|
||||||
prow-presubmit-check: \
|
prow-presubmit-check: \
|
||||||
lint-kustomize \
|
lint-kustomize \
|
||||||
test-unit-kustomize-all
|
test-unit-kustomize-all \
|
||||||
|
test-unit-cmd-all \
|
||||||
|
test-go-mod
|
||||||
|
|
||||||
.PHONY: verify-kustomize-e2e
|
.PHONY: verify-kustomize-e2e
|
||||||
verify-kustomize-e2e: test-examples-e2e-kustomize
|
verify-kustomize-e2e: test-examples-e2e-kustomize
|
||||||
@@ -33,12 +35,12 @@ verify-kustomize-e2e: test-examples-e2e-kustomize
|
|||||||
# since everything uses the same implicit GOPATH.
|
# since everything uses the same implicit GOPATH.
|
||||||
# This installs in a temp dir to avoid overwriting someone else's
|
# This installs in a temp dir to avoid overwriting someone else's
|
||||||
# linter, then installs in MYGOBIN with a new name.
|
# linter, then installs in MYGOBIN with a new name.
|
||||||
# Version pinned by api/go.mod
|
# Version pinned by hack/go.mod
|
||||||
$(MYGOBIN)/golangci-lint-kustomize:
|
$(MYGOBIN)/golangci-lint-kustomize:
|
||||||
( \
|
( \
|
||||||
set -e; \
|
set -e; \
|
||||||
export GOBIN=$$(mktemp -d) \
|
export GOBIN=$$(mktemp -d); \
|
||||||
cd api; \
|
cd hack; \
|
||||||
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint; \
|
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint; \
|
||||||
mv $$GOBIN/golangci-lint $(MYGOBIN)/golangci-lint-kustomize \
|
mv $$GOBIN/golangci-lint $(MYGOBIN)/golangci-lint-kustomize \
|
||||||
)
|
)
|
||||||
@@ -204,6 +206,12 @@ test-unit-kustomize-all: \
|
|||||||
test-unit-kustomize-cli \
|
test-unit-kustomize-cli \
|
||||||
test-unit-kustomize-plugins
|
test-unit-kustomize-plugins
|
||||||
|
|
||||||
|
test-unit-cmd-all:
|
||||||
|
./travis/kyaml-pre-commit.sh
|
||||||
|
|
||||||
|
test-go-mod:
|
||||||
|
./travis/check-go-mod.sh
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip
|
test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip
|
||||||
./hack/testExamplesAgainstKustomize.sh HEAD
|
./hack/testExamplesAgainstKustomize.sh HEAD
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ aliases:
|
|||||||
- mengqiy
|
- mengqiy
|
||||||
- monopole
|
- monopole
|
||||||
- pwittrock
|
- pwittrock
|
||||||
|
- mortent
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ and it's like [`sed`], in that it emits edited text.
|
|||||||
This tool is sponsored by [sig-cli] ([KEP]), and
|
This tool is sponsored by [sig-cli] ([KEP]), and
|
||||||
inspired by [DAM].
|
inspired by [DAM].
|
||||||
|
|
||||||
|
[](https://prow.k8s.io/job-history/kubernetes-jenkins/pr-logs/directory/kustomize-presubmit-master)
|
||||||
[](https://travis-ci.org/kubernetes-sigs/kustomize)
|
|
||||||
[](https://goreportcard.com/report/github.com/kubernetes-sigs/kustomize)
|
[](https://goreportcard.com/report/github.com/kubernetes-sigs/kustomize)
|
||||||
|
|
||||||
Download a binary from the [release page], or see
|
Download a binary from the [release page], or see
|
||||||
@@ -107,7 +106,7 @@ Take the work from step (1) above, move it into a
|
|||||||
`someApp` subdirectory called `base`, then
|
`someApp` subdirectory called `base`, then
|
||||||
place overlays in a sibling directory.
|
place overlays in a sibling directory.
|
||||||
|
|
||||||
An overlay is just another kustomization, refering to
|
An overlay is just another kustomization, referring to
|
||||||
the base, and referring to patches to apply to that
|
the base, and referring to patches to apply to that
|
||||||
base.
|
base.
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
package builtins
|
package builtins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/annotations"
|
||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
"sigs.k8s.io/kustomize/api/transform"
|
"sigs.k8s.io/kustomize/api/transform"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/filtersutil"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,6 +16,10 @@ import (
|
|||||||
type AnnotationsTransformerPlugin struct {
|
type AnnotationsTransformerPlugin struct {
|
||||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||||
FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||||
|
|
||||||
|
// YAMLSupport can be set to true to use the kyaml filter instead of the
|
||||||
|
// kunstruct transformer
|
||||||
|
YAMLSupport bool `json:"yamlSupport,omitempty" yaml:"yamlSupport,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *AnnotationsTransformerPlugin) Config(
|
func (p *AnnotationsTransformerPlugin) Config(
|
||||||
@@ -24,14 +30,27 @@ func (p *AnnotationsTransformerPlugin) Config(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *AnnotationsTransformerPlugin) Transform(m resmap.ResMap) error {
|
func (p *AnnotationsTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||||
t, err := transform.NewMapTransformer(
|
if p.YAMLSupport {
|
||||||
p.FieldSpecs,
|
for _, r := range m.Resources() {
|
||||||
p.Annotations,
|
err := filtersutil.ApplyToJSON(annotations.Filter{
|
||||||
)
|
Annotations: p.Annotations,
|
||||||
if err != nil {
|
FsSlice: p.FieldSpecs,
|
||||||
return err
|
}, r.Kunstructured)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
t, err := transform.NewMapTransformer(
|
||||||
|
p.FieldSpecs,
|
||||||
|
p.Annotations,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return t.Transform(m)
|
||||||
}
|
}
|
||||||
return t.Transform(m)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAnnotationsTransformerPlugin() resmap.TransformerPlugin {
|
func NewAnnotationsTransformerPlugin() resmap.TransformerPlugin {
|
||||||
|
|||||||
@@ -144,8 +144,10 @@ func (p *ImageTagTransformerPlugin) findContainers(obj map[string]interface{}) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isImageMatched(s, t string) bool {
|
func isImageMatched(s, t string) bool {
|
||||||
// Tag values are limited to [a-zA-Z0-9_.-].
|
// Tag values are limited to [a-zA-Z0-9_.{}-].
|
||||||
pattern, _ := regexp.Compile("^" + t + "(@sha256)?(:[a-zA-Z0-9_.-]*)?$")
|
// Some tools like Bazel rules_k8s allow tag patterns with {} characters.
|
||||||
|
// More info: https://github.com/bazelbuild/rules_k8s/pull/423
|
||||||
|
pattern, _ := regexp.Compile("^" + t + "(@sha256)?(:[a-zA-Z0-9_.{}-]*)?$")
|
||||||
return pattern.MatchString(s)
|
return pattern.MatchString(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ package builtins
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/api/transform"
|
"sigs.k8s.io/kustomize/api/filters/namespace"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/api/resid"
|
"sigs.k8s.io/kustomize/api/resid"
|
||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
"sigs.k8s.io/kustomize/api/resource"
|
"sigs.k8s.io/kustomize/api/resource"
|
||||||
|
"sigs.k8s.io/kustomize/api/transform"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/filtersutil"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,6 +20,11 @@ import (
|
|||||||
type NamespaceTransformerPlugin struct {
|
type NamespaceTransformerPlugin struct {
|
||||||
types.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
types.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||||
|
|
||||||
|
// YAMLSupport can be set to true to use the kyaml filter instead of the
|
||||||
|
// kunstruct transformer.
|
||||||
|
// TODO: change the default to use kyaml when it is stable
|
||||||
|
YAMLSupport bool `json:"yamlSupport,omitempty" yaml:"yamlSupport,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *NamespaceTransformerPlugin) Config(
|
func (p *NamespaceTransformerPlugin) Config(
|
||||||
@@ -39,12 +45,25 @@ func (p *NamespaceTransformerPlugin) Transform(m resmap.ResMap) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id := r.OrgId()
|
id := r.OrgId()
|
||||||
applicableFs := p.applicableFieldSpecs(id)
|
|
||||||
|
|
||||||
for _, fs := range applicableFs {
|
if !p.YAMLSupport {
|
||||||
err := transform.MutateField(
|
// use the old style transform
|
||||||
r.Map(), fs.PathSlice(), fs.CreateIfNotPresent,
|
applicableFs := p.applicableFieldSpecs(id)
|
||||||
p.changeNamespace(r))
|
|
||||||
|
for _, fs := range applicableFs {
|
||||||
|
err := transform.MutateField(
|
||||||
|
r.Map(), fs.PathSlice(), fs.CreateIfNotPresent,
|
||||||
|
p.changeNamespace(r))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// use the new style transform
|
||||||
|
err := filtersutil.ApplyToJSON(namespace.Filter{
|
||||||
|
Namespace: p.Namespace,
|
||||||
|
FsSlice: p.FieldSpecs,
|
||||||
|
}, r.Kunstructured)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -52,7 +71,7 @@ func (p *NamespaceTransformerPlugin) Transform(m resmap.ResMap) error {
|
|||||||
|
|
||||||
matches := m.GetMatchingResourcesByCurrentId(r.CurId().Equals)
|
matches := m.GetMatchingResourcesByCurrentId(r.CurId().Equals)
|
||||||
if len(matches) != 1 {
|
if len(matches) != 1 {
|
||||||
return fmt.Errorf("namespace tranformation produces ID conflict: %+v", matches)
|
return fmt.Errorf("namespace transformation produces ID conflict: %+v", matches)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ import (
|
|||||||
|
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/patchjson6902"
|
||||||
"sigs.k8s.io/kustomize/api/ifc"
|
"sigs.k8s.io/kustomize/api/ifc"
|
||||||
"sigs.k8s.io/kustomize/api/resid"
|
"sigs.k8s.io/kustomize/api/resid"
|
||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/filtersutil"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,6 +23,8 @@ type PatchJson6902TransformerPlugin struct {
|
|||||||
Target types.PatchTarget `json:"target,omitempty" yaml:"target,omitempty"`
|
Target types.PatchTarget `json:"target,omitempty" yaml:"target,omitempty"`
|
||||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||||
JsonOp string `json:"jsonOp,omitempty" yaml:"jsonOp,omitempty"`
|
JsonOp string `json:"jsonOp,omitempty" yaml:"jsonOp,omitempty"`
|
||||||
|
|
||||||
|
YAMLSupport bool `json:"yamlSupport,omitempty" yaml:"yamlSupport,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PatchJson6902TransformerPlugin) Config(
|
func (p *PatchJson6902TransformerPlugin) Config(
|
||||||
@@ -83,16 +87,22 @@ func (p *PatchJson6902TransformerPlugin) Transform(m resmap.ResMap) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rawObj, err := obj.MarshalJSON()
|
if !p.YAMLSupport {
|
||||||
if err != nil {
|
rawObj, err := obj.MarshalJSON()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
modifiedObj, err := p.decodedPatch.Apply(rawObj)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(
|
||||||
|
err, "failed to apply json patch '%s'", p.JsonOp)
|
||||||
|
}
|
||||||
|
return obj.UnmarshalJSON(modifiedObj)
|
||||||
|
} else {
|
||||||
|
return filtersutil.ApplyToJSON(patchjson6902.Filter{
|
||||||
|
Patch: p.JsonOp,
|
||||||
|
}, obj.Kunstructured)
|
||||||
}
|
}
|
||||||
modifiedObj, err := p.decodedPatch.Apply(rawObj)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrapf(
|
|
||||||
err, "failed to apply json patch '%s'", p.JsonOp)
|
|
||||||
}
|
|
||||||
return obj.UnmarshalJSON(modifiedObj)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPatchJson6902TransformerPlugin() resmap.TransformerPlugin {
|
func NewPatchJson6902TransformerPlugin() resmap.TransformerPlugin {
|
||||||
|
|||||||
@@ -4,11 +4,16 @@
|
|||||||
package builtins
|
package builtins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
kyaml "sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/patchstrategicmerge"
|
||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
"sigs.k8s.io/kustomize/api/resource"
|
"sigs.k8s.io/kustomize/api/resource"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/filtersutil"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,6 +22,8 @@ type PatchStrategicMergeTransformerPlugin struct {
|
|||||||
loadedPatches []*resource.Resource
|
loadedPatches []*resource.Resource
|
||||||
Paths []types.PatchStrategicMerge `json:"paths,omitempty" yaml:"paths,omitempty"`
|
Paths []types.PatchStrategicMerge `json:"paths,omitempty" yaml:"paths,omitempty"`
|
||||||
Patches string `json:"patches,omitempty" yaml:"patches,omitempty"`
|
Patches string `json:"patches,omitempty" yaml:"patches,omitempty"`
|
||||||
|
|
||||||
|
YAMLSupport bool `json:"yamlSupport,omitempty" yaml:"yamlSupport,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PatchStrategicMergeTransformerPlugin) Config(
|
func (p *PatchStrategicMergeTransformerPlugin) Config(
|
||||||
@@ -69,22 +76,42 @@ func (p *PatchStrategicMergeTransformerPlugin) Transform(m resmap.ResMap) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = target.Patch(patch.Kunstructured)
|
if !p.YAMLSupport {
|
||||||
if err != nil {
|
err = target.Patch(patch.Kunstructured)
|
||||||
return err
|
|
||||||
}
|
|
||||||
// remove the resource from resmap
|
|
||||||
// when the patch is to $patch: delete that target
|
|
||||||
if len(target.Map()) == 0 {
|
|
||||||
err = m.Remove(target.CurId())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// remove the resource from resmap
|
||||||
|
// when the patch is to $patch: delete that target
|
||||||
|
if len(target.Map()) == 0 {
|
||||||
|
err = m.Remove(target.CurId())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
node, err := getRNode(patch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = filtersutil.ApplyToJSON(patchstrategicmerge.Filter{
|
||||||
|
Patch: node,
|
||||||
|
}, target.Kunstructured)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Remove this once the next version of kyaml is released which
|
||||||
|
// exposes GetRNode from the filutersutil package.
|
||||||
|
func getRNode(k json.Marshaler) (*kyaml.RNode, error) {
|
||||||
|
j, err := k.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return kyaml.Parse(string(j))
|
||||||
|
}
|
||||||
|
|
||||||
func NewPatchStrategicMergeTransformerPlugin() resmap.TransformerPlugin {
|
func NewPatchStrategicMergeTransformerPlugin() resmap.TransformerPlugin {
|
||||||
return &PatchStrategicMergeTransformerPlugin{}
|
return &PatchStrategicMergeTransformerPlugin{}
|
||||||
}
|
}
|
||||||
|
|||||||
42
api/filters/annotations/annotations.go
Normal file
42
api/filters/annotations/annotations.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package annotations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/filtersutil"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type annoMap map[string]string
|
||||||
|
|
||||||
|
type Filter struct {
|
||||||
|
// Annotations is the set of annotations to apply to the inputs
|
||||||
|
Annotations annoMap `yaml:"annotations,omitempty"`
|
||||||
|
|
||||||
|
// FsSlice contains the FieldSpecs to locate the namespace field
|
||||||
|
FsSlice types.FsSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
keys := filtersutil.SortedMapKeys(f.Annotations)
|
||||||
|
_, err := kio.FilterAll(yaml.FilterFunc(
|
||||||
|
func(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
for _, k := range keys {
|
||||||
|
if err := node.PipeE(fsslice.Filter{
|
||||||
|
FsSlice: f.FsSlice,
|
||||||
|
SetValue: fsslice.SetEntry(k, f.Annotations[k]),
|
||||||
|
CreateKind: yaml.MappingNode, // Annotations are MappingNodes.
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node, nil
|
||||||
|
})).Filter(nodes)
|
||||||
|
return nodes, err
|
||||||
|
}
|
||||||
139
api/filters/annotations/annotations_test.go
Normal file
139
api/filters/annotations/annotations_test.go
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package annotations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
filtertest_test "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var annosFs = builtinconfig.MakeDefaultConfig().CommonAnnotations
|
||||||
|
|
||||||
|
func TestAnnotations_Filter(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input string
|
||||||
|
expectedOutput string
|
||||||
|
filter Filter
|
||||||
|
fsslice types.FsSlice
|
||||||
|
}{
|
||||||
|
"add": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
annotations:
|
||||||
|
hero: batman
|
||||||
|
fiend: riddler
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
annotations:
|
||||||
|
hero: batman
|
||||||
|
fiend: riddler
|
||||||
|
auto: ford
|
||||||
|
bean: cannellini
|
||||||
|
clown: emmett kelley
|
||||||
|
dragon: smaug
|
||||||
|
`,
|
||||||
|
filter: Filter{Annotations: annoMap{
|
||||||
|
"clown": "emmett kelley",
|
||||||
|
"auto": "ford",
|
||||||
|
"dragon": "smaug",
|
||||||
|
"bean": "cannellini",
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
"update": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
annotations:
|
||||||
|
hero: batman
|
||||||
|
fiend: riddler
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
annotations:
|
||||||
|
hero: superman
|
||||||
|
fiend: luthor
|
||||||
|
bean: cannellini
|
||||||
|
clown: emmett kelley
|
||||||
|
`,
|
||||||
|
filter: Filter{Annotations: annoMap{
|
||||||
|
"clown": "emmett kelley",
|
||||||
|
"hero": "superman",
|
||||||
|
"fiend": "luthor",
|
||||||
|
"bean": "cannellini",
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
"data-fieldspecs": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
annotations:
|
||||||
|
sleater: kinney
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
sleater: kinney
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
annotations:
|
||||||
|
sleater: kinney
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
sleater: kinney
|
||||||
|
`,
|
||||||
|
filter: Filter{Annotations: annoMap{
|
||||||
|
"sleater": "kinney",
|
||||||
|
}},
|
||||||
|
fsslice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "a/b",
|
||||||
|
CreateIfNotPresent: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
filter := tc.filter
|
||||||
|
filter.FsSlice = append(annosFs, tc.fsslice...)
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expectedOutput),
|
||||||
|
strings.TrimSpace(filtertest_test.RunFilter(t, tc.input, filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
6
api/filters/annotations/doc.go
Normal file
6
api/filters/annotations/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package annotations contains a kio.Filter implementation of the kustomize
|
||||||
|
// annotations transformer.
|
||||||
|
package annotations
|
||||||
55
api/filters/annotations/example_test.go
Normal file
55
api/filters/annotations/example_test.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package annotations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
fss := builtinconfig.MakeDefaultConfig().CommonAnnotations
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{Filter{
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
FsSlice: fss,
|
||||||
|
}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// annotations:
|
||||||
|
// foo: bar
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// annotations:
|
||||||
|
// foo: bar
|
||||||
|
}
|
||||||
21
api/filters/filtersutil/filtersutil.go
Normal file
21
api/filters/filtersutil/filtersutil.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package filtersutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SortedMapKeys returns a sorted slice of keys to the given map.
|
||||||
|
// Writing this function never gets old.
|
||||||
|
func SortedMapKeys(m map[string]string) []string {
|
||||||
|
keys := make([]string, len(m))
|
||||||
|
i := 0
|
||||||
|
for k := range m {
|
||||||
|
keys[i] = k
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
return keys
|
||||||
|
}
|
||||||
34
api/filters/filtersutil/filtersutil_test.go
Normal file
34
api/filters/filtersutil/filtersutil_test.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package filtersutil_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/filtersutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSortedKeys(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input map[string]string
|
||||||
|
expected []string
|
||||||
|
}{
|
||||||
|
"empty": {
|
||||||
|
input: map[string]string{},
|
||||||
|
expected: []string{}},
|
||||||
|
"one": {
|
||||||
|
input: map[string]string{"a": "aaa"},
|
||||||
|
expected: []string{"a"}},
|
||||||
|
"three": {
|
||||||
|
input: map[string]string{"c": "ccc", "b": "bbb", "a": "aaa"},
|
||||||
|
expected: []string{"a", "b", "c"}},
|
||||||
|
}
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
if !assert.Equal(t,
|
||||||
|
filtersutil.SortedMapKeys(tc.input),
|
||||||
|
tc.expected) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
6
api/filters/fsslice/doc.go
Normal file
6
api/filters/fsslice/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package fsslice contains a yaml.Filter to modify a resource using an
|
||||||
|
// FsSlice to identify fields to be updated within the resource.
|
||||||
|
package fsslice
|
||||||
62
api/filters/fsslice/example_test.go
Normal file
62
api/filters/fsslice/example_test.go
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package fsslice_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
in := &kio.ByteReader{
|
||||||
|
Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`),
|
||||||
|
}
|
||||||
|
fltr := fsslice.Filter{
|
||||||
|
CreateKind: yaml.ScalarNode,
|
||||||
|
SetValue: fsslice.SetScalar("green"),
|
||||||
|
FsSlice: []types.FieldSpec{
|
||||||
|
{Path: "a/b", CreateIfNotPresent: true},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{in},
|
||||||
|
Filters: []kio.Filter{kio.FilterAll(fltr)},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// a:
|
||||||
|
// b: green
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// a:
|
||||||
|
// b: green
|
||||||
|
}
|
||||||
145
api/filters/fsslice/fieldspec_filter.go
Normal file
145
api/filters/fsslice/fieldspec_filter.go
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package fsslice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/errors"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fieldSpecFilter applies a single fieldSpec to a single object
|
||||||
|
// fieldSpecFilter stores internal state and should not be reused
|
||||||
|
type fieldSpecFilter struct {
|
||||||
|
// FieldSpec contains the path to the value to set.
|
||||||
|
FieldSpec types.FieldSpec `yaml:"fieldSpec"`
|
||||||
|
|
||||||
|
// Set the field using this function
|
||||||
|
SetValue SetFn
|
||||||
|
|
||||||
|
// CreateKind defines the type of node to create if the field is not found
|
||||||
|
CreateKind yaml.Kind
|
||||||
|
|
||||||
|
// path keeps internal state about the current path
|
||||||
|
path []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fltr fieldSpecFilter) Filter(obj *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
// check if the FieldSpec applies to the object
|
||||||
|
if match, err := isMatchGVK(fltr.FieldSpec, obj); !match || err != nil {
|
||||||
|
return obj, errors.Wrap(err)
|
||||||
|
}
|
||||||
|
fltr.path = strings.Split(fltr.FieldSpec.Path, "/")
|
||||||
|
if err := fltr.filter(obj); err != nil {
|
||||||
|
s, _ := obj.String()
|
||||||
|
return nil, errors.WrapPrefixf(err,
|
||||||
|
"obj %v at path %v", s, fltr.FieldSpec.Path)
|
||||||
|
}
|
||||||
|
return obj, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fltr fieldSpecFilter) filter(obj *yaml.RNode) error {
|
||||||
|
if len(fltr.path) == 0 {
|
||||||
|
// found the field -- set its value
|
||||||
|
return fltr.SetValue(obj)
|
||||||
|
}
|
||||||
|
switch obj.YNode().Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
return fltr.seq(obj)
|
||||||
|
case yaml.MappingNode:
|
||||||
|
return fltr.field(obj)
|
||||||
|
}
|
||||||
|
// not found -- this might be an error since the type doesn't match
|
||||||
|
|
||||||
|
return errors.Errorf("unsupported yaml node")
|
||||||
|
}
|
||||||
|
|
||||||
|
// field calls filter on the field matching the next path element
|
||||||
|
func (fltr fieldSpecFilter) field(obj *yaml.RNode) error {
|
||||||
|
fieldName, isSeq := isSequenceField(fltr.path[0])
|
||||||
|
|
||||||
|
// lookup the field matching the next path element
|
||||||
|
var lookupField yaml.Filter
|
||||||
|
switch {
|
||||||
|
case !fltr.FieldSpec.CreateIfNotPresent || fltr.CreateKind == 0 || isSeq:
|
||||||
|
// dont' create the field if we don't find it
|
||||||
|
lookupField = yaml.Lookup(fieldName)
|
||||||
|
case len(fltr.path) <= 1:
|
||||||
|
// create the field if it is missing: use the provided node kind
|
||||||
|
lookupField = yaml.LookupCreate(fltr.CreateKind, fieldName)
|
||||||
|
default:
|
||||||
|
// create the field if it is missing: must be a mapping node
|
||||||
|
lookupField = yaml.LookupCreate(yaml.MappingNode, fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// locate (or maybe create) the field
|
||||||
|
field, err := obj.Pipe(lookupField)
|
||||||
|
if err != nil || field == nil {
|
||||||
|
return errors.WrapPrefixf(err, "fieldName: %s", fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy the current fltr and change the path on the copy
|
||||||
|
var next = fltr
|
||||||
|
// call filter for the next path element on the matching field
|
||||||
|
next.path = fltr.path[1:]
|
||||||
|
return next.filter(field)
|
||||||
|
}
|
||||||
|
|
||||||
|
// seq calls filter on all sequence elements
|
||||||
|
func (fltr fieldSpecFilter) seq(obj *yaml.RNode) error {
|
||||||
|
if err := obj.VisitElements(func(node *yaml.RNode) error {
|
||||||
|
// recurse on each element -- re-allocating a fieldSpecFilter is
|
||||||
|
// not strictly required, but is more consistent with field
|
||||||
|
// and less likely to have side effects
|
||||||
|
// keep the entire path -- it does not contain parts for sequences
|
||||||
|
return fltr.filter(node)
|
||||||
|
}); err != nil {
|
||||||
|
return errors.WrapPrefixf(err,
|
||||||
|
"visit traversal on path: %v", fltr.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// isSequenceField returns true if the path element is for a sequence field.
|
||||||
|
// isSequence also returns the path element with the '[]' suffix trimmed
|
||||||
|
func isSequenceField(name string) (string, bool) {
|
||||||
|
isSeq := strings.HasSuffix(name, "[]")
|
||||||
|
name = strings.TrimSuffix(name, "[]")
|
||||||
|
return name, isSeq
|
||||||
|
}
|
||||||
|
|
||||||
|
// isMatchGVK returns true if the fs.GVK matches the obj GVK.
|
||||||
|
func isMatchGVK(fs types.FieldSpec, obj *yaml.RNode) (bool, error) {
|
||||||
|
meta, err := obj.GetMeta()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if fs.Kind != "" && fs.Kind != meta.Kind {
|
||||||
|
// kind doesn't match
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse the group and version from the apiVersion field
|
||||||
|
var group, version string
|
||||||
|
parts := strings.SplitN(meta.APIVersion, "/", 2)
|
||||||
|
group = parts[0]
|
||||||
|
if len(parts) > 1 {
|
||||||
|
version = parts[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
if fs.Group != "" && fs.Group != group {
|
||||||
|
// group doesn't match
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if fs.Version != "" && fs.Version != version {
|
||||||
|
// version doesn't match
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
78
api/filters/fsslice/fsslice.go
Normal file
78
api/filters/fsslice/fsslice.go
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package fsslice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/resid"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetFn sets a value
|
||||||
|
type SetFn func(*yaml.RNode) error
|
||||||
|
|
||||||
|
// SetScalar returns a SetFn to set a scalar value
|
||||||
|
func SetScalar(value string) SetFn {
|
||||||
|
return func(node *yaml.RNode) error {
|
||||||
|
return node.PipeE(yaml.FieldSetter{StringValue: value})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntry returns a SetFn to set an entry in a map
|
||||||
|
func SetEntry(key, value string) SetFn {
|
||||||
|
return func(node *yaml.RNode) error {
|
||||||
|
return node.PipeE(yaml.FieldSetter{
|
||||||
|
Name: key, StringValue: value})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ yaml.Filter = Filter{}
|
||||||
|
|
||||||
|
// Filter uses an FsSlice to modify fields on a single object
|
||||||
|
type Filter struct {
|
||||||
|
// FieldSpecList list of FieldSpecs to set
|
||||||
|
FsSlice types.FsSlice `yaml:"fsSlice"`
|
||||||
|
|
||||||
|
// SetValue is called on each field that matches one of the FieldSpecs
|
||||||
|
SetValue SetFn
|
||||||
|
|
||||||
|
// CreateKind is used to create fields that do not exist
|
||||||
|
CreateKind yaml.Kind
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fltr Filter) Filter(obj *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
for i := range fltr.FsSlice {
|
||||||
|
// apply this FieldSpec
|
||||||
|
// create a new filter for each iteration because they
|
||||||
|
// store internal state about the field paths
|
||||||
|
_, err := (&fieldSpecFilter{
|
||||||
|
FieldSpec: fltr.FsSlice[i],
|
||||||
|
SetValue: fltr.SetValue,
|
||||||
|
CreateKind: fltr.CreateKind,
|
||||||
|
}).Filter(obj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGVK parses the metadata into a GVK
|
||||||
|
func GetGVK(meta yaml.ResourceMeta) resid.Gvk {
|
||||||
|
// parse the group and version from the apiVersion field
|
||||||
|
var group, version string
|
||||||
|
parts := strings.SplitN(meta.APIVersion, "/", 2)
|
||||||
|
group = parts[0]
|
||||||
|
if len(parts) > 1 {
|
||||||
|
version = parts[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return resid.Gvk{
|
||||||
|
Group: group,
|
||||||
|
Version: version,
|
||||||
|
Kind: meta.Kind,
|
||||||
|
}
|
||||||
|
}
|
||||||
354
api/filters/fsslice/fsslice_test.go
Normal file
354
api/filters/fsslice/fsslice_test.go
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package fsslice_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/resid"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TestCase struct {
|
||||||
|
name string
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
filter fsslice.Filter
|
||||||
|
fsSlice string
|
||||||
|
error string
|
||||||
|
}
|
||||||
|
|
||||||
|
var tests = []TestCase{
|
||||||
|
{
|
||||||
|
name: "update",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b
|
||||||
|
group: foo
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: e
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update-kind-not-match",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b
|
||||||
|
group: foo
|
||||||
|
kind: Bar1
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar2
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar2
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update-group-not-match",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b
|
||||||
|
group: foo1
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo2/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo2/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update-version-not-match",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b
|
||||||
|
group: foo
|
||||||
|
version: v1beta1
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta2
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta2
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "bad-version",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b
|
||||||
|
group: foo
|
||||||
|
version: v1beta1
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta2/something
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta2/something
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "bad-meta",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b
|
||||||
|
group: foo
|
||||||
|
version: v1beta1
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
a:
|
||||||
|
b: c
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
error: "missing Resource metadata",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "miss-match-type",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b/c
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b: a
|
||||||
|
`,
|
||||||
|
error: "obj kind: Bar\na:\n b: a\n at path a/b/c: unsupported yaml node",
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "add",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b/c/d
|
||||||
|
group: foo
|
||||||
|
create: true
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a: {}
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a: {b: {c: {d: e}}}
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
CreateKind: yaml.ScalarNode,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update-in-sequence",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b[]/c/d
|
||||||
|
group: foo
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
- c:
|
||||||
|
d: a
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
- c:
|
||||||
|
d: e
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Don't create a sequence
|
||||||
|
{
|
||||||
|
name: "empty-sequence-no-create",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b[]/c/d
|
||||||
|
group: foo
|
||||||
|
create: true
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a: {}
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a: {}
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
CreateKind: yaml.ScalarNode,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Create a new field for an element in a sequence
|
||||||
|
{
|
||||||
|
name: "empty-sequence-create",
|
||||||
|
fsSlice: `
|
||||||
|
- path: a/b[]/c/d
|
||||||
|
group: foo
|
||||||
|
create: true
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
- c: {}
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: foo/v1beta1
|
||||||
|
kind: Bar
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
- c: {d: e}
|
||||||
|
`,
|
||||||
|
filter: fsslice.Filter{
|
||||||
|
SetValue: fsslice.SetScalar("e"),
|
||||||
|
CreateKind: yaml.ScalarNode,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilter_Filter(t *testing.T) {
|
||||||
|
for i := range tests {
|
||||||
|
test := tests[i]
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
err := yaml.Unmarshal([]byte(test.fsSlice), &test.filter.FsSlice)
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
out := &bytes.Buffer{}
|
||||||
|
rw := &kio.ByteReadWriter{
|
||||||
|
Reader: bytes.NewBufferString(test.input),
|
||||||
|
Writer: out,
|
||||||
|
OmitReaderAnnotations: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
// run the filter
|
||||||
|
err = kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{rw},
|
||||||
|
Filters: []kio.Filter{kio.FilterAll(test.filter)},
|
||||||
|
Outputs: []kio.Writer{rw},
|
||||||
|
}.Execute()
|
||||||
|
if test.error != "" {
|
||||||
|
if !assert.EqualError(t, err, test.error) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
// stop rest of test
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
// check results
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(test.expected),
|
||||||
|
strings.TrimSpace(out.String())) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetGVK(t *testing.T) {
|
||||||
|
obj, err := yaml.Parse(`
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
`)
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
meta, err := obj.GetMeta()
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
gvk := fsslice.GetGVK(meta)
|
||||||
|
expected := resid.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
||||||
|
if !assert.Equal(t, expected, gvk) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
12
api/filters/imagetag/doc.go
Normal file
12
api/filters/imagetag/doc.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package imagetag contains two kio.Filter implementations to cover the
|
||||||
|
// functionality of the kustomize imagetag transformer.
|
||||||
|
//
|
||||||
|
// Filter updates fields based on a FieldSpec and an ImageTag.
|
||||||
|
//
|
||||||
|
// LegacyFilter doesn't use a FieldSpec, and instead only updates image
|
||||||
|
// references if the field is name image and it is underneath a field called
|
||||||
|
// either containers or initContainers.
|
||||||
|
package imagetag
|
||||||
126
api/filters/imagetag/example_test.go
Normal file
126
api/filters/imagetag/example_test.go
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package imagetag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: FooBar
|
||||||
|
image: nginx
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: BarFoo
|
||||||
|
image: nginx:1.2.1
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{Filter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
Digest: "12345",
|
||||||
|
},
|
||||||
|
FsSlice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "spec/containers[]/image",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// containers:
|
||||||
|
// - name: FooBar
|
||||||
|
// image: apache@12345
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// containers:
|
||||||
|
// - name: BarFoo
|
||||||
|
// image: apache@12345
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExampleLegacyFilter() {
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: FooBar
|
||||||
|
image: nginx
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: BarFoo
|
||||||
|
image: nginx:1.2.1
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{LegacyFilter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
Digest: "12345",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// containers:
|
||||||
|
// - name: FooBar
|
||||||
|
// image: apache@12345
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// containers:
|
||||||
|
// - name: BarFoo
|
||||||
|
// image: apache@12345
|
||||||
|
}
|
||||||
44
api/filters/imagetag/imagetag.go
Normal file
44
api/filters/imagetag/imagetag.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package imagetag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Filter struct {
|
||||||
|
// imageTag is the tag we want to apply to the inputs
|
||||||
|
ImageTag types.Image `json:"imageTag,omitempty" yaml:"imageTag,omitempty"`
|
||||||
|
|
||||||
|
// FsSlice contains the FieldSpecs to locate the namespace field
|
||||||
|
FsSlice types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
_, err := kio.FilterAll(yaml.FilterFunc(f.filter)).Filter(nodes)
|
||||||
|
return nodes, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f Filter) filter(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
if err := node.PipeE(fsslice.Filter{
|
||||||
|
FsSlice: f.FsSlice,
|
||||||
|
SetValue: updateImageTagFn(f.ImageTag),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateImageTagFn(imageTag types.Image) fsslice.SetFn {
|
||||||
|
return func(node *yaml.RNode) error {
|
||||||
|
return node.PipeE(imageTagUpdater{
|
||||||
|
ImageTag: imageTag,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
101
api/filters/imagetag/imagetag_test.go
Normal file
101
api/filters/imagetag/imagetag_test.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package imagetag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
filtertest "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestImageTagUpdater_Filter(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input string
|
||||||
|
expectedOutput string
|
||||||
|
filter Filter
|
||||||
|
fsSlice types.FsSlice
|
||||||
|
}{
|
||||||
|
"update with digest": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
image: nginx:1.2.1
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
image: apache@12345
|
||||||
|
`,
|
||||||
|
filter: Filter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
Digest: "12345",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fsSlice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "spec/image",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"multiple matches in sequence": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
- image: not_nginx@54321
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: apache:3.2.1
|
||||||
|
- image: not_nginx@54321
|
||||||
|
- image: apache:3.2.1
|
||||||
|
`,
|
||||||
|
filter: Filter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
NewTag: "3.2.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fsSlice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "spec/containers/image",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
filter := tc.filter
|
||||||
|
filter.FsSlice = tc.fsSlice
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expectedOutput),
|
||||||
|
strings.TrimSpace(filtertest.RunFilter(t, tc.input, filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
113
api/filters/imagetag/legacy.go
Normal file
113
api/filters/imagetag/legacy.go
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package imagetag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LegacyFilter is an implementation of the kio.Filter interface
|
||||||
|
// that scans through the provided kyaml data structure and updates
|
||||||
|
// any values of any image fields that is inside a sequence under
|
||||||
|
// a field called either containers or initContainers. The field is only
|
||||||
|
// update if it has a value that matches and image reference and the name
|
||||||
|
// of the image is a match with the provided ImageTag.
|
||||||
|
type LegacyFilter struct {
|
||||||
|
ImageTag types.Image `json:"imageTag,omitempty" yaml:"imageTag,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = LegacyFilter{}
|
||||||
|
|
||||||
|
func (lf LegacyFilter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
return kio.FilterAll(yaml.FilterFunc(lf.filter)).Filter(nodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lf LegacyFilter) filter(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
meta, err := node.GetMeta()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// We do not make any changes if the type of the resource
|
||||||
|
// is CustomResourceDefinition.
|
||||||
|
if meta.Kind == `CustomResourceDefinition` {
|
||||||
|
return node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
fff := findFieldsFilter{
|
||||||
|
fields: []string{"containers", "initContainers"},
|
||||||
|
fieldCallback: checkImageTagsFn(lf.ImageTag),
|
||||||
|
}
|
||||||
|
if err := node.PipeE(fff); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type fieldCallback func(node *yaml.RNode) error
|
||||||
|
|
||||||
|
// findFieldsFilter is an implementation of the kio.Filter
|
||||||
|
// interface. It will walk the data structure and look for fields
|
||||||
|
// that matches the provided list of field names. For each match,
|
||||||
|
// the value of the field will be passed in as a parameter to the
|
||||||
|
// provided fieldCallback.
|
||||||
|
// TODO: move this to kyaml/filterutils
|
||||||
|
type findFieldsFilter struct {
|
||||||
|
fields []string
|
||||||
|
|
||||||
|
fieldCallback fieldCallback
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f findFieldsFilter) Filter(obj *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
return obj, f.walk(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f findFieldsFilter) walk(node *yaml.RNode) error {
|
||||||
|
switch node.YNode().Kind {
|
||||||
|
case yaml.MappingNode:
|
||||||
|
return node.VisitFields(func(n *yaml.MapNode) error {
|
||||||
|
err := f.walk(n.Value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
key := n.Key.YNode().Value
|
||||||
|
if contains(f.fields, key) {
|
||||||
|
return f.fieldCallback(n.Value)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
return node.VisitElements(func(n *yaml.RNode) error {
|
||||||
|
return f.walk(n)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func contains(slice []string, str string) bool {
|
||||||
|
for _, s := range slice {
|
||||||
|
if s == str {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkImageTagsFn(imageTag types.Image) fieldCallback {
|
||||||
|
return func(node *yaml.RNode) error {
|
||||||
|
if node.YNode().Kind != yaml.SequenceNode {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return node.VisitElements(func(n *yaml.RNode) error {
|
||||||
|
// Look up any fields on the provided node that is named
|
||||||
|
// image.
|
||||||
|
return n.PipeE(yaml.Get("image"), imageTagUpdater{
|
||||||
|
ImageTag: imageTag,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
136
api/filters/imagetag/legacy_test.go
Normal file
136
api/filters/imagetag/legacy_test.go
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package imagetag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
filtertest "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLegacyImageTag_Filter(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input string
|
||||||
|
expectedOutput string
|
||||||
|
filter LegacyFilter
|
||||||
|
}{
|
||||||
|
"updates multiple images inside containers": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
- image: nginx:2.1.2
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: apache@12345
|
||||||
|
- image: apache@12345
|
||||||
|
`,
|
||||||
|
filter: LegacyFilter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
Digest: "12345",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"updates inside both containers and initContainers": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
- image: tomcat:1.2.3
|
||||||
|
initContainers:
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
- image: apache:1.2.3
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: apache:3.2.1
|
||||||
|
- image: tomcat:1.2.3
|
||||||
|
initContainers:
|
||||||
|
- image: apache:3.2.1
|
||||||
|
- image: apache:1.2.3
|
||||||
|
`,
|
||||||
|
filter: LegacyFilter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
NewTag: "3.2.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"updates on multiple depths": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
- image: tomcat:1.2.3
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
initContainers:
|
||||||
|
- image: nginx:1.2.1
|
||||||
|
- image: apache:1.2.3
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: apache:3.2.1
|
||||||
|
- image: tomcat:1.2.3
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
initContainers:
|
||||||
|
- image: apache:3.2.1
|
||||||
|
- image: apache:1.2.3
|
||||||
|
`,
|
||||||
|
filter: LegacyFilter{
|
||||||
|
ImageTag: types.Image{
|
||||||
|
Name: "nginx",
|
||||||
|
NewName: "apache",
|
||||||
|
NewTag: "3.2.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
filter := tc.filter
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expectedOutput),
|
||||||
|
strings.TrimSpace(filtertest.RunFilter(t, tc.input, filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
43
api/filters/imagetag/updater.go
Normal file
43
api/filters/imagetag/updater.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package imagetag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/image"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
// imageTagUpdater is an implementation of the kio.Filter interface
|
||||||
|
// that will update the value of the yaml node based on the provided
|
||||||
|
// ImageTag if the current value matches the format of an image reference.
|
||||||
|
type imageTagUpdater struct {
|
||||||
|
Kind string `yaml:"kind,omitempty"`
|
||||||
|
ImageTag types.Image `yaml:"imageTag,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u imageTagUpdater) Filter(rn *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
if err := yaml.ErrorIfInvalid(rn, yaml.ScalarNode); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
value := rn.YNode().Value
|
||||||
|
|
||||||
|
if !image.IsImageMatched(value, u.ImageTag.Name) {
|
||||||
|
return rn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
name, tag := image.Split(value)
|
||||||
|
if u.ImageTag.NewName != "" {
|
||||||
|
name = u.ImageTag.NewName
|
||||||
|
}
|
||||||
|
if u.ImageTag.NewTag != "" {
|
||||||
|
tag = ":" + u.ImageTag.NewTag
|
||||||
|
}
|
||||||
|
if u.ImageTag.Digest != "" {
|
||||||
|
tag = "@" + u.ImageTag.Digest
|
||||||
|
}
|
||||||
|
|
||||||
|
return rn.Pipe(yaml.FieldSetter{StringValue: name + tag})
|
||||||
|
}
|
||||||
6
api/filters/labels/doc.go
Normal file
6
api/filters/labels/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package labels contains a kio.Filter implementation of the kustomize
|
||||||
|
// labels transformer.
|
||||||
|
package labels
|
||||||
55
api/filters/labels/example_test.go
Normal file
55
api/filters/labels/example_test.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package labels
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
fss := builtinconfig.MakeDefaultConfig().CommonLabels
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{Filter{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
FsSlice: fss,
|
||||||
|
}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// labels:
|
||||||
|
// foo: bar
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// labels:
|
||||||
|
// foo: bar
|
||||||
|
}
|
||||||
43
api/filters/labels/labels.go
Normal file
43
api/filters/labels/labels.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package labels
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/filtersutil"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type labelMap map[string]string
|
||||||
|
|
||||||
|
// Filter sets labels.
|
||||||
|
type Filter struct {
|
||||||
|
// Labels is the set of labels to apply to the inputs
|
||||||
|
Labels labelMap `yaml:"labels,omitempty"`
|
||||||
|
|
||||||
|
// FsSlice identifies the label fields.
|
||||||
|
FsSlice types.FsSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
keys := filtersutil.SortedMapKeys(f.Labels)
|
||||||
|
_, err := kio.FilterAll(yaml.FilterFunc(
|
||||||
|
func(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
for _, k := range keys {
|
||||||
|
if err := node.PipeE(fsslice.Filter{
|
||||||
|
FsSlice: f.FsSlice,
|
||||||
|
SetValue: fsslice.SetEntry(k, f.Labels[k]),
|
||||||
|
CreateKind: yaml.MappingNode, // Labels are MappingNodes.
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node, nil
|
||||||
|
})).Filter(nodes)
|
||||||
|
return nodes, err
|
||||||
|
}
|
||||||
139
api/filters/labels/labels_test.go
Normal file
139
api/filters/labels/labels_test.go
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package labels
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
filtertest_test "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var labelsFs = builtinconfig.MakeDefaultConfig().CommonLabels
|
||||||
|
|
||||||
|
func TestLabels_Filter(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input string
|
||||||
|
expectedOutput string
|
||||||
|
filter Filter
|
||||||
|
fsSlice types.FsSlice
|
||||||
|
}{
|
||||||
|
"add": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
labels:
|
||||||
|
hero: batman
|
||||||
|
fiend: riddler
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
labels:
|
||||||
|
hero: batman
|
||||||
|
fiend: riddler
|
||||||
|
auto: ford
|
||||||
|
bean: cannellini
|
||||||
|
clown: emmett kelley
|
||||||
|
dragon: smaug
|
||||||
|
`,
|
||||||
|
filter: Filter{Labels: labelMap{
|
||||||
|
"clown": "emmett kelley",
|
||||||
|
"auto": "ford",
|
||||||
|
"dragon": "smaug",
|
||||||
|
"bean": "cannellini",
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
"update": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
labels:
|
||||||
|
hero: batman
|
||||||
|
fiend: riddler
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
labels:
|
||||||
|
hero: superman
|
||||||
|
fiend: luthor
|
||||||
|
bean: cannellini
|
||||||
|
clown: emmett kelley
|
||||||
|
`,
|
||||||
|
filter: Filter{Labels: labelMap{
|
||||||
|
"clown": "emmett kelley",
|
||||||
|
"hero": "superman",
|
||||||
|
"fiend": "luthor",
|
||||||
|
"bean": "cannellini",
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
"data-fieldspecs": {
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
labels:
|
||||||
|
sleater: kinney
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
sleater: kinney
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
labels:
|
||||||
|
sleater: kinney
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
sleater: kinney
|
||||||
|
`,
|
||||||
|
filter: Filter{Labels: labelMap{
|
||||||
|
"sleater": "kinney",
|
||||||
|
}},
|
||||||
|
fsSlice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "a/b",
|
||||||
|
CreateIfNotPresent: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
filter := tc.filter
|
||||||
|
filter.FsSlice = append(labelsFs, tc.fsSlice...)
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expectedOutput),
|
||||||
|
strings.TrimSpace(filtertest_test.RunFilter(t, tc.input, filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
9
api/filters/namespace/doc.go
Normal file
9
api/filters/namespace/doc.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package namespace contains a kio.Filter implementation of the kustomize
|
||||||
|
// namespace transformer.
|
||||||
|
//
|
||||||
|
// Special cases for known Kubernetes resources have been hardcoded in addition
|
||||||
|
// to those defined by the FsSlice.
|
||||||
|
package namespace
|
||||||
50
api/filters/namespace/example_test.go
Normal file
50
api/filters/namespace/example_test.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package namespace_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/namespace"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
fss := builtinconfig.MakeDefaultConfig().NameSpace
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: bar
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{namespace.Filter{Namespace: "app", FsSlice: fss}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// namespace: app
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// namespace: app
|
||||||
|
}
|
||||||
167
api/filters/namespace/namespace.go
Normal file
167
api/filters/namespace/namespace.go
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package namespace
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Filter struct {
|
||||||
|
// Namespace is the namespace to apply to the inputs
|
||||||
|
Namespace string `yaml:"namespace,omitempty"`
|
||||||
|
|
||||||
|
// FsSlice contains the FieldSpecs to locate the namespace field
|
||||||
|
FsSlice types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (ns Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
return kio.FilterAll(yaml.FilterFunc(ns.run)).Filter(nodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run runs the filter on a single node rather than a slice
|
||||||
|
func (ns Filter) run(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
// hacks for hardcoded types -- :(
|
||||||
|
if err := ns.hacks(node); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the fieldspecs that are for hardcoded fields. The fieldspecs
|
||||||
|
// exist for backwards compatibility with other implementations
|
||||||
|
// of this transformation.
|
||||||
|
// This implementation of the namespace transformation
|
||||||
|
// Does not use the fieldspecs for implementing cases which
|
||||||
|
// require hardcoded logic.
|
||||||
|
ns.FsSlice = ns.removeFieldSpecsForHacks(ns.FsSlice)
|
||||||
|
|
||||||
|
// transformations based on data -- :)
|
||||||
|
err := node.PipeE(fsslice.Filter{
|
||||||
|
FsSlice: ns.FsSlice,
|
||||||
|
SetValue: fsslice.SetScalar(ns.Namespace),
|
||||||
|
CreateKind: yaml.ScalarNode, // Namespace is a ScalarNode
|
||||||
|
})
|
||||||
|
return node, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// hacks applies the namespace transforms that are hardcoded rather
|
||||||
|
// than specified through FieldSpecs.
|
||||||
|
func (ns Filter) hacks(obj *yaml.RNode) error {
|
||||||
|
meta, err := obj.GetMeta()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ns.metaNamespaceHack(obj, meta); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ns.roleBindingHack(obj, meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
// metaNamespaceHack is a hack for implementing the namespace transform
|
||||||
|
// for the metadata.namespace field on namespace scoped resources.
|
||||||
|
// namespace scoped resources are determined by NOT being present
|
||||||
|
// in a blacklist of cluster-scoped resource types (by apiVersion and kind).
|
||||||
|
//
|
||||||
|
// This hack should be updated to allow individual resources to specify
|
||||||
|
// if they are cluster scoped through either an annotation on the resources,
|
||||||
|
// or through inlined OpenAPI on the resource as a YAML comment.
|
||||||
|
func (ns Filter) metaNamespaceHack(obj *yaml.RNode, meta yaml.ResourceMeta) error {
|
||||||
|
gvk := fsslice.GetGVK(meta)
|
||||||
|
if !gvk.IsNamespaceableKind() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
f := fsslice.Filter{
|
||||||
|
FsSlice: []types.FieldSpec{
|
||||||
|
{Path: metaNamespaceField, CreateIfNotPresent: true},
|
||||||
|
},
|
||||||
|
SetValue: fsslice.SetScalar(ns.Namespace),
|
||||||
|
CreateKind: yaml.ScalarNode, // Namespace is a ScalarNode
|
||||||
|
}
|
||||||
|
_, err := f.Filter(obj)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// roleBindingHack is a hack for implementing the namespace transform
|
||||||
|
// for RoleBinding and ClusterRoleBinding resource types.
|
||||||
|
// RoleBinding and ClusterRoleBinding have namespace set on
|
||||||
|
// elements of the "subjects" field if and only if the subject elements
|
||||||
|
// "name" is "default". Otherwise the namespace is not set.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// kind: RoleBinding
|
||||||
|
// subjects:
|
||||||
|
// - name: "default" # this will have the namespace set
|
||||||
|
// ...
|
||||||
|
// - name: "something-else" # this will not have the namespace set
|
||||||
|
// ...
|
||||||
|
func (ns Filter) roleBindingHack(obj *yaml.RNode, meta yaml.ResourceMeta) error {
|
||||||
|
if meta.Kind != roleBindingKind && meta.Kind != clusterRoleBindingKind {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup the namespace field on all elements.
|
||||||
|
// We should change the fieldspec so this isn't necessary.
|
||||||
|
obj, err := obj.Pipe(yaml.Lookup(subjectsField))
|
||||||
|
if err != nil || yaml.IsEmpty(obj) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the namespace to each "subject" with name: default
|
||||||
|
err = obj.VisitElements(func(o *yaml.RNode) error {
|
||||||
|
// copied from kunstruct based kustomize NamespaceTransformer plugin
|
||||||
|
// The only case we need to force the namespace
|
||||||
|
// if for the "service account". "default" is
|
||||||
|
// kind of hardcoded here for right now.
|
||||||
|
name, err := o.Pipe(
|
||||||
|
yaml.Lookup("name"), yaml.Match("default"),
|
||||||
|
)
|
||||||
|
if err != nil || yaml.IsEmpty(name) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the namespace for the default account
|
||||||
|
v := yaml.NewScalarRNode(ns.Namespace)
|
||||||
|
return o.PipeE(
|
||||||
|
yaml.LookupCreate(yaml.ScalarNode, "namespace"),
|
||||||
|
yaml.FieldSetter{Value: v},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// removeFieldSpecsForHacks removes from the list fieldspecs that
|
||||||
|
// have hardcoded implementations
|
||||||
|
func (ns Filter) removeFieldSpecsForHacks(fs types.FsSlice) types.FsSlice {
|
||||||
|
var val types.FsSlice
|
||||||
|
for i := range fs {
|
||||||
|
// implemented by metaNamespaceHack
|
||||||
|
if fs[i].Path == metaNamespaceField {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// implemented by roleBindingHack
|
||||||
|
if fs[i].Kind == roleBindingKind && fs[i].Path == subjectsField {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// implemented by roleBindingHack
|
||||||
|
if fs[i].Kind == clusterRoleBindingKind && fs[i].Path == subjectsField {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val = append(val, fs[i])
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
metaNamespaceField = "metadata/namespace"
|
||||||
|
subjectsField = "subjects"
|
||||||
|
roleBindingKind = "RoleBinding"
|
||||||
|
clusterRoleBindingKind = "ClusterRoleBinding"
|
||||||
|
)
|
||||||
280
api/filters/namespace/namespace_test.go
Normal file
280
api/filters/namespace/namespace_test.go
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package namespace_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/namespace"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
filtertest_test "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var tests = []TestCase{
|
||||||
|
{
|
||||||
|
name: "add",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: foo
|
||||||
|
`,
|
||||||
|
filter: namespace.Filter{Namespace: "foo"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "add-recurse",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
namespace: foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
namespace: foo
|
||||||
|
`,
|
||||||
|
filter: namespace.Filter{Namespace: "foo"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
# update this namespace
|
||||||
|
namespace: bar
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: bar
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
# update this namespace
|
||||||
|
namespace: foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: foo
|
||||||
|
`,
|
||||||
|
filter: namespace.Filter{Namespace: "foo"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update-rolebinding",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
namespace: foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
namespace: foo
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
namespace: bar
|
||||||
|
metadata:
|
||||||
|
namespace: bar
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
namespace: bar
|
||||||
|
metadata:
|
||||||
|
namespace: bar
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
metadata:
|
||||||
|
namespace: bar
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
namespace: foo
|
||||||
|
metadata:
|
||||||
|
namespace: bar
|
||||||
|
`,
|
||||||
|
filter: namespace.Filter{Namespace: "bar"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "update-clusterrolebinding",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
namespace: foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
namespace: foo
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
namespace: bar
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: default
|
||||||
|
namespace: bar
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
subjects:
|
||||||
|
- name: something
|
||||||
|
namespace: foo
|
||||||
|
`,
|
||||||
|
filter: namespace.Filter{Namespace: "bar"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "data-fieldspecs",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: foo
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: foo
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: foo
|
||||||
|
`,
|
||||||
|
filter: namespace.Filter{Namespace: "foo"},
|
||||||
|
fsslice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "a/b/c",
|
||||||
|
CreateIfNotPresent: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestCase struct {
|
||||||
|
name string
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
filter namespace.Filter
|
||||||
|
fsslice types.FsSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = builtinconfig.MakeDefaultConfig()
|
||||||
|
|
||||||
|
func TestNamespace_Filter(t *testing.T) {
|
||||||
|
for i := range tests {
|
||||||
|
test := tests[i]
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
test.filter.FsSlice = append(config.NameSpace, test.fsslice...)
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(test.expected),
|
||||||
|
strings.TrimSpace(
|
||||||
|
filtertest_test.RunFilter(t, test.input, test.filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
6
api/filters/patchjson6902/doc.go
Normal file
6
api/filters/patchjson6902/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package namespace contains a kio.Filter implementation of the kustomize
|
||||||
|
// patchjson6902 transformer
|
||||||
|
package patchjson6902
|
||||||
55
api/filters/patchjson6902/example_test.go
Normal file
55
api/filters/patchjson6902/example_test.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package patchjson6902
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
namespace: bar
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{
|
||||||
|
Filter{
|
||||||
|
Patch: `
|
||||||
|
- op: replace
|
||||||
|
path: /metadata/namespace
|
||||||
|
value: "ns"
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// namespace: ns
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// namespace: ns
|
||||||
|
}
|
||||||
65
api/filters/patchjson6902/patchjson6902.go
Normal file
65
api/filters/patchjson6902/patchjson6902.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package patchjson6902
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
k8syaml "sigs.k8s.io/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Filter struct {
|
||||||
|
Patch string
|
||||||
|
|
||||||
|
decodedPatch jsonpatch.Patch
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (pf Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
decodedPatch, err := pf.decodePatch()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pf.decodedPatch = decodedPatch
|
||||||
|
return kio.FilterAll(yaml.FilterFunc(pf.run)).Filter(nodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pf Filter) decodePatch() (jsonpatch.Patch, error) {
|
||||||
|
patch := pf.Patch
|
||||||
|
// If the patch doesn't look like a JSON6902 patch, we
|
||||||
|
// try to parse it to json.
|
||||||
|
if !strings.HasPrefix(pf.Patch, "[") {
|
||||||
|
p, err := k8syaml.YAMLToJSON([]byte(patch))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
patch = string(p)
|
||||||
|
}
|
||||||
|
decodedPatch, err := jsonpatch.DecodePatch([]byte(patch))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return decodedPatch, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pf Filter) run(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
// We don't actually use the kyaml library for manipulating the
|
||||||
|
// yaml here. We just marshal it to json and rely on the
|
||||||
|
// jsonpatch library to take care of applying the patch.
|
||||||
|
// This means ordering might not be preserved with this filter.
|
||||||
|
b, err := node.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res, err := pf.decodedPatch.Apply(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = node.UnmarshalJSON(res)
|
||||||
|
return node, err
|
||||||
|
}
|
||||||
173
api/filters/patchjson6902/patchjson6902_test.go
Normal file
173
api/filters/patchjson6902/patchjson6902_test.go
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package patchjson6902
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
filtertest "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
)
|
||||||
|
|
||||||
|
const input = `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
spec:
|
||||||
|
replica: 2
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
old-label: old-value
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
`
|
||||||
|
|
||||||
|
func TestSomething(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
testName string
|
||||||
|
input string
|
||||||
|
filter Filter
|
||||||
|
expectedOutput string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
testName: "single operation, json",
|
||||||
|
input: input,
|
||||||
|
filter: Filter{
|
||||||
|
Patch: `[
|
||||||
|
{"op": "replace", "path": "/spec/replica", "value": 5}
|
||||||
|
]`,
|
||||||
|
},
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
spec:
|
||||||
|
replica: 5
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
old-label: old-value
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "multiple operations, json",
|
||||||
|
input: input,
|
||||||
|
filter: Filter{
|
||||||
|
Patch: `[
|
||||||
|
{"op": "replace", "path": "/spec/template/spec/containers/0/name", "value": "my-nginx"},
|
||||||
|
{"op": "add", "path": "/spec/replica", "value": 999},
|
||||||
|
{"op": "add", "path": "/spec/template/spec/containers/0/command", "value": ["arg1", "arg2", "arg3"]}
|
||||||
|
]`,
|
||||||
|
},
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
spec:
|
||||||
|
replica: 999
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
old-label: old-value
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- arg1
|
||||||
|
- arg2
|
||||||
|
- arg3
|
||||||
|
image: nginx
|
||||||
|
name: my-nginx
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "single operation, yaml",
|
||||||
|
input: input,
|
||||||
|
filter: Filter{
|
||||||
|
Patch: `
|
||||||
|
- op: replace
|
||||||
|
path: /spec/replica
|
||||||
|
value: 5
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
spec:
|
||||||
|
replica: 5
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
old-label: old-value
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "multiple operations, yaml",
|
||||||
|
input: input,
|
||||||
|
filter: Filter{
|
||||||
|
Patch: `
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/name
|
||||||
|
value: my-nginx
|
||||||
|
- op: add
|
||||||
|
path: /spec/replica
|
||||||
|
value: 999
|
||||||
|
- op: add
|
||||||
|
path: /spec/template/spec/containers/0/command
|
||||||
|
value:
|
||||||
|
- arg1
|
||||||
|
- arg2
|
||||||
|
- arg3
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
expectedOutput: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
spec:
|
||||||
|
replica: 999
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
old-label: old-value
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- arg1
|
||||||
|
- arg2
|
||||||
|
- arg3
|
||||||
|
image: nginx
|
||||||
|
name: my-nginx
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expectedOutput),
|
||||||
|
strings.TrimSpace(
|
||||||
|
filtertest.RunFilter(t, tc.input, tc.filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
6
api/filters/patchstrategicmerge/doc.go
Normal file
6
api/filters/patchstrategicmerge/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package patchstrategicmerge contains a kio.Filter implementation of the
|
||||||
|
// kustomize strategic merge patch transformer.
|
||||||
|
package patchstrategicmerge
|
||||||
49
api/filters/patchstrategicmerge/example_test.go
Normal file
49
api/filters/patchstrategicmerge/example_test.go
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package patchstrategicmerge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{Filter{
|
||||||
|
Patch: yaml.MustParse(`
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
`),
|
||||||
|
}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// replicas: 3
|
||||||
|
// template:
|
||||||
|
// containers:
|
||||||
|
// - image: nginx
|
||||||
|
}
|
||||||
21
api/filters/patchstrategicmerge/patchstrategicmerge.go
Normal file
21
api/filters/patchstrategicmerge/patchstrategicmerge.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package patchstrategicmerge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml/merge2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Filter struct {
|
||||||
|
Patch *yaml.RNode
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (pf Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
return kio.FilterAll(yaml.FilterFunc(pf.run)).Filter(nodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pf Filter) run(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
return merge2.Merge(pf.Patch, node)
|
||||||
|
}
|
||||||
82
api/filters/patchstrategicmerge/patchstrategicmerge_test.go
Normal file
82
api/filters/patchstrategicmerge/patchstrategicmerge_test.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package patchstrategicmerge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
filtertest "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFilter(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input string
|
||||||
|
patch *yaml.RNode
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
"simple patch": {
|
||||||
|
input: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
kind: Deployment
|
||||||
|
`,
|
||||||
|
patch: yaml.MustParse(`
|
||||||
|
metadata:
|
||||||
|
name: yourDeploy
|
||||||
|
`),
|
||||||
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
name: yourDeploy
|
||||||
|
kind: Deployment
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
"nested patch": {
|
||||||
|
input: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
args:
|
||||||
|
- abc
|
||||||
|
`,
|
||||||
|
patch: yaml.MustParse(`
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
args:
|
||||||
|
- def
|
||||||
|
`),
|
||||||
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
name: myDeploy
|
||||||
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
args:
|
||||||
|
- def
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
f := Filter{
|
||||||
|
Patch: tc.patch,
|
||||||
|
}
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expected),
|
||||||
|
strings.TrimSpace(
|
||||||
|
filtertest.RunFilter(t, tc.input, f))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
6
api/filters/prefixsuffix/doc.go
Normal file
6
api/filters/prefixsuffix/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package prefixsuffix contains a kio.Filter implementation of the kustomize
|
||||||
|
// PrefixSuffixTransformer.
|
||||||
|
package prefixsuffix
|
||||||
47
api/filters/prefixsuffix/example_test.go
Normal file
47
api/filters/prefixsuffix/example_test.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package prefixsuffix_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/prefixsuffix"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
fss := builtinconfig.MakeDefaultConfig().NamePrefix
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{prefixsuffix.Filter{Prefix: "baz-", FsSlice: fss}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: baz-instance
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: baz-instance
|
||||||
|
}
|
||||||
43
api/filters/prefixsuffix/prefixsuffix.go
Normal file
43
api/filters/prefixsuffix/prefixsuffix.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package prefixsuffix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Filter applies resource name prefix's and suffix's using the fieldSpecs
|
||||||
|
type Filter struct {
|
||||||
|
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
|
||||||
|
Suffix string `json:"suffix,omitempty" yaml:"suffix,omitempty"`
|
||||||
|
|
||||||
|
FsSlice types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (ns Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
return kio.FilterAll(yaml.FilterFunc(ns.run)).Filter(nodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run runs the filter on a single node rather than a slice
|
||||||
|
func (ns Filter) run(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
// transformations based on data -- :)
|
||||||
|
err := node.PipeE(fsslice.Filter{
|
||||||
|
FsSlice: ns.FsSlice,
|
||||||
|
SetValue: ns.set,
|
||||||
|
CreateKind: yaml.ScalarNode, // Name is a ScalarNode
|
||||||
|
})
|
||||||
|
return node, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ns Filter) set(node *yaml.RNode) error {
|
||||||
|
return fsslice.SetScalar(fmt.Sprintf(
|
||||||
|
"%s%s%s", ns.Prefix, node.YNode().Value, ns.Suffix))(node)
|
||||||
|
}
|
||||||
167
api/filters/prefixsuffix/prefixsuffix_test.go
Normal file
167
api/filters/prefixsuffix/prefixsuffix_test.go
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package prefixsuffix_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/prefixsuffix"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
filtertest_test "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var tests = []TestCase{
|
||||||
|
{
|
||||||
|
name: "prefix",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: foo-instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: foo-instance
|
||||||
|
`,
|
||||||
|
filter: prefixsuffix.Filter{Prefix: "foo-"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "suffix",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance-foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance-foo
|
||||||
|
`,
|
||||||
|
filter: prefixsuffix.Filter{Suffix: "-foo"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "prefix-suffix",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: bar-instance-foo
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: bar-instance-foo
|
||||||
|
`,
|
||||||
|
filter: prefixsuffix.Filter{Prefix: "bar-", Suffix: "-foo"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "data-fieldspecs",
|
||||||
|
input: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: d
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: d
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: foo-instance
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: foo-d
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: foo-instance
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: foo-d
|
||||||
|
`,
|
||||||
|
filter: prefixsuffix.Filter{Prefix: "foo-"},
|
||||||
|
fsslice: []types.FieldSpec{
|
||||||
|
{
|
||||||
|
Path: "a/b/c",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestCase struct {
|
||||||
|
name string
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
filter prefixsuffix.Filter
|
||||||
|
fsslice types.FsSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = builtinconfig.MakeDefaultConfig()
|
||||||
|
|
||||||
|
func TestFilter(t *testing.T) {
|
||||||
|
for i := range tests {
|
||||||
|
test := tests[i]
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
test.filter.FsSlice = append(config.NamePrefix, test.fsslice...)
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(test.expected),
|
||||||
|
strings.TrimSpace(
|
||||||
|
filtertest_test.RunFilter(t, test.input, test.filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
6
api/filters/replicacount/doc.go
Normal file
6
api/filters/replicacount/doc.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Package replicacount contains a kio.Filter implementation of the kustomize
|
||||||
|
// ReplicaCountTransformer.
|
||||||
|
package replicacount
|
||||||
64
api/filters/replicacount/example_test.go
Normal file
64
api/filters/replicacount/example_test.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package replicacount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleFilter() {
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Foo
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
replicas: 5
|
||||||
|
---
|
||||||
|
apiVersion: example.com/v1
|
||||||
|
kind: Bar
|
||||||
|
metadata:
|
||||||
|
name: instance
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
replicas: 5
|
||||||
|
`)}},
|
||||||
|
Filters: []kio.Filter{Filter{
|
||||||
|
Replica: types.Replica{
|
||||||
|
Count: 42,
|
||||||
|
Name: "instance",
|
||||||
|
},
|
||||||
|
FsSlice: types.FsSlice{
|
||||||
|
{
|
||||||
|
Path: "spec/template/replicas",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||||
|
}.Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Foo
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// template:
|
||||||
|
// replicas: 42
|
||||||
|
// ---
|
||||||
|
// apiVersion: example.com/v1
|
||||||
|
// kind: Bar
|
||||||
|
// metadata:
|
||||||
|
// name: instance
|
||||||
|
// spec:
|
||||||
|
// template:
|
||||||
|
// replicas: 42
|
||||||
|
}
|
||||||
48
api/filters/replicacount/replicacount.go
Normal file
48
api/filters/replicacount/replicacount.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package replicacount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/api/filters/fsslice"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Filter updates/sets replicas fields using the fieldSpecs
|
||||||
|
type Filter struct {
|
||||||
|
Replica types.Replica `json:"replica,omitempty" yaml:"replica,omitempty"`
|
||||||
|
|
||||||
|
// FsSlice contains the FieldSpecs to locate the namespace field
|
||||||
|
FsSlice types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ kio.Filter = Filter{}
|
||||||
|
|
||||||
|
func (rc Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||||
|
return kio.FilterAll(yaml.FilterFunc(rc.run)).Filter(nodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// run processes each node individually.
|
||||||
|
func (rc Filter) run(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
meta, err := node.GetMeta()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// only update resources where the name matches the Replica name.
|
||||||
|
if meta.Name != rc.Replica.Name {
|
||||||
|
return node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = node.PipeE(fsslice.Filter{
|
||||||
|
FsSlice: rc.FsSlice,
|
||||||
|
SetValue: rc.set,
|
||||||
|
CreateKind: yaml.ScalarNode, // replicas is a ScalarNode
|
||||||
|
})
|
||||||
|
return node, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rc Filter) set(node *yaml.RNode) error {
|
||||||
|
return fsslice.SetScalar(strconv.FormatInt(rc.Replica.Count, 10))(node)
|
||||||
|
}
|
||||||
164
api/filters/replicacount/replicacount_test.go
Normal file
164
api/filters/replicacount/replicacount_test.go
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
package replicacount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||||
|
filtertest_test "sigs.k8s.io/kustomize/api/testutils/filtertest"
|
||||||
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFilter(t *testing.T) {
|
||||||
|
var config = builtinconfig.MakeDefaultConfig()
|
||||||
|
|
||||||
|
testCases := map[string]struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
filter Filter
|
||||||
|
fsslice types.FsSlice
|
||||||
|
}{
|
||||||
|
"update field": {
|
||||||
|
input: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dep
|
||||||
|
spec:
|
||||||
|
replicas: 5
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dep
|
||||||
|
spec:
|
||||||
|
replicas: 42
|
||||||
|
`,
|
||||||
|
filter: Filter{
|
||||||
|
Replica: types.Replica{
|
||||||
|
Name: "dep",
|
||||||
|
Count: 42,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fsslice: types.FsSlice{
|
||||||
|
{
|
||||||
|
Path: "spec/replicas",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"add field": {
|
||||||
|
input: `
|
||||||
|
apiVersion: custom/v1
|
||||||
|
kind: Custom
|
||||||
|
metadata:
|
||||||
|
name: cus
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
other: something
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: custom/v1
|
||||||
|
kind: Custom
|
||||||
|
metadata:
|
||||||
|
name: cus
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
other: something
|
||||||
|
replicas: 42
|
||||||
|
`,
|
||||||
|
filter: Filter{
|
||||||
|
Replica: types.Replica{
|
||||||
|
Name: "cus",
|
||||||
|
Count: 42,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fsslice: types.FsSlice{
|
||||||
|
{
|
||||||
|
Path: "spec/template/replicas",
|
||||||
|
CreateIfNotPresent: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"no update if CreateIfNotPresent is false": {
|
||||||
|
input: `
|
||||||
|
apiVersion: custom/v1
|
||||||
|
kind: Custom
|
||||||
|
metadata:
|
||||||
|
name: cus
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
other: something
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: custom/v1
|
||||||
|
kind: Custom
|
||||||
|
metadata:
|
||||||
|
name: cus
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
other: something
|
||||||
|
`,
|
||||||
|
filter: Filter{
|
||||||
|
Replica: types.Replica{
|
||||||
|
Name: "cus",
|
||||||
|
Count: 42,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fsslice: types.FsSlice{
|
||||||
|
{
|
||||||
|
Path: "spec/template/replicas",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"update multiple fields": {
|
||||||
|
input: `
|
||||||
|
apiVersion: custom/v1
|
||||||
|
kind: Custom
|
||||||
|
metadata:
|
||||||
|
name: cus
|
||||||
|
spec:
|
||||||
|
replicas: 5
|
||||||
|
template:
|
||||||
|
replicas: 5
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: custom/v1
|
||||||
|
kind: Custom
|
||||||
|
metadata:
|
||||||
|
name: cus
|
||||||
|
spec:
|
||||||
|
replicas: 42
|
||||||
|
template:
|
||||||
|
replicas: 42
|
||||||
|
`,
|
||||||
|
filter: Filter{
|
||||||
|
Replica: types.Replica{
|
||||||
|
Name: "cus",
|
||||||
|
Count: 42,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fsslice: types.FsSlice{
|
||||||
|
{
|
||||||
|
Path: "spec/template/replicas",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Path: "spec/replicas",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for tn, tc := range testCases {
|
||||||
|
t.Run(tn, func(t *testing.T) {
|
||||||
|
tc.filter.FsSlice = append(config.Replicas, tc.fsslice...)
|
||||||
|
if !assert.Equal(t,
|
||||||
|
strings.TrimSpace(tc.expected),
|
||||||
|
strings.TrimSpace(
|
||||||
|
filtertest_test.RunFilter(t, tc.input, tc.filter))) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,15 +4,18 @@ go 1.13
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/evanphx/json-patch v4.5.0+incompatible
|
github.com/evanphx/json-patch v4.5.0+incompatible
|
||||||
github.com/go-openapi/spec v0.19.4
|
github.com/go-openapi/spec v0.19.5
|
||||||
github.com/golangci/golangci-lint v1.21.0
|
github.com/golangci/golangci-lint v1.21.0
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
|
github.com/stretchr/testify v1.4.0
|
||||||
|
github.com/yujunz/go-getter v1.4.1-lite
|
||||||
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff
|
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff
|
||||||
gopkg.in/yaml.v2 v2.2.4
|
gopkg.in/yaml.v2 v2.2.7
|
||||||
k8s.io/api v0.17.0
|
k8s.io/api v0.17.0
|
||||||
k8s.io/apimachinery v0.17.0
|
k8s.io/apimachinery v0.17.0
|
||||||
k8s.io/client-go v0.17.0
|
k8s.io/client-go v0.17.0
|
||||||
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
|
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.5
|
||||||
sigs.k8s.io/yaml v1.1.0
|
sigs.k8s.io/yaml v1.1.0
|
||||||
)
|
)
|
||||||
|
|||||||
57
api/go.sum
57
api/go.sum
@@ -1,6 +1,7 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||||
|
github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE=
|
||||||
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
|
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
|
||||||
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
|
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
|
||||||
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
|
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
|
||||||
@@ -14,6 +15,7 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
|
|||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/OpenPeeDeeP/depguard v1.0.1 h1:VlW4R6jmBIv3/u1JNlawEvJMM4J+dPORPaZasQee8Us=
|
github.com/OpenPeeDeeP/depguard v1.0.1 h1:VlW4R6jmBIv3/u1JNlawEvJMM4J+dPORPaZasQee8Us=
|
||||||
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
|
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
|
||||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
@@ -23,12 +25,18 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
|
|||||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
|
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
|
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
|
||||||
|
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
|
||||||
github.com/bombsimon/wsl v1.2.5 h1:9gTOkIwVtoDZywvX802SDHokeX4kW1cKnV8ZTVAPkRs=
|
github.com/bombsimon/wsl v1.2.5 h1:9gTOkIwVtoDZywvX802SDHokeX4kW1cKnV8ZTVAPkRs=
|
||||||
github.com/bombsimon/wsl v1.2.5/go.mod h1:43lEF/i0kpXbLCeDXL9LMT8c92HyBywXb0AsgMHYngM=
|
github.com/bombsimon/wsl v1.2.5/go.mod h1:43lEF/i0kpXbLCeDXL9LMT8c92HyBywXb0AsgMHYngM=
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
@@ -45,6 +53,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||||
|
github.com/dustmop/soup v1.1.2-0.20190516214245-38228baa104e/go.mod h1:CgNC6SGbT+Xb8wGGvzilttZL1mc5sQ/5KkcxsZttMIk=
|
||||||
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw=
|
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw=
|
||||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||||
@@ -59,6 +68,8 @@ github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2H
|
|||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db h1:GYXWx7Vr3+zv833u+8IoXbNnQY0AdXsxAgI0kX7xcwA=
|
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db h1:GYXWx7Vr3+zv833u+8IoXbNnQY0AdXsxAgI0kX7xcwA=
|
||||||
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db/go.mod h1:+sE8vrLDS2M0pZkBk0wy6+nLdKexVDrl/jBqQOTDThA=
|
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db/go.mod h1:+sE8vrLDS2M0pZkBk0wy6+nLdKexVDrl/jBqQOTDThA=
|
||||||
|
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
|
||||||
|
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-lintpack/lintpack v0.5.2 h1:DI5mA3+eKdWeJ40nU4d6Wc26qmdG8RCi/btYq0TuRN0=
|
github.com/go-lintpack/lintpack v0.5.2 h1:DI5mA3+eKdWeJ40nU4d6Wc26qmdG8RCi/btYq0TuRN0=
|
||||||
github.com/go-lintpack/lintpack v0.5.2/go.mod h1:NwZuYi2nUHho8XEIZ6SIxihrnPoqBTDqfpXvXAN0sXM=
|
github.com/go-lintpack/lintpack v0.5.2/go.mod h1:NwZuYi2nUHho8XEIZ6SIxihrnPoqBTDqfpXvXAN0sXM=
|
||||||
@@ -74,8 +85,8 @@ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1
|
|||||||
github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
|
github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
|
||||||
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||||
github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo=
|
github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw=
|
||||||
github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
|
github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
|
||||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||||
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
|
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
|
||||||
@@ -176,6 +187,12 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb
|
|||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||||
|
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
|
||||||
|
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
|
||||||
|
github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0=
|
||||||
|
github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||||
@@ -205,7 +222,6 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB
|
|||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
|
||||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
@@ -225,9 +241,12 @@ github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE
|
|||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
|
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
|
||||||
|
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
|
||||||
|
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -237,6 +256,7 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN
|
|||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||||
github.com/mozilla/tls-observatory v0.0.0-20190404164649-a3c1b6cfecfd/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
|
github.com/mozilla/tls-observatory v0.0.0-20190404164649-a3c1b6cfecfd/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
@@ -251,6 +271,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
|
|||||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||||
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/paulmach/orb v0.1.3/go.mod h1:VFlX/8C+IQ1p6FTRRKzKoOPJnvEtA5G0Veuqwbu//Vk=
|
||||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||||
@@ -269,12 +290,14 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
|
|||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
|
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA=
|
||||||
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
|
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d h1:BzRvVq1EHuIjxpijCEKpAxzKUUMurOQ4sknehIATRh8=
|
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d h1:BzRvVq1EHuIjxpijCEKpAxzKUUMurOQ4sknehIATRh8=
|
||||||
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d/go.mod h1:w5+eXa0mYznDkHaMCXA4XYffjlH+cy1oyKbfzJXa2Do=
|
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d/go.mod h1:w5+eXa0mYznDkHaMCXA4XYffjlH+cy1oyKbfzJXa2Do=
|
||||||
|
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||||
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
|
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
|
||||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
||||||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM=
|
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM=
|
||||||
@@ -310,6 +333,7 @@ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
|||||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
@@ -318,6 +342,8 @@ github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiff
|
|||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
|
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
|
||||||
|
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||||
github.com/ultraware/funlen v0.0.2 h1:Av96YVBwwNSe4MLR7iI/BIa3VyI7/djnto/pK3Uxbdo=
|
github.com/ultraware/funlen v0.0.2 h1:Av96YVBwwNSe4MLR7iI/BIa3VyI7/djnto/pK3Uxbdo=
|
||||||
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
||||||
github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg=
|
github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg=
|
||||||
@@ -329,9 +355,15 @@ github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk
|
|||||||
github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
|
github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
|
||||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
|
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
|
||||||
|
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
|
github.com/yujunz/go-getter v1.4.1-lite h1:FhvNc94AXMZkfqUwfMKhnQEC9phkphSGdPTL7tIdhOM=
|
||||||
|
github.com/yujunz/go-getter v1.4.1-lite/go.mod h1:sbmqxXjyLunH1PkF3n7zSlnVeMvmYUuIl9ZVs/7NyCc=
|
||||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
|
go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||||
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
@@ -340,7 +372,6 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf
|
|||||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
@@ -350,6 +381,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
|
|||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@@ -387,10 +419,10 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLgaVbMHMn2ISQXJeJ5EM=
|
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLgaVbMHMn2ISQXJeJ5EM=
|
||||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
@@ -412,8 +444,6 @@ golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3
|
|||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88=
|
|
||||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||||
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
@@ -448,6 +478,10 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||||
|
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 h1:XZx7nhd5GMaZpmDaEHFVafUZC7ya0fuo7cSJ3UCKYmM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||||
@@ -472,6 +506,15 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphD
|
|||||||
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
|
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
|
||||||
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f h1:Cq7MalBHYACRd6EesksG1Q8EoIAKOsiZviGKbOLIej4=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f h1:Cq7MalBHYACRd6EesksG1Q8EoIAKOsiZviGKbOLIej4=
|
||||||
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
|
sigs.k8s.io/kustomize v1.0.11 h1:Yb+6DDt9+aR2AvQApvUaKS/ugteeG4MPyoFeUHiPOjk=
|
||||||
|
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.1 h1:nGUNYINljZNmlAS8uoobUv/wx/s3Pg8dNxYo+W7uYh0=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.1/go.mod h1:/NdPPfrperSCGjm55cwEro1loBVtbtVIXSb7FguK6uk=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.2 h1:l12+QGl+ETUHhP8/bZAi6TknU7H194fXL/9b2gUxZFY=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.3 h1:zbeHVTMCQPtWgjIH/YYJZC45mm7coTdw2TblyJ79BrY=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.3/go.mod h1:461i94nj0h0ylJ6w83jLkR4SqqVhn1iY6fjD0JSTQeE=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.5 h1:NicBWYTwkuOfVyZDbNkfSBSCwSgin4uirkedtyZltIc=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.1.5/go.mod h1:461i94nj0h0ylJ6w83jLkR4SqqVhn1iY6fjD0JSTQeE=
|
||||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
|
|||||||
50
api/image/image.go
Normal file
50
api/image/image.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package image
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsImageMatched returns true if the value of t is identical to the
|
||||||
|
// image name in the full image name and tag as given by s.
|
||||||
|
func IsImageMatched(s, t string) bool {
|
||||||
|
// Tag values are limited to [a-zA-Z0-9_.{}-].
|
||||||
|
// Some tools like Bazel rules_k8s allow tag patterns with {} characters.
|
||||||
|
// More info: https://github.com/bazelbuild/rules_k8s/pull/423
|
||||||
|
pattern, _ := regexp.Compile("^" + t + "(@sha256)?(:[a-zA-Z0-9_.{}-]*)?$")
|
||||||
|
return pattern.MatchString(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split separates and returns the name and tag parts
|
||||||
|
// from the image string using either colon `:` or at `@` separators.
|
||||||
|
// Note that the returned tag keeps its separator.
|
||||||
|
func Split(imageName string) (name string, tag string) {
|
||||||
|
// check if image name contains a domain
|
||||||
|
// if domain is present, ignore domain and check for `:`
|
||||||
|
ic := -1
|
||||||
|
if slashIndex := strings.Index(imageName, "/"); slashIndex < 0 {
|
||||||
|
ic = strings.LastIndex(imageName, ":")
|
||||||
|
} else {
|
||||||
|
lastIc := strings.LastIndex(imageName[slashIndex:], ":")
|
||||||
|
// set ic only if `:` is present
|
||||||
|
if lastIc > 0 {
|
||||||
|
ic = slashIndex + lastIc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ia := strings.LastIndex(imageName, "@")
|
||||||
|
if ic < 0 && ia < 0 {
|
||||||
|
return imageName, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
i := ic
|
||||||
|
if ia > 0 {
|
||||||
|
i = ia
|
||||||
|
}
|
||||||
|
|
||||||
|
name = imageName[:i]
|
||||||
|
tag = imageName[i:]
|
||||||
|
return
|
||||||
|
}
|
||||||
80
api/image/image_test.go
Normal file
80
api/image/image_test.go
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package image
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsImageMatched(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
testName string
|
||||||
|
value string
|
||||||
|
name string
|
||||||
|
isMatched bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
testName: "identical",
|
||||||
|
value: "nginx",
|
||||||
|
name: "nginx",
|
||||||
|
isMatched: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "name is match",
|
||||||
|
value: "nginx:12345",
|
||||||
|
name: "nginx",
|
||||||
|
isMatched: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "name is not a match",
|
||||||
|
value: "apache:12345",
|
||||||
|
name: "nginx",
|
||||||
|
isMatched: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
|
assert.Equal(t, tc.isMatched, IsImageMatched(tc.value, tc.name))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSplit(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
testName string
|
||||||
|
value string
|
||||||
|
name string
|
||||||
|
tag string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
testName: "no tag",
|
||||||
|
value: "nginx",
|
||||||
|
name: "nginx",
|
||||||
|
tag: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "with tag",
|
||||||
|
value: "nginx:1.2.3",
|
||||||
|
name: "nginx",
|
||||||
|
tag: ":1.2.3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "with digest",
|
||||||
|
value: "nginx@12345",
|
||||||
|
name: "nginx",
|
||||||
|
tag: "@12345",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
|
name, tag := Split(tc.value)
|
||||||
|
assert.Equal(t, tc.name, name)
|
||||||
|
assert.Equal(t, tc.tag, tag)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -209,7 +209,7 @@ but they are functional.
|
|||||||
|
|
||||||
## Technical details
|
## Technical details
|
||||||
|
|
||||||
### Overall design and imlpementation
|
### Overall design and implementations
|
||||||
|
|
||||||
There are a few components that are all running together in order to get
|
There are a few components that are all running together in order to get
|
||||||
the overall application to work smoothly. This section will provide a brief
|
the overall application to work smoothly. This section will provide a brief
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
storage:
|
storage:
|
||||||
gcs:
|
gcs:
|
||||||
# the bucket must exist for the snapshot respository to be created successfully.
|
# the bucket must exist for the snapshot repository to be created successfully.
|
||||||
bucket: kustomize-backup
|
bucket: kustomize-backup
|
||||||
# the path does not need to exist.
|
# the path does not need to exist.
|
||||||
# If the path does not exist, the controller will create the folder in the GCS bucket.
|
# If the path does not exist, the controller will create the folder in the GCS bucket.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Find all the trasnformer files whose `kinds` field includes `HelmValues`, and
|
Find all the transformer files whose `kinds` field includes `HelmValues`, and
|
||||||
only output certain fields of each document:
|
only output certain fields of each document:
|
||||||
```
|
```
|
||||||
curl -s -X GET "${ElasticSearchURL}:9200/${INDEXNAME}/_search?pretty" -H 'Content-Type: application/json' -d'
|
curl -s -X GET "${ElasticSearchURL}:9200/${INDEXNAME}/_search?pretty" -H 'Content-Type: application/json' -d'
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ func (f *Factory) MakeConfigMap(
|
|||||||
return nil, errors.Wrap(err, "trouble mapping")
|
return nil, errors.Wrap(err, "trouble mapping")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if f.options != nil {
|
f.setLabelsAndAnnnotations(cm, args.GeneratorOptions)
|
||||||
cm.SetLabels(f.options.Labels)
|
|
||||||
cm.SetAnnotations(f.options.Annotations)
|
|
||||||
}
|
|
||||||
return cm, nil
|
return cm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ BAR=baz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeLiteralConfigMap(name string) *corev1.ConfigMap {
|
func makeLiteralConfigMap(name string, labels, annotations map[string]string) *corev1.ConfigMap {
|
||||||
cm := &corev1.ConfigMap{
|
cm := &corev1.ConfigMap{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "v1",
|
APIVersion: "v1",
|
||||||
@@ -69,7 +69,12 @@ func makeLiteralConfigMap(name string) *corev1.ConfigMap {
|
|||||||
"d": "true",
|
"d": "true",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cm.SetLabels(map[string]string{"foo": "bar"})
|
if labels != nil {
|
||||||
|
cm.SetLabels(labels)
|
||||||
|
}
|
||||||
|
if annotations != nil {
|
||||||
|
cm.SetAnnotations(annotations)
|
||||||
|
}
|
||||||
return cm
|
return cm
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +133,49 @@ func TestConstructConfigMap(t *testing.T) {
|
|||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: makeLiteralConfigMap("literalConfigMap"),
|
expected: makeLiteralConfigMap("literalConfigMap", map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
}, nil),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "construct config map from literal with GeneratorOptions in ConfigMapArgs",
|
||||||
|
input: types.ConfigMapArgs{
|
||||||
|
GeneratorArgs: types.GeneratorArgs{
|
||||||
|
Name: "literalConfigMap",
|
||||||
|
KvPairSources: types.KvPairSources{
|
||||||
|
LiteralSources: []string{"a=x", "b=y", "c=\"Hello World\"", "d='true'"},
|
||||||
|
},
|
||||||
|
GeneratorOptions: &types.GeneratorOptions{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
},
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: &types.GeneratorOptions{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// GeneratorOptions from the ConfigMapArgs take precedence over the
|
||||||
|
// factory level GeneratorOptions and should overwrite
|
||||||
|
// labels/annotations set in the factory level if there are common
|
||||||
|
// labels/annotations
|
||||||
|
expected: makeLiteralConfigMap("literalConfigMap", map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
}, map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package configmapandsecret
|
package configmapandsecret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"sigs.k8s.io/kustomize/api/ifc"
|
"sigs.k8s.io/kustomize/api/ifc"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/types"
|
||||||
)
|
)
|
||||||
@@ -20,4 +21,35 @@ func NewFactory(
|
|||||||
return &Factory{kvLdr: kvLdr, options: o}
|
return &Factory{kvLdr: kvLdr, options: o}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setLabelsAndAnnnotations will take the labels and annotations from
|
||||||
|
// global GeneratorOptions and resource level GeneratorOptions and merge them
|
||||||
|
// with the resource level taking precedence, and then set them on the provided
|
||||||
|
// obj.
|
||||||
|
func (f *Factory) setLabelsAndAnnnotations(obj metav1.Object, opts *types.GeneratorOptions) {
|
||||||
|
labels := make(map[string]string)
|
||||||
|
annotations := make(map[string]string)
|
||||||
|
if f.options != nil {
|
||||||
|
for k, v := range f.options.Labels {
|
||||||
|
labels[k] = v
|
||||||
|
}
|
||||||
|
for k, v := range f.options.Annotations {
|
||||||
|
annotations[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if opts != nil {
|
||||||
|
for k, v := range opts.Labels {
|
||||||
|
labels[k] = v
|
||||||
|
}
|
||||||
|
for k, v := range opts.Annotations {
|
||||||
|
annotations[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(labels) != 0 {
|
||||||
|
obj.SetLabels(labels)
|
||||||
|
}
|
||||||
|
if len(annotations) != 0 {
|
||||||
|
obj.SetAnnotations(annotations)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const keyExistsErrorMsg = "cannot add key %s, another key by that name already exists: %v"
|
const keyExistsErrorMsg = "cannot add key %s, another key by that name already exists: %v"
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ func (f *Factory) MakeSecret(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if f.options != nil {
|
f.setLabelsAndAnnnotations(s, args.GeneratorOptions)
|
||||||
s.SetLabels(f.options.Labels)
|
|
||||||
s.SetAnnotations(f.options.Annotations)
|
|
||||||
}
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ BAR=baz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeLiteralSecret(name string) *corev1.Secret {
|
func makeLiteralSecret(name string, labels, annotations map[string]string) *corev1.Secret {
|
||||||
s := &corev1.Secret{
|
s := &corev1.Secret{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "v1",
|
APIVersion: "v1",
|
||||||
@@ -66,7 +66,12 @@ func makeLiteralSecret(name string) *corev1.Secret {
|
|||||||
},
|
},
|
||||||
Type: "Opaque",
|
Type: "Opaque",
|
||||||
}
|
}
|
||||||
s.SetLabels(map[string]string{"foo": "bar"})
|
if labels != nil {
|
||||||
|
s.SetLabels(labels)
|
||||||
|
}
|
||||||
|
if annotations != nil {
|
||||||
|
s.SetAnnotations(annotations)
|
||||||
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +125,49 @@ func TestConstructSecret(t *testing.T) {
|
|||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: makeLiteralSecret("literalSecret"),
|
expected: makeLiteralSecret("literalSecret", map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
}, nil),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "construct secret from literal with GeneratorOptions in SecretArgs",
|
||||||
|
input: types.SecretArgs{
|
||||||
|
GeneratorArgs: types.GeneratorArgs{
|
||||||
|
Name: "literalSecret",
|
||||||
|
KvPairSources: types.KvPairSources{
|
||||||
|
LiteralSources: []string{"a=x", "b=y"},
|
||||||
|
},
|
||||||
|
GeneratorOptions: &types.GeneratorOptions{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
},
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: &types.GeneratorOptions{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// GeneratorOptions from the SecretArgs take precedence over the
|
||||||
|
// factory level GeneratorOptions and should overwrite
|
||||||
|
// labels/annotations set in the factory level if there are common
|
||||||
|
// labels/annotations
|
||||||
|
expected: makeLiteralSecret("literalSecret", map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
}, map[string]string{
|
||||||
|
"foo": "changed",
|
||||||
|
"cat": "dog",
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -302,18 +301,15 @@ func (kt *KustTarget) configureExternalTransformers() ([]resmap.Transformer, err
|
|||||||
func (kt *KustTarget) accumulateResources(
|
func (kt *KustTarget) accumulateResources(
|
||||||
ra *accumulator.ResAccumulator, paths []string) error {
|
ra *accumulator.ResAccumulator, paths []string) error {
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
ldr, err := kt.ldr.New(path)
|
// try loading resource as file then as base (directory or git repository)
|
||||||
if err == nil {
|
if errF := kt.accumulateFile(ra, path); errF != nil {
|
||||||
err = kt.accumulateDirectory(ra, ldr)
|
ldr, errL := kt.ldr.New(path)
|
||||||
if err != nil {
|
if errL != nil {
|
||||||
return err
|
return fmt.Errorf("accumulateFile %q, loader.New %q", errF, errL)
|
||||||
}
|
}
|
||||||
} else {
|
errD := kt.accumulateDirectory(ra, ldr)
|
||||||
err2 := kt.accumulateFile(ra, path)
|
if errD != nil {
|
||||||
if err2 != nil {
|
return fmt.Errorf("accumulateFile %q, accumulateDirector: %q", errF, errD)
|
||||||
// Log ldr.New() error to highlight git failures.
|
|
||||||
log.Print(err.Error())
|
|
||||||
return err2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func (fs *UnstructAdapter) selectSubtree(path string) (map[string]interface{}, [
|
|||||||
func (fs *UnstructAdapter) GetFieldValue(path string) (interface{}, error) {
|
func (fs *UnstructAdapter) GetFieldValue(path string) (interface{}, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedFieldNoCopy(
|
s, found, err := unstructured.NestedFieldNoCopy(
|
||||||
@@ -141,14 +141,14 @@ func (fs *UnstructAdapter) GetFieldValue(path string) (interface{}, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetString returns value at the given fieldpath.
|
// GetString returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetString(path string) (string, error) {
|
func (fs *UnstructAdapter) GetString(path string) (string, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return "", noFieldError{Field: path}
|
return "", NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedString(
|
s, found, err := unstructured.NestedString(
|
||||||
@@ -156,14 +156,14 @@ func (fs *UnstructAdapter) GetString(path string) (string, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return "", noFieldError{Field: path}
|
return "", NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStringSlice returns value at the given fieldpath.
|
// GetStringSlice returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetStringSlice(path string) ([]string, error) {
|
func (fs *UnstructAdapter) GetStringSlice(path string) ([]string, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return []string{}, noFieldError{Field: path}
|
return []string{}, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedStringSlice(
|
s, found, err := unstructured.NestedStringSlice(
|
||||||
@@ -171,14 +171,14 @@ func (fs *UnstructAdapter) GetStringSlice(path string) ([]string, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return []string{}, noFieldError{Field: path}
|
return []string{}, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBool returns value at the given fieldpath.
|
// GetBool returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetBool(path string) (bool, error) {
|
func (fs *UnstructAdapter) GetBool(path string) (bool, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return false, noFieldError{Field: path}
|
return false, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedBool(
|
s, found, err := unstructured.NestedBool(
|
||||||
@@ -186,7 +186,7 @@ func (fs *UnstructAdapter) GetBool(path string) (bool, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return false, noFieldError{Field: path}
|
return false, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFloat64 returns value at the given fieldpath.
|
// GetFloat64 returns value at the given fieldpath.
|
||||||
@@ -201,14 +201,14 @@ func (fs *UnstructAdapter) GetFloat64(path string) (float64, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return 0, noFieldError{Field: path}
|
return 0, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetInt64 returns value at the given fieldpath.
|
// GetInt64 returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetInt64(path string) (int64, error) {
|
func (fs *UnstructAdapter) GetInt64(path string) (int64, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return 0, noFieldError{Field: path}
|
return 0, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedInt64(
|
s, found, err := unstructured.NestedInt64(
|
||||||
@@ -216,14 +216,14 @@ func (fs *UnstructAdapter) GetInt64(path string) (int64, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return 0, noFieldError{Field: path}
|
return 0, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSlice returns value at the given fieldpath.
|
// GetSlice returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetSlice(path string) ([]interface{}, error) {
|
func (fs *UnstructAdapter) GetSlice(path string) ([]interface{}, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedSlice(
|
s, found, err := unstructured.NestedSlice(
|
||||||
@@ -231,14 +231,14 @@ func (fs *UnstructAdapter) GetSlice(path string) ([]interface{}, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStringMap returns value at the given fieldpath.
|
// GetStringMap returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetStringMap(path string) (map[string]string, error) {
|
func (fs *UnstructAdapter) GetStringMap(path string) (map[string]string, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedStringMap(
|
s, found, err := unstructured.NestedStringMap(
|
||||||
@@ -246,14 +246,14 @@ func (fs *UnstructAdapter) GetStringMap(path string) (map[string]string, error)
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMap returns value at the given fieldpath.
|
// GetMap returns value at the given fieldpath.
|
||||||
func (fs *UnstructAdapter) GetMap(path string) (map[string]interface{}, error) {
|
func (fs *UnstructAdapter) GetMap(path string) (map[string]interface{}, error) {
|
||||||
content, fields, found, err := fs.selectSubtree(path)
|
content, fields, found, err := fs.selectSubtree(path)
|
||||||
if !found || err != nil {
|
if !found || err != nil {
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, found, err := unstructured.NestedMap(
|
s, found, err := unstructured.NestedMap(
|
||||||
@@ -261,7 +261,7 @@ func (fs *UnstructAdapter) GetMap(path string) (map[string]interface{}, error) {
|
|||||||
if found || err != nil {
|
if found || err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
return nil, noFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *UnstructAdapter) MatchesLabelSelector(selector string) (bool, error) {
|
func (fs *UnstructAdapter) MatchesLabelSelector(selector string) (bool, error) {
|
||||||
@@ -340,11 +340,11 @@ func toSchemaGvk(x resid.Gvk) schema.GroupVersionKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// noFieldError is returned when a field is expected, but missing.
|
// NoFieldError is returned when a field is expected, but missing.
|
||||||
type noFieldError struct {
|
type NoFieldError struct {
|
||||||
Field string
|
Field string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e noFieldError) Error() string {
|
func (e NoFieldError) Error() string {
|
||||||
return fmt.Sprintf("no field named '%s'", e.Field)
|
return fmt.Sprintf("no field named '%s'", e.Field)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,5 +345,24 @@ nameReference:
|
|||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
- path: spec/volumeClaimTemplates/spec/storageClassName
|
- path: spec/volumeClaimTemplates/spec/storageClassName
|
||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
|
|
||||||
|
- kind: PriorityClass
|
||||||
|
version: v1
|
||||||
|
group: scheduling.k8s.io
|
||||||
|
fieldSpecs:
|
||||||
|
- path: spec/priorityClassName
|
||||||
|
kind: Pod
|
||||||
|
- path: spec/template/spec/priorityClassName
|
||||||
|
kind: StatefulSet
|
||||||
|
- path: spec/template/spec/priorityClassName
|
||||||
|
kind: Deployment
|
||||||
|
- path: spec/template/spec/priorityClassName
|
||||||
|
kind: ReplicationController
|
||||||
|
- path: spec/jobTemplate/spec/template/spec/priorityClassName
|
||||||
|
kind: CronJob
|
||||||
|
- path: spec/template/spec/priorityClassName
|
||||||
|
kind: Job
|
||||||
|
- path: spec/template/spec/priorityClassName
|
||||||
|
kind: DaemonSet
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ varReference:
|
|||||||
- path: spec/jobTemplate/spec/template/spec/initContainers/volumeMounts/mountPath
|
- path: spec/jobTemplate/spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
kind: CronJob
|
kind: CronJob
|
||||||
|
|
||||||
|
- path: spec/jobTemplate/spec/template/volumes/nfs/server
|
||||||
|
kind: CronJob
|
||||||
|
|
||||||
- path: spec/template/spec/containers/args
|
- path: spec/template/spec/containers/args
|
||||||
kind: DaemonSet
|
kind: DaemonSet
|
||||||
|
|
||||||
@@ -54,6 +57,9 @@ varReference:
|
|||||||
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
kind: DaemonSet
|
kind: DaemonSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/volumes/nfs/server
|
||||||
|
kind: DaemonSet
|
||||||
|
|
||||||
- path: spec/template/spec/containers/args
|
- path: spec/template/spec/containers/args
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
||||||
@@ -78,6 +84,9 @@ varReference:
|
|||||||
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
||||||
|
- path: spec/template/spec/volumes/nfs/server
|
||||||
|
kind: Deployment
|
||||||
|
|
||||||
- path: spec/rules/host
|
- path: spec/rules/host
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
|
|
||||||
@@ -111,6 +120,9 @@ varReference:
|
|||||||
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
kind: Job
|
kind: Job
|
||||||
|
|
||||||
|
- path: spec/template/spec/volumes/nfs/server
|
||||||
|
kind: Job
|
||||||
|
|
||||||
- path: spec/containers/args
|
- path: spec/containers/args
|
||||||
kind: Pod
|
kind: Pod
|
||||||
|
|
||||||
@@ -135,6 +147,9 @@ varReference:
|
|||||||
- path: spec/initContainers/volumeMounts/mountPath
|
- path: spec/initContainers/volumeMounts/mountPath
|
||||||
kind: Pod
|
kind: Pod
|
||||||
|
|
||||||
|
- path: spec/volumes/nfs/server
|
||||||
|
kind: Pod
|
||||||
|
|
||||||
- path: spec/template/spec/containers/args
|
- path: spec/template/spec/containers/args
|
||||||
kind: ReplicaSet
|
kind: ReplicaSet
|
||||||
|
|
||||||
@@ -159,6 +174,9 @@ varReference:
|
|||||||
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
kind: ReplicaSet
|
kind: ReplicaSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/volumes/nfs/server
|
||||||
|
kind: ReplicaSet
|
||||||
|
|
||||||
- path: spec/ports/port
|
- path: spec/ports/port
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|
||||||
@@ -189,6 +207,12 @@ varReference:
|
|||||||
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
|
|
||||||
|
- path: spec/volumeClaimTemplates/spec/nfs/server
|
||||||
|
kind: StatefulSet
|
||||||
|
|
||||||
|
- path: spec/nfs/server
|
||||||
|
kind: PersistentVolume
|
||||||
|
|
||||||
- path: metadata/labels
|
- path: metadata/labels
|
||||||
|
|
||||||
- path: metadata/annotations
|
- path: metadata/annotations
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ spec:
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected an error")
|
t.Fatalf("expected an error")
|
||||||
}
|
}
|
||||||
if !IsMissingKustomizationFileError(err) {
|
if !strings.Contains(err.Error(), "accumulating resources") {
|
||||||
t.Fatalf("unexpected error: %q", err)
|
t.Fatalf("unexpected error: %q", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ resources:
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected an error")
|
t.Fatalf("expected an error")
|
||||||
}
|
}
|
||||||
if !strings.Contains(err.Error(), "'/app/deployment.yaml' doesn't exist") {
|
if !strings.Contains(err.Error(), "accumulating resources") {
|
||||||
t.Fatalf("unexpected error: %q", err)
|
t.Fatalf("unexpected error: %q", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package krusty_test
|
package krusty_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
@@ -21,7 +22,7 @@ func TestEmptyFileSystem(t *testing.T) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected error")
|
t.Fatalf("expected error")
|
||||||
}
|
}
|
||||||
if err.Error() != "'noSuchThing' doesn't exist" {
|
if !strings.Contains(err.Error(), "'noSuchThing' doesn't exist") {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1336,3 +1336,637 @@ spec:
|
|||||||
protocol: TCP
|
protocol: TCP
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestVariableRefNFSServer(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK("/app/base", `
|
||||||
|
resources:
|
||||||
|
- pv_pvc.yaml
|
||||||
|
- nfs_deployment.yaml
|
||||||
|
- nfs_service.yaml
|
||||||
|
- Deployment.yaml
|
||||||
|
- CronJob.yaml
|
||||||
|
- DaemonSet.yaml
|
||||||
|
- ReplicaSet.yaml
|
||||||
|
- StatefulSet.yaml
|
||||||
|
- Pod.yaml
|
||||||
|
- Job.yaml
|
||||||
|
- nfs_pv.yaml
|
||||||
|
|
||||||
|
vars:
|
||||||
|
- name: NFS_SERVER_SERVICE_NAME
|
||||||
|
objref:
|
||||||
|
kind: Service
|
||||||
|
name: nfs-server-service
|
||||||
|
apiVersion: v1
|
||||||
|
fieldref:
|
||||||
|
fieldpath: metadata.name
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/pv_pvc.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: shared-volume-claim
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/nfs_deployment.yaml", `
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nfs-server
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
role: nfs-server
|
||||||
|
containers:
|
||||||
|
- name: nfs-server
|
||||||
|
image: gcr.io/google_containers/volume-nfs:0.8
|
||||||
|
ports:
|
||||||
|
- name: nfs
|
||||||
|
containerPort: 2049
|
||||||
|
- name: mountd
|
||||||
|
containerPort: 20048
|
||||||
|
- name: rpcbind
|
||||||
|
containerPort: 111
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /exports
|
||||||
|
name: shared-files
|
||||||
|
volumes:
|
||||||
|
- name: shared-files
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: shared-volume-claim
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/nfs_service.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: nfs-server-service
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: nfs
|
||||||
|
port: 2049
|
||||||
|
- name: mountd
|
||||||
|
port: 20048
|
||||||
|
- name: rpcbind
|
||||||
|
port: 111
|
||||||
|
selector:
|
||||||
|
role: nfs-server
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/Deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: nginx
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:1.15.7-alpine
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/CronJob.yaml", `
|
||||||
|
apiVersion: batch/v1beta1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: hello
|
||||||
|
spec:
|
||||||
|
schedule: "*/1 * * * *"
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: hello
|
||||||
|
image: busybox
|
||||||
|
args:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- date; echo Hello from the Kubernetes cluster
|
||||||
|
restartPolicy: OnFailure
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/DaemonSet.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: DaemonSet
|
||||||
|
metadata:
|
||||||
|
name: fluentd-elasticsearch
|
||||||
|
namespace: kube-system
|
||||||
|
labels:
|
||||||
|
k8s-app: fluentd-logging
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
name: fluentd-elasticsearch
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: fluentd-elasticsearch
|
||||||
|
spec:
|
||||||
|
tolerations:
|
||||||
|
- key: node-role.kubernetes.io/master
|
||||||
|
effect: NoSchedule
|
||||||
|
containers:
|
||||||
|
- name: fluentd-elasticsearch
|
||||||
|
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 200Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 200Mi
|
||||||
|
volumeMounts:
|
||||||
|
- name: varlog
|
||||||
|
mountPath: /var/log
|
||||||
|
- name: varlibdockercontainers
|
||||||
|
mountPath: /var/lib/docker/containers
|
||||||
|
readOnly: true
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
volumes:
|
||||||
|
- name: varlog
|
||||||
|
hostPath:
|
||||||
|
path: /var/log
|
||||||
|
- name: varlibdockercontainers
|
||||||
|
hostPath:
|
||||||
|
path: /var/lib/docker/containers
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/ReplicaSet.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: ReplicaSet
|
||||||
|
metadata:
|
||||||
|
name: frontend
|
||||||
|
labels:
|
||||||
|
app: guestbook
|
||||||
|
tier: frontend
|
||||||
|
spec:
|
||||||
|
# modify replicas according to your case
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
tier: frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
tier: frontend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: php-redis
|
||||||
|
image: gcr.io/google_samples/gb-frontend:v3
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
|
||||||
|
th.WriteF("/app/base/Job.yaml", `
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: pi
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: pi
|
||||||
|
image: perl
|
||||||
|
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
restartPolicy: Never
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
backoffLimit: 4
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/StatefulSet.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: web
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nginx # has to match .spec.template.metadata.labels
|
||||||
|
serviceName: "nginx"
|
||||||
|
replicas: 3 # by default is 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx # has to match .spec.selector.matchLabels
|
||||||
|
spec:
|
||||||
|
terminationGracePeriodSeconds: 10
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: k8s.gcr.io/nginx-slim:0.8
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
name: web
|
||||||
|
volumeMounts:
|
||||||
|
- name: www
|
||||||
|
mountPath: /usr/share/nginx/html
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- metadata:
|
||||||
|
name: www
|
||||||
|
spec:
|
||||||
|
accessModes: [ "ReadWriteMany" ]
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/Pod.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: myapp-pod
|
||||||
|
labels:
|
||||||
|
app: myapp
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:1.15.7-alpine
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
mountPath: /app/shared-files
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/base/nfs_pv.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: nfs-files-pv
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: 10Gi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
nfs:
|
||||||
|
server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
`)
|
||||||
|
th.WriteK("/app/overlay", `
|
||||||
|
nameprefix: kustomized-
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
|
`)
|
||||||
|
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: kustomized-shared-volume-claim
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
---
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: kustomized-nfs-server
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: gcr.io/google_containers/volume-nfs:0.8
|
||||||
|
name: nfs-server
|
||||||
|
ports:
|
||||||
|
- containerPort: 2049
|
||||||
|
name: nfs
|
||||||
|
- containerPort: 20048
|
||||||
|
name: mountd
|
||||||
|
- containerPort: 111
|
||||||
|
name: rpcbind
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /exports
|
||||||
|
name: shared-files
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
role: nfs-server
|
||||||
|
volumes:
|
||||||
|
- name: shared-files
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: kustomized-shared-volume-claim
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: kustomized-nfs-server-service
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: nfs
|
||||||
|
port: 2049
|
||||||
|
- name: mountd
|
||||||
|
port: 20048
|
||||||
|
- name: rpcbind
|
||||||
|
port: 111
|
||||||
|
selector:
|
||||||
|
role: nfs-server
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: nginx
|
||||||
|
name: kustomized-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: nginx
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:1.15.7-alpine
|
||||||
|
name: nginx
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
name: http
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1beta1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: kustomized-hello
|
||||||
|
spec:
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- date; echo Hello from the Kubernetes cluster
|
||||||
|
image: busybox
|
||||||
|
name: hello
|
||||||
|
restartPolicy: OnFailure
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
schedule: '*/1 * * * *'
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: DaemonSet
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
k8s-app: fluentd-logging
|
||||||
|
name: kustomized-fluentd-elasticsearch
|
||||||
|
namespace: kube-system
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
name: fluentd-elasticsearch
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: fluentd-elasticsearch
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
|
||||||
|
name: fluentd-elasticsearch
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 200Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 200Mi
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /var/log
|
||||||
|
name: varlog
|
||||||
|
- mountPath: /var/lib/docker/containers
|
||||||
|
name: varlibdockercontainers
|
||||||
|
readOnly: true
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
tolerations:
|
||||||
|
- effect: NoSchedule
|
||||||
|
key: node-role.kubernetes.io/master
|
||||||
|
volumes:
|
||||||
|
- hostPath:
|
||||||
|
path: /var/log
|
||||||
|
name: varlog
|
||||||
|
- hostPath:
|
||||||
|
path: /var/lib/docker/containers
|
||||||
|
name: varlibdockercontainers
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: ReplicaSet
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: guestbook
|
||||||
|
tier: frontend
|
||||||
|
name: kustomized-frontend
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
tier: frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
tier: frontend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: gcr.io/google_samples/gb-frontend:v3
|
||||||
|
name: php-redis
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: kustomized-web
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nginx
|
||||||
|
serviceName: nginx
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: k8s.gcr.io/nginx-slim:0.8
|
||||||
|
name: nginx
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
name: web
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /usr/share/nginx/html
|
||||||
|
name: www
|
||||||
|
terminationGracePeriodSeconds: 10
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- metadata:
|
||||||
|
name: www
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: myapp
|
||||||
|
name: kustomized-myapp-pod
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:1.15.7-alpine
|
||||||
|
name: nginx
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
name: http
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: kustomized-pi
|
||||||
|
spec:
|
||||||
|
backoffLimit: 4
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- perl
|
||||||
|
- -Mbignum=bpi
|
||||||
|
- -wle
|
||||||
|
- print bpi(2000)
|
||||||
|
image: perl
|
||||||
|
name: pi
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /app/shared-files
|
||||||
|
name: nfs-files-vol
|
||||||
|
restartPolicy: Never
|
||||||
|
volumes:
|
||||||
|
- name: nfs-files-vol
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: kustomized-nfs-files-pv
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
capacity:
|
||||||
|
storage: 10Gi
|
||||||
|
nfs:
|
||||||
|
path: /
|
||||||
|
readOnly: false
|
||||||
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ package loader
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -86,9 +89,19 @@ type fileLoader struct {
|
|||||||
// File system utilities.
|
// File system utilities.
|
||||||
fSys filesys.FileSystem
|
fSys filesys.FileSystem
|
||||||
|
|
||||||
|
// Used to load from HTTP
|
||||||
|
http *http.Client
|
||||||
|
|
||||||
// Used to clone repositories.
|
// Used to clone repositories.
|
||||||
cloner git.Cloner
|
cloner git.Cloner
|
||||||
|
|
||||||
|
// If this is non-nil, the files were
|
||||||
|
// obtained from the given resource
|
||||||
|
rscSpec *remoteTargetSpec
|
||||||
|
|
||||||
|
// Used to get resources
|
||||||
|
getter remoteTargetGetter
|
||||||
|
|
||||||
// Used to clean up, as needed.
|
// Used to clean up, as needed.
|
||||||
cleaner func() error
|
cleaner func() error
|
||||||
}
|
}
|
||||||
@@ -121,20 +134,21 @@ func newLoaderOrDie(
|
|||||||
log.Fatalf("unable to make loader at '%s'; %v", path, err)
|
log.Fatalf("unable to make loader at '%s'; %v", path, err)
|
||||||
}
|
}
|
||||||
return newLoaderAtConfirmedDir(
|
return newLoaderAtConfirmedDir(
|
||||||
lr, root, fSys, nil, git.ClonerUsingGitExec)
|
lr, root, fSys, nil, git.ClonerUsingGitExec, getRemoteTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newLoaderAtConfirmedDir returns a new fileLoader with given root.
|
// newLoaderAtConfirmedDir returns a new fileLoader with given root.
|
||||||
func newLoaderAtConfirmedDir(
|
func newLoaderAtConfirmedDir(
|
||||||
lr LoadRestrictorFunc,
|
lr LoadRestrictorFunc,
|
||||||
root filesys.ConfirmedDir, fSys filesys.FileSystem,
|
root filesys.ConfirmedDir, fSys filesys.FileSystem,
|
||||||
referrer *fileLoader, cloner git.Cloner) *fileLoader {
|
referrer *fileLoader, cloner git.Cloner, getter remoteTargetGetter) *fileLoader {
|
||||||
return &fileLoader{
|
return &fileLoader{
|
||||||
loadRestrictor: lr,
|
loadRestrictor: lr,
|
||||||
root: root,
|
root: root,
|
||||||
referrer: referrer,
|
referrer: referrer,
|
||||||
fSys: fSys,
|
fSys: fSys,
|
||||||
cloner: cloner,
|
cloner: cloner,
|
||||||
|
getter: getter,
|
||||||
cleaner: func() error { return nil },
|
cleaner: func() error { return nil },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,37 +178,44 @@ func (fl *fileLoader) New(path string) (ifc.Loader, error) {
|
|||||||
if path == "" {
|
if path == "" {
|
||||||
return nil, fmt.Errorf("new root cannot be empty")
|
return nil, fmt.Errorf("new root cannot be empty")
|
||||||
}
|
}
|
||||||
repoSpec, err := git.NewRepoSpecFromUrl(path)
|
|
||||||
if err == nil {
|
ldr, errGet := newLoaderAtGetter(path, fl.fSys, nil, fl.cloner, fl.getter)
|
||||||
|
if errGet == nil {
|
||||||
|
return ldr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
repoSpec, errGit := git.NewRepoSpecFromUrl(path)
|
||||||
|
if errGit == nil {
|
||||||
// Treat this as git repo clone request.
|
// Treat this as git repo clone request.
|
||||||
if err := fl.errIfRepoCycle(repoSpec); err != nil {
|
if errGit := fl.errIfRepoCycle(repoSpec); errGit != nil {
|
||||||
return nil, err
|
return nil, errGit
|
||||||
}
|
}
|
||||||
return newLoaderAtGitClone(
|
return newLoaderAtGitClone(
|
||||||
repoSpec, fl.fSys, fl, fl.cloner)
|
repoSpec, fl.fSys, fl, fl.cloner, fl.getter)
|
||||||
}
|
}
|
||||||
|
|
||||||
if filepath.IsAbs(path) {
|
if filepath.IsAbs(path) {
|
||||||
return nil, fmt.Errorf("new root '%s' cannot be absolute", path)
|
return nil, fmt.Errorf("new root '%s' cannot be absolute", path)
|
||||||
}
|
}
|
||||||
root, err := demandDirectoryRoot(fl.fSys, fl.root.Join(path))
|
root, errDir := demandDirectoryRoot(fl.fSys, fl.root.Join(path))
|
||||||
if err != nil {
|
if errDir != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("Error loading %s with git: %v, dir: %v, get: %v", path, errGit, errDir, errGet)
|
||||||
}
|
}
|
||||||
if err := fl.errIfGitContainmentViolation(root); err != nil {
|
if errDir := fl.errIfGitContainmentViolation(root); errDir != nil {
|
||||||
return nil, err
|
return nil, errDir
|
||||||
}
|
}
|
||||||
if err := fl.errIfArgEqualOrHigher(root); err != nil {
|
if errDir := fl.errIfArgEqualOrHigher(root); errDir != nil {
|
||||||
return nil, err
|
return nil, errDir
|
||||||
}
|
}
|
||||||
return newLoaderAtConfirmedDir(
|
return newLoaderAtConfirmedDir(
|
||||||
fl.loadRestrictor, root, fl.fSys, fl, fl.cloner), nil
|
fl.loadRestrictor, root, fl.fSys, fl, fl.cloner, fl.getter), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// newLoaderAtGitClone returns a new Loader pinned to a temporary
|
// newLoaderAtGitClone returns a new Loader pinned to a temporary
|
||||||
// directory holding a cloned git repo.
|
// directory holding a cloned git repo.
|
||||||
func newLoaderAtGitClone(
|
func newLoaderAtGitClone(
|
||||||
repoSpec *git.RepoSpec, fSys filesys.FileSystem,
|
repoSpec *git.RepoSpec, fSys filesys.FileSystem,
|
||||||
referrer *fileLoader, cloner git.Cloner) (ifc.Loader, error) {
|
referrer *fileLoader, cloner git.Cloner, getter remoteTargetGetter) (ifc.Loader, error) {
|
||||||
cleaner := repoSpec.Cleaner(fSys)
|
cleaner := repoSpec.Cleaner(fSys)
|
||||||
err := cloner(repoSpec)
|
err := cloner(repoSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -224,6 +245,7 @@ func newLoaderAtGitClone(
|
|||||||
repoSpec: repoSpec,
|
repoSpec: repoSpec,
|
||||||
fSys: fSys,
|
fSys: fSys,
|
||||||
cloner: cloner,
|
cloner: cloner,
|
||||||
|
getter: getter,
|
||||||
cleaner: cleaner,
|
cleaner: cleaner,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -293,6 +315,25 @@ func (fl *fileLoader) errIfRepoCycle(newRepoSpec *git.RepoSpec) error {
|
|||||||
// else an error. Relative paths are taken relative
|
// else an error. Relative paths are taken relative
|
||||||
// to the root.
|
// to the root.
|
||||||
func (fl *fileLoader) Load(path string) ([]byte, error) {
|
func (fl *fileLoader) Load(path string) ([]byte, error) {
|
||||||
|
if u, err := url.Parse(path); err == nil && (u.Scheme == "http" || u.Scheme == "https") {
|
||||||
|
var hc *http.Client
|
||||||
|
if fl.http != nil {
|
||||||
|
hc = fl.http
|
||||||
|
} else {
|
||||||
|
hc = &http.Client{}
|
||||||
|
}
|
||||||
|
resp, err := hc.Get(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return body, nil
|
||||||
|
}
|
||||||
|
|
||||||
if !filepath.IsAbs(path) {
|
if !filepath.IsAbs(path) {
|
||||||
path = fl.root.Join(path)
|
path = fl.root.Join(path)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
package loader
|
package loader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -54,6 +56,7 @@ func makeLoader() *fileLoader {
|
|||||||
return NewFileLoaderAtRoot(MakeFakeFs(testCases))
|
return NewFileLoaderAtRoot(MakeFakeFs(testCases))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoaderLoad(t *testing.T) {
|
func TestLoaderLoad(t *testing.T) {
|
||||||
l1 := makeLoader()
|
l1 := makeLoader()
|
||||||
if "/" != l1.Root() {
|
if "/" != l1.Root() {
|
||||||
@@ -385,7 +388,7 @@ whatever
|
|||||||
}
|
}
|
||||||
l, err := newLoaderAtGitClone(
|
l, err := newLoaderAtGitClone(
|
||||||
repoSpec, fSys, nil,
|
repoSpec, fSys, nil,
|
||||||
git.DoNothingCloner(filesys.ConfirmedDir(coRoot)))
|
git.DoNothingCloner(filesys.ConfirmedDir(coRoot)), getNothing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected err: %v\n", err)
|
t.Fatalf("unexpected err: %v\n", err)
|
||||||
}
|
}
|
||||||
@@ -464,7 +467,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
|
|||||||
}
|
}
|
||||||
l1, err = newLoaderAtGitClone(
|
l1, err = newLoaderAtGitClone(
|
||||||
repoSpec, fSys, nil,
|
repoSpec, fSys, nil,
|
||||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)), getNothing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected err: %v\n", err)
|
t.Fatalf("unexpected err: %v\n", err)
|
||||||
}
|
}
|
||||||
@@ -503,7 +506,7 @@ func TestLocalLoaderReferencingGitBase(t *testing.T) {
|
|||||||
}
|
}
|
||||||
l1 := newLoaderAtConfirmedDir(
|
l1 := newLoaderAtConfirmedDir(
|
||||||
RestrictionRootOnly, root, fSys, nil,
|
RestrictionRootOnly, root, fSys, nil,
|
||||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)), getNothing)
|
||||||
if l1.Root() != topDir {
|
if l1.Root() != topDir {
|
||||||
t.Fatalf("unexpected root %s", l1.Root())
|
t.Fatalf("unexpected root %s", l1.Root())
|
||||||
}
|
}
|
||||||
@@ -529,7 +532,7 @@ func TestRepoDirectCycleDetection(t *testing.T) {
|
|||||||
}
|
}
|
||||||
l1 := newLoaderAtConfirmedDir(
|
l1 := newLoaderAtConfirmedDir(
|
||||||
RestrictionRootOnly, root, fSys, nil,
|
RestrictionRootOnly, root, fSys, nil,
|
||||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)), getNothing)
|
||||||
p1 := "github.com/someOrg/someRepo/foo"
|
p1 := "github.com/someOrg/someRepo/foo"
|
||||||
rs1, err := git.NewRepoSpecFromUrl(p1)
|
rs1, err := git.NewRepoSpecFromUrl(p1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -558,7 +561,7 @@ func TestRepoIndirectCycleDetection(t *testing.T) {
|
|||||||
}
|
}
|
||||||
l0 := newLoaderAtConfirmedDir(
|
l0 := newLoaderAtConfirmedDir(
|
||||||
RestrictionRootOnly, root, fSys, nil,
|
RestrictionRootOnly, root, fSys, nil,
|
||||||
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)))
|
git.DoNothingCloner(filesys.ConfirmedDir(cloneRoot)), getNothing)
|
||||||
|
|
||||||
p1 := "github.com/someOrg/someRepo1"
|
p1 := "github.com/someOrg/someRepo1"
|
||||||
p2 := "github.com/someOrg/someRepo2"
|
p2 := "github.com/someOrg/someRepo2"
|
||||||
@@ -579,3 +582,93 @@ func TestRepoIndirectCycleDetection(t *testing.T) {
|
|||||||
t.Fatalf("unexpected err: %v", err)
|
t.Fatalf("unexpected err: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inspired by https://hassansin.github.io/Unit-Testing-http-client-in-Go
|
||||||
|
type fakeRoundTripper func(req *http.Request) *http.Response
|
||||||
|
|
||||||
|
func (f fakeRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
return f(req), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeFakeHTTPClient(fn fakeRoundTripper) *http.Client {
|
||||||
|
return &http.Client{
|
||||||
|
Transport: fn,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestLoaderHTTP test http file loader
|
||||||
|
func TestLoaderHTTP(t *testing.T) {
|
||||||
|
var testCasesFile = []testData{
|
||||||
|
{
|
||||||
|
path: "http/file.yaml",
|
||||||
|
expectedContent: "file content",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
l1 := NewFileLoaderAtRoot(MakeFakeFs(testCasesFile))
|
||||||
|
if "/" != l1.Root() {
|
||||||
|
t.Fatalf("incorrect root: '%s'\n", l1.Root())
|
||||||
|
}
|
||||||
|
for _, x := range testCasesFile {
|
||||||
|
b, err := l1.Load(x.path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected load error: %v", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual([]byte(x.expectedContent), b) {
|
||||||
|
t.Fatalf("in load expected %s, but got %s", x.expectedContent, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var testCasesHTTP = []testData{
|
||||||
|
{
|
||||||
|
path: "http://example.com/resource.yaml",
|
||||||
|
expectedContent: "http content",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "https://example.com/resource.yaml",
|
||||||
|
expectedContent: "https content",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, x := range testCasesHTTP {
|
||||||
|
hc := makeFakeHTTPClient(func(req *http.Request) *http.Response {
|
||||||
|
u := req.URL.String()
|
||||||
|
if x.path != u {
|
||||||
|
t.Fatalf("expected URL %s, but got %s", x.path, u)
|
||||||
|
}
|
||||||
|
return &http.Response{
|
||||||
|
StatusCode: 200,
|
||||||
|
Body: ioutil.NopCloser(bytes.NewBufferString(x.expectedContent)),
|
||||||
|
Header: make(http.Header),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
l2 := l1
|
||||||
|
l2.http = hc
|
||||||
|
b, err := l2.Load(x.path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected load error: %v", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual([]byte(x.expectedContent), b) {
|
||||||
|
t.Fatalf("in load expected %s, but got %s", x.expectedContent, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var testCaseUnsupported = []testData{
|
||||||
|
{
|
||||||
|
path: "httpsnotreal://example.com/resource.yaml",
|
||||||
|
expectedContent: "invalid",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, x := range testCaseUnsupported {
|
||||||
|
hc := makeFakeHTTPClient(func(req *http.Request) *http.Response {
|
||||||
|
t.Fatalf("unexpected request to URL %s", req.URL.String())
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
l2 := l1
|
||||||
|
l2.http = hc
|
||||||
|
_, err := l2.Load(x.path)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expect error but get %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
101
api/loader/getter.go
Normal file
101
api/loader/getter.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package loader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/yujunz/go-getter"
|
||||||
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
|
"sigs.k8s.io/kustomize/api/ifc"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/git"
|
||||||
|
)
|
||||||
|
|
||||||
|
type remoteTargetSpec struct {
|
||||||
|
// Raw is the original resource in kustomization.yaml
|
||||||
|
Raw string
|
||||||
|
|
||||||
|
// Dir is where the resource is saved
|
||||||
|
Dir filesys.ConfirmedDir
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter is a function that can gets resource
|
||||||
|
type remoteTargetGetter func(rs *remoteTargetSpec) error
|
||||||
|
|
||||||
|
func newLoaderAtGetter(raw string, fSys filesys.FileSystem, referrer *fileLoader, cloner git.Cloner, getter remoteTargetGetter) (ifc.Loader, error) {
|
||||||
|
rs := &remoteTargetSpec{
|
||||||
|
Raw: raw,
|
||||||
|
}
|
||||||
|
|
||||||
|
cleaner := func() error {
|
||||||
|
return fSys.RemoveAll(rs.Dir.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := getter(rs); err != nil {
|
||||||
|
cleaner()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &fileLoader{
|
||||||
|
loadRestrictor: RestrictionRootOnly,
|
||||||
|
// TODO(yujunz): limit to getter root
|
||||||
|
root: rs.Dir,
|
||||||
|
referrer: referrer,
|
||||||
|
fSys: fSys,
|
||||||
|
cloner: cloner,
|
||||||
|
rscSpec: rs,
|
||||||
|
getter: getter,
|
||||||
|
cleaner: cleaner,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRemoteTarget(rs *remoteTargetSpec) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
rs.Dir, err = filesys.NewTmpConfirmedDir()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the pwd
|
||||||
|
pwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error getting wd: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := []getter.ClientOption{}
|
||||||
|
client := &getter.Client{
|
||||||
|
Ctx: context.TODO(),
|
||||||
|
Src: rs.Raw,
|
||||||
|
Dst: rs.Dir.String(),
|
||||||
|
Pwd: pwd,
|
||||||
|
Mode: getter.ClientModeAny,
|
||||||
|
Detectors: []getter.Detector{
|
||||||
|
new(getter.GitHubDetector),
|
||||||
|
new(getter.GitDetector),
|
||||||
|
new(getter.BitBucketDetector),
|
||||||
|
},
|
||||||
|
Options: opts,
|
||||||
|
}
|
||||||
|
return client.Get()
|
||||||
|
}
|
||||||
|
|
||||||
|
func getNothing(rs *remoteTargetSpec) error {
|
||||||
|
var err error
|
||||||
|
rs.Dir, err = filesys.NewTmpConfirmedDir()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the pwd
|
||||||
|
pwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error getting wd: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = getter.Detect(rs.Raw, pwd, []getter.Detector{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
package loader
|
package loader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
"sigs.k8s.io/kustomize/api/ifc"
|
"sigs.k8s.io/kustomize/api/ifc"
|
||||||
"sigs.k8s.io/kustomize/api/internal/git"
|
"sigs.k8s.io/kustomize/api/internal/git"
|
||||||
@@ -19,16 +21,23 @@ import (
|
|||||||
func NewLoader(
|
func NewLoader(
|
||||||
lr LoadRestrictorFunc,
|
lr LoadRestrictorFunc,
|
||||||
target string, fSys filesys.FileSystem) (ifc.Loader, error) {
|
target string, fSys filesys.FileSystem) (ifc.Loader, error) {
|
||||||
repoSpec, err := git.NewRepoSpecFromUrl(target)
|
|
||||||
if err == nil {
|
ldr, errGet := newLoaderAtGetter(target, fSys, nil, git.ClonerUsingGitExec, getRemoteTarget)
|
||||||
|
if errGet == nil {
|
||||||
|
return ldr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
repoSpec, errGit := git.NewRepoSpecFromUrl(target)
|
||||||
|
if errGit == nil {
|
||||||
// The target qualifies as a remote git target.
|
// The target qualifies as a remote git target.
|
||||||
return newLoaderAtGitClone(
|
return newLoaderAtGitClone(
|
||||||
repoSpec, fSys, nil, git.ClonerUsingGitExec)
|
repoSpec, fSys, nil, git.ClonerUsingGitExec, getRemoteTarget)
|
||||||
}
|
}
|
||||||
root, err := demandDirectoryRoot(fSys, target)
|
|
||||||
if err != nil {
|
root, errDir := demandDirectoryRoot(fSys, target)
|
||||||
return nil, err
|
if errDir == nil {
|
||||||
|
return newLoaderAtConfirmedDir(lr, root, fSys, nil, git.ClonerUsingGitExec, getRemoteTarget), nil
|
||||||
}
|
}
|
||||||
return newLoaderAtConfirmedDir(
|
|
||||||
lr, root, fSys, nil, git.ClonerUsingGitExec), nil
|
return nil, fmt.Errorf("Error creating new loader with git: %v, dir: %v, get: %v", errGit, errDir, errGet)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ type ResMap interface {
|
|||||||
Append(*resource.Resource) error
|
Append(*resource.Resource) error
|
||||||
|
|
||||||
// AppendAll appends another ResMap to self,
|
// AppendAll appends another ResMap to self,
|
||||||
// failing on any OrgId collision.
|
// failing on any CurId collision.
|
||||||
AppendAll(ResMap) error
|
AppendAll(ResMap) error
|
||||||
|
|
||||||
// AbsorbAll appends, replaces or merges the contents
|
// AbsorbAll appends, replaces or merges the contents
|
||||||
|
|||||||
30
api/testutils/filtertest/runfilter.go
Normal file
30
api/testutils/filtertest/runfilter.go
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package filtertest_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunFilter(t *testing.T, input string, f kio.Filter) string {
|
||||||
|
var out bytes.Buffer
|
||||||
|
rw := kio.ByteReadWriter{
|
||||||
|
Reader: bytes.NewBufferString(input),
|
||||||
|
Writer: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&rw},
|
||||||
|
Filters: []kio.Filter{f},
|
||||||
|
Outputs: []kio.Writer{&rw},
|
||||||
|
}.Execute()
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
return out.String()
|
||||||
|
}
|
||||||
@@ -4,6 +4,9 @@
|
|||||||
package kusttest_test
|
package kusttest_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
@@ -16,6 +19,8 @@ import (
|
|||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
"sigs.k8s.io/kustomize/api/resource"
|
"sigs.k8s.io/kustomize/api/resource"
|
||||||
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
|
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HarnessEnhanced manages a full plugin environment for tests.
|
// HarnessEnhanced manages a full plugin environment for tests.
|
||||||
@@ -109,12 +114,69 @@ func (th *HarnessEnhanced) LoadAndRunTransformer(
|
|||||||
return resMap
|
return resMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (th *HarnessEnhanced) RunTransformerAndCheckResult(
|
||||||
|
config, input, expected string) {
|
||||||
|
for _, b := range []bool{true, false} {
|
||||||
|
th.t.Run(fmt.Sprintf("yaml-%v", b), func(t *testing.T) {
|
||||||
|
c, err := toggleYamlSupportField(config, b)
|
||||||
|
if err != nil {
|
||||||
|
th.t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
resMap, err := th.RunTransformer(c, input)
|
||||||
|
if err != nil {
|
||||||
|
th.t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
th.AssertActualEqualsExpected(resMap, expected)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func toggleYamlSupportField(config string, yamlSupport bool) (string, error) {
|
||||||
|
var out bytes.Buffer
|
||||||
|
rw := kio.ByteReadWriter{
|
||||||
|
Reader: bytes.NewBufferString(config),
|
||||||
|
Writer: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := kio.Pipeline{
|
||||||
|
Inputs: []kio.Reader{&rw},
|
||||||
|
Filters: []kio.Filter{
|
||||||
|
kio.FilterAll(yaml.FilterFunc(
|
||||||
|
func(node *yaml.RNode) (*yaml.RNode, error) {
|
||||||
|
return node.Pipe(yaml.FieldSetter{
|
||||||
|
Name: "yamlSupport",
|
||||||
|
StringValue: strconv.FormatBool(yamlSupport),
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Outputs: []kio.Writer{&rw},
|
||||||
|
}.Execute()
|
||||||
|
return out.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
func (th *HarnessEnhanced) ErrorFromLoadAndRunTransformer(
|
func (th *HarnessEnhanced) ErrorFromLoadAndRunTransformer(
|
||||||
config, input string) error {
|
config, input string) error {
|
||||||
_, err := th.RunTransformer(config, input)
|
_, err := th.RunTransformer(config, input)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AssertFunc func(t *testing.T, err error)
|
||||||
|
|
||||||
|
func (th *HarnessEnhanced) RunTransformerAndCheckError(
|
||||||
|
config, input string, assertFn AssertFunc) {
|
||||||
|
for _, b := range []bool{true, false} {
|
||||||
|
th.t.Run(fmt.Sprintf("yaml-%v", b), func(t *testing.T) {
|
||||||
|
c, err := toggleYamlSupportField(config, b)
|
||||||
|
if err != nil {
|
||||||
|
th.t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
_, err = th.RunTransformer(c, input)
|
||||||
|
assertFn(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (th *HarnessEnhanced) RunTransformer(
|
func (th *HarnessEnhanced) RunTransformer(
|
||||||
config, input string) (resmap.ResMap, error) {
|
config, input string) (resmap.ResMap, error) {
|
||||||
resMap, err := th.rf.NewResMapFromBytes([]byte(input))
|
resMap, err := th.rf.NewResMapFromBytes([]byte(input))
|
||||||
|
|||||||
@@ -21,4 +21,7 @@ type GeneratorArgs struct {
|
|||||||
|
|
||||||
// KvPairSources for the generator.
|
// KvPairSources for the generator.
|
||||||
KvPairSources `json:",inline,omitempty" yaml:",inline,omitempty"`
|
KvPairSources `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||||
|
|
||||||
|
// GeneratorOptions modify this generator
|
||||||
|
GeneratorOptions *GeneratorOptions `json:"generatorOptions,omitempty" yaml:"generatorOptions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ List setters for Resources.
|
|||||||
|
|
||||||
Show setters:
|
Show setters:
|
||||||
|
|
||||||
$ config set DIR/
|
$ config list-setters DIR/
|
||||||
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
||||||
name-prefix '' PREFIX string 2
|
name-prefix '' PREFIX string 2
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ the configuration as comments.
|
|||||||
Optional. The value to set on the field.
|
Optional. The value to set on the field.
|
||||||
|
|
||||||
|
|
||||||
To print the possible setters for the Resources in a directory, run `set` on
|
To print the possible setters for the Resources in a directory, run
|
||||||
a directory -- e.g. `kustomize config set DIR/`.
|
`list-setters` on a directory -- e.g. `kustomize config list-setters DIR/`.
|
||||||
|
|
||||||
#### Tips
|
#### Tips
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ To create a custom setter for a field see: `kustomize help config create-setter`
|
|||||||
|
|
||||||
List setters: Show the possible setters
|
List setters: Show the possible setters
|
||||||
|
|
||||||
$ config set DIR/
|
$ config list-setters DIR/
|
||||||
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
||||||
name-prefix '' PREFIX string 2
|
name-prefix '' PREFIX string 2
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ To create a custom setter for a field see: `kustomize help config create-setter`
|
|||||||
|
|
||||||
List setters: Show the new values
|
List setters: Show the new values
|
||||||
|
|
||||||
$ config set DIR/
|
$ config list-setters DIR/
|
||||||
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
||||||
name-prefix 'test environment' test string 2 dev
|
name-prefix 'test environment' test string 2 dev
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
|
github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
|
||||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
|
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
@@ -16,6 +22,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||||
|
github.com/dustmop/soup v1.1.2-0.20190516214245-38228baa104e/go.mod h1:CgNC6SGbT+Xb8wGGvzilttZL1mc5sQ/5KkcxsZttMIk=
|
||||||
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||||
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
@@ -82,6 +89,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
|
|||||||
github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
||||||
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
|
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
|
||||||
@@ -91,6 +99,7 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
|||||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/paulmach/orb v0.1.3/go.mod h1:VFlX/8C+IQ1p6FTRRKzKoOPJnvEtA5G0Veuqwbu//Vk=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
@@ -100,6 +109,8 @@ github.com/posener/complete/v2 v2.0.1-alpha.12 h1:0wvkuDfHb5vSZlNBYgpEH4XQHpF46M
|
|||||||
github.com/posener/complete/v2 v2.0.1-alpha.12/go.mod h1://JlL91cS2JV7rOl6LVHrRqBXoBUecJu3ILQPgbJiMQ=
|
github.com/posener/complete/v2 v2.0.1-alpha.12/go.mod h1://JlL91cS2JV7rOl6LVHrRqBXoBUecJu3ILQPgbJiMQ=
|
||||||
github.com/posener/script v1.0.4 h1:nSuXW5ZdmFnQIueLB2s0qvs4oNsUloM1Zydzh75v42w=
|
github.com/posener/script v1.0.4 h1:nSuXW5ZdmFnQIueLB2s0qvs4oNsUloM1Zydzh75v42w=
|
||||||
github.com/posener/script v1.0.4/go.mod h1:Rg3ijooqulo05aGLyGsHoLmIOUzHUVK19WVgrYBPU/E=
|
github.com/posener/script v1.0.4/go.mod h1:Rg3ijooqulo05aGLyGsHoLmIOUzHUVK19WVgrYBPU/E=
|
||||||
|
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d h1:K6eOUihrFLdZjZnA4XlRp864fmWXv9YTIk7VPLhRacA=
|
||||||
|
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA=
|
||||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||||
@@ -116,6 +127,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
@@ -123,10 +135,16 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
|
|||||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
|
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
|
||||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
|
go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||||
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
|
||||||
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
|
||||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
|
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
|
||||||
@@ -137,6 +155,7 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||||
@@ -156,8 +175,10 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d h1:LCPbGQ34PMrwad11aMZ+dbz5SAsq/0ySjRwQ8I9Qwd8=
|
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 h1:XZx7nhd5GMaZpmDaEHFVafUZC7ya0fuo7cSJ3UCKYmM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo=
|
k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo=
|
||||||
k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
|
k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
|
||||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ func NewCreateSetterRunner(parent string) *CreateSetterRunner {
|
|||||||
"kind of the Resource on which to create the setter.")
|
"kind of the Resource on which to create the setter.")
|
||||||
set.Flags().MarkHidden("kind")
|
set.Flags().MarkHidden("kind")
|
||||||
set.Flags().StringVar(&r.Set.SetPartialField.Type, "type", "",
|
set.Flags().StringVar(&r.Set.SetPartialField.Type, "type", "",
|
||||||
"valid OpenAPI field type -- e.g. integer,boolean,string.")
|
"OpenAPI field type for the setter -- e.g. integer,boolean,string.")
|
||||||
set.Flags().MarkHidden("type")
|
|
||||||
set.Flags().BoolVar(&r.Set.SetPartialField.Partial, "partial", false,
|
set.Flags().BoolVar(&r.Set.SetPartialField.Partial, "partial", false,
|
||||||
"create a partial setter for only part of the field value.")
|
"create a partial setter for only part of the field value.")
|
||||||
set.Flags().MarkHidden("partial")
|
set.Flags().MarkHidden("partial")
|
||||||
@@ -89,6 +88,7 @@ func (r *CreateSetterRunner) preRunE(c *cobra.Command, args []string) error {
|
|||||||
r.OpenAPIFile, err = ext.GetOpenAPIFile(args)
|
r.OpenAPIFile, err = ext.GetOpenAPIFile(args)
|
||||||
r.CreateSetter.Description = r.Set.SetPartialField.Description
|
r.CreateSetter.Description = r.Set.SetPartialField.Description
|
||||||
r.CreateSetter.SetBy = r.Set.SetPartialField.SetBy
|
r.CreateSetter.SetBy = r.Set.SetPartialField.SetBy
|
||||||
|
r.CreateSetter.Type = r.Set.SetPartialField.Type
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,72 @@ spec:
|
|||||||
image: nginx:1.7.9 # {"$ref":"#/definitions/io.k8s.cli.substitutions.image"}
|
image: nginx:1.7.9 # {"$ref":"#/definitions/io.k8s.cli.substitutions.image"}
|
||||||
- name: sidecar
|
- name: sidecar
|
||||||
image: sidecar:1.7.9
|
image: sidecar:1.7.9
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "substitution and create setters 1",
|
||||||
|
args: []string{
|
||||||
|
"image", "something/nginx::1.7.9/nginxotherthing", "--pattern", "something/IMAGE::TAG/nginxotherthing",
|
||||||
|
"--value", "IMAGE=image", "--value", "TAG=tag"},
|
||||||
|
input: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: something/nginx::1.7.9/nginxotherthing
|
||||||
|
- name: sidecar
|
||||||
|
image: sidecar:1.7.9
|
||||||
|
`,
|
||||||
|
inputOpenAPI: `
|
||||||
|
apiVersion: v1alpha1
|
||||||
|
kind: Example
|
||||||
|
`,
|
||||||
|
expectedOpenAPI: `
|
||||||
|
apiVersion: v1alpha1
|
||||||
|
kind: Example
|
||||||
|
openAPI:
|
||||||
|
definitions:
|
||||||
|
io.k8s.cli.setters.image:
|
||||||
|
x-k8s-cli:
|
||||||
|
setter:
|
||||||
|
name: image
|
||||||
|
value: nginx
|
||||||
|
io.k8s.cli.setters.tag:
|
||||||
|
x-k8s-cli:
|
||||||
|
setter:
|
||||||
|
name: tag
|
||||||
|
value: 1.7.9
|
||||||
|
io.k8s.cli.substitutions.image:
|
||||||
|
x-k8s-cli:
|
||||||
|
substitution:
|
||||||
|
name: image
|
||||||
|
pattern: something/IMAGE::TAG/nginxotherthing
|
||||||
|
values:
|
||||||
|
- marker: IMAGE
|
||||||
|
ref: '#/definitions/io.k8s.cli.setters.image'
|
||||||
|
- marker: TAG
|
||||||
|
ref: '#/definitions/io.k8s.cli.setters.tag'
|
||||||
|
`,
|
||||||
|
expectedResources: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: something/nginx::1.7.9/nginxotherthing # {"$ref":"#/definitions/io.k8s.cli.substitutions.image"}
|
||||||
|
- name: sidecar
|
||||||
|
image: sidecar:1.7.9
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/olekukonko/tablewriter"
|
"github.com/olekukonko/tablewriter"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -28,6 +29,8 @@ func NewListSettersRunner(parent string) *ListSettersRunner {
|
|||||||
PreRunE: r.preRunE,
|
PreRunE: r.preRunE,
|
||||||
RunE: r.runE,
|
RunE: r.runE,
|
||||||
}
|
}
|
||||||
|
c.Flags().BoolVar(&r.Markdown, "markdown", false,
|
||||||
|
"output as github markdown")
|
||||||
fixDocs(parent, c)
|
fixDocs(parent, c)
|
||||||
r.Command = c
|
r.Command = c
|
||||||
return r
|
return r
|
||||||
@@ -38,9 +41,10 @@ func ListSettersCommand(parent string) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ListSettersRunner struct {
|
type ListSettersRunner struct {
|
||||||
Command *cobra.Command
|
Command *cobra.Command
|
||||||
Lookup setters.LookupSetters
|
Lookup setters.LookupSetters
|
||||||
List setters2.List
|
List setters2.List
|
||||||
|
Markdown bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ListSettersRunner) preRunE(c *cobra.Command, args []string) error {
|
func (r *ListSettersRunner) preRunE(c *cobra.Command, args []string) error {
|
||||||
@@ -63,12 +67,19 @@ func (r *ListSettersRunner) runE(c *cobra.Command, args []string) error {
|
|||||||
if err := r.List.List(path, args[0]); err != nil {
|
if err := r.List.List(path, args[0]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
table := newTable(c.OutOrStdout())
|
table := newTable(c.OutOrStdout(), r.Markdown)
|
||||||
table.SetHeader([]string{"NAME", "VALUE", "SET BY", "DESCRIPTION", "COUNT"})
|
table.SetHeader([]string{"NAME", "VALUE", "SET BY", "DESCRIPTION", "COUNT"})
|
||||||
for i := range r.List.Setters {
|
for i := range r.List.Setters {
|
||||||
s := r.List.Setters[i]
|
s := r.List.Setters[i]
|
||||||
|
v := s.Value
|
||||||
|
|
||||||
|
// if the setter is for a list, populate the values
|
||||||
|
if len(s.ListValues) > 0 {
|
||||||
|
v = strings.Join(s.ListValues, ",")
|
||||||
|
v = fmt.Sprintf("[%s]", v)
|
||||||
|
}
|
||||||
table.Append([]string{
|
table.Append([]string{
|
||||||
s.Name, s.Value, s.SetBy, s.Description, fmt.Sprintf("%d", s.Count)})
|
s.Name, v, s.SetBy, s.Description, fmt.Sprintf("%d", s.Count)})
|
||||||
}
|
}
|
||||||
table.Render()
|
table.Render()
|
||||||
|
|
||||||
@@ -84,13 +95,19 @@ func (r *ListSettersRunner) runE(c *cobra.Command, args []string) error {
|
|||||||
return handleError(c, lookup(r.Lookup, c, args))
|
return handleError(c, lookup(r.Lookup, c, args))
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTable(o io.Writer) *tablewriter.Table {
|
func newTable(o io.Writer, m bool) *tablewriter.Table {
|
||||||
table := tablewriter.NewWriter(o)
|
table := tablewriter.NewWriter(o)
|
||||||
table.SetRowLine(false)
|
table.SetRowLine(false)
|
||||||
table.SetBorder(false)
|
if m {
|
||||||
table.SetHeaderLine(false)
|
// markdown format
|
||||||
table.SetColumnSeparator(" ")
|
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
|
||||||
table.SetCenterSeparator(" ")
|
table.SetCenterSeparator("|")
|
||||||
|
} else {
|
||||||
|
table.SetBorder(false)
|
||||||
|
table.SetHeaderLine(false)
|
||||||
|
table.SetColumnSeparator(" ")
|
||||||
|
table.SetCenterSeparator(" ")
|
||||||
|
}
|
||||||
table.SetAlignment(tablewriter.ALIGN_LEFT)
|
table.SetAlignment(tablewriter.ALIGN_LEFT)
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func NewSetRunner(parent string) *SetRunner {
|
|||||||
r := &SetRunner{}
|
r := &SetRunner{}
|
||||||
c := &cobra.Command{
|
c := &cobra.Command{
|
||||||
Use: "set DIR NAME [VALUE]",
|
Use: "set DIR NAME [VALUE]",
|
||||||
Args: cobra.RangeArgs(1, 3),
|
Args: cobra.MinimumNArgs(3),
|
||||||
Short: commands.SetShort,
|
Short: commands.SetShort,
|
||||||
Long: commands.SetLong,
|
Long: commands.SetLong,
|
||||||
Example: commands.SetExamples,
|
Example: commands.SetExamples,
|
||||||
@@ -94,6 +94,11 @@ func (r *SetRunner) preRunE(c *cobra.Command, args []string) error {
|
|||||||
var err error
|
var err error
|
||||||
r.Set.Name = args[1]
|
r.Set.Name = args[1]
|
||||||
r.Set.Value = args[2]
|
r.Set.Value = args[2]
|
||||||
|
|
||||||
|
// set remaining values as list values
|
||||||
|
if len(args) > 3 {
|
||||||
|
r.Set.ListValues = args[3:]
|
||||||
|
}
|
||||||
r.Set.Description = r.Perform.Description
|
r.Set.Description = r.Perform.Description
|
||||||
r.Set.SetBy = r.Perform.SetBy
|
r.Set.SetBy = r.Perform.SetBy
|
||||||
r.OpenAPIFile, err = ext.GetOpenAPIFile(args)
|
r.OpenAPIFile, err = ext.GetOpenAPIFile(args)
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ openAPI:
|
|||||||
setter:
|
setter:
|
||||||
name: replicas
|
name: replicas
|
||||||
value: "4"
|
value: "4"
|
||||||
setBy: me
|
|
||||||
`,
|
`,
|
||||||
expectedResources: `
|
expectedResources: `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"
|
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"
|
||||||
"sigs.k8s.io/kustomize/kyaml/errors"
|
"sigs.k8s.io/kustomize/kyaml/errors"
|
||||||
|
"sigs.k8s.io/kustomize/kyaml/kio/filters"
|
||||||
"sigs.k8s.io/kustomize/kyaml/runfn"
|
"sigs.k8s.io/kustomize/kyaml/runfn"
|
||||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
)
|
)
|
||||||
@@ -40,10 +41,23 @@ func GetRunFnRunner(name string) *RunFnRunner {
|
|||||||
r.Command.Flags().StringVar(
|
r.Command.Flags().StringVar(
|
||||||
&r.Image, "image", "",
|
&r.Image, "image", "",
|
||||||
"run this image as a function instead of discovering them.")
|
"run this image as a function instead of discovering them.")
|
||||||
|
r.Command.Flags().BoolVar(
|
||||||
|
&r.EnableStar, "enable-star", false, "enable support for starlark functions.")
|
||||||
|
r.Command.Flags().MarkHidden("enable-star")
|
||||||
|
r.Command.Flags().StringVar(
|
||||||
|
&r.StarPath, "star-path", "", "run a starlark script as a function.")
|
||||||
|
r.Command.Flags().MarkHidden("star-path")
|
||||||
|
r.Command.Flags().StringVar(
|
||||||
|
&r.StarName, "star-name", "", "name of starlark program.")
|
||||||
|
r.Command.Flags().MarkHidden("star-name")
|
||||||
|
|
||||||
r.Command.Flags().BoolVar(
|
r.Command.Flags().BoolVar(
|
||||||
&r.Network, "network", false, "enable network access for functions that declare it")
|
&r.Network, "network", false, "enable network access for functions that declare it")
|
||||||
r.Command.Flags().StringVar(
|
r.Command.Flags().StringVar(
|
||||||
&r.NetworkName, "network-name", "bridge", "the docker network to run the container in")
|
&r.NetworkName, "network-name", "bridge", "the docker network to run the container in")
|
||||||
|
r.Command.Flags().StringArrayVar(
|
||||||
|
&r.Mounts, "mount", []string{},
|
||||||
|
"a list of storage options read from the filesystem")
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,35 +73,74 @@ type RunFnRunner struct {
|
|||||||
GlobalScope bool
|
GlobalScope bool
|
||||||
FnPaths []string
|
FnPaths []string
|
||||||
Image string
|
Image string
|
||||||
|
EnableStar bool
|
||||||
|
StarPath string
|
||||||
|
StarName string
|
||||||
RunFns runfn.RunFns
|
RunFns runfn.RunFns
|
||||||
Network bool
|
Network bool
|
||||||
NetworkName string
|
NetworkName string
|
||||||
|
Mounts []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
|
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
|
||||||
return handleError(c, r.RunFns.Execute())
|
return handleError(c, r.RunFns.Execute())
|
||||||
}
|
}
|
||||||
|
|
||||||
// getFunctions parses the commandline flags and arguments into explicit
|
// getContainerFunctions parses the commandline flags and arguments into explicit
|
||||||
// Functions to run.
|
// Functions to run.
|
||||||
func (r *RunFnRunner) getFunctions(c *cobra.Command, args, dataItems []string) (
|
func (r *RunFnRunner) getContainerFunctions(c *cobra.Command, args, dataItems []string) (
|
||||||
[]*yaml.RNode, error) {
|
[]*yaml.RNode, error) {
|
||||||
// if image isn't specified, then Functions is empty
|
if r.Image == "" && r.StarPath == "" {
|
||||||
if r.Image == "" {
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the function spec to set as an annotation
|
var fn *yaml.RNode
|
||||||
fn, err := yaml.Parse(`container: {}`)
|
var err error
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
// if image isn't specified, then Functions is empty
|
||||||
}
|
if r.Image != "" {
|
||||||
// TODO: add support network, volumes, etc based on flag values
|
// create the function spec to set as an annotation
|
||||||
err = fn.PipeE(
|
fn, err = yaml.Parse(`container: {}`)
|
||||||
yaml.Lookup("container"),
|
if err != nil {
|
||||||
yaml.SetField("image", yaml.NewScalarRNode(r.Image)))
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
// TODO: add support network, volumes, etc based on flag values
|
||||||
|
err = fn.PipeE(
|
||||||
|
yaml.Lookup("container"),
|
||||||
|
yaml.SetField("image", yaml.NewScalarRNode(r.Image)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if r.Network {
|
||||||
|
err = fn.PipeE(
|
||||||
|
yaml.LookupCreate(yaml.MappingNode, "container", "network"),
|
||||||
|
yaml.SetField("required", yaml.NewScalarRNode("true")))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if r.EnableStar && r.StarPath != "" {
|
||||||
|
// create the function spec to set as an annotation
|
||||||
|
fn, err = yaml.Parse(`starlark: {}`)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = fn.PipeE(
|
||||||
|
yaml.Lookup("starlark"),
|
||||||
|
yaml.SetField("path", yaml.NewScalarRNode(r.StarPath)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = fn.PipeE(
|
||||||
|
yaml.Lookup("starlark"),
|
||||||
|
yaml.SetField("name", yaml.NewScalarRNode(r.StarName)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the function config
|
// create the function config
|
||||||
@@ -151,8 +204,21 @@ data: {}
|
|||||||
return []*yaml.RNode{rc}, nil
|
return []*yaml.RNode{rc}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func toStorageMounts(mounts []string) []filters.StorageMount {
|
||||||
|
var sms []filters.StorageMount
|
||||||
|
for _, mount := range mounts {
|
||||||
|
sms = append(sms, filters.StringToStorageMount(mount))
|
||||||
|
}
|
||||||
|
return sms
|
||||||
|
}
|
||||||
|
|
||||||
func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
|
func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
|
||||||
if c.ArgsLenAtDash() >= 0 && r.Image == "" {
|
if r.EnableStar != (r.StarPath != "") {
|
||||||
|
return errors.Errorf("must specify --star-path with --enable-star")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.ArgsLenAtDash() >= 0 && r.Image == "" &&
|
||||||
|
!(r.EnableStar && r.StarPath != "") {
|
||||||
return errors.Errorf("must specify --image")
|
return errors.Errorf("must specify --image")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +231,7 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
|
|||||||
return errors.Errorf("0 or 1 arguments supported, function arguments go after '--'")
|
return errors.Errorf("0 or 1 arguments supported, function arguments go after '--'")
|
||||||
}
|
}
|
||||||
|
|
||||||
fns, err := r.getFunctions(c, args, dataItems)
|
fns, err := r.getContainerFunctions(c, args, dataItems)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -187,15 +253,20 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
|
|||||||
path = args[0]
|
path = args[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse mounts to set storageMounts
|
||||||
|
storageMounts := toStorageMounts(r.Mounts)
|
||||||
|
|
||||||
r.RunFns = runfn.RunFns{
|
r.RunFns = runfn.RunFns{
|
||||||
FunctionPaths: r.FnPaths,
|
FunctionPaths: r.FnPaths,
|
||||||
GlobalScope: r.GlobalScope,
|
GlobalScope: r.GlobalScope,
|
||||||
Functions: fns,
|
Functions: fns,
|
||||||
Output: output,
|
Output: output,
|
||||||
Input: input,
|
Input: input,
|
||||||
Path: path,
|
Path: path,
|
||||||
Network: r.Network,
|
Network: r.Network,
|
||||||
NetworkName: r.NetworkName,
|
NetworkName: r.NetworkName,
|
||||||
|
EnableStarlark: r.EnableStar,
|
||||||
|
StorageMounts: storageMounts,
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't consider args for the function
|
// don't consider args for the function
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ func TestRunFnCommand_preRunE(t *testing.T) {
|
|||||||
functionPaths []string
|
functionPaths []string
|
||||||
network bool
|
network bool
|
||||||
networkName string
|
networkName string
|
||||||
|
mount []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "config map",
|
name: "config map",
|
||||||
@@ -101,7 +102,7 @@ metadata:
|
|||||||
name: function-input
|
name: function-input
|
||||||
annotations:
|
annotations:
|
||||||
config.kubernetes.io/function: |
|
config.kubernetes.io/function: |
|
||||||
container: {image: 'foo:bar'}
|
container: {image: 'foo:bar', network: {required: true}}
|
||||||
data: {}
|
data: {}
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -118,7 +119,7 @@ metadata:
|
|||||||
name: function-input
|
name: function-input
|
||||||
annotations:
|
annotations:
|
||||||
config.kubernetes.io/function: |
|
config.kubernetes.io/function: |
|
||||||
container: {image: 'foo:bar'}
|
container: {image: 'foo:bar', network: {required: true}}
|
||||||
data: {}
|
data: {}
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -154,6 +155,44 @@ kind: Foo
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "star",
|
||||||
|
args: []string{"run", "dir",
|
||||||
|
"--enable-star",
|
||||||
|
"--star-path", "a/b/c",
|
||||||
|
"--star-name", "foo",
|
||||||
|
"--", "Foo", "g=h"},
|
||||||
|
path: "dir",
|
||||||
|
expected: `
|
||||||
|
metadata:
|
||||||
|
name: function-input
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
starlark: {path: a/b/c, name: foo}
|
||||||
|
data: {g: h}
|
||||||
|
kind: Foo
|
||||||
|
apiVersion: v1
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "star-not-enabled",
|
||||||
|
args: []string{"run", "dir",
|
||||||
|
"--star-path", "a/b/c",
|
||||||
|
"--star-name", "foo",
|
||||||
|
"--", "Foo", "g=h"},
|
||||||
|
path: "dir",
|
||||||
|
err: "must specify --star-path with --enable-star",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "image-star-not-enabled",
|
||||||
|
args: []string{"run", "dir",
|
||||||
|
"--image", "some_image",
|
||||||
|
"--star-path", "a/b/c",
|
||||||
|
"--star-name", "foo",
|
||||||
|
"--", "Foo", "g=h"},
|
||||||
|
path: "dir",
|
||||||
|
err: "must specify --star-path with --enable-star",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "function paths",
|
name: "function paths",
|
||||||
args: []string{"run", "dir", "--fn-path", "path1", "--fn-path", "path2"},
|
args: []string{"run", "dir", "--fn-path", "path1", "--fn-path", "path2"},
|
||||||
@@ -175,6 +214,26 @@ metadata:
|
|||||||
data: {g: h, i: j=k}
|
data: {g: h, i: j=k}
|
||||||
kind: Foo
|
kind: Foo
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "custom kind with storage mounts",
|
||||||
|
args: []string{
|
||||||
|
"run", "dir", "--mount", "type=bind,src=/mount/path,dst=/local/",
|
||||||
|
"--mount", "type=volume,src=myvol,dst=/local/",
|
||||||
|
"--mount", "type=tmpfs,dst=/local/",
|
||||||
|
"--image", "foo:bar", "--", "Foo", "g=h", "i=j=k"},
|
||||||
|
path: "dir",
|
||||||
|
mount: []string{"type=bind,src=/mount/path,dst=/local/", "type=volume,src=myvol,dst=/local/", "type=tmpfs,dst=/local/"},
|
||||||
|
expected: `
|
||||||
|
metadata:
|
||||||
|
name: function-input
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
container: {image: 'foo:bar'}
|
||||||
|
data: {g: h, i: j=k}
|
||||||
|
kind: Foo
|
||||||
|
apiVersion: v1
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -265,6 +324,10 @@ apiVersion: v1
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !assert.Equal(t, toStorageMounts(tt.mount), r.RunFns.StorageMounts) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
// check if Functions were set
|
// check if Functions were set
|
||||||
if tt.expected != "" {
|
if tt.expected != "" {
|
||||||
if !assert.Len(t, r.RunFns.Functions, 1) {
|
if !assert.Len(t, r.RunFns.Functions, 1) {
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ List setters for Resources.
|
|||||||
var ListSettersExamples = `
|
var ListSettersExamples = `
|
||||||
Show setters:
|
Show setters:
|
||||||
|
|
||||||
$ config set DIR/
|
$ config list-setters DIR/
|
||||||
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
||||||
name-prefix '' PREFIX string 2`
|
name-prefix '' PREFIX string 2`
|
||||||
|
|
||||||
@@ -289,8 +289,8 @@ the configuration as comments.
|
|||||||
Optional. The value to set on the field.
|
Optional. The value to set on the field.
|
||||||
|
|
||||||
|
|
||||||
To print the possible setters for the Resources in a directory, run ` + "`" + `set` + "`" + ` on
|
To print the possible setters for the Resources in a directory, run
|
||||||
a directory -- e.g. ` + "`" + `kustomize config set DIR/` + "`" + `.
|
` + "`" + `list-setters` + "`" + ` on a directory -- e.g. ` + "`" + `kustomize config list-setters DIR/` + "`" + `.
|
||||||
|
|
||||||
#### Tips
|
#### Tips
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ var SetExamples = `
|
|||||||
|
|
||||||
List setters: Show the possible setters
|
List setters: Show the possible setters
|
||||||
|
|
||||||
$ config set DIR/
|
$ config list-setters DIR/
|
||||||
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
||||||
name-prefix '' PREFIX string 2
|
name-prefix '' PREFIX string 2
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ var SetExamples = `
|
|||||||
|
|
||||||
List setters: Show the new values
|
List setters: Show the new values
|
||||||
|
|
||||||
$ config set DIR/
|
$ config list-setters DIR/
|
||||||
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
NAME DESCRIPTION VALUE TYPE COUNT SETBY
|
||||||
name-prefix 'test environment' test string 2 dev
|
name-prefix 'test environment' test string 2 dev
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ cluster
|
|||||||
Resources (including configmap and secret generators)
|
Resources (including configmap and secret generators)
|
||||||
can _still be shared_ via the recommended best practice
|
can _still be shared_ via the recommended best practice
|
||||||
of placing them in a directory with their own
|
of placing them in a directory with their own
|
||||||
kustomization file, and refering to this directory as a
|
kustomization file, and referring to this directory as a
|
||||||
[`base`](glossary.md#base) from any kustomization that
|
[`base`](glossary.md#base) from any kustomization that
|
||||||
wants to use it. This encourages modularity and
|
wants to use it. This encourages modularity and
|
||||||
relocatability.
|
relocatability.
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ like adding labels or annotatations, get dedicated
|
|||||||
transformer plugins - `LabelTransformer`,
|
transformer plugins - `LabelTransformer`,
|
||||||
`AnnotationsTransformer`, etc.
|
`AnnotationsTransformer`, etc.
|
||||||
These accept relatively simple YAML configuration
|
These accept relatively simple YAML configuration
|
||||||
allowing easy targetting of any number of resources.
|
allowing easy targeting of any number of resources.
|
||||||
|
|
||||||
Another class of edits take data from one specific
|
Another class of edits take data from one specific
|
||||||
object's field and use it in another (e.g. a service
|
object's field and use it in another (e.g. a service
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ crds:
|
|||||||
Modifies behavior of all [ConfigMap](#configmapgenerator)
|
Modifies behavior of all [ConfigMap](#configmapgenerator)
|
||||||
and [Secret](#secretgenerator) generators.
|
and [Secret](#secretgenerator) generators.
|
||||||
|
|
||||||
|
Additionally, generatorOptions can be set on a per resource level within each
|
||||||
|
generator. For details on per-resource generatorOptions usage see
|
||||||
|
[field-name-configMapGenerator] and See [field-name-secretGenerator].
|
||||||
|
|
||||||
```
|
```
|
||||||
generatorOptions:
|
generatorOptions:
|
||||||
# labels to add to all generated resources
|
# labels to add to all generated resources
|
||||||
@@ -202,7 +206,7 @@ See [field-name-replicas].
|
|||||||
### resources
|
### resources
|
||||||
|
|
||||||
Each entry in this list must be a path to a
|
Each entry in this list must be a path to a
|
||||||
_file_, or a path (or URL) refering to another
|
_file_, or a path (or URL) referring to another
|
||||||
kustomization _directory_, e.g.
|
kustomization _directory_, e.g.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -273,9 +273,9 @@ more than one version).
|
|||||||
|
|
||||||
_kustomize_ is a command line tool supporting
|
_kustomize_ is a command line tool supporting
|
||||||
template-free, structured customization of declarative
|
template-free, structured customization of declarative
|
||||||
configuration targetted to k8s-style objects.
|
configuration targeted to k8s-style objects.
|
||||||
|
|
||||||
_Targetted to k8s means_ that kustomize has some
|
_Targeted to k8s means_ that kustomize has some
|
||||||
understanding of API resources, k8s concepts like
|
understanding of API resources, k8s concepts like
|
||||||
names, labels, namespaces, etc. and the semantics of
|
names, labels, namespaces, etc. and the semantics of
|
||||||
resource patching.
|
resource patching.
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ The _inventory_ ConfigMap contains two special annotations:
|
|||||||
The value of this annotation is a hash that is
|
The value of this annotation is a hash that is
|
||||||
computed from the list of items in the Inventory
|
computed from the list of items in the Inventory
|
||||||
|
|
||||||
Basically, this inventory object acts a record of objects that are applied as a group.
|
Basically, this inventory object acts as a record of objects that are applied as a group.
|
||||||
This object can be consumed by a client such as
|
This object can be consumed by a client such as
|
||||||
[cli-experimental](https://github.com/kubernetes-sigs/cli-experimental).
|
[cli-experimental](https://github.com/kubernetes-sigs/cli-experimental).
|
||||||
The client can recognize the inventory annotations and take proper actions
|
The client can recognize the inventory annotations and take proper actions
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ a YAML file containing its configuration (the file name
|
|||||||
provided in the kustomization file).
|
provided in the kustomization file).
|
||||||
|
|
||||||
> TODO: restrictions on plugin to allow the _same exec
|
> TODO: restrictions on plugin to allow the _same exec
|
||||||
> plugin_ to be targetted by both the
|
> plugin_ to be targeted by both the
|
||||||
> `generators` and `transformers` fields.
|
> `generators` and `transformers` fields.
|
||||||
>
|
>
|
||||||
> - first arg could be the fixed string
|
> - first arg could be the fixed string
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ commonAnnotations:
|
|||||||
Each entry in this list results in the creation of
|
Each entry in this list results in the creation of
|
||||||
one ConfigMap resource (it's a generator of n maps).
|
one ConfigMap resource (it's a generator of n maps).
|
||||||
|
|
||||||
The example below creates two ConfigMaps. One with the
|
The example below creates three ConfigMaps. One with the names and contents of
|
||||||
names and contents of the given files, the other with
|
the given files, one with key/value as data, and a third which sets an
|
||||||
key/value as data.
|
annotation and label via generatorOptions for that single ConfigMap.
|
||||||
|
|
||||||
Each configMapGenerator item accepts a parameter of
|
Each configMapGenerator item accepts a parameter of
|
||||||
`behavior: [create|replace|merge]`.
|
`behavior: [create|replace|merge]`.
|
||||||
@@ -109,6 +109,14 @@ configMapGenerator:
|
|||||||
literals:
|
literals:
|
||||||
- JAVA_HOME=/opt/java/jdk
|
- JAVA_HOME=/opt/java/jdk
|
||||||
- JAVA_TOOL_OPTIONS=-agentlib:hprof
|
- JAVA_TOOL_OPTIONS=-agentlib:hprof
|
||||||
|
- name: dashboards
|
||||||
|
files:
|
||||||
|
- mydashboard.json
|
||||||
|
generatorOptions:
|
||||||
|
annotations:
|
||||||
|
dashboard: "1"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: "app1"
|
||||||
```
|
```
|
||||||
|
|
||||||
It is also possible to
|
It is also possible to
|
||||||
@@ -651,6 +659,15 @@ secretGenerator:
|
|||||||
envs:
|
envs:
|
||||||
- env.txt
|
- env.txt
|
||||||
type: Opaque
|
type: Opaque
|
||||||
|
- name: secret-with-annotation
|
||||||
|
files:
|
||||||
|
- app-config.yaml
|
||||||
|
type: Opaque
|
||||||
|
generatorOptions:
|
||||||
|
annotations:
|
||||||
|
app_config: "true"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: "app2"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Usage via plugin
|
### Usage via plugin
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ a7a2589e Fix yaml in generator examples.
|
|||||||
529db049 Introduce envs field.
|
529db049 Introduce envs field.
|
||||||
6d309b52 Introduce stacked transformers.
|
6d309b52 Introduce stacked transformers.
|
||||||
abf538d8 Keep backward compatibility for image transformer
|
abf538d8 Keep backward compatibility for image transformer
|
||||||
7e12918f Keep var refernce in resources
|
7e12918f Keep var references in resources
|
||||||
7130e3ff Leave defautconfig empty for images
|
7130e3ff Leave defautconfig empty for images
|
||||||
3e85c458 Load default config for image transformer
|
3e85c458 Load default config for image transformer
|
||||||
4162dbc2 Maintain resources in order loaded.
|
4162dbc2 Maintain resources in order loaded.
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ the _kustomize Go API_.
|
|||||||
|
|
||||||
[import path]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
|
[import path]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
|
||||||
|
|
||||||
In `kustomize/v3` (and preceeding major versions), the
|
In `kustomize/v3` (and preceding major versions), the
|
||||||
kustomize program and the API live the same Go
|
kustomize program and the API live the same Go
|
||||||
module at `sigs.k8s.io/kustomize`, at [import path]
|
module at `sigs.k8s.io/kustomize`, at [import path]
|
||||||
`sigs.k8s.io/kustomize/v3`.
|
`sigs.k8s.io/kustomize/v3`.
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ commonLabels:
|
|||||||
org: acmeCorporation
|
org: acmeCorporation
|
||||||
commonAnnotations:
|
commonAnnotations:
|
||||||
note: Hello, I am staging!
|
note: Hello, I am staging!
|
||||||
resources:
|
bases:
|
||||||
- ../../base
|
- ../../base
|
||||||
patchesStrategicMerge:
|
patchesStrategicMerge:
|
||||||
- map.yaml
|
- map.yaml
|
||||||
@@ -189,7 +189,7 @@ commonLabels:
|
|||||||
org: acmeCorporation
|
org: acmeCorporation
|
||||||
commonAnnotations:
|
commonAnnotations:
|
||||||
note: Hello, I am production!
|
note: Hello, I am production!
|
||||||
resources:
|
bases:
|
||||||
- ../../base
|
- ../../base
|
||||||
patchesStrategicMerge:
|
patchesStrategicMerge:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# Demo: Inline Patch
|
# Demo: Inline Patch
|
||||||
|
|
||||||
A kustomization file supports patching in three ways:
|
A kustomization file supports patching in three ways:
|
||||||
- patchesStrategicMerge: A list of patch files where each file is parsed as a [Stragetic Merge Patch].
|
- patchesStrategicMerge: A list of patch files where each file is parsed as a [Strategic Merge Patch].
|
||||||
- patchesJSON6902: A list of patches and associated targetes, where each file is parsed as a [JSON Patch] and can only be applied to one target resource.
|
- patchesJSON6902: A list of patches and associated targetes, where each file is parsed as a [JSON Patch] and can only be applied to one target resource.
|
||||||
- patches: A list of patches and their associated targets. The patch can be applied to multiple objects. It auto detects whether the patch is a [Strategic Merge Patch] or [JSON Patch].
|
- patches: A list of patches and their associated targets. The patch can be applied to multiple objects. It auto detects whether the patch is a [Strategic Merge Patch] or [JSON Patch].
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user