mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-29 09:40:49 +00:00
Compare commits
99 Commits
api/v0.6.7
...
kustomize/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f30fea4c07 | ||
|
|
8732671919 | ||
|
|
07cada36fa | ||
|
|
0d6b232b49 | ||
|
|
61455fe489 | ||
|
|
c63ed033ad | ||
|
|
455bd0c563 | ||
|
|
9ad4b1ddca | ||
|
|
d529eb8777 | ||
|
|
f7b2f0c067 | ||
|
|
ff6b337ebe | ||
|
|
76f05f3a40 | ||
|
|
d181a73f56 | ||
|
|
979fe3b457 | ||
|
|
bec45093e2 | ||
|
|
c113c41c9c | ||
|
|
99c9edfc3d | ||
|
|
cde6a5741e | ||
|
|
a315eb56ec | ||
|
|
90654b39bf | ||
|
|
24c4c66403 | ||
|
|
2b5029952c | ||
|
|
6a3bb5df44 | ||
|
|
d9623ab307 | ||
|
|
dd1df5a30e | ||
|
|
0e13a9c02b | ||
|
|
eb26d79fa0 | ||
|
|
7f8da385c0 | ||
|
|
1426137883 | ||
|
|
d90d77cdaf | ||
|
|
1ffd790cfb | ||
|
|
454906d093 | ||
|
|
8b97274af3 | ||
|
|
b1056b43cb | ||
|
|
e411942a74 | ||
|
|
6b30b72ebc | ||
|
|
9ddf0fe304 | ||
|
|
8a952a1b26 | ||
|
|
fff484e98b | ||
|
|
e819a2ba9d | ||
|
|
4908654c09 | ||
|
|
586515ebc4 | ||
|
|
735befef19 | ||
|
|
35087ed0cc | ||
|
|
f84f8f28fd | ||
|
|
45e118458c | ||
|
|
1102153ae3 | ||
|
|
338910d36c | ||
|
|
38e9770f40 | ||
|
|
20a4153893 | ||
|
|
51fba009b3 | ||
|
|
002215d719 | ||
|
|
f9d1e800e4 | ||
|
|
82db6cd73d | ||
|
|
3c25584658 | ||
|
|
c32a809dbd | ||
|
|
02be687778 | ||
|
|
c0a754e7b0 | ||
|
|
63e441a673 | ||
|
|
bd27d5f8bb | ||
|
|
0aa250c6e2 | ||
|
|
e269ad4a80 | ||
|
|
9db6b37b88 | ||
|
|
2361b70967 | ||
|
|
d016326877 | ||
|
|
67e445c10b | ||
|
|
76970a6b05 | ||
|
|
66db1df79a | ||
|
|
6442047e52 | ||
|
|
8ac6954de1 | ||
|
|
494977b9d0 | ||
|
|
0a0a6e1018 | ||
|
|
fa69d4ba9d | ||
|
|
36bdcca735 | ||
|
|
c71a4534a0 | ||
|
|
97402f1136 | ||
|
|
1329afa3ca | ||
|
|
60c8f4c594 | ||
|
|
428e25b856 | ||
|
|
8dd6f2b185 | ||
|
|
a3bf3ba608 | ||
|
|
b97e59c57e | ||
|
|
bae3228557 | ||
|
|
cc43a2d732 | ||
|
|
d25e1effb7 | ||
|
|
485b8121d3 | ||
|
|
401118728a | ||
|
|
0f45bd9583 | ||
|
|
97e4353755 | ||
|
|
826b5d9792 | ||
|
|
8c9da15156 | ||
|
|
e18d619c9e | ||
|
|
f8a3c04286 | ||
|
|
1a4c82241a | ||
|
|
81ca271e62 | ||
|
|
72262c5e71 | ||
|
|
125762d94d | ||
|
|
0ecbd5905b | ||
|
|
cb2b376065 |
23
Makefile
23
Makefile
@@ -26,7 +26,8 @@ verify-kustomize: \
|
|||||||
lint-kustomize \
|
lint-kustomize \
|
||||||
test-unit-kustomize-all \
|
test-unit-kustomize-all \
|
||||||
test-examples-kustomize-against-HEAD \
|
test-examples-kustomize-against-HEAD \
|
||||||
test-examples-kustomize-against-3.8.6
|
test-examples-kustomize-against-3.9.0 \
|
||||||
|
test-examples-kustomize-against-3.8.8
|
||||||
|
|
||||||
# The following target referenced by a file in
|
# The following target referenced by a file in
|
||||||
# https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-sigs/kustomize
|
# https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-sigs/kustomize
|
||||||
@@ -38,7 +39,8 @@ prow-presubmit-check: \
|
|||||||
test-unit-cmd-all \
|
test-unit-cmd-all \
|
||||||
test-go-mod \
|
test-go-mod \
|
||||||
test-examples-kustomize-against-HEAD \
|
test-examples-kustomize-against-HEAD \
|
||||||
test-examples-kustomize-against-3.8.6
|
test-examples-kustomize-against-3.9.0 \
|
||||||
|
test-examples-kustomize-against-3.8.8
|
||||||
|
|
||||||
.PHONY: verify-kustomize-e2e
|
.PHONY: verify-kustomize-e2e
|
||||||
verify-kustomize-e2e: test-examples-e2e-kustomize
|
verify-kustomize-e2e: test-examples-e2e-kustomize
|
||||||
@@ -274,17 +276,12 @@ test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip
|
|||||||
./hack/testExamplesAgainstKustomize.sh HEAD
|
./hack/testExamplesAgainstKustomize.sh HEAD
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
test-examples-kustomize-against-3.8.6: $(MYGOBIN)/mdrip
|
test-examples-kustomize-against-3.9.0: $(MYGOBIN)/mdrip
|
||||||
( \
|
./hack/testExamplesAgainstKustomize.sh v3.9.0
|
||||||
set -e; \
|
|
||||||
tag=v3.8.6; \
|
.PHONY:
|
||||||
/bin/rm -f $(MYGOBIN)/kustomize; \
|
test-examples-kustomize-against-3.8.8: $(MYGOBIN)/mdrip
|
||||||
echo "Installing kustomize $$tag."; \
|
./hack/testExamplesAgainstKustomize.sh v3.8.8
|
||||||
GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3@$${tag}; \
|
|
||||||
./hack/testExamplesAgainstKustomize.sh $$tag; \
|
|
||||||
echo "Reinstalling kustomize from HEAD."; \
|
|
||||||
cd kustomize; go install .; \
|
|
||||||
)
|
|
||||||
|
|
||||||
# linux only.
|
# linux only.
|
||||||
# This is for testing an example plugin that
|
# This is for testing an example plugin that
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ package builtins
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/imdario/mergo"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
@@ -62,6 +65,9 @@ func (p *HelmChartInflationGeneratorPlugin) Config(h *resmap.PluginHelpers, conf
|
|||||||
if p.Values == "" {
|
if p.Values == "" {
|
||||||
p.Values = path.Join(p.ChartHome, p.ChartName, "values.yaml")
|
p.Values = path.Join(p.ChartHome, p.ChartName, "values.yaml")
|
||||||
}
|
}
|
||||||
|
if p.ValuesMerge == "" {
|
||||||
|
p.ValuesMerge = "override"
|
||||||
|
}
|
||||||
// runHelmCommand will run `helm` command with args provided. Return stdout
|
// runHelmCommand will run `helm` command with args provided. Return stdout
|
||||||
// and error if there is any.
|
// and error if there is any.
|
||||||
p.runHelmCommand = func(args []string) ([]byte, error) {
|
p.runHelmCommand = func(args []string) ([]byte, error) {
|
||||||
@@ -88,6 +94,63 @@ func (p *HelmChartInflationGeneratorPlugin) Config(h *resmap.PluginHelpers, conf
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EncodeValues for writing
|
||||||
|
func (p *HelmChartInflationGeneratorPlugin) EncodeValues(w io.Writer) error {
|
||||||
|
d, err := yaml.Marshal(p.ValuesLocal)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = w.Write(d)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// useValuesLocal process (merge) inflator config provided values with chart default values.yaml
|
||||||
|
func (p *HelmChartInflationGeneratorPlugin) useValuesLocal() error {
|
||||||
|
fn := path.Join(p.ChartHome, p.ChartName, "kustomize-values.yaml")
|
||||||
|
vf, err := os.Create(fn)
|
||||||
|
defer vf.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// override, merge, none
|
||||||
|
if p.ValuesMerge == "none" || p.ValuesMerge == "no" || p.ValuesMerge == "false" {
|
||||||
|
p.Values = fn
|
||||||
|
} else {
|
||||||
|
pValues, err := ioutil.ReadFile(p.Values)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
chValues := make(map[string]interface{})
|
||||||
|
err = yaml.Unmarshal(pValues, &chValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if p.ValuesMerge == "override" {
|
||||||
|
err = mergo.Merge(&chValues, p.ValuesLocal, mergo.WithOverride)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if p.ValuesMerge == "merge" {
|
||||||
|
err = mergo.Merge(&chValues, p.ValuesLocal)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.ValuesLocal = chValues
|
||||||
|
p.Values = fn
|
||||||
|
}
|
||||||
|
err = p.EncodeValues(vf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vf.Sync()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Generate implements generator
|
// Generate implements generator
|
||||||
func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
||||||
// cleanup
|
// cleanup
|
||||||
@@ -104,6 +167,15 @@ func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inflator config valuesLocal
|
||||||
|
if len(p.ValuesLocal) > 0 {
|
||||||
|
err := p.useValuesLocal()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// render the charts
|
// render the charts
|
||||||
stdout, err := p.runHelmCommand(p.getTemplateCommandArgs())
|
stdout, err := p.runHelmCommand(p.getTemplateCommandArgs())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type PatchStrategicMergeTransformerPlugin struct {
|
type PatchStrategicMergeTransformerPlugin struct {
|
||||||
h *resmap.PluginHelpers
|
|
||||||
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"`
|
||||||
@@ -21,7 +20,6 @@ type PatchStrategicMergeTransformerPlugin struct {
|
|||||||
|
|
||||||
func (p *PatchStrategicMergeTransformerPlugin) Config(
|
func (p *PatchStrategicMergeTransformerPlugin) Config(
|
||||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||||
p.h = h
|
|
||||||
err = yaml.Unmarshal(c, p)
|
err = yaml.Unmarshal(c, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -36,13 +34,13 @@ func (p *PatchStrategicMergeTransformerPlugin) Config(
|
|||||||
// All tests pass if this code is commented out. This code should
|
// All tests pass if this code is commented out. This code should
|
||||||
// be deleted; the user should use the Patches field which
|
// be deleted; the user should use the Patches field which
|
||||||
// exists for this purpose (inline patch declaration).
|
// exists for this purpose (inline patch declaration).
|
||||||
res, err := p.h.ResmapFactory().RF().SliceFromBytes([]byte(onePath))
|
res, err := h.ResmapFactory().RF().SliceFromBytes([]byte(onePath))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
p.loadedPatches = append(p.loadedPatches, res...)
|
p.loadedPatches = append(p.loadedPatches, res...)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
res, err = p.h.ResmapFactory().RF().SliceFromPatches(
|
res, err = h.ResmapFactory().RF().SliceFromPatches(
|
||||||
p.h.Loader(), []types.PatchStrategicMerge{onePath})
|
h.Loader(), []types.PatchStrategicMerge{onePath})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -50,7 +48,7 @@ func (p *PatchStrategicMergeTransformerPlugin) Config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.Patches != "" {
|
if p.Patches != "" {
|
||||||
res, err := p.h.ResmapFactory().RF().SliceFromBytes([]byte(p.Patches))
|
res, err := h.ResmapFactory().RF().SliceFromBytes([]byte(p.Patches))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -61,15 +59,17 @@ func (p *PatchStrategicMergeTransformerPlugin) Config(
|
|||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"patch appears to be empty; files=%v, Patch=%s", p.Paths, p.Patches)
|
"patch appears to be empty; files=%v, Patch=%s", p.Paths, p.Patches)
|
||||||
}
|
}
|
||||||
return err
|
// Merge the patches, looking for conflicts.
|
||||||
}
|
m, err := h.ResmapFactory().ConflatePatches(p.loadedPatches)
|
||||||
|
|
||||||
func (p *PatchStrategicMergeTransformerPlugin) Transform(m resmap.ResMap) error {
|
|
||||||
patches, err := p.h.ResmapFactory().Merge(p.loadedPatches)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, patch := range patches.Resources() {
|
p.loadedPatches = m.Resources()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PatchStrategicMergeTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||||
|
for _, patch := range p.loadedPatches {
|
||||||
target, err := m.GetById(patch.OrgId())
|
target, err := m.GetById(patch.OrgId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func TestImageTagUpdater_Filter(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
"ignore CustomResourceDefinition": {
|
"ignore CustomResourceDefinition": {
|
||||||
input: `
|
input: `
|
||||||
apiVersion: apiextensions.k8s.io/v1beta1
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: whatever
|
name: whatever
|
||||||
@@ -30,7 +30,7 @@ spec:
|
|||||||
- image: whatever
|
- image: whatever
|
||||||
`,
|
`,
|
||||||
expectedOutput: `
|
expectedOutput: `
|
||||||
apiVersion: apiextensions.k8s.io/v1beta1
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: whatever
|
name: whatever
|
||||||
|
|||||||
@@ -15,6 +15,29 @@ func TestFilter(t *testing.T) {
|
|||||||
patch *yaml.RNode
|
patch *yaml.RNode
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
|
"simple": {
|
||||||
|
input: `apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 1
|
||||||
|
`,
|
||||||
|
patch: yaml.MustParse(`apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`),
|
||||||
|
expected: `apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`,
|
||||||
|
},
|
||||||
"nullMapEntry1": {
|
"nullMapEntry1": {
|
||||||
input: `
|
input: `
|
||||||
apiVersion: example.com/v1
|
apiVersion: example.com/v1
|
||||||
|
|||||||
@@ -10,16 +10,17 @@ require (
|
|||||||
github.com/google/go-cmp v0.3.0
|
github.com/google/go-cmp v0.3.0
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||||
github.com/hashicorp/go-multierror v1.1.0
|
github.com/hashicorp/go-multierror v1.1.0
|
||||||
|
github.com/imdario/mergo v0.3.5
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
github.com/yujunz/go-getter v1.5.1-lite.0.20201201013212-6d9c071adddf
|
github.com/yujunz/go-getter v1.5.1-lite.0.20201201013212-6d9c071adddf
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
|
||||||
gopkg.in/yaml.v2 v2.3.0
|
gopkg.in/yaml.v2 v2.3.0
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
||||||
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.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
@@ -571,8 +572,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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=
|
||||||
@@ -598,8 +599,8 @@ 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/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ type Kunstructured interface {
|
|||||||
// Several uses.
|
// Several uses.
|
||||||
Copy() Kunstructured
|
Copy() Kunstructured
|
||||||
|
|
||||||
// Used by Resource.Replace, which in turn is used in many places, e.g.
|
// GetAnnotations returns the k8s annotations.
|
||||||
// - resource.Resource.Merge
|
|
||||||
// - resWrangler.appendReplaceOrMerge (AbsorbAll)
|
|
||||||
// - api.internal.k8sdeps.transformer.patch.conflictdetector
|
|
||||||
GetAnnotations() map[string]string
|
GetAnnotations() map[string]string
|
||||||
|
|
||||||
|
// GetData returns a top-level "data" field, as in a ConfigMap.
|
||||||
|
GetDataMap() map[string]string
|
||||||
|
|
||||||
// Used by ResAccumulator and ReplacementTransformer.
|
// Used by ResAccumulator and ReplacementTransformer.
|
||||||
GetFieldValue(string) (interface{}, error)
|
GetFieldValue(string) (interface{}, error)
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ type Kunstructured interface {
|
|||||||
// Used by resource.Factory.SliceFromBytes
|
// Used by resource.Factory.SliceFromBytes
|
||||||
GetKind() string
|
GetKind() string
|
||||||
|
|
||||||
// Used by Resource.Replace
|
// GetLabels returns the k8s labels.
|
||||||
GetLabels() map[string]string
|
GetLabels() map[string]string
|
||||||
|
|
||||||
// Used by Resource.CurId and resource factory.
|
// Used by Resource.CurId and resource factory.
|
||||||
@@ -84,19 +84,22 @@ type Kunstructured interface {
|
|||||||
// Used by resWrangler.Select
|
// Used by resWrangler.Select
|
||||||
MatchesLabelSelector(selector string) (bool, error)
|
MatchesLabelSelector(selector string) (bool, error)
|
||||||
|
|
||||||
// Used by Resource.Replace.
|
// SetAnnotations replaces the k8s annotations.
|
||||||
SetAnnotations(map[string]string)
|
SetAnnotations(map[string]string)
|
||||||
|
|
||||||
|
// SetDataMap sets a top-level "data" field, as in a ConfigMap.
|
||||||
|
SetDataMap(map[string]string)
|
||||||
|
|
||||||
// Used by PatchStrategicMergeTransformer.
|
// Used by PatchStrategicMergeTransformer.
|
||||||
SetGvk(resid.Gvk)
|
SetGvk(resid.Gvk)
|
||||||
|
|
||||||
// Used by Resource.Replace and used to remove "validated by" labels.
|
// SetLabels replaces the k8s labels.
|
||||||
SetLabels(map[string]string)
|
SetLabels(map[string]string)
|
||||||
|
|
||||||
// Used by Resource.Replace.
|
// SetName changes the name.
|
||||||
SetName(string)
|
SetName(string)
|
||||||
|
|
||||||
// Used by Resource.Replace.
|
// SetNamespace changes the namespace.
|
||||||
SetNamespace(string)
|
SetNamespace(string)
|
||||||
|
|
||||||
// Needed, for now, by kyaml/filtersutil.ApplyToJSON.
|
// Needed, for now, by kyaml/filtersutil.ApplyToJSON.
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ func TestNameReferenceHappyRun(t *testing.T) {
|
|||||||
"secret1",
|
"secret1",
|
||||||
"secret1",
|
"secret1",
|
||||||
"secret2",
|
"secret2",
|
||||||
|
"cm1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -420,6 +421,7 @@ func TestNameReferenceHappyRun(t *testing.T) {
|
|||||||
"someprefix-secret1-somehash",
|
"someprefix-secret1-somehash",
|
||||||
"someprefix-secret1-somehash",
|
"someprefix-secret1-somehash",
|
||||||
"secret2",
|
"secret2",
|
||||||
|
"someprefix-cm1-somehash",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,13 +41,11 @@ func (ra *ResAccumulator) Vars() []types.Var {
|
|||||||
return ra.varSet.AsSlice()
|
return ra.varSet.AsSlice()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ra *ResAccumulator) AppendAll(
|
func (ra *ResAccumulator) AppendAll(resources resmap.ResMap) error {
|
||||||
resources resmap.ResMap) error {
|
|
||||||
return ra.resMap.AppendAll(resources)
|
return ra.resMap.AppendAll(resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ra *ResAccumulator) AbsorbAll(
|
func (ra *ResAccumulator) AbsorbAll(resources resmap.ResMap) error {
|
||||||
resources resmap.ResMap) error {
|
|
||||||
return ra.resMap.AbsorbAll(resources)
|
return ra.resMap.AbsorbAll(resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ func (c *smPatchMergeOnlyDetector) HasConflict(
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There's at least one case that doesn't work. Suppose one has a
|
||||||
|
// Deployment with a volume with the bizarre "emptyDir: {}" entry.
|
||||||
|
// If you want to get rid of this entry via a patch containing
|
||||||
|
// the entry "emptyDir: null", then the following won't work,
|
||||||
|
// because null entries are eliminated.
|
||||||
func (c *smPatchMergeOnlyDetector) MergePatches(
|
func (c *smPatchMergeOnlyDetector) MergePatches(
|
||||||
r, patch *resource.Resource) (*resource.Resource, error) {
|
r, patch *resource.Resource) (*resource.Resource, error) {
|
||||||
err := r.ApplySmPatch(patch)
|
err := r.ApplySmPatch(patch)
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -511,8 +512,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -533,8 +534,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -37,10 +37,14 @@ func MakeSecret(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
t := "Opaque"
|
||||||
|
if args.Type != "" {
|
||||||
|
t = args.Type
|
||||||
|
}
|
||||||
if _, err := rn.Pipe(
|
if _, err := rn.Pipe(
|
||||||
yaml.FieldSetter{
|
yaml.FieldSetter{
|
||||||
Name: "type",
|
Name: "type",
|
||||||
Value: yaml.NewStringRNode("Opaque")}); err != nil {
|
Value: yaml.NewStringRNode(t)}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m, err := makeValidatedDataMap(ldr, args.Name, args.KvPairSources)
|
m, err := makeValidatedDataMap(ldr, args.Name, args.KvPairSources)
|
||||||
|
|||||||
@@ -122,6 +122,34 @@ data:
|
|||||||
b: eQ==
|
b: eQ==
|
||||||
c: SGVsbG8gV29ybGQ=
|
c: SGVsbG8gV29ybGQ=
|
||||||
d: dHJ1ZQ==
|
d: dHJ1ZQ==
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"construct secret with type": {
|
||||||
|
args: types.SecretArgs{
|
||||||
|
GeneratorArgs: types.GeneratorArgs{
|
||||||
|
Name: "literalSecret1",
|
||||||
|
KvPairSources: types.KvPairSources{
|
||||||
|
LiteralSources: []string{"a=x"},
|
||||||
|
},
|
||||||
|
Options: &types.GeneratorOptions{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Type: "foobar",
|
||||||
|
},
|
||||||
|
exp: expected{
|
||||||
|
out: `apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: literalSecret1
|
||||||
|
labels:
|
||||||
|
foo: 'bar'
|
||||||
|
type: foobar
|
||||||
|
data:
|
||||||
|
a: eA==
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Arbitrary, but non-infinite, timeout for running commands.
|
// Arbitrary, but non-infinite, timeout for running commands.
|
||||||
@@ -41,25 +41,18 @@ func newCmdRunner() (*gitRunner, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run a command with a timeout.
|
// run a command with a timeout.
|
||||||
func (r gitRunner) run(args ...string) (err error) {
|
func (r gitRunner) run(args ...string) error {
|
||||||
ch := make(chan bool, 1)
|
|
||||||
defer close(ch)
|
|
||||||
//nolint: gosec
|
//nolint: gosec
|
||||||
cmd := exec.Command(r.gitProgram, args...)
|
cmd := exec.Command(r.gitProgram, args...)
|
||||||
cmd.Dir = r.dir.String()
|
cmd.Dir = r.dir.String()
|
||||||
timer := time.NewTimer(r.duration)
|
return utils.TimedCall(
|
||||||
defer timer.Stop()
|
cmd.String(),
|
||||||
go func() {
|
r.duration,
|
||||||
_, err = cmd.CombinedOutput()
|
func() error {
|
||||||
ch <- true
|
_, err := cmd.CombinedOutput()
|
||||||
}()
|
if err != nil {
|
||||||
select {
|
return errors.Wrapf(err, "git cmd = '%s'", cmd.String())
|
||||||
case <-ch:
|
}
|
||||||
if err != nil {
|
return err
|
||||||
return errors.Wrapf(err, "git cmd = '%s'", cmd.String())
|
})
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case <-timer.C:
|
|
||||||
return types.NewErrTimeOut(r.duration, cmd.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Kubernetes Authors.
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package types
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
23
api/internal/utils/timedcall.go
Normal file
23
api/internal/utils/timedcall.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TimedCall runs fn, failing if it doesn't complete in the given duration.
|
||||||
|
// The description is used in the timeout error message.
|
||||||
|
func TimedCall(description string, d time.Duration, fn func() error) error {
|
||||||
|
done := make(chan error)
|
||||||
|
timer := time.NewTimer(d)
|
||||||
|
defer timer.Stop()
|
||||||
|
go func() { done <- fn() }()
|
||||||
|
select {
|
||||||
|
case err := <-done:
|
||||||
|
return err
|
||||||
|
case <-timer.C:
|
||||||
|
return NewErrTimeOut(d, description)
|
||||||
|
}
|
||||||
|
}
|
||||||
64
api/internal/utils/timedcall_test.go
Normal file
64
api/internal/utils/timedcall_test.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
// Copyright 2020 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package utils_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
. "sigs.k8s.io/kustomize/api/internal/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
timeToWait = 10 * time.Millisecond
|
||||||
|
tooSlow = 2 * timeToWait
|
||||||
|
)
|
||||||
|
|
||||||
|
func errMsg(msg string) string {
|
||||||
|
return fmt.Sprintf("hit %s timeout running '%s'", timeToWait, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTimedCallFastNoError(t *testing.T) {
|
||||||
|
err := TimedCall(
|
||||||
|
"fast no error", timeToWait,
|
||||||
|
func() error { return nil })
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTimedCallFastWithError(t *testing.T) {
|
||||||
|
err := TimedCall(
|
||||||
|
"fast with error", timeToWait,
|
||||||
|
func() error { return assert.AnError })
|
||||||
|
if assert.Error(t, err) {
|
||||||
|
assert.EqualError(t, err, assert.AnError.Error())
|
||||||
|
} else {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTimedCallSlowNoError(t *testing.T) {
|
||||||
|
err := TimedCall(
|
||||||
|
"slow no error", timeToWait,
|
||||||
|
func() error { time.Sleep(tooSlow); return nil })
|
||||||
|
if assert.Error(t, err) {
|
||||||
|
assert.EqualError(t, err, errMsg("slow no error"))
|
||||||
|
} else {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTimedCallSlowWithError(t *testing.T) {
|
||||||
|
err := TimedCall(
|
||||||
|
"slow with error", timeToWait,
|
||||||
|
func() error { time.Sleep(tooSlow); return assert.AnError })
|
||||||
|
if assert.Error(t, err) {
|
||||||
|
assert.EqualError(t, err, errMsg("slow with error"))
|
||||||
|
} else {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,8 +91,8 @@ func (wn *WNode) GetFieldValue(path string) (interface{}, error) {
|
|||||||
// Return value as slice for SequenceNode kind
|
// Return value as slice for SequenceNode kind
|
||||||
if yn.Kind == yaml.SequenceNode {
|
if yn.Kind == yaml.SequenceNode {
|
||||||
var result []interface{}
|
var result []interface{}
|
||||||
for _, node := range yn.Content {
|
if err := yn.Decode(&result); err != nil {
|
||||||
result = append(result, node.Value)
|
return nil, err
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -108,6 +108,16 @@ func (wn *WNode) GetGvk() resid.Gvk {
|
|||||||
return resid.Gvk{Group: g, Version: v, Kind: meta.Kind}
|
return resid.Gvk{Group: g, Version: v, Kind: meta.Kind}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDataMap implements ifc.Kunstructured.
|
||||||
|
func (wn *WNode) GetDataMap() map[string]string {
|
||||||
|
return wn.node.GetDataMap()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDataMap implements ifc.Kunstructured.
|
||||||
|
func (wn *WNode) SetDataMap(m map[string]string) {
|
||||||
|
wn.node.SetDataMap(m)
|
||||||
|
}
|
||||||
|
|
||||||
// GetKind implements ifc.Kunstructured.
|
// GetKind implements ifc.Kunstructured.
|
||||||
func (wn *WNode) GetKind() string {
|
func (wn *WNode) GetKind() string {
|
||||||
return wn.demandMetaData("GetKind").Kind
|
return wn.demandMetaData("GetKind").Kind
|
||||||
@@ -182,9 +192,7 @@ func (wn *WNode) SetAnnotations(annotations map[string]string) {
|
|||||||
// SetGvk implements ifc.Kunstructured.
|
// SetGvk implements ifc.Kunstructured.
|
||||||
func (wn *WNode) SetGvk(gvk resid.Gvk) {
|
func (wn *WNode) SetGvk(gvk resid.Gvk) {
|
||||||
wn.setMapField(yaml.NewScalarRNode(gvk.Kind), yaml.KindField)
|
wn.setMapField(yaml.NewScalarRNode(gvk.Kind), yaml.KindField)
|
||||||
wn.setMapField(
|
wn.setMapField(yaml.NewScalarRNode(gvk.ApiVersion()), yaml.APIVersionField)
|
||||||
yaml.NewScalarRNode(
|
|
||||||
fmt.Sprintf("%s/%s", gvk.Group, gvk.Version)), yaml.APIVersionField)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLabels implements ifc.Kunstructured.
|
// SetLabels implements ifc.Kunstructured.
|
||||||
|
|||||||
@@ -377,6 +377,39 @@ func TestGetFieldValueReturnsSlice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetFieldValueReturnsSliceOfMappings(t *testing.T) {
|
||||||
|
bytes, err := yaml.Marshal(makeBigMap())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected yaml.Marshal err: %v", err)
|
||||||
|
}
|
||||||
|
rNode, err := kyaml.Parse(string(bytes))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected yaml.Marshal err: %v", err)
|
||||||
|
}
|
||||||
|
wn := FromRNode(rNode)
|
||||||
|
expected := []interface{}{
|
||||||
|
map[string]interface{}{
|
||||||
|
"field1": "idx0foo",
|
||||||
|
"field2": "idx0bar",
|
||||||
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"field1": "idx1foo",
|
||||||
|
"field2": "idx1bar",
|
||||||
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"field1": "idx2foo",
|
||||||
|
"field2": "idx2bar",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
actual, err := wn.GetFieldValue("those")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error getting slice: %v", err)
|
||||||
|
}
|
||||||
|
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||||
|
t.Fatalf("actual slice does not deep equal expected slice:\n%v", diff)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetFieldValueReturnsString(t *testing.T) {
|
func TestGetFieldValueReturnsString(t *testing.T) {
|
||||||
wn := NewWNode()
|
wn := NewWNode()
|
||||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package kunstruct
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -249,6 +250,29 @@ func (fs *UnstructAdapter) GetStringMap(path string) (map[string]string, error)
|
|||||||
return nil, NoFieldError{Field: path}
|
return nil, NoFieldError{Field: path}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fs *UnstructAdapter) GetDataMap() map[string]string {
|
||||||
|
m, err := fs.GetStringMap("data")
|
||||||
|
if err != nil {
|
||||||
|
return map[string]string{}
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fs *UnstructAdapter) SetDataMap(m map[string]string) {
|
||||||
|
if m == nil {
|
||||||
|
unstructured.RemoveNestedField(fs.Object, "data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s := make(map[string]interface{}, len(m))
|
||||||
|
for i, v := range m {
|
||||||
|
s[i] = v
|
||||||
|
}
|
||||||
|
err := unstructured.SetNestedMap(fs.Object, s, "data")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ package kunstruct
|
|||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var kunstructured = NewKunstructuredFactoryImpl().FromMap(map[string]interface{}{
|
var kunstructured = NewKunstructuredFactoryImpl().FromMap(map[string]interface{}{
|
||||||
@@ -557,3 +559,139 @@ func compareValues(t *testing.T, name string, pathToField string, expectedValue
|
|||||||
t.Logf("%T value at `%s`", typedV, pathToField)
|
t.Logf("%T value at `%s`", typedV, pathToField)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestKunstGetDataMap(t *testing.T) {
|
||||||
|
emptyMap := map[string]string{}
|
||||||
|
testCases := map[string]struct {
|
||||||
|
theMap map[string]interface{}
|
||||||
|
expected map[string]string
|
||||||
|
}{
|
||||||
|
"actuallyNil": {
|
||||||
|
theMap: nil,
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"empty": {
|
||||||
|
theMap: map[string]interface{}{},
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"mostlyEmpty": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"hey": "there",
|
||||||
|
},
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"noNameConfigMap": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "ConfigMap",
|
||||||
|
},
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"configMap": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "ConfigMap",
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"name": "winnie",
|
||||||
|
},
|
||||||
|
"data": map[string]interface{}{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
"city": "brownsville",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// order irrelevant, because assert.Equals is smart about maps.
|
||||||
|
expected: map[string]string{
|
||||||
|
"city": "brownsville",
|
||||||
|
"wine": "cabernet",
|
||||||
|
"planet": "mars",
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for n := range testCases {
|
||||||
|
tc := testCases[n]
|
||||||
|
t.Run(n, func(t *testing.T) {
|
||||||
|
kunstr := NewKunstructuredFactoryImpl().FromMap(tc.theMap)
|
||||||
|
m := kunstr.GetDataMap()
|
||||||
|
if !assert.Equal(t, tc.expected, m) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKunstSetDataMap(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
theMap map[string]interface{}
|
||||||
|
input map[string]string
|
||||||
|
expected map[string]string
|
||||||
|
}{
|
||||||
|
"empty": {
|
||||||
|
theMap: map[string]interface{}{},
|
||||||
|
input: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
expected: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"replace": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"foo": 3,
|
||||||
|
"data": map[string]string{
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
expected: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"clear1": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"foo": 3,
|
||||||
|
"data": map[string]string{
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input: map[string]string{},
|
||||||
|
expected: map[string]string{},
|
||||||
|
},
|
||||||
|
"clear2": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"foo": 3,
|
||||||
|
"data": map[string]string{
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input: nil,
|
||||||
|
expected: map[string]string{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for n := range testCases {
|
||||||
|
tc := testCases[n]
|
||||||
|
t.Run(n, func(t *testing.T) {
|
||||||
|
kunstr := NewKunstructuredFactoryImpl().FromMap(tc.theMap)
|
||||||
|
kunstr.SetDataMap(tc.input)
|
||||||
|
m := kunstr.GetDataMap()
|
||||||
|
if !assert.Equal(t, tc.expected, m) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ commonLabels:
|
|||||||
group: apps
|
group: apps
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
||||||
|
- path: spec/template/spec/topologySpreadConstraints/labelSelector/matchLabels
|
||||||
|
create: false
|
||||||
|
group: apps
|
||||||
|
kind: Deployment
|
||||||
|
|
||||||
- path: spec/selector/matchLabels
|
- path: spec/selector/matchLabels
|
||||||
create: true
|
create: true
|
||||||
kind: ReplicaSet
|
kind: ReplicaSet
|
||||||
@@ -97,6 +102,11 @@ commonLabels:
|
|||||||
group: apps
|
group: apps
|
||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/topologySpreadConstraints/labelSelector/matchLabels
|
||||||
|
create: false
|
||||||
|
group: apps
|
||||||
|
kind: StatefulSet
|
||||||
|
|
||||||
- path: spec/volumeClaimTemplates[]/metadata/labels
|
- path: spec/volumeClaimTemplates[]/metadata/labels
|
||||||
create: true
|
create: true
|
||||||
group: apps
|
group: apps
|
||||||
|
|||||||
@@ -121,6 +121,10 @@ nameReference:
|
|||||||
kind: CronJob
|
kind: CronJob
|
||||||
- path: spec/configSource/configMap
|
- path: spec/configSource/configMap
|
||||||
kind: Node
|
kind: Node
|
||||||
|
- path: rules/resourceNames
|
||||||
|
kind: Role
|
||||||
|
- path: rules/resourceNames
|
||||||
|
kind: ClusterRole
|
||||||
|
|
||||||
- kind: Secret
|
- kind: Secret
|
||||||
version: v1
|
version: v1
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ resources:
|
|||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
literals:
|
literals:
|
||||||
- testValue=1
|
- testValue=purple
|
||||||
- otherValue=10
|
- otherValue=green
|
||||||
`)
|
`)
|
||||||
th.WriteF("/app/base/deploy.yaml", `
|
th.WriteF("/app/base/deploy.yaml", `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -64,8 +64,8 @@ configMapGenerator:
|
|||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- testValue=2
|
- testValue=blue
|
||||||
- compValue=5
|
- compValue=red
|
||||||
`)
|
`)
|
||||||
th.WriteF("/app/comp/stub.yaml", `
|
th.WriteF("/app/comp/stub.yaml", `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -125,14 +125,12 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
compValue: "5"
|
compValue: red
|
||||||
otherValue: "10"
|
otherValue: green
|
||||||
testValue: "2"
|
testValue: blue
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: comp-my-configmap-97647ckcmg
|
||||||
labels: {}
|
|
||||||
name: comp-my-configmap-kc6k2kmkh9
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -156,7 +154,7 @@ configMapGenerator:
|
|||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- otherValue=9
|
- otherValue=orange
|
||||||
`),
|
`),
|
||||||
writeK("/app/prod", `
|
writeK("/app/prod", `
|
||||||
resources:
|
resources:
|
||||||
@@ -179,14 +177,12 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
compValue: "5"
|
compValue: red
|
||||||
otherValue: "9"
|
otherValue: orange
|
||||||
testValue: "2"
|
testValue: blue
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: comp-my-configmap-g486mb229k
|
||||||
labels: {}
|
|
||||||
name: comp-my-configmap-55249mf5kb
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -212,7 +208,7 @@ configMapGenerator:
|
|||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- otherValue=9
|
- otherValue=orange
|
||||||
`),
|
`),
|
||||||
writeK("/app/prod", `
|
writeK("/app/prod", `
|
||||||
resources:
|
resources:
|
||||||
@@ -234,14 +230,12 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
compValue: "5"
|
compValue: red
|
||||||
otherValue: "9"
|
otherValue: orange
|
||||||
testValue: "2"
|
testValue: blue
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: comp-my-configmap-g486mb229k
|
||||||
labels: {}
|
|
||||||
name: comp-my-configmap-55249mf5kb
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -279,11 +273,11 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
otherValue: "10"
|
otherValue: green
|
||||||
testValue: "1"
|
testValue: purple
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: my-configmap-2g9c94mhb8
|
name: my-configmap-9cd648hm8f
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -294,14 +288,12 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
compValue: "5"
|
compValue: red
|
||||||
otherValue: "10"
|
otherValue: green
|
||||||
testValue: "2"
|
testValue: blue
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: comp-my-configmap-97647ckcmg
|
||||||
labels: {}
|
|
||||||
name: comp-my-configmap-kc6k2kmkh9
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -327,8 +319,8 @@ configMapGenerator:
|
|||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- compValue=5
|
- compValue=red
|
||||||
- testValue=2
|
- testValue=blue
|
||||||
`),
|
`),
|
||||||
},
|
},
|
||||||
runPath: "/app/direct-component",
|
runPath: "/app/direct-component",
|
||||||
@@ -342,14 +334,12 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
compValue: "5"
|
compValue: red
|
||||||
otherValue: "10"
|
otherValue: green
|
||||||
testValue: "2"
|
testValue: blue
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: my-configmap-97647ckcmg
|
||||||
labels: {}
|
|
||||||
name: my-configmap-kc6k2kmkh9
|
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
"missing-optional-component-api-version": {
|
"missing-optional-component-api-version": {
|
||||||
@@ -360,7 +350,7 @@ configMapGenerator:
|
|||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- otherValue=9
|
- otherValue=orange
|
||||||
`),
|
`),
|
||||||
},
|
},
|
||||||
runPath: "/app/prod",
|
runPath: "/app/prod",
|
||||||
@@ -374,13 +364,11 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
otherValue: "9"
|
otherValue: orange
|
||||||
testValue: "1"
|
testValue: purple
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: my-configmap-6hhdg8gkdg
|
||||||
labels: {}
|
|
||||||
name: my-configmap-5g7gh5mgt5
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -423,11 +411,11 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
otherValue: "10"
|
otherValue: green
|
||||||
testValue: "1"
|
testValue: purple
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: my-configmap-a-b-2g9c94mhb8
|
name: my-configmap-a-b-9cd648hm8f
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -438,11 +426,11 @@ spec:
|
|||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
otherValue: "10"
|
otherValue: green
|
||||||
testValue: "1"
|
testValue: purple
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: my-configmap-b-2g9c94mhb8
|
name: my-configmap-b-9cd648hm8f
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -574,7 +562,7 @@ configMapGenerator:
|
|||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- otherValue=9
|
- otherValue=orange
|
||||||
`),
|
`),
|
||||||
},
|
},
|
||||||
runPath: "/app/prod",
|
runPath: "/app/prod",
|
||||||
|
|||||||
@@ -4,11 +4,100 @@
|
|||||||
package krusty_test
|
package krusty_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Numbers and booleans are quoted
|
||||||
|
func TestGeneratorIntVsStringNoMerge(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK(".", `
|
||||||
|
resources:
|
||||||
|
- service.yaml
|
||||||
|
configMapGenerator:
|
||||||
|
- name: bob
|
||||||
|
literals:
|
||||||
|
- fruit=Indian Gooseberry
|
||||||
|
- year=2020
|
||||||
|
- crisis=true
|
||||||
|
`)
|
||||||
|
th.WriteF("service.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
port: 8080
|
||||||
|
happy: true
|
||||||
|
color: green
|
||||||
|
name: demo
|
||||||
|
spec:
|
||||||
|
clusterIP: None
|
||||||
|
`)
|
||||||
|
m := th.Run(".", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(
|
||||||
|
m, `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
color: green
|
||||||
|
happy: true
|
||||||
|
port: 8080
|
||||||
|
name: demo
|
||||||
|
spec:
|
||||||
|
clusterIP: None
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
crisis: "true"
|
||||||
|
fruit: Indian Gooseberry
|
||||||
|
year: "2020"
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: bob-79t79mt227
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Observation: Numbers no longer quoted
|
||||||
|
func TestGeneratorIntVsStringWithMerge(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK("base", `
|
||||||
|
configMapGenerator:
|
||||||
|
- name: bob
|
||||||
|
literals:
|
||||||
|
- fruit=Indian Gooseberry
|
||||||
|
- year=2020
|
||||||
|
- crisis=true
|
||||||
|
`)
|
||||||
|
th.WriteK("overlay", `
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
|
configMapGenerator:
|
||||||
|
- name: bob
|
||||||
|
behavior: merge
|
||||||
|
literals:
|
||||||
|
- month=12
|
||||||
|
`)
|
||||||
|
opts := th.MakeDefaultOptions()
|
||||||
|
m := th.Run("overlay", opts)
|
||||||
|
expFmt := `apiVersion: v1
|
||||||
|
data:
|
||||||
|
crisis: %s
|
||||||
|
fruit: Indian Gooseberry
|
||||||
|
month: %s
|
||||||
|
year: %s
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: bob-%s
|
||||||
|
`
|
||||||
|
th.AssertActualEqualsExpected(
|
||||||
|
m, opts.IfApiMachineryElseKyaml(
|
||||||
|
fmt.Sprintf(expFmt, `"true"`, `"12"`, `"2020"`, `bk46gm59c6`),
|
||||||
|
fmt.Sprintf(expFmt, `true`, `12`, `2020`, `bkmtk2t2fb`)))
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a Secret and a ConfigMap from the same data
|
// Generate a Secret and a ConfigMap from the same data
|
||||||
// to compare the result.
|
// to compare the result.
|
||||||
func TestGeneratorBasics(t *testing.T) {
|
func TestGeneratorBasics(t *testing.T) {
|
||||||
@@ -59,10 +148,9 @@ electromagnetic
|
|||||||
strong nuclear
|
strong nuclear
|
||||||
weak nuclear
|
weak nuclear
|
||||||
`)
|
`)
|
||||||
|
opts := th.MakeDefaultOptions()
|
||||||
m := th.Run("/app", th.MakeDefaultOptions())
|
m := th.Run("/app", opts)
|
||||||
th.AssertActualEqualsExpected(m, `
|
expFmt := `apiVersion: v1
|
||||||
apiVersion: v1
|
|
||||||
data:
|
data:
|
||||||
MOUNTAIN: everest
|
MOUNTAIN: everest
|
||||||
OCEAN: pacific
|
OCEAN: pacific
|
||||||
@@ -95,15 +183,26 @@ apiVersion: v1
|
|||||||
data:
|
data:
|
||||||
MOUNTAIN: ZXZlcmVzdA==
|
MOUNTAIN: ZXZlcmVzdA==
|
||||||
OCEAN: cGFjaWZpYw==
|
OCEAN: cGFjaWZpYw==
|
||||||
forces.txt: CmdyYXZpdGF0aW9uYWwKZWxlY3Ryb21hZ25ldGljCnN0cm9uZyBudWNsZWFyCndlYWsgbnVjbGVhcgo=
|
forces.txt: %s
|
||||||
fruit: YXBwbGU=
|
fruit: YXBwbGU=
|
||||||
passphrase: CkxpZmUgaXMgc2hvcnQuCkJ1dCB0aGUgeWVhcnMgYXJlIGxvbmcuCk5vdCB3aGlsZSB0aGUgZXZpbCBkYXlzIGNvbWUgbm90Lgo=
|
passphrase: %s
|
||||||
vegetable: YnJvY2NvbGk=
|
vegetable: YnJvY2NvbGk=
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: blah-bob-ftht6hfgmb
|
name: blah-bob-%s
|
||||||
type: Opaque
|
type: Opaque
|
||||||
`)
|
`
|
||||||
|
th.AssertActualEqualsExpected(
|
||||||
|
m, opts.IfApiMachineryElseKyaml(
|
||||||
|
fmt.Sprintf(expFmt,
|
||||||
|
`CmdyYXZpdGF0aW9uYWwKZWxlY3Ryb21hZ25ldGljCnN0cm9uZyBudWNsZWFyCndlYWsgbnVjbGVhcgo=`,
|
||||||
|
`CkxpZmUgaXMgc2hvcnQuCkJ1dCB0aGUgeWVhcnMgYXJlIGxvbmcuCk5vdCB3aGlsZSB0aGUgZXZpbCBkYXlzIGNvbWUgbm90Lgo=`,
|
||||||
|
`ftht6hfgmb`),
|
||||||
|
fmt.Sprintf(expFmt, `|
|
||||||
|
CmdyYXZpdGF0aW9uYWwKZWxlY3Ryb21hZ25ldGljCnN0cm9uZyBudWNsZWFyCndlYWsgbn
|
||||||
|
VjbGVhcgo=`, `|
|
||||||
|
CkxpZmUgaXMgc2hvcnQuCkJ1dCB0aGUgeWVhcnMgYXJlIGxvbmcuCk5vdCB3aGlsZSB0aG
|
||||||
|
UgZXZpbCBkYXlzIGNvbWUgbm90Lgo=`, `9t25t44gg4`)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: These should be errors instead.
|
// TODO: These should be errors instead.
|
||||||
@@ -159,6 +258,68 @@ metadata:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue3393(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK(".", `
|
||||||
|
resources:
|
||||||
|
- cm.yaml
|
||||||
|
configMapGenerator:
|
||||||
|
- name: project
|
||||||
|
behavior: merge
|
||||||
|
literals:
|
||||||
|
- ANOTHER_ENV_VARIABLE="bar"
|
||||||
|
`)
|
||||||
|
th.WriteF("cm.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: project
|
||||||
|
data:
|
||||||
|
A_FIRST_ENV_VARIABLE: "foo"
|
||||||
|
`)
|
||||||
|
m := th.Run(".", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
A_FIRST_ENV_VARIABLE: foo
|
||||||
|
ANOTHER_ENV_VARIABLE: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: project
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGeneratorSimpleOverlay(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK("base", `
|
||||||
|
namePrefix: p-
|
||||||
|
configMapGenerator:
|
||||||
|
- name: cm
|
||||||
|
behavior: create
|
||||||
|
literals:
|
||||||
|
- fruit=apple
|
||||||
|
`)
|
||||||
|
th.WriteK("overlay", `
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
|
configMapGenerator:
|
||||||
|
- name: cm
|
||||||
|
behavior: merge
|
||||||
|
literals:
|
||||||
|
- veggie=broccoli
|
||||||
|
`)
|
||||||
|
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
fruit: apple
|
||||||
|
veggie: broccoli
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: p-cm-877mt5hc89
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
func TestGeneratorOverlays(t *testing.T) {
|
func TestGeneratorOverlays(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
th.WriteK("/app/base1", `
|
th.WriteK("/app/base1", `
|
||||||
@@ -215,8 +376,6 @@ data:
|
|||||||
from: overlay
|
from: overlay
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
|
||||||
labels: {}
|
|
||||||
name: p1-com1-8tc62428t2
|
name: p1-com1-8tc62428t2
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -224,8 +383,6 @@ data:
|
|||||||
from: overlay
|
from: overlay
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
|
||||||
labels: {}
|
|
||||||
name: p2-com2-87mcggf7d7
|
name: p2-com2-87mcggf7d7
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
@@ -272,8 +429,6 @@ data:
|
|||||||
foo: bar
|
foo: bar
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
|
||||||
labels: {}
|
|
||||||
name: o1-cm-ft9mmdc8c6
|
name: o1-cm-ft9mmdc8c6
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -282,8 +437,6 @@ data:
|
|||||||
foo: bar
|
foo: bar
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
|
||||||
labels: {}
|
|
||||||
name: cm-o2-5k95kd76ft
|
name: cm-o2-5k95kd76ft
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ spec:
|
|||||||
action: fly
|
action: fly
|
||||||
`)
|
`)
|
||||||
th.WriteF("/app/base/mykind.yaml", `
|
th.WriteF("/app/base/mykind.yaml", `
|
||||||
apiVersion: jingfang.example.com/v1beta1
|
apiVersion: jingfang.example.com/v1
|
||||||
kind: MyKind
|
kind: MyKind
|
||||||
metadata:
|
metadata:
|
||||||
name: mykind
|
name: mykind
|
||||||
@@ -236,7 +236,7 @@ kind: Secret
|
|||||||
metadata:
|
metadata:
|
||||||
name: x-crdsecret
|
name: x-crdsecret
|
||||||
---
|
---
|
||||||
apiVersion: jingfang.example.com/v1beta1
|
apiVersion: jingfang.example.com/v1
|
||||||
kind: MyKind
|
kind: MyKind
|
||||||
metadata:
|
metadata:
|
||||||
name: x-mykind
|
name: x-mykind
|
||||||
@@ -285,7 +285,7 @@ kind: Secret
|
|||||||
metadata:
|
metadata:
|
||||||
name: prod-x-crdsecret
|
name: prod-x-crdsecret
|
||||||
---
|
---
|
||||||
apiVersion: jingfang.example.com/v1beta1
|
apiVersion: jingfang.example.com/v1
|
||||||
kind: MyKind
|
kind: MyKind
|
||||||
metadata:
|
metadata:
|
||||||
name: prod-x-mykind
|
name: prod-x-mykind
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package krusty_test
|
package krusty_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -128,8 +129,9 @@ stringData:
|
|||||||
bootcmd:
|
bootcmd:
|
||||||
- mkdir /mnt/vda
|
- mkdir /mnt/vda
|
||||||
`)
|
`)
|
||||||
m := th.Run("/app", th.MakeOptionsPluginsEnabled())
|
opts := th.MakeOptionsPluginsEnabled()
|
||||||
th.AssertActualEqualsExpected(m, `
|
m := th.Run("/app", opts)
|
||||||
|
expFmt := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
@@ -152,7 +154,7 @@ metadata:
|
|||||||
name: demo
|
name: demo
|
||||||
name: demo-budget
|
name: demo-budget
|
||||||
spec:
|
spec:
|
||||||
minAvailable: 67%
|
minAvailable: 67%%
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: cockroachdb
|
app: cockroachdb
|
||||||
@@ -185,9 +187,7 @@ metadata:
|
|||||||
annotations:
|
annotations:
|
||||||
config.kubernetes.io/path: config/demo_service.yaml
|
config.kubernetes.io/path: config/demo_service.yaml
|
||||||
prometheus.io/path: _status/vars
|
prometheus.io/path: _status/vars
|
||||||
prometheus.io/port: "8080"
|
%s
|
||||||
prometheus.io/scrape: "true"
|
|
||||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
|
||||||
labels:
|
labels:
|
||||||
app: cockroachdb
|
app: cockroachdb
|
||||||
name: demo
|
name: demo
|
||||||
@@ -244,7 +244,7 @@ spec:
|
|||||||
- /bin/bash
|
- /bin/bash
|
||||||
- -ecx
|
- -ecx
|
||||||
- |
|
- |
|
||||||
# The use of qualified `+"`hostname -f`"+` is crucial:
|
# The use of qualified ` + "`hostname -f`" + ` is crucial:
|
||||||
# Other nodes aren't able to look up the unqualified hostname.
|
# Other nodes aren't able to look up the unqualified hostname.
|
||||||
CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0")
|
CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0")
|
||||||
# We only want to initialize a new cluster (by omitting the join flag)
|
# We only want to initialize a new cluster (by omitting the join flag)
|
||||||
@@ -302,7 +302,14 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 1Gi
|
storage: 1Gi
|
||||||
`)
|
`
|
||||||
|
th.AssertActualEqualsExpected(m, opts.IfApiMachineryElseKyaml(
|
||||||
|
fmt.Sprintf(expFmt, ` prometheus.io/port: "8080"
|
||||||
|
prometheus.io/scrape: "true"
|
||||||
|
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"`),
|
||||||
|
fmt.Sprintf(expFmt, ` prometheus.io/port: 8080
|
||||||
|
prometheus.io/scrape: true
|
||||||
|
service.alpha.kubernetes.io/tolerate-unready-endpoints: true`)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFnContainerTransformer(t *testing.T) {
|
func TestFnContainerTransformer(t *testing.T) {
|
||||||
|
|||||||
@@ -4,12 +4,333 @@
|
|||||||
package krusty_test
|
package krusty_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestRemoveEmptyDirWithNullFieldInSmp(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK(".", `
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch.yaml
|
||||||
|
`)
|
||||||
|
th.WriteF("deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
emptyDir: {}
|
||||||
|
`)
|
||||||
|
th.WriteF("patch.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
emptyDir: null
|
||||||
|
`)
|
||||||
|
m := th.Run(".", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRemoveEmptyDirAddPersistentDisk(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK(".", `
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch.yaml
|
||||||
|
`)
|
||||||
|
th.WriteF("deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
emptyDir: {}
|
||||||
|
`)
|
||||||
|
th.WriteF("patch.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
emptyDir: null
|
||||||
|
gcePersistentDisk:
|
||||||
|
pdName: fancyDisk
|
||||||
|
`)
|
||||||
|
m := th.Run(".", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- gcePersistentDisk:
|
||||||
|
pdName: fancyDisk
|
||||||
|
name: fancyDisk
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestVolumeRemoveEmptyDirInOverlay(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK("base", `
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
configMapGenerator:
|
||||||
|
- name: baseCm
|
||||||
|
literals:
|
||||||
|
- foo=bar
|
||||||
|
`)
|
||||||
|
th.WriteF("base/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- name: fancyDisk
|
||||||
|
mountPath: /tmp/ps
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
emptyDir: {}
|
||||||
|
- configMap:
|
||||||
|
name: baseCm
|
||||||
|
name: baseCm
|
||||||
|
`)
|
||||||
|
m := th.Run("base", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /tmp/ps
|
||||||
|
name: fancyDisk
|
||||||
|
volumes:
|
||||||
|
- emptyDir: {}
|
||||||
|
name: fancyDisk
|
||||||
|
- configMap:
|
||||||
|
name: baseCm-798k5k7g9f
|
||||||
|
name: baseCm
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: baseCm-798k5k7g9f
|
||||||
|
`)
|
||||||
|
|
||||||
|
th.WriteK("overlay", `
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch.yaml
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
|
configMapGenerator:
|
||||||
|
- name: overlayCm
|
||||||
|
literals:
|
||||||
|
- hello=world
|
||||||
|
`)
|
||||||
|
th.WriteF("overlay/patch.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: fancyDisk
|
||||||
|
emptyDir: null
|
||||||
|
gcePersistentDisk:
|
||||||
|
pdName: fancyDisk
|
||||||
|
- configMap:
|
||||||
|
name: overlayCm
|
||||||
|
name: overlayCm
|
||||||
|
`)
|
||||||
|
m = th.Run("overlay", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /tmp/ps
|
||||||
|
name: fancyDisk
|
||||||
|
volumes:
|
||||||
|
- gcePersistentDisk:
|
||||||
|
pdName: fancyDisk
|
||||||
|
name: fancyDisk
|
||||||
|
- configMap:
|
||||||
|
name: overlayCm-dc6fm46dhm
|
||||||
|
name: overlayCm
|
||||||
|
- configMap:
|
||||||
|
name: baseCm-798k5k7g9f
|
||||||
|
name: baseCm
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: baseCm-798k5k7g9f
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
hello: world
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: overlayCm-dc6fm46dhm
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRemoveEmptyDirWithPatchesAtSameLevel(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK("base", `
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
`)
|
||||||
|
th.WriteF("base/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
- name: sidecar
|
||||||
|
image: sidecar:latest
|
||||||
|
volumes:
|
||||||
|
- name: nginx-persistent-storage
|
||||||
|
emptyDir: {}
|
||||||
|
`)
|
||||||
|
th.WriteK("overlay", `
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- deployment-patch1.yaml
|
||||||
|
- deployment-patch2.yaml
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
|
`)
|
||||||
|
th.WriteF("overlay/deployment-patch1.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: nginx-persistent-storage
|
||||||
|
emptyDir: null
|
||||||
|
gcePersistentDisk:
|
||||||
|
pdName: nginx-persistent-storage
|
||||||
|
`)
|
||||||
|
th.WriteF("overlay/deployment-patch2.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
env:
|
||||||
|
- name: ANOTHERENV
|
||||||
|
value: FOO
|
||||||
|
volumes:
|
||||||
|
- name: nginx-persistent-storage
|
||||||
|
`)
|
||||||
|
opts := th.MakeDefaultOptions()
|
||||||
|
m := th.Run("overlay", opts)
|
||||||
|
expFmt := `apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: ANOTHERENV
|
||||||
|
value: FOO
|
||||||
|
image: nginx
|
||||||
|
name: nginx
|
||||||
|
- image: sidecar:latest
|
||||||
|
name: sidecar
|
||||||
|
volumes:%s
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
`
|
||||||
|
// TODO(#3394)
|
||||||
|
th.AssertActualEqualsExpected(
|
||||||
|
m, opts.IfApiMachineryElseKyaml(
|
||||||
|
fmt.Sprintf(expFmt, `
|
||||||
|
- gcePersistentDisk:
|
||||||
|
pdName: nginx-persistent-storage`),
|
||||||
|
fmt.Sprintf(expFmt, `
|
||||||
|
- emptyDir: {}
|
||||||
|
gcePersistentDisk:
|
||||||
|
pdName: nginx-persistent-storage`),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
func TestSimpleMultiplePatches(t *testing.T) {
|
func TestSimpleMultiplePatches(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
th.WriteK("base", `
|
th.WriteK("base", `
|
||||||
@@ -41,8 +362,6 @@ spec:
|
|||||||
- name: sidecar
|
- name: sidecar
|
||||||
image: sidecar:latest
|
image: sidecar:latest
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
|
||||||
emptyDir: {}
|
|
||||||
- configMap:
|
- configMap:
|
||||||
name: configmap-in-base
|
name: configmap-in-base
|
||||||
name: configmap-in-base
|
name: configmap-in-base
|
||||||
@@ -86,7 +405,6 @@ spec:
|
|||||||
value: ENVVALUE
|
value: ENVVALUE
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
- name: nginx-persistent-storage
|
||||||
emptyDir: null
|
|
||||||
gcePersistentDisk:
|
gcePersistentDisk:
|
||||||
pdName: nginx-persistent-storage
|
pdName: nginx-persistent-storage
|
||||||
- configMap:
|
- configMap:
|
||||||
@@ -106,8 +424,6 @@ spec:
|
|||||||
env:
|
env:
|
||||||
- name: ANOTHERENV
|
- name: ANOTHERENV
|
||||||
value: FOO
|
value: FOO
|
||||||
volumes:
|
|
||||||
- name: nginx-persistent-storage
|
|
||||||
`)
|
`)
|
||||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
@@ -188,7 +504,7 @@ metadata:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeCommonFileForMultiplePatchTest(th kusttest_test.Harness) {
|
func makeCommonFilesForMultiplePatchTests(th kusttest_test.Harness) {
|
||||||
th.WriteK("/app/base", `
|
th.WriteK("/app/base", `
|
||||||
namePrefix: team-foo-
|
namePrefix: team-foo-
|
||||||
commonLabels:
|
commonLabels:
|
||||||
@@ -227,8 +543,6 @@ spec:
|
|||||||
- name: sidecar
|
- name: sidecar
|
||||||
image: sidecar:latest
|
image: sidecar:latest
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
|
||||||
emptyDir: {}
|
|
||||||
- configMap:
|
- configMap:
|
||||||
name: configmap-in-base
|
name: configmap-in-base
|
||||||
name: configmap-in-base
|
name: configmap-in-base
|
||||||
@@ -264,7 +578,7 @@ configMapGenerator:
|
|||||||
|
|
||||||
func TestMultiplePatchesNoConflict(t *testing.T) {
|
func TestMultiplePatchesNoConflict(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFilesForMultiplePatchTests(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -281,7 +595,6 @@ spec:
|
|||||||
value: ENVVALUE
|
value: ENVVALUE
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
- name: nginx-persistent-storage
|
||||||
emptyDir: null
|
|
||||||
gcePersistentDisk:
|
gcePersistentDisk:
|
||||||
pdName: nginx-persistent-storage
|
pdName: nginx-persistent-storage
|
||||||
- configMap:
|
- configMap:
|
||||||
@@ -301,8 +614,6 @@ spec:
|
|||||||
env:
|
env:
|
||||||
- name: ANOTHERENV
|
- name: ANOTHERENV
|
||||||
value: FOO
|
value: FOO
|
||||||
volumes:
|
|
||||||
- name: nginx-persistent-storage
|
|
||||||
`)
|
`)
|
||||||
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
@@ -405,7 +716,7 @@ metadata:
|
|||||||
|
|
||||||
func TestMultiplePatchesWithConflict(t *testing.T) {
|
func TestMultiplePatchesWithConflict(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFilesForMultiplePatchTests(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -421,7 +732,6 @@ spec:
|
|||||||
value: TRUE
|
value: TRUE
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
- name: nginx-persistent-storage
|
||||||
emptyDir: null
|
|
||||||
gcePersistentDisk:
|
gcePersistentDisk:
|
||||||
pdName: nginx-persistent-storage
|
pdName: nginx-persistent-storage
|
||||||
- configMap:
|
- configMap:
|
||||||
@@ -442,13 +752,114 @@ spec:
|
|||||||
- name: ENABLE_FEATURE_FOO
|
- name: ENABLE_FEATURE_FOO
|
||||||
value: FALSE
|
value: FALSE
|
||||||
`)
|
`)
|
||||||
err := th.RunWithErr("/app/overlay/staging", th.MakeDefaultOptions())
|
opts := th.MakeDefaultOptions()
|
||||||
if err == nil {
|
if opts.UseKyaml {
|
||||||
t.Fatalf("expected conflict")
|
// kyaml doesn't try to detect conflicts in patches
|
||||||
}
|
// (so ENABLE_FEATURE_FOO FALSE wins).
|
||||||
if !strings.Contains(
|
m := th.Run("/app/overlay/staging", opts)
|
||||||
err.Error(), "conflict between ") {
|
th.AssertActualEqualsExpected(m, `
|
||||||
t.Fatalf("Unexpected err: %v", err)
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: ENABLE_FEATURE_FOO
|
||||||
|
value: false
|
||||||
|
image: nginx
|
||||||
|
name: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /tmp/ps
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
- image: sidecar:latest
|
||||||
|
name: sidecar
|
||||||
|
volumes:
|
||||||
|
- gcePersistentDisk:
|
||||||
|
pdName: nginx-persistent-storage
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
name: staging-configmap-in-overlay-dc6fm46dhm
|
||||||
|
name: configmap-in-overlay
|
||||||
|
- configMap:
|
||||||
|
name: staging-team-foo-configmap-in-base-798k5k7g9f
|
||||||
|
name: configmap-in-base
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-configmap-in-base-798k5k7g9f
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
hello: world
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
env: staging
|
||||||
|
name: staging-configmap-in-overlay-dc6fm46dhm
|
||||||
|
`)
|
||||||
|
} else {
|
||||||
|
err := th.RunWithErr("/app/overlay/staging", opts)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expected conflict")
|
||||||
|
}
|
||||||
|
if !strings.Contains(
|
||||||
|
err.Error(), "conflict between ") {
|
||||||
|
t.Fatalf("Unexpected err: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,8 +908,7 @@ spec:
|
|||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
makeCommonFilesForMultiplePatchTests(th)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", c.patch1)
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", c.patch1)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", c.patch2)
|
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", c.patch2)
|
||||||
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||||
@@ -540,8 +950,6 @@ spec:
|
|||||||
- mountPath: /tmp/ps
|
- mountPath: /tmp/ps
|
||||||
name: nginx-persistent-storage
|
name: nginx-persistent-storage
|
||||||
volumes:
|
volumes:
|
||||||
- emptyDir: {}
|
|
||||||
name: nginx-persistent-storage
|
|
||||||
- configMap:
|
- configMap:
|
||||||
name: staging-team-foo-configmap-in-base-798k5k7g9f
|
name: staging-team-foo-configmap-in-base-798k5k7g9f
|
||||||
name: configmap-in-base
|
name: configmap-in-base
|
||||||
@@ -595,7 +1003,7 @@ metadata:
|
|||||||
|
|
||||||
func TestMultiplePatchesBothWithPatchDeleteDirective(t *testing.T) {
|
func TestMultiplePatchesBothWithPatchDeleteDirective(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFilesForMultiplePatchTests(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -620,12 +1028,98 @@ spec:
|
|||||||
- $patch: delete
|
- $patch: delete
|
||||||
name: nginx
|
name: nginx
|
||||||
`)
|
`)
|
||||||
err := th.RunWithErr("/app/overlay/staging", th.MakeDefaultOptions())
|
opt := th.MakeDefaultOptions()
|
||||||
if err == nil {
|
if opt.UseKyaml {
|
||||||
t.Fatalf("Expected error")
|
// kyaml doesn't fail on conflicts in patches; both containers
|
||||||
}
|
// (nginx and sidecar) are deleted per this patching instruction.
|
||||||
if !strings.Contains(
|
m := th.Run("/app/overlay/staging", opt)
|
||||||
err.Error(), "both containing ") {
|
th.AssertActualEqualsExpected(m, `
|
||||||
t.Fatalf("Unexpected err: %v", err)
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
spec:
|
||||||
|
containers: []
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
name: staging-team-foo-configmap-in-base-798k5k7g9f
|
||||||
|
name: configmap-in-base
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-configmap-in-base-798k5k7g9f
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
hello: world
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
env: staging
|
||||||
|
name: staging-configmap-in-overlay-dc6fm46dhm
|
||||||
|
`)
|
||||||
|
} else {
|
||||||
|
// No kyaml means error on a patch conflict.
|
||||||
|
err := th.RunWithErr("/app/overlay/staging", opt)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("Expected error")
|
||||||
|
}
|
||||||
|
if !strings.Contains(
|
||||||
|
err.Error(), "both containing ") {
|
||||||
|
t.Fatalf("Unexpected err: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ configMapGenerator:
|
|||||||
literals:
|
literals:
|
||||||
- MYSQL_USER=default
|
- MYSQL_USER=default
|
||||||
- MYSQL_DATABASE=default
|
- MYSQL_DATABASE=default
|
||||||
- PORT=3306
|
- HOST=everest
|
||||||
`)
|
`)
|
||||||
|
|
||||||
th.WriteK(".", `
|
th.WriteK(".", `
|
||||||
@@ -82,15 +82,13 @@ patches:
|
|||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
|
HOST: everest
|
||||||
MYSQL_DATABASE: db
|
MYSQL_DATABASE: db
|
||||||
MYSQL_PASSWORD: correct horse battery staple
|
MYSQL_PASSWORD: correct horse battery staple
|
||||||
MYSQL_USER: my-user
|
MYSQL_USER: my-user
|
||||||
PORT: "3306"
|
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: mysql-t7tt4cdbmf
|
||||||
labels: {}
|
|
||||||
name: mysql-9792mdchtg
|
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -104,10 +102,10 @@ spec:
|
|||||||
- valueFrom:
|
- valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: MYSQL_DATABASE
|
key: MYSQL_DATABASE
|
||||||
name: mysql-9792mdchtg
|
name: mysql-t7tt4cdbmf
|
||||||
envFrom:
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: mysql-9792mdchtg
|
name: mysql-t7tt4cdbmf
|
||||||
name: handler
|
name: handler
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace: base
|
|||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: testCase
|
- name: testCase
|
||||||
literals:
|
literals:
|
||||||
- base=true
|
- base=apple
|
||||||
`)
|
`)
|
||||||
th.WriteK("/app/overlay", `
|
th.WriteK("/app/overlay", `
|
||||||
resources:
|
resources:
|
||||||
@@ -92,19 +92,17 @@ configMapGenerator:
|
|||||||
- name: testCase
|
- name: testCase
|
||||||
behavior: merge
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
- overlay=true
|
- overlay=peach
|
||||||
`)
|
`)
|
||||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
data:
|
data:
|
||||||
base: "true"
|
base: apple
|
||||||
overlay: "true"
|
overlay: peach
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations: {}
|
name: testCase-gmfch8gkbt
|
||||||
labels: {}
|
|
||||||
name: testCase-bcbmmg48hd
|
|
||||||
namespace: overlay
|
namespace: overlay
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ metadata:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This serie of constants is used to prove the need of
|
// This series of constants is used to prove the need of
|
||||||
// the namespace field in the objref field of the var declaration.
|
// the namespace field in the objref field of the var declaration.
|
||||||
// The following tests demonstrate that it creates umbiguous variable
|
// The following tests demonstrate that it creates umbiguous variable
|
||||||
// declaration if two entities of the kind with the same name
|
// declaration if two entities of the kind with the same name
|
||||||
@@ -472,10 +472,12 @@ spec:
|
|||||||
// not specified
|
// not specified
|
||||||
func TestVariablesAmbiguous(t *testing.T) {
|
func TestVariablesAmbiguous(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
th.WriteK("/namespaceNeedInVar/myapp", namespaceNeedInVarMyApp)
|
th.WriteK(".", namespaceNeedInVarMyApp)
|
||||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
th.WriteF("elasticsearch-dev-service.yaml",
|
||||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
namespaceNeedInVarDevResources)
|
||||||
err := th.RunWithErr("/namespaceNeedInVar/myapp", th.MakeDefaultOptions())
|
th.WriteF("elasticsearch-test-service.yaml",
|
||||||
|
namespaceNeedInVarTestResources)
|
||||||
|
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected error")
|
t.Fatalf("expected error")
|
||||||
}
|
}
|
||||||
@@ -529,16 +531,20 @@ vars:
|
|||||||
// and resources into multiple kustomization context/folders instead of one.
|
// and resources into multiple kustomization context/folders instead of one.
|
||||||
func TestVariablesAmbiguousWorkaround(t *testing.T) {
|
func TestVariablesAmbiguousWorkaround(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
th.WriteK("/namespaceNeedInVar/dev", namespaceNeedInVarDevFolder)
|
opts := th.MakeDefaultOptions()
|
||||||
th.WriteF("/namespaceNeedInVar/dev/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
if opts.UseKyaml {
|
||||||
th.WriteK("/namespaceNeedInVar/test", namespaceNeedInVarTestFolder)
|
t.Skip("TODO(#3396)")
|
||||||
th.WriteF("/namespaceNeedInVar/test/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
}
|
||||||
th.WriteK("/namespaceNeedInVar/workaround", `
|
th.WriteK("dev", namespaceNeedInVarDevFolder)
|
||||||
|
th.WriteF("dev/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||||
|
th.WriteK("test", namespaceNeedInVarTestFolder)
|
||||||
|
th.WriteF("test/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||||
|
th.WriteK("workaround", `
|
||||||
resources:
|
resources:
|
||||||
- ../dev
|
- ../dev
|
||||||
- ../test
|
- ../test
|
||||||
`)
|
`)
|
||||||
m := th.Run("/namespaceNeedInVar/workaround", th.MakeDefaultOptions())
|
m := th.Run("workaround", opts)
|
||||||
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
|
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,9 +591,13 @@ vars:
|
|||||||
// to the variable declarations allows to disambiguate the variables.
|
// to the variable declarations allows to disambiguate the variables.
|
||||||
func TestVariablesDisambiguatedWithNamespace(t *testing.T) {
|
func TestVariablesDisambiguatedWithNamespace(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
th.WriteK("/namespaceNeedInVar/myapp", namespaceNeedInVarMyAppWithNamespace)
|
opts := th.MakeDefaultOptions()
|
||||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
if opts.UseKyaml {
|
||||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
t.Skip("TODO(#3396)")
|
||||||
m := th.Run("/namespaceNeedInVar/myapp", th.MakeDefaultOptions())
|
}
|
||||||
|
th.WriteK(".", namespaceNeedInVarMyAppWithNamespace)
|
||||||
|
th.WriteF("elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||||
|
th.WriteF("elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||||
|
m := th.Run(".", th.MakeDefaultOptions())
|
||||||
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
|
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ subjects:
|
|||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: default
|
name: default
|
||||||
namespace: foo
|
namespace: foo
|
||||||
---
|
---
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: Role
|
kind: Role
|
||||||
metadata:
|
metadata:
|
||||||
|
|||||||
@@ -50,7 +50,14 @@ func MakeDefaultOptions() *Options {
|
|||||||
LoadRestrictions: types.LoadRestrictionsRootOnly,
|
LoadRestrictions: types.LoadRestrictionsRootOnly,
|
||||||
DoPrune: false,
|
DoPrune: false,
|
||||||
PluginConfig: konfig.DisabledPluginConfig(),
|
PluginConfig: konfig.DisabledPluginConfig(),
|
||||||
UseKyaml: false,
|
UseKyaml: konfig.FlagEnableKyamlDefaultValue,
|
||||||
AllowResourceIdChanges: false,
|
AllowResourceIdChanges: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o Options) IfApiMachineryElseKyaml(s1, s2 string) string {
|
||||||
|
if !o.UseKyaml {
|
||||||
|
return s1
|
||||||
|
}
|
||||||
|
return s2
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
|
"sigs.k8s.io/kustomize/api/internal/utils"
|
||||||
"sigs.k8s.io/kustomize/api/krusty"
|
"sigs.k8s.io/kustomize/api/krusty"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRemoteLoad(t *testing.T) {
|
func TestRemoteLoad(t *testing.T) {
|
||||||
@@ -17,7 +17,7 @@ func TestRemoteLoad(t *testing.T) {
|
|||||||
b := krusty.MakeKustomizer(fSys, krusty.MakeDefaultOptions())
|
b := krusty.MakeKustomizer(fSys, krusty.MakeDefaultOptions())
|
||||||
m, err := b.Run(
|
m, err := b.Run(
|
||||||
"github.com/kubernetes-sigs/kustomize/examples/multibases/dev/?ref=v1.0.6")
|
"github.com/kubernetes-sigs/kustomize/examples/multibases/dev/?ref=v1.0.6")
|
||||||
if types.IsErrTimeout(err) {
|
if utils.IsErrTimeout(err) {
|
||||||
// Don't fail on timeouts.
|
// Don't fail on timeouts.
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
|
|||||||
47
api/krusty/simple_test.go
Normal file
47
api/krusty/simple_test.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package krusty_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimple1(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteF("/dep.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 1
|
||||||
|
`)
|
||||||
|
th.WriteF("/patch.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`)
|
||||||
|
|
||||||
|
th.WriteK("/", `
|
||||||
|
resources:
|
||||||
|
- dep.yaml
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch.yaml
|
||||||
|
`)
|
||||||
|
m := th.Run("/", th.MakeDefaultOptions())
|
||||||
|
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`)
|
||||||
|
}
|
||||||
@@ -74,7 +74,7 @@ kind: ConfigMap
|
|||||||
metadata:
|
metadata:
|
||||||
name: configmap-a
|
name: configmap-a
|
||||||
annotations:
|
annotations:
|
||||||
kustomize.k8s.io/Generated: "false"
|
fruit: peach
|
||||||
data:
|
data:
|
||||||
foo: $FOO
|
foo: $FOO
|
||||||
`)
|
`)
|
||||||
@@ -87,7 +87,7 @@ data:
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
kustomize.k8s.io/Generated: "false"
|
fruit: peach
|
||||||
name: configmap-a
|
name: configmap-a
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
|||||||
@@ -362,6 +362,10 @@ resources:
|
|||||||
|
|
||||||
func TestVarRefBig(t *testing.T) {
|
func TestVarRefBig(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
opts := th.MakeDefaultOptions()
|
||||||
|
if opts.UseKyaml {
|
||||||
|
t.Skip("TODO(#3396)")
|
||||||
|
}
|
||||||
th.WriteK("/app/base", `
|
th.WriteK("/app/base", `
|
||||||
namePrefix: base-
|
namePrefix: base-
|
||||||
resources:
|
resources:
|
||||||
@@ -678,7 +682,7 @@ namePrefix: dev-
|
|||||||
resources:
|
resources:
|
||||||
- ../../base
|
- ../../base
|
||||||
`)
|
`)
|
||||||
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
m := th.Run("/app/overlay/staging", opts)
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ServiceAccount
|
kind: ServiceAccount
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"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"
|
||||||
"sigs.k8s.io/kustomize/api/types"
|
"sigs.k8s.io/kustomize/api/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type remoteTargetSpec struct {
|
type remoteTargetSpec struct {
|
||||||
@@ -93,22 +93,7 @@ func getRemoteTarget(rs *remoteTargetSpec) error {
|
|||||||
},
|
},
|
||||||
Options: opts,
|
Options: opts,
|
||||||
}
|
}
|
||||||
|
return utils.TimedCall("go-getter client.Get", 21*time.Second, client.Get)
|
||||||
ch := make(chan bool, 1)
|
|
||||||
defer close(ch)
|
|
||||||
d := 21 * time.Second // arbitrary
|
|
||||||
timer := time.NewTimer(d)
|
|
||||||
defer timer.Stop()
|
|
||||||
go func() {
|
|
||||||
err = client.Get()
|
|
||||||
ch <- true
|
|
||||||
}()
|
|
||||||
select {
|
|
||||||
case <-ch:
|
|
||||||
case <-timer.C:
|
|
||||||
err = types.NewErrTimeOut(d, "go-getter client.Get")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNothing(rs *remoteTargetSpec) error {
|
func getNothing(rs *remoteTargetSpec) error {
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ func (x Gvk) String() string {
|
|||||||
return strings.Join([]string{g, v, k}, fieldSep)
|
return strings.Join([]string{g, v, k}, fieldSep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApiVersion returns the combination of Group and Version
|
||||||
|
func (x Gvk) ApiVersion() string {
|
||||||
|
if x.Group == "" {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return x.Group + "/" + x.Version
|
||||||
|
}
|
||||||
|
|
||||||
// StringWoEmptyField returns a string representation of the GVK. Non-exist
|
// StringWoEmptyField returns a string representation of the GVK. Non-exist
|
||||||
// fields will be omitted.
|
// fields will be omitted.
|
||||||
func (x Gvk) StringWoEmptyField() string {
|
func (x Gvk) StringWoEmptyField() string {
|
||||||
|
|||||||
@@ -1,18 +1,5 @@
|
|||||||
/*
|
// Copyright 2018 The Kubernetes Authors.
|
||||||
Copyright 2018 The Kubernetes Authors.
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package resid
|
package resid
|
||||||
|
|
||||||
@@ -112,17 +99,31 @@ var stringTests = []struct {
|
|||||||
|
|
||||||
func TestString(t *testing.T) {
|
func TestString(t *testing.T) {
|
||||||
for _, hey := range stringTests {
|
for _, hey := range stringTests {
|
||||||
if hey.x.String() != hey.s {
|
assert.Equal(t, hey.s, hey.x.String())
|
||||||
t.Fatalf("bad string for %v '%s'", hey.x, hey.s)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApiVersion(t *testing.T) {
|
||||||
|
for _, hey := range []struct {
|
||||||
|
x Gvk
|
||||||
|
exp string
|
||||||
|
}{
|
||||||
|
{Gvk{}, ""},
|
||||||
|
{Gvk{Kind: "k"}, ""},
|
||||||
|
{Gvk{Version: "v"}, "v"},
|
||||||
|
{Gvk{Version: "v", Kind: "k"}, "v"},
|
||||||
|
{Gvk{Group: "g"}, "g/"},
|
||||||
|
{Gvk{Group: "g", Kind: "k"}, "g/"},
|
||||||
|
{Gvk{Group: "g", Version: "v"}, "g/v"},
|
||||||
|
{Gvk{Group: "g", Version: "v", Kind: "k"}, "g/v"},
|
||||||
|
} {
|
||||||
|
assert.Equal(t, hey.exp, hey.x.ApiVersion())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStringWoEmptyField(t *testing.T) {
|
func TestStringWoEmptyField(t *testing.T) {
|
||||||
for _, hey := range stringTests {
|
for _, hey := range stringTests {
|
||||||
if hey.x.StringWoEmptyField() != hey.r {
|
assert.Equal(t, hey.r, hey.x.StringWoEmptyField())
|
||||||
t.Fatalf("bad string %s for %v '%s'", hey.x.StringWoEmptyField(), hey.x, hey.r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,12 +142,8 @@ func TestParseGroupVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
g, v := ParseGroupVersion(tc.input)
|
g, v := ParseGroupVersion(tc.input)
|
||||||
if g != tc.g {
|
assert.Equal(t, tc.g, g, tc.input)
|
||||||
t.Errorf("%s: expected group '%s', got '%s'", tc.input, tc.g, g)
|
assert.Equal(t, tc.v, v, tc.input)
|
||||||
}
|
|
||||||
if v != tc.v {
|
|
||||||
t.Errorf("%s: expected version '%s', got '%s'", tc.input, tc.v, v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,9 +249,7 @@ func TestSelectByGVK(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
filtered := tc.in.IsSelected(tc.filter)
|
filtered := tc.in.IsSelected(tc.filter)
|
||||||
if filtered != tc.expected {
|
assert.Equal(t, tc.expected, filtered, tc.description)
|
||||||
t.Fatalf("unexpected filter result for test case: %v", tc.description)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,10 +126,11 @@ func (rmF *Factory) FromSecretArgs(
|
|||||||
return rmF.FromResource(res), nil
|
return rmF.FromResource(res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge creates a new ResMap by merging incoming resources.
|
// ConflatePatches creates a new ResMap containing a merger of the
|
||||||
|
// incoming patches.
|
||||||
// Error if conflict found.
|
// Error if conflict found.
|
||||||
func (rmF *Factory) Merge(incoming []*resource.Resource) (ResMap, error) {
|
func (rmF *Factory) ConflatePatches(patches []*resource.Resource) (ResMap, error) {
|
||||||
return (&merginator{cdf: rmF.cdf}).Merge(incoming)
|
return (&merginator{cdf: rmF.cdf}).ConflatePatches(patches)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newResMapFromResourceSlice(
|
func newResMapFromResourceSlice(
|
||||||
@@ -152,11 +153,11 @@ func (rmF *Factory) NewResMapFromRNodeSlice(rnodes []*yaml.RNode) (ResMap, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r, err := rmF.resF.FromBytes([]byte(s))
|
r, err := rmF.resF.SliceFromBytes([]byte(s))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resources = append(resources, r)
|
resources = append(resources, r...)
|
||||||
}
|
}
|
||||||
return newResMapFromResourceSlice(resources)
|
return newResMapFromResourceSlice(resources)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,7 +277,17 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFromRNodeSlice(t *testing.T) {
|
func TestFromRNodeSlice(t *testing.T) {
|
||||||
input := `apiVersion: rbac.authorization.k8s.io/v1
|
type testcase struct {
|
||||||
|
input string
|
||||||
|
expected ResMap
|
||||||
|
}
|
||||||
|
testcases := map[string]testcase{
|
||||||
|
"no resource": {
|
||||||
|
input: "---",
|
||||||
|
expected: resmaptest_test.NewRmBuilder(t, rf).ResMap(),
|
||||||
|
},
|
||||||
|
"single resource": {
|
||||||
|
input: `apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
metadata:
|
metadata:
|
||||||
name: namespace-reader
|
name: namespace-reader
|
||||||
@@ -290,52 +300,64 @@ rules:
|
|||||||
- get
|
- get
|
||||||
- watch
|
- watch
|
||||||
- list
|
- list
|
||||||
`
|
`,
|
||||||
rnodes := []*yaml.RNode{
|
expected: resmaptest_test.NewRmBuilder(t, rf).Add(
|
||||||
yaml.MustParse(input),
|
|
||||||
}
|
|
||||||
|
|
||||||
rm, err := rmF.NewResMapFromRNodeSlice(rnodes)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
expected := resmaptest_test.NewRmBuilder(t, rf).Add(
|
|
||||||
map[string]interface{}{
|
|
||||||
"apiVersion": "rbac.authorization.k8s.io/v1",
|
|
||||||
"kind": "ClusterRole",
|
|
||||||
"metadata": map[string]interface{}{
|
|
||||||
"name": "namespace-reader",
|
|
||||||
},
|
|
||||||
"rules": []interface{}{
|
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"apiGroups": []interface{}{
|
"apiVersion": "rbac.authorization.k8s.io/v1",
|
||||||
"",
|
"kind": "ClusterRole",
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"name": "namespace-reader",
|
||||||
},
|
},
|
||||||
"resources": []interface{}{
|
"rules": []interface{}{
|
||||||
"namespaces",
|
map[string]interface{}{
|
||||||
|
"apiGroups": []interface{}{
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
"resources": []interface{}{
|
||||||
|
"namespaces",
|
||||||
|
},
|
||||||
|
"verbs": []interface{}{
|
||||||
|
"get",
|
||||||
|
"watch",
|
||||||
|
"list",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"verbs": []interface{}{
|
}).ResMap(),
|
||||||
"get",
|
},
|
||||||
"watch",
|
"local config": {
|
||||||
"list",
|
// local config should be ignored
|
||||||
},
|
input: `apiVersion: v1
|
||||||
},
|
kind: ConfigMap
|
||||||
},
|
metadata:
|
||||||
}).ResMap()
|
name: my-config
|
||||||
|
annotations:
|
||||||
if err = expected.ErrorIfNotEqualLists(rm); err != nil {
|
config.kubernetes.io/local-config: 'true'
|
||||||
t.Fatalf("error: %s", err)
|
`,
|
||||||
|
expected: resmaptest_test.NewRmBuilder(t, rf).ResMap(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for name, tc := range testcases {
|
||||||
|
rnodes := []*yaml.RNode{
|
||||||
|
yaml.MustParse(tc.input),
|
||||||
|
}
|
||||||
|
rm, err := rmF.NewResMapFromRNodeSlice(rnodes)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error in test case [%s]: %v", name, err)
|
||||||
|
}
|
||||||
|
if err = tc.expected.ErrorIfNotEqualLists(rm); err != nil {
|
||||||
|
t.Fatalf("error in test case [%s]: %s", name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMerge_Empty(t *testing.T) {
|
func TestConflatePatches_Empty(t *testing.T) {
|
||||||
rm, err := rmF.Merge([]*resource.Resource{})
|
rm, err := rmF.ConflatePatches([]*resource.Resource{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 0, rm.Size())
|
assert.Equal(t, 0, rm.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMerge(t *testing.T) {
|
func TestConflatePatches(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
yml []byte
|
yml []byte
|
||||||
@@ -365,7 +387,7 @@ spec:
|
|||||||
`))
|
`))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
rm, err := rmF.Merge([]*resource.Resource{r1, r2})
|
rm, err := rmF.ConflatePatches([]*resource.Resource{r1, r2})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
yml, err = rm.AsYaml()
|
yml, err = rm.AsYaml()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type merginator struct {
|
|||||||
result ResMap
|
result ResMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *merginator) Merge(in []*resource.Resource) (ResMap, error) {
|
func (m *merginator) ConflatePatches(in []*resource.Resource) (ResMap, error) {
|
||||||
m.result = New()
|
m.result = New()
|
||||||
m.incoming = in
|
m.incoming = in
|
||||||
for index := range m.incoming {
|
for index := range m.incoming {
|
||||||
|
|||||||
@@ -456,8 +456,7 @@ func (m *resWrangler) AbsorbAll(other ResMap) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *resWrangler) appendReplaceOrMerge(
|
func (m *resWrangler) appendReplaceOrMerge(res *resource.Resource) error {
|
||||||
res *resource.Resource) error {
|
|
||||||
id := res.CurId()
|
id := res.CurId()
|
||||||
matches := m.GetMatchingResourcesByOriginalId(id.Equals)
|
matches := m.GetMatchingResourcesByOriginalId(id.Equals)
|
||||||
if len(matches) == 0 {
|
if len(matches) == 0 {
|
||||||
@@ -471,10 +470,7 @@ func (m *resWrangler) appendReplaceOrMerge(
|
|||||||
"id %#v does not exist; cannot merge or replace", id)
|
"id %#v does not exist; cannot merge or replace", id)
|
||||||
default:
|
default:
|
||||||
// presumably types.BehaviorCreate
|
// presumably types.BehaviorCreate
|
||||||
err := m.Append(res)
|
return m.Append(res)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
old := matches[0]
|
old := matches[0]
|
||||||
@@ -487,9 +483,10 @@ func (m *resWrangler) appendReplaceOrMerge(
|
|||||||
}
|
}
|
||||||
switch res.Behavior() {
|
switch res.Behavior() {
|
||||||
case types.BehaviorReplace:
|
case types.BehaviorReplace:
|
||||||
res.Replace(old)
|
res.CopyMergeMetaDataFieldsFrom(old)
|
||||||
case types.BehaviorMerge:
|
case types.BehaviorMerge:
|
||||||
res.Merge(old)
|
res.CopyMergeMetaDataFieldsFrom(old)
|
||||||
|
res.MergeDataMapFrom(old)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"id %#v exists; behavior must be merge or replace", id)
|
"id %#v exists; behavior must be merge or replace", id)
|
||||||
@@ -499,14 +496,14 @@ func (m *resWrangler) appendReplaceOrMerge(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if i != index {
|
if i != index {
|
||||||
return fmt.Errorf("unexpected index in replacement")
|
return fmt.Errorf("unexpected target index in replacement")
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"found multiple objects %v that could accept merge of %v",
|
"found multiple objects %v that could accept merge of %v",
|
||||||
matches, id)
|
matches, id)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select returns a list of resources that
|
// Select returns a list of resources that
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"sigs.k8s.io/kustomize/api/konfig"
|
|
||||||
"sigs.k8s.io/kustomize/api/provider"
|
"sigs.k8s.io/kustomize/api/provider"
|
||||||
"sigs.k8s.io/kustomize/api/resid"
|
"sigs.k8s.io/kustomize/api/resid"
|
||||||
. "sigs.k8s.io/kustomize/api/resmap"
|
. "sigs.k8s.io/kustomize/api/resmap"
|
||||||
@@ -694,10 +693,6 @@ func TestAbsorbAll(t *testing.T) {
|
|||||||
metadata := map[string]interface{}{
|
metadata := map[string]interface{}{
|
||||||
"name": "cmap",
|
"name": "cmap",
|
||||||
}
|
}
|
||||||
if !konfig.FlagEnableKyamlDefaultValue {
|
|
||||||
metadata["annotations"] = map[string]interface{}{}
|
|
||||||
metadata["labels"] = map[string]interface{}{}
|
|
||||||
}
|
|
||||||
expected := rmF.FromResource(rf.FromMapAndOption(
|
expected := rmF.FromResource(rf.FromMapAndOption(
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"apiVersion": "apps/v1",
|
"apiVersion": "apps/v1",
|
||||||
@@ -804,6 +799,34 @@ spec:
|
|||||||
errorExpected bool
|
errorExpected bool
|
||||||
errorMsg string
|
errorMsg string
|
||||||
}{
|
}{
|
||||||
|
"clown": {
|
||||||
|
base: []string{`apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 1
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
patches: []string{`apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
errorExpected: false,
|
||||||
|
expected: []string{
|
||||||
|
`apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
},
|
||||||
"confusion": {
|
"confusion": {
|
||||||
base: []string{`apiVersion: example.com/v1
|
base: []string{`apiVersion: example.com/v1
|
||||||
kind: Foo
|
kind: Foo
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ func (r *Resource) GetFieldValue(f string) (interface{}, error) {
|
|||||||
return r.kunStr.GetFieldValue(f)
|
return r.kunStr.GetFieldValue(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resource) GetDataMap() map[string]string {
|
||||||
|
return r.kunStr.GetDataMap()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Resource) GetGvk() resid.Gvk {
|
func (r *Resource) GetGvk() resid.Gvk {
|
||||||
return r.kunStr.GetGvk()
|
return r.kunStr.GetGvk()
|
||||||
}
|
}
|
||||||
@@ -91,14 +95,28 @@ func (r *Resource) MatchesAnnotationSelector(selector string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resource) SetAnnotations(m map[string]string) {
|
func (r *Resource) SetAnnotations(m map[string]string) {
|
||||||
|
if len(m) == 0 {
|
||||||
|
// Force field erasure.
|
||||||
|
r.kunStr.SetAnnotations(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
r.kunStr.SetAnnotations(m)
|
r.kunStr.SetAnnotations(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resource) SetDataMap(m map[string]string) {
|
||||||
|
r.kunStr.SetDataMap(m)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Resource) SetGvk(gvk resid.Gvk) {
|
func (r *Resource) SetGvk(gvk resid.Gvk) {
|
||||||
r.kunStr.SetGvk(gvk)
|
r.kunStr.SetGvk(gvk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resource) SetLabels(m map[string]string) {
|
func (r *Resource) SetLabels(m map[string]string) {
|
||||||
|
if len(m) == 0 {
|
||||||
|
// Force field erasure.
|
||||||
|
r.kunStr.SetLabels(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
r.kunStr.SetLabels(m)
|
r.kunStr.SetLabels(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,10 +157,12 @@ func (r *Resource) DeepCopy() *Resource {
|
|||||||
return rc
|
return rc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace performs replace with other resource.
|
// CopyMergeMetaDataFields copies everything but the non-metadata in
|
||||||
func (r *Resource) Replace(other *Resource) {
|
// the ifc.Kunstructured map, merging labels and annotations.
|
||||||
|
func (r *Resource) CopyMergeMetaDataFieldsFrom(other *Resource) {
|
||||||
r.SetLabels(mergeStringMaps(other.GetLabels(), r.GetLabels()))
|
r.SetLabels(mergeStringMaps(other.GetLabels(), r.GetLabels()))
|
||||||
r.SetAnnotations(mergeStringMaps(other.GetAnnotations(), r.GetAnnotations()))
|
r.SetAnnotations(
|
||||||
|
mergeStringMaps(other.GetAnnotations(), r.GetAnnotations()))
|
||||||
r.SetName(other.GetName())
|
r.SetName(other.GetName())
|
||||||
r.SetNamespace(other.GetNamespace())
|
r.SetNamespace(other.GetNamespace())
|
||||||
r.copyOtherFields(other)
|
r.copyOtherFields(other)
|
||||||
@@ -158,6 +178,10 @@ func (r *Resource) copyOtherFields(other *Resource) {
|
|||||||
r.nameSuffixes = copyStringSlice(other.nameSuffixes)
|
r.nameSuffixes = copyStringSlice(other.nameSuffixes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resource) MergeDataMapFrom(o *Resource) {
|
||||||
|
r.SetDataMap(mergeStringMaps(o.GetDataMap(), r.GetDataMap()))
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Resource) ErrIfNotEquals(o *Resource) error {
|
func (r *Resource) ErrIfNotEquals(o *Resource) error {
|
||||||
meYaml, err := r.AsYAML()
|
meYaml, err := r.AsYAML()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -198,12 +222,6 @@ func (r *Resource) KunstructEqual(o *Resource) bool {
|
|||||||
return reflect.DeepEqual(r.kunStr, o.kunStr)
|
return reflect.DeepEqual(r.kunStr, o.kunStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge performs merge with other resource.
|
|
||||||
func (r *Resource) Merge(other *Resource) {
|
|
||||||
r.Replace(other)
|
|
||||||
mergeConfigmap(r.Map(), other.Map(), r.Map())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Resource) copyRefBy() []resid.ResId {
|
func (r *Resource) copyRefBy() []resid.ResId {
|
||||||
if r.refBy == nil {
|
if r.refBy == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -414,22 +432,6 @@ func (r *Resource) ApplySmPatch(patch *Resource) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add BinaryData once we sync to new k8s.io/api
|
|
||||||
func mergeConfigmap(
|
|
||||||
mergedTo map[string]interface{},
|
|
||||||
maps ...map[string]interface{}) {
|
|
||||||
mergedMap := map[string]interface{}{}
|
|
||||||
for _, m := range maps {
|
|
||||||
datamap, ok := m["data"].(map[string]interface{})
|
|
||||||
if ok {
|
|
||||||
for key, value := range datamap {
|
|
||||||
mergedMap[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mergedTo["data"] = mergedMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func mergeStringMaps(maps ...map[string]string) map[string]string {
|
func mergeStringMaps(maps ...map[string]string) map[string]string {
|
||||||
result := map[string]string{}
|
result := map[string]string{}
|
||||||
for _, m := range maps {
|
for _, m := range maps {
|
||||||
|
|||||||
@@ -250,6 +250,73 @@ spec:
|
|||||||
`, string(bytes))
|
`, string(bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApplySmPatch_3(t *testing.T) {
|
||||||
|
resource, err := factory.FromBytes([]byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 1
|
||||||
|
`))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
patch, err := factory.FromBytes([]byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NoError(t, resource.ApplySmPatch(patch))
|
||||||
|
bytes, err := resource.AsYAML()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, `apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
spec:
|
||||||
|
numReplicas: 999
|
||||||
|
`, string(bytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeDataMapFrom(t *testing.T) {
|
||||||
|
resource, err := factory.FromBytes([]byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
kind: BlahBlah
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
data:
|
||||||
|
fruit: pear
|
||||||
|
`))
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
patch, err := factory.FromBytes([]byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Whatever
|
||||||
|
metadata:
|
||||||
|
name: spaceship
|
||||||
|
data:
|
||||||
|
spaceship: enterprise
|
||||||
|
`))
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
resource.MergeDataMapFrom(patch)
|
||||||
|
bytes, err := resource.AsYAML()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, `apiVersion: v1
|
||||||
|
data:
|
||||||
|
fruit: pear
|
||||||
|
spaceship: enterprise
|
||||||
|
kind: BlahBlah
|
||||||
|
metadata:
|
||||||
|
name: clown
|
||||||
|
`, string(bytes))
|
||||||
|
}
|
||||||
|
|
||||||
func TestApplySmPatch_SwapOrder(t *testing.T) {
|
func TestApplySmPatch_SwapOrder(t *testing.T) {
|
||||||
s1 := `
|
s1 := `
|
||||||
apiVersion: example.com/v1
|
apiVersion: example.com/v1
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ type HelmChartArgs struct {
|
|||||||
ChartRepoURL string `json:"chartRepoUrl,omitempty" yaml:"chartRepoUrl,omitempty"`
|
ChartRepoURL string `json:"chartRepoUrl,omitempty" yaml:"chartRepoUrl,omitempty"`
|
||||||
ChartHome string `json:"chartHome,omitempty" yaml:"chartHome,omitempty"`
|
ChartHome string `json:"chartHome,omitempty" yaml:"chartHome,omitempty"`
|
||||||
// Use chartRelease to keep compatible with old exec plugin
|
// Use chartRelease to keep compatible with old exec plugin
|
||||||
ChartRepoName string `json:"chartRelease,omitempty" yaml:"chartRelease,omitempty"`
|
ChartRepoName string `json:"chartRelease,omitempty" yaml:"chartRelease,omitempty"`
|
||||||
HelmBin string `json:"helmBin,omitempty" yaml:"helmBin,omitempty"`
|
HelmBin string `json:"helmBin,omitempty" yaml:"helmBin,omitempty"`
|
||||||
HelmHome string `json:"helmHome,omitempty" yaml:"helmHome,omitempty"`
|
HelmHome string `json:"helmHome,omitempty" yaml:"helmHome,omitempty"`
|
||||||
Values string `json:"values,omitempty" yaml:"values,omitempty"`
|
Values string `json:"values,omitempty" yaml:"values,omitempty"`
|
||||||
ReleaseName string `json:"releaseName,omitempty" yaml:"releaseName,omitempty"`
|
ValuesLocal map[string]interface{} `json:"valuesLocal,omitempty" yaml:"valuesLocal,omitempty"`
|
||||||
ReleaseNamespace string `json:"releaseNamespace,omitempty" yaml:"releaseNamespace,omitempty"`
|
ValuesMerge string `json:"valuesMerge,omitempty" yaml:"valuesMerge,omitempty"`
|
||||||
ExtraArgs []string `json:"extraArgs,omitempty" yaml:"extraArgs,omitempty"`
|
ReleaseName string `json:"releaseName,omitempty" yaml:"releaseName,omitempty"`
|
||||||
|
ReleaseNamespace string `json:"releaseNamespace,omitempty" yaml:"releaseNamespace,omitempty"`
|
||||||
|
ExtraArgs []string `json:"extraArgs,omitempty" yaml:"extraArgs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ require (
|
|||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
||||||
k8s.io/apimachinery v0.18.10
|
k8s.io/apimachinery v0.18.10
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -378,8 +378,6 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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=
|
||||||
@@ -390,8 +388,8 @@ k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUc
|
|||||||
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
||||||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||||
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
|
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||||
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ func (e *Editor) Tidy() error {
|
|||||||
func (e *Editor) Pin(target misc.LaModule, oldV, newV semver.SemVer) error {
|
func (e *Editor) Pin(target misc.LaModule, oldV, newV semver.SemVer) error {
|
||||||
err := e.run(
|
err := e.run(
|
||||||
"edit",
|
"edit",
|
||||||
|
"-dropreplace="+target.ImportPath(),
|
||||||
"-dropreplace="+target.ImportPath()+"@"+oldV.String(),
|
"-dropreplace="+target.ImportPath()+"@"+oldV.String(),
|
||||||
"-require="+target.ImportPath()+"@"+newV.String(),
|
"-require="+target.ImportPath()+"@"+newV.String(),
|
||||||
)
|
)
|
||||||
@@ -66,8 +67,9 @@ func (e *Editor) Pin(target misc.LaModule, oldV, newV semver.SemVer) error {
|
|||||||
func (e *Editor) UnPin(target misc.LaModule, oldV semver.SemVer) error {
|
func (e *Editor) UnPin(target misc.LaModule, oldV semver.SemVer) error {
|
||||||
var r strings.Builder
|
var r strings.Builder
|
||||||
r.WriteString(target.ImportPath())
|
r.WriteString(target.ImportPath())
|
||||||
r.WriteString("@")
|
// Don't specify the old version.
|
||||||
r.WriteString(oldV.String())
|
// r.WriteString("@")
|
||||||
|
// r.WriteString(oldV.String())
|
||||||
r.WriteString("=")
|
r.WriteString("=")
|
||||||
r.WriteString(upstairs(e.module.ShortName().Depth()))
|
r.WriteString(upstairs(e.module.ShortName().Depth()))
|
||||||
r.WriteString(string(target.ShortName()))
|
r.WriteString(string(target.ShortName()))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ require (
|
|||||||
github.com/rakyll/statik v0.1.7
|
github.com/rakyll/statik v0.1.7
|
||||||
github.com/spf13/cobra v1.0.0
|
github.com/spf13/cobra v1.0.0
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
@@ -511,8 +512,8 @@ gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -533,10 +534,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: arbitrary
|
||||||
|
|
||||||
# Example configuration for the webserver
|
# Example configuration for the webserver
|
||||||
# at https://github.com/monopole/hello
|
# at https://github.com/monopole/hello
|
||||||
commonLabels:
|
commonLabels:
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ resources:
|
|||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
Make a transformer configration file.
|
Make a transformer configuration file.
|
||||||
|
|
||||||
The transformer used is called `AddValueTransformer`. It's
|
The transformer used is called `AddValueTransformer`. It's
|
||||||
intended to implement the 'add' operation of
|
intended to implement the 'add' operation of
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#
|
#
|
||||||
# Fails if the file already exists.
|
# Fails if the file already exists.
|
||||||
|
|
||||||
|
curl_timeout=600
|
||||||
release_url=https://api.github.com/repos/kubernetes-sigs/kustomize/releases
|
release_url=https://api.github.com/repos/kubernetes-sigs/kustomize/releases
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
@@ -45,11 +46,11 @@ elif [[ "$OSTYPE" == darwin* ]]; then
|
|||||||
opsys=darwin
|
opsys=darwin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl -s $release_url |\
|
curl -m $curl_timeout -s $release_url |\
|
||||||
grep browser_download.*${opsys}_${arch} |\
|
grep browser_download.*${opsys}_${arch} |\
|
||||||
cut -d '"' -f 4 |\
|
cut -d '"' -f 4 |\
|
||||||
sort | tail -n 1 |\
|
sort | tail -n 1 |\
|
||||||
xargs curl -sLO
|
xargs curl -m $curl_timeout -sLO
|
||||||
|
|
||||||
if [ -e ./kustomize_v*_${opsys}_amd64.tar.gz ]; then
|
if [ -e ./kustomize_v*_${opsys}_amd64.tar.gz ]; then
|
||||||
tar xzf ./kustomize_v*_${opsys}_amd64.tar.gz
|
tar xzf ./kustomize_v*_${opsys}_amd64.tar.gz
|
||||||
|
|||||||
@@ -12,11 +12,22 @@ version=$1
|
|||||||
# All hack scripts should run from top level.
|
# All hack scripts should run from top level.
|
||||||
. hack/shellHelpers.sh
|
. hack/shellHelpers.sh
|
||||||
|
|
||||||
|
echo "Installing kustomize ${version}"
|
||||||
|
|
||||||
|
# Always rebuild, never assume the installed verion is
|
||||||
|
# the right one to test.
|
||||||
|
rm -f $(go env GOPATH)/bin/kustomize
|
||||||
|
if [ "$version" == "HEAD" ]; then
|
||||||
|
(cd kustomize; go install .)
|
||||||
|
else
|
||||||
|
GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3@${version}
|
||||||
|
fi
|
||||||
|
|
||||||
# TODO: change the label?
|
# TODO: change the label?
|
||||||
# We test against the latest release, and HEAD, and presumably
|
# We test against the latest release, and HEAD, and presumably
|
||||||
# any branch using this label, so it should probably get
|
# any branch using this label, so it should probably get
|
||||||
# a new value.
|
# a new value.
|
||||||
mdrip --mode test \
|
mdrip --mode test --blockTimeOut 15m \
|
||||||
--label testAgainstLatestRelease examples
|
--label testAgainstLatestRelease examples
|
||||||
|
|
||||||
# TODO: make work for non-linux
|
# TODO: make work for non-linux
|
||||||
@@ -28,4 +39,10 @@ if onLinuxAndNotOnRemoteCI; then
|
|||||||
mdrip --mode test --label helmtest examples/chart.md
|
mdrip --mode test --label helmtest examples/chart.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Force outside logic to rebuild kustomize rather than
|
||||||
|
# rely on whatever this script just did. Tests should
|
||||||
|
# be order independent.
|
||||||
|
echo "Removing kustomize ${version}"
|
||||||
|
rm $(go env GOPATH)/bin/kustomize
|
||||||
|
|
||||||
echo "Example tests passed against ${version}."
|
echo "Example tests passed against ${version}."
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ FROM golang:alpine as builder
|
|||||||
ARG VERSION
|
ARG VERSION
|
||||||
ARG COMMIT
|
ARG COMMIT
|
||||||
ARG DATE
|
ARG DATE
|
||||||
RUN mkdir /build
|
RUN mkdir /build
|
||||||
ADD . /build/
|
ADD . /build/
|
||||||
WORKDIR /build/kustomize
|
WORKDIR /build/kustomize
|
||||||
RUN CGO_ENABLED=0 GO111MODULE=on go build \
|
RUN CGO_ENABLED=0 GO111MODULE=on go build \
|
||||||
@@ -17,4 +17,5 @@ FROM alpine
|
|||||||
RUN apk add git openssh
|
RUN apk add git openssh
|
||||||
COPY --from=builder /build/kustomize /app/
|
COPY --from=builder /build/kustomize /app/
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
ENV PATH "$PATH:/app"
|
||||||
ENTRYPOINT ["/app/kustomize"]
|
ENTRYPOINT ["/app/kustomize"]
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ require (
|
|||||||
github.com/spf13/cobra v1.0.0
|
github.com/spf13/cobra v1.0.0
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
k8s.io/client-go v0.18.10
|
k8s.io/client-go v0.18.10
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/cmd/config v0.8.6
|
sigs.k8s.io/kustomize/cmd/config v0.8.7
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,5 +19,3 @@ exclude (
|
|||||||
sigs.k8s.io/kustomize/api v0.2.0
|
sigs.k8s.io/kustomize/api v0.2.0
|
||||||
sigs.k8s.io/kustomize/cmd/config v0.2.0
|
sigs.k8s.io/kustomize/cmd/config v0.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
replace sigs.k8s.io/kustomize/api => ../api
|
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
@@ -591,8 +592,6 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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=
|
||||||
@@ -623,10 +622,12 @@ k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/cmd/config v0.8.6 h1:Rr7eyD+h32OfruN6V+cgUqHRpC2Y5ZnjjAPbjhKFLGE=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/cmd/config v0.8.6/go.mod h1:e4PgdLUNnkf+Iapvjyb6gTG9DZQkDZIR6uS1Bv4YA6s=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/cmd/config v0.8.7 h1:qhwnysAgGbSRD9AyLHmnybq7O8OuQkdDv7ZcEtkRWQQ=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/cmd/config v0.8.7/go.mod h1:TFvRemJUSkvJykqvrEErHd8GvC/TSEOKfPOpx/+f8Lc=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ=
|
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ=
|
||||||
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/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ images:
|
|||||||
|
|
||||||
to the kustomization file if it doesn't exist,
|
to the kustomization file if it doesn't exist,
|
||||||
and overwrite the previous ones if the image name exists.
|
and overwrite the previous ones if the image name exists.
|
||||||
|
|
||||||
|
The image tag can only contain alphanumeric, '.', '_' and '-'.
|
||||||
`,
|
`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
err := o.Validate(args)
|
err := o.Validate(args)
|
||||||
|
|||||||
@@ -19,5 +19,5 @@ require (
|
|||||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
|
||||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect
|
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect
|
||||||
gopkg.in/yaml.v2 v2.3.0
|
gopkg.in/yaml.v2 v2.3.0
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -295,6 +295,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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=
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ spec:
|
|||||||
// TestFormatInput_service verifies a Service yaml is formatted correctly
|
// TestFormatInput_service verifies a Service yaml is formatted correctly
|
||||||
func TestFormatInput_validatingWebhookConfiguration(t *testing.T) {
|
func TestFormatInput_validatingWebhookConfiguration(t *testing.T) {
|
||||||
y := `
|
y := `
|
||||||
apiVersion: admissionregistration.k8s.io/v1beta1
|
apiVersion: admissionregistration.k8s.io/v1
|
||||||
kind: ValidatingWebhookConfiguration
|
kind: ValidatingWebhookConfiguration
|
||||||
metadata:
|
metadata:
|
||||||
name: <name of this configuration object>
|
name: <name of this configuration object>
|
||||||
@@ -490,7 +490,7 @@ webhooks:
|
|||||||
- v1beta1
|
- v1beta1
|
||||||
timeoutSeconds: 1
|
timeoutSeconds: 1
|
||||||
`
|
`
|
||||||
expected := `apiVersion: admissionregistration.k8s.io/v1beta1
|
expected := `apiVersion: admissionregistration.k8s.io/v1
|
||||||
kind: ValidatingWebhookConfiguration
|
kind: ValidatingWebhookConfiguration
|
||||||
metadata:
|
metadata:
|
||||||
name: <name of this configuration object>
|
name: <name of this configuration object>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@@ -252,7 +253,10 @@ func (r RunFns) getFunctionsFromInput(nodes []*yaml.RNode) ([]kio.Filter, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sortFns(buff)
|
err = sortFns(buff)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return r.getFunctionFilters(false, buff.Nodes...)
|
return r.getFunctionFilters(false, buff.Nodes...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,12 +335,33 @@ func (r RunFns) getFunctionFilters(global bool, fns ...*yaml.RNode) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sortFns sorts functions so that functions with the longest paths come first
|
// sortFns sorts functions so that functions with the longest paths come first
|
||||||
func sortFns(buff *kio.PackageBuffer) {
|
func sortFns(buff *kio.PackageBuffer) error {
|
||||||
|
var outerErr error
|
||||||
// sort the nodes so that we traverse them depth first
|
// sort the nodes so that we traverse them depth first
|
||||||
// functions deeper in the file system tree should be run first
|
// functions deeper in the file system tree should be run first
|
||||||
sort.Slice(buff.Nodes, func(i, j int) bool {
|
sort.Slice(buff.Nodes, func(i, j int) bool {
|
||||||
mi, _ := buff.Nodes[i].GetMeta()
|
mi, _ := buff.Nodes[i].GetMeta()
|
||||||
pi := filepath.ToSlash(mi.Annotations[kioutil.PathAnnotation])
|
pi := filepath.ToSlash(mi.Annotations[kioutil.PathAnnotation])
|
||||||
|
|
||||||
|
mj, _ := buff.Nodes[j].GetMeta()
|
||||||
|
pj := filepath.ToSlash(mj.Annotations[kioutil.PathAnnotation])
|
||||||
|
|
||||||
|
// If the path is the same, we decide the ordering based on the
|
||||||
|
// index annotation.
|
||||||
|
if pi == pj {
|
||||||
|
iIndex, err := strconv.Atoi(mi.Annotations[kioutil.IndexAnnotation])
|
||||||
|
if err != nil {
|
||||||
|
outerErr = err
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
jIndex, err := strconv.Atoi(mj.Annotations[kioutil.IndexAnnotation])
|
||||||
|
if err != nil {
|
||||||
|
outerErr = err
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return iIndex < jIndex
|
||||||
|
}
|
||||||
|
|
||||||
if filepath.Base(path.Dir(pi)) == "functions" {
|
if filepath.Base(path.Dir(pi)) == "functions" {
|
||||||
// don't count the functions dir, the functions are scoped 1 level above
|
// don't count the functions dir, the functions are scoped 1 level above
|
||||||
pi = filepath.Dir(path.Dir(pi))
|
pi = filepath.Dir(path.Dir(pi))
|
||||||
@@ -344,8 +369,6 @@ func sortFns(buff *kio.PackageBuffer) {
|
|||||||
pi = filepath.Dir(pi)
|
pi = filepath.Dir(pi)
|
||||||
}
|
}
|
||||||
|
|
||||||
mj, _ := buff.Nodes[j].GetMeta()
|
|
||||||
pj := filepath.ToSlash(mj.Annotations[kioutil.PathAnnotation])
|
|
||||||
if filepath.Base(path.Dir(pj)) == "functions" {
|
if filepath.Base(path.Dir(pj)) == "functions" {
|
||||||
// don't count the functions dir, the functions are scoped 1 level above
|
// don't count the functions dir, the functions are scoped 1 level above
|
||||||
pj = filepath.Dir(path.Dir(pj))
|
pj = filepath.Dir(path.Dir(pj))
|
||||||
@@ -374,6 +397,7 @@ func sortFns(buff *kio.PackageBuffer) {
|
|||||||
// sort by path names if depths are equal
|
// sort by path names if depths are equal
|
||||||
return pi < pj
|
return pi < pj
|
||||||
})
|
})
|
||||||
|
return outerErr
|
||||||
}
|
}
|
||||||
|
|
||||||
// init initializes the RunFns with a containerFilterProvider.
|
// init initializes the RunFns with a containerFilterProvider.
|
||||||
|
|||||||
@@ -734,6 +734,94 @@ metadata:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRunFns_sortFns(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
nodes []*yaml.RNode
|
||||||
|
expectedImages []string
|
||||||
|
expectedErrMsg string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "multiple functions in the same file are ordered by index",
|
||||||
|
nodes: []*yaml.RNode{
|
||||||
|
yaml.MustParse(`
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/path: functions.yaml
|
||||||
|
config.kubernetes.io/index: 1
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
container:
|
||||||
|
image: a
|
||||||
|
`),
|
||||||
|
yaml.MustParse(`
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/path: functions.yaml
|
||||||
|
config.kubernetes.io/index: 0
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
container:
|
||||||
|
image: b
|
||||||
|
`),
|
||||||
|
},
|
||||||
|
expectedImages: []string{"b", "a"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "non-integer value in index annotation is an error",
|
||||||
|
nodes: []*yaml.RNode{
|
||||||
|
yaml.MustParse(`
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/path: functions.yaml
|
||||||
|
config.kubernetes.io/index: 0
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
container:
|
||||||
|
image: a
|
||||||
|
`),
|
||||||
|
yaml.MustParse(`
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/path: functions.yaml
|
||||||
|
config.kubernetes.io/index: abc
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
container:
|
||||||
|
image: b
|
||||||
|
`),
|
||||||
|
},
|
||||||
|
expectedErrMsg: "strconv.Atoi: parsing \"abc\": invalid syntax",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range testCases {
|
||||||
|
test := testCases[i]
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
packageBuff := &kio.PackageBuffer{
|
||||||
|
Nodes: test.nodes,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := sortFns(packageBuff)
|
||||||
|
if test.expectedErrMsg != "" {
|
||||||
|
if !assert.Error(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
assert.Equal(t, test.expectedErrMsg, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
var images []string
|
||||||
|
for _, n := range packageBuff.Nodes {
|
||||||
|
spec := runtimeutil.GetFunctionSpec(n)
|
||||||
|
images = append(images, spec.Container.Image)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, test.expectedImages, images)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRunFns_network(t *testing.T) {
|
func TestRunFns_network(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ func validateAgainstSchema(ext *CliExtension, sch *spec.Schema) error {
|
|||||||
// document that we can use for validation.
|
// document that we can use for validation.
|
||||||
var tmplText string
|
var tmplText string
|
||||||
if sch.Items != nil && sch.Items.Schema != nil &&
|
if sch.Items != nil && sch.Items.Schema != nil &&
|
||||||
sch.Items.Schema.Type.Contains("string") {
|
shouldQuoteSetterValue(ext.Setter.ListValues, sch.Items.Schema.Type) {
|
||||||
// If string is one of the legal types for the value, we
|
// If string is one of the legal types for the value, we
|
||||||
// output it with quotes in the yaml document to make sure it
|
// output it with quotes in the yaml document to make sure it
|
||||||
// is later parsed as a string.
|
// is later parsed as a string.
|
||||||
@@ -295,7 +295,7 @@ func validateAgainstSchema(ext *CliExtension, sch *spec.Schema) error {
|
|||||||
var format string
|
var format string
|
||||||
// Only add quotes around the value is string is one of the
|
// Only add quotes around the value is string is one of the
|
||||||
// types in the schema.
|
// types in the schema.
|
||||||
if sch.Type.Contains("string") {
|
if shouldQuoteSetterValue([]string{ext.Setter.Value}, sch.Type) {
|
||||||
format = "%s: \"%s\""
|
format = "%s: \"%s\""
|
||||||
} else {
|
} else {
|
||||||
format = "%s: %s"
|
format = "%s: %s"
|
||||||
@@ -315,6 +315,22 @@ func validateAgainstSchema(ext *CliExtension, sch *spec.Schema) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shouldQuoteSetterValue returns true if string is one of the types in the
|
||||||
|
// schema, or if the value ends in a ':' (the yaml parser gets confused by
|
||||||
|
// the ':' at the end unless the value is quoted)
|
||||||
|
func shouldQuoteSetterValue(a []string, schType spec.StringOrArray) bool {
|
||||||
|
if schType.Contains("string") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, s := range a {
|
||||||
|
if strings.HasSuffix(s, ":") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// fixSchemaTypes traverses the schema and checks for some common
|
// fixSchemaTypes traverses the schema and checks for some common
|
||||||
// errors for the type field. This currently involves users using
|
// errors for the type field. This currently involves users using
|
||||||
// 'int' instead of 'integer' and 'bool' instead of 'boolean'. Early versions
|
// 'int' instead of 'integer' and 'bool' instead of 'boolean'. Early versions
|
||||||
|
|||||||
@@ -730,6 +730,73 @@ metadata:
|
|||||||
name: nginx-deployment
|
name: nginx-deployment
|
||||||
annotations:
|
annotations:
|
||||||
foo: true # {"$ref": "#/definitions/io.k8s.cli.setters.foo"}
|
foo: true # {"$ref": "#/definitions/io.k8s.cli.setters.foo"}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "set-quoted-value-with-colon",
|
||||||
|
description: "if a value ends in ':', we should accept it",
|
||||||
|
setter: "app",
|
||||||
|
openapi: `
|
||||||
|
openAPI:
|
||||||
|
definitions:
|
||||||
|
io.k8s.cli.setters.app:
|
||||||
|
x-k8s-cli:
|
||||||
|
setter:
|
||||||
|
name: app
|
||||||
|
value: "value:"
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
annotations:
|
||||||
|
app: nginx # {"$ref": "#/definitions/io.k8s.cli.setters.app"}
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
annotations:
|
||||||
|
app: "value:" # {"$ref": "#/definitions/io.k8s.cli.setters.app"}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "set-quoted-list-values-with-colon",
|
||||||
|
setter: "args",
|
||||||
|
openapi: `
|
||||||
|
openAPI:
|
||||||
|
definitions:
|
||||||
|
io.k8s.cli.setters.args:
|
||||||
|
x-k8s-cli:
|
||||||
|
type: array
|
||||||
|
setter:
|
||||||
|
name: args
|
||||||
|
listValues: ["1:", "2:", "3:"]
|
||||||
|
`,
|
||||||
|
input: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
spec:
|
||||||
|
# {"$ref": "#/definitions/io.k8s.cli.setters.args"}
|
||||||
|
replicas:
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
spec:
|
||||||
|
# {"$ref": "#/definitions/io.k8s.cli.setters.args"}
|
||||||
|
replicas:
|
||||||
|
- "1:"
|
||||||
|
- "2:"
|
||||||
|
- "3:"
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ var WhitelistedListSortKinds = newSet(
|
|||||||
// sorting list field elements
|
// sorting list field elements
|
||||||
var WhitelistedListSortApis = newSet(
|
var WhitelistedListSortApis = newSet(
|
||||||
"apps/v1", "apps/v1beta1", "apps/v1beta2", "batch/v1", "batch/v1beta1",
|
"apps/v1", "apps/v1beta1", "apps/v1beta2", "batch/v1", "batch/v1beta1",
|
||||||
"extensions/v1beta1", "v1", "admissionregistration.k8s.io/v1beta1")
|
"extensions/v1beta1", "v1", "admissionregistration.k8s.io/v1")
|
||||||
|
|
||||||
// WhitelistedListSortFields contains json paths to list fields that should
|
// WhitelistedListSortFields contains json paths to list fields that should
|
||||||
// be sorted, and the field they should be sorted by
|
// be sorted, and the field they should be sorted by
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -197,7 +198,8 @@ func (rn *RNode) IsNilOrEmpty() bool {
|
|||||||
return rn.IsNil() ||
|
return rn.IsNil() ||
|
||||||
IsYNodeTaggedNull(rn.YNode()) ||
|
IsYNodeTaggedNull(rn.YNode()) ||
|
||||||
IsYNodeEmptyMap(rn.YNode()) ||
|
IsYNodeEmptyMap(rn.YNode()) ||
|
||||||
IsYNodeEmptySeq(rn.YNode())
|
IsYNodeEmptySeq(rn.YNode()) ||
|
||||||
|
IsYNodeZero(rn.YNode())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMeta returns the ResourceMeta for an RNode
|
// GetMeta returns the ResourceMeta for an RNode
|
||||||
@@ -416,6 +418,34 @@ func (rn *RNode) SetMapField(value *RNode, path ...string) error {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rn *RNode) GetDataMap() map[string]string {
|
||||||
|
n, err := rn.Pipe(Lookup(DataField))
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
result := map[string]string{}
|
||||||
|
_ = n.VisitFields(func(node *MapNode) error {
|
||||||
|
result[GetValue(node.Key)] = GetValue(node.Value)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rn *RNode) SetDataMap(m map[string]string) {
|
||||||
|
if rn == nil {
|
||||||
|
log.Fatal("cannot set data map on nil Rnode")
|
||||||
|
}
|
||||||
|
if len(m) == 0 {
|
||||||
|
if err := rn.PipeE(Clear(DataField)); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := rn.SetMapField(NewMapRNode(&m), DataField); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AppendToFieldPath appends a field name to the FieldPath.
|
// AppendToFieldPath appends a field name to the FieldPath.
|
||||||
func (rn *RNode) AppendToFieldPath(parts ...string) {
|
func (rn *RNode) AppendToFieldPath(parts ...string) {
|
||||||
rn.fieldPath = append(rn.fieldPath, parts...)
|
rn.fieldPath = append(rn.fieldPath, parts...)
|
||||||
|
|||||||
@@ -115,6 +115,148 @@ func TestRNodeNewStringRNodeBinary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRNodeGetDataMap(t *testing.T) {
|
||||||
|
emptyMap := map[string]string{}
|
||||||
|
testCases := map[string]struct {
|
||||||
|
theMap map[string]interface{}
|
||||||
|
expected map[string]string
|
||||||
|
}{
|
||||||
|
"actuallyNil": {
|
||||||
|
theMap: nil,
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"empty": {
|
||||||
|
theMap: map[string]interface{}{},
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"mostlyEmpty": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"hey": "there",
|
||||||
|
},
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"noNameConfigMap": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "ConfigMap",
|
||||||
|
},
|
||||||
|
expected: emptyMap,
|
||||||
|
},
|
||||||
|
"configmap": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "ConfigMap",
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"name": "winnie",
|
||||||
|
},
|
||||||
|
"data": map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
"city": "brownsville",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// order irrelevant, because assert.Equals is smart about maps.
|
||||||
|
expected: map[string]string{
|
||||||
|
"city": "brownsville",
|
||||||
|
"wine": "cabernet",
|
||||||
|
"planet": "mars",
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for n := range testCases {
|
||||||
|
tc := testCases[n]
|
||||||
|
t.Run(n, func(t *testing.T) {
|
||||||
|
rn, err := FromMap(tc.theMap)
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
m := rn.GetDataMap()
|
||||||
|
if !assert.Equal(t, tc.expected, m) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRNodeSetDataMap(t *testing.T) {
|
||||||
|
testCases := map[string]struct {
|
||||||
|
theMap map[string]interface{}
|
||||||
|
input map[string]string
|
||||||
|
expected map[string]string
|
||||||
|
}{
|
||||||
|
"empty": {
|
||||||
|
theMap: map[string]interface{}{},
|
||||||
|
input: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
expected: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"replace": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"foo": 3,
|
||||||
|
"data": map[string]string{
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
expected: map[string]string{
|
||||||
|
"wine": "cabernet",
|
||||||
|
"truck": "ford",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"clear1": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"foo": 3,
|
||||||
|
"data": map[string]string{
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input: map[string]string{},
|
||||||
|
expected: map[string]string{},
|
||||||
|
},
|
||||||
|
"clear2": {
|
||||||
|
theMap: map[string]interface{}{
|
||||||
|
"foo": 3,
|
||||||
|
"data": map[string]string{
|
||||||
|
"rocket": "falcon9",
|
||||||
|
"planet": "mars",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input: nil,
|
||||||
|
expected: map[string]string{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for n := range testCases {
|
||||||
|
tc := testCases[n]
|
||||||
|
t.Run(n, func(t *testing.T) {
|
||||||
|
rn, err := FromMap(tc.theMap)
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
rn.SetDataMap(tc.input)
|
||||||
|
m := rn.GetDataMap()
|
||||||
|
if !assert.Equal(t, tc.expected, m) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRNodeGetValidatedMetadata(t *testing.T) {
|
func TestRNodeGetValidatedMetadata(t *testing.T) {
|
||||||
testConfigMap := map[string]interface{}{
|
testConfigMap := map[string]interface{}{
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
@@ -750,6 +892,10 @@ func TestRNodeIsNilOrEmpty(t *testing.T) {
|
|||||||
if NewListRNode("foo").IsNilOrEmpty() {
|
if NewListRNode("foo").IsNilOrEmpty() {
|
||||||
t.Fatalf("non-empty list should not be empty")
|
t.Fatalf("non-empty list should not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !NewRNode(&Node{}).IsNilOrEmpty() {
|
||||||
|
t.Fatalf("zero YNode should be empty")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deploymentJSON = `
|
const deploymentJSON = `
|
||||||
|
|||||||
@@ -54,6 +54,18 @@ func IsYNodeString(n *yaml.Node) bool {
|
|||||||
return n.Kind == yaml.ScalarNode && n.Tag == NodeTagString
|
return n.Kind == yaml.ScalarNode && n.Tag == NodeTagString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsYNodeZero is true if all the public fields in the Node are empty.
|
||||||
|
// Which means it's not initialized and should be omitted when marshal.
|
||||||
|
// The Node itself has a method IsZero but it is not released
|
||||||
|
// in yaml.v3. https://pkg.go.dev/gopkg.in/yaml.v3#Node.IsZero
|
||||||
|
func IsYNodeZero(n *yaml.Node) bool {
|
||||||
|
// TODO: Change this to use IsZero when it's avaialable.
|
||||||
|
return n != nil && n.Kind == 0 && n.Style == 0 && n.Tag == "" && n.Value == "" &&
|
||||||
|
n.Anchor == "" && n.Alias == nil && n.Content == nil &&
|
||||||
|
n.HeadComment == "" && n.LineComment == "" && n.FootComment == "" &&
|
||||||
|
n.Line == 0 && n.Column == 0
|
||||||
|
}
|
||||||
|
|
||||||
// Parser parses values into configuration.
|
// Parser parses values into configuration.
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
Kind string `yaml:"kind,omitempty"`
|
Kind string `yaml:"kind,omitempty"`
|
||||||
|
|||||||
@@ -112,3 +112,15 @@ func TestIsYNodeEmptySeq(t *testing.T) {
|
|||||||
t.Fatalf("a node with content isn't empty")
|
t.Fatalf("a node with content isn't empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIsYNodeZero(t *testing.T) {
|
||||||
|
if IsYNodeZero(nil) {
|
||||||
|
t.Fatalf("nil node should not be zero")
|
||||||
|
}
|
||||||
|
if !IsYNodeZero(&Node{}) {
|
||||||
|
t.Fatalf("node is zero")
|
||||||
|
}
|
||||||
|
if IsYNodeZero(&Node{Kind: MappingNode}) {
|
||||||
|
t.Fatalf("node is not zero")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module sigs.k8s.io/kustomize/plugin/builtin/annotationstransformer
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module sigs.k8s.io/kustomize/plugin/builtin/configmapgenerator
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,8 +533,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
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=
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ module sigs.k8s.io/kustomize/plugin/builtin/hashtransformer
|
|||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require sigs.k8s.io/kustomize/api v0.6.6
|
require sigs.k8s.io/kustomize/api v0.6.8
|
||||||
|
|
||||||
replace sigs.k8s.io/kustomize/kyaml => ../../../kyaml
|
replace sigs.k8s.io/kustomize/kyaml => ../../../kyaml
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,8 +533,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
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=
|
||||||
|
|||||||
@@ -13,12 +13,15 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/imdario/mergo"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
"sigs.k8s.io/kustomize/api/resmap"
|
"sigs.k8s.io/kustomize/api/resmap"
|
||||||
@@ -70,6 +73,9 @@ func (p *HelmChartInflationGeneratorPlugin) Config(h *resmap.PluginHelpers, conf
|
|||||||
if p.Values == "" {
|
if p.Values == "" {
|
||||||
p.Values = path.Join(p.ChartHome, p.ChartName, "values.yaml")
|
p.Values = path.Join(p.ChartHome, p.ChartName, "values.yaml")
|
||||||
}
|
}
|
||||||
|
if p.ValuesMerge == "" {
|
||||||
|
p.ValuesMerge = "override"
|
||||||
|
}
|
||||||
// runHelmCommand will run `helm` command with args provided. Return stdout
|
// runHelmCommand will run `helm` command with args provided. Return stdout
|
||||||
// and error if there is any.
|
// and error if there is any.
|
||||||
p.runHelmCommand = func(args []string) ([]byte, error) {
|
p.runHelmCommand = func(args []string) ([]byte, error) {
|
||||||
@@ -96,6 +102,63 @@ func (p *HelmChartInflationGeneratorPlugin) Config(h *resmap.PluginHelpers, conf
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EncodeValues for writing
|
||||||
|
func (p *HelmChartInflationGeneratorPlugin) EncodeValues(w io.Writer) error {
|
||||||
|
d, err := yaml.Marshal(p.ValuesLocal)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = w.Write(d)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// useValuesLocal process (merge) inflator config provided values with chart default values.yaml
|
||||||
|
func (p *HelmChartInflationGeneratorPlugin) useValuesLocal() error {
|
||||||
|
fn := path.Join(p.ChartHome, p.ChartName, "kustomize-values.yaml")
|
||||||
|
vf, err := os.Create(fn)
|
||||||
|
defer vf.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// override, merge, none
|
||||||
|
if p.ValuesMerge == "none" || p.ValuesMerge == "no" || p.ValuesMerge == "false" {
|
||||||
|
p.Values = fn
|
||||||
|
} else {
|
||||||
|
pValues, err := ioutil.ReadFile(p.Values)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
chValues := make(map[string]interface{})
|
||||||
|
err = yaml.Unmarshal(pValues, &chValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if p.ValuesMerge == "override" {
|
||||||
|
err = mergo.Merge(&chValues, p.ValuesLocal, mergo.WithOverride)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if p.ValuesMerge == "merge" {
|
||||||
|
err = mergo.Merge(&chValues, p.ValuesLocal)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.ValuesLocal = chValues
|
||||||
|
p.Values = fn
|
||||||
|
}
|
||||||
|
err = p.EncodeValues(vf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vf.Sync()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Generate implements generator
|
// Generate implements generator
|
||||||
func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
||||||
// cleanup
|
// cleanup
|
||||||
@@ -112,6 +175,15 @@ func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inflator config valuesLocal
|
||||||
|
if len(p.ValuesLocal) > 0 {
|
||||||
|
err := p.useValuesLocal()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// render the charts
|
// render the charts
|
||||||
stdout, err := p.runHelmCommand(p.getTemplateCommandArgs())
|
stdout, err := p.runHelmCommand(p.getTemplateCommandArgs())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -114,6 +114,14 @@ releaseName: test
|
|||||||
releaseNamespace: testNamespace
|
releaseNamespace: testNamespace
|
||||||
values: %s
|
values: %s
|
||||||
`, tempDir, tempDir, valuesPath))
|
`, tempDir, tempDir, valuesPath))
|
||||||
|
valuesLocal:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512Mi
|
||||||
|
cpu: 1000m
|
||||||
|
requests:
|
||||||
|
memory: 512Mi
|
||||||
|
cpu: 200m
|
||||||
|
|
||||||
th.AssertActualEqualsExpected(rm, `
|
th.AssertActualEqualsExpected(rm, `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ module sigs.k8s.io/kustomize/plugin/builtin/helmchartinflationgenerator
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/imdario/mergo v0.3.5
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -505,8 +506,8 @@ gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -528,10 +529,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module sigs.k8s.io/kustomize/plugin/builtin/imagetagtransformer
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module sigs.k8s.io/kustomize/plugin/builtin/labeltransformer
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ go 1.15
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
)
|
)
|
||||||
|
|
||||||
replace sigs.k8s.io/kustomize/kyaml => ../../../kyaml
|
replace sigs.k8s.io/kustomize/kyaml => ../../../kyaml
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,8 +533,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
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=
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ subjects:
|
|||||||
name: another
|
name: another
|
||||||
namespace: random
|
namespace: random
|
||||||
---
|
---
|
||||||
apiVersion: admissionregistration.k8s.io/v1beta1
|
apiVersion: admissionregistration.k8s.io/v1
|
||||||
kind: ValidatingWebhookConfiguration
|
kind: ValidatingWebhookConfiguration
|
||||||
metadata:
|
metadata:
|
||||||
name: example
|
name: example
|
||||||
@@ -94,21 +94,21 @@ webhooks:
|
|||||||
name: svc2
|
name: svc2
|
||||||
namespace: system
|
namespace: system
|
||||||
---
|
---
|
||||||
apiVersion: apiextensions.k8s.io/v1beta1
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: crd
|
name: crd
|
||||||
`,
|
`,
|
||||||
// Import note: The namespace transformer is in charge of
|
// Import note: The namespace transformer is in charge of
|
||||||
// the metadata.namespace field. The namespace transformer SHOULD
|
// the metadata.namespace field. The namespace transformer SHOULD
|
||||||
// NOT modify neither the "namespace" subfield within the
|
// NOT modify neither the "namespace" subfield within the
|
||||||
// ClusterRoleBinding.subjects field nor the "namespace"
|
// ClusterRoleBinding.subjects field nor the "namespace"
|
||||||
// subfield in the ValidatingWebhookConfiguration.webhooks field.
|
// subfield in the ValidatingWebhookConfiguration.webhooks field.
|
||||||
// This is the role of the namereference Transformer to handle
|
// This is the role of the namereference Transformer to handle
|
||||||
// object reference changes (prefix/suffix and namespace).
|
// object reference changes (prefix/suffix and namespace).
|
||||||
// For use cases involving simultaneous change of name and namespace,
|
// For use cases involving simultaneous change of name and namespace,
|
||||||
// refer to namespaces tests in pkg/target test suites.
|
// refer to namespaces tests in pkg/target test suites.
|
||||||
`
|
`
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
@@ -159,7 +159,7 @@ subjects:
|
|||||||
name: another
|
name: another
|
||||||
namespace: random
|
namespace: random
|
||||||
---
|
---
|
||||||
apiVersion: admissionregistration.k8s.io/v1beta1
|
apiVersion: admissionregistration.k8s.io/v1
|
||||||
kind: ValidatingWebhookConfiguration
|
kind: ValidatingWebhookConfiguration
|
||||||
metadata:
|
metadata:
|
||||||
name: example
|
name: example
|
||||||
@@ -175,7 +175,7 @@ webhooks:
|
|||||||
namespace: system
|
namespace: system
|
||||||
name: example2
|
name: example2
|
||||||
---
|
---
|
||||||
apiVersion: apiextensions.k8s.io/v1beta1
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: crd
|
name: crd
|
||||||
@@ -259,12 +259,12 @@ metadata:
|
|||||||
name: cm
|
name: cm
|
||||||
namespace: bar
|
namespace: bar
|
||||||
`,
|
`,
|
||||||
func(t *testing.T, err error) {
|
func(t *testing.T, err error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error")
|
t.Fatal("expected error")
|
||||||
}
|
}
|
||||||
if !strings.Contains(err.Error(), "ID conflict") {
|
if !strings.Contains(err.Error(), "ID conflict") {
|
||||||
t.Fatalf("unexpected error: %s", err.Error())
|
t.Fatalf("unexpected error: %s", err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module sigs.k8s.io/kustomize/plugin/builtin/namespacetransformer
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ go 1.15
|
|||||||
require (
|
require (
|
||||||
github.com/evanphx/json-patch v4.5.0+incompatible
|
github.com/evanphx/json-patch v4.5.0+incompatible
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type plugin struct {
|
type plugin struct {
|
||||||
h *resmap.PluginHelpers
|
|
||||||
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"`
|
||||||
@@ -25,7 +24,6 @@ var KustomizePlugin plugin
|
|||||||
|
|
||||||
func (p *plugin) Config(
|
func (p *plugin) Config(
|
||||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||||
p.h = h
|
|
||||||
err = yaml.Unmarshal(c, p)
|
err = yaml.Unmarshal(c, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -40,13 +38,13 @@ func (p *plugin) Config(
|
|||||||
// All tests pass if this code is commented out. This code should
|
// All tests pass if this code is commented out. This code should
|
||||||
// be deleted; the user should use the Patches field which
|
// be deleted; the user should use the Patches field which
|
||||||
// exists for this purpose (inline patch declaration).
|
// exists for this purpose (inline patch declaration).
|
||||||
res, err := p.h.ResmapFactory().RF().SliceFromBytes([]byte(onePath))
|
res, err := h.ResmapFactory().RF().SliceFromBytes([]byte(onePath))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
p.loadedPatches = append(p.loadedPatches, res...)
|
p.loadedPatches = append(p.loadedPatches, res...)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
res, err = p.h.ResmapFactory().RF().SliceFromPatches(
|
res, err = h.ResmapFactory().RF().SliceFromPatches(
|
||||||
p.h.Loader(), []types.PatchStrategicMerge{onePath})
|
h.Loader(), []types.PatchStrategicMerge{onePath})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -54,7 +52,7 @@ func (p *plugin) Config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.Patches != "" {
|
if p.Patches != "" {
|
||||||
res, err := p.h.ResmapFactory().RF().SliceFromBytes([]byte(p.Patches))
|
res, err := h.ResmapFactory().RF().SliceFromBytes([]byte(p.Patches))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -65,15 +63,17 @@ func (p *plugin) Config(
|
|||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"patch appears to be empty; files=%v, Patch=%s", p.Paths, p.Patches)
|
"patch appears to be empty; files=%v, Patch=%s", p.Paths, p.Patches)
|
||||||
}
|
}
|
||||||
return err
|
// Merge the patches, looking for conflicts.
|
||||||
}
|
m, err := h.ResmapFactory().ConflatePatches(p.loadedPatches)
|
||||||
|
|
||||||
func (p *plugin) Transform(m resmap.ResMap) error {
|
|
||||||
patches, err := p.h.ResmapFactory().Merge(p.loadedPatches)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, patch := range patches.Resources() {
|
p.loadedPatches = m.Resources()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *plugin) Transform(m resmap.ResMap) error {
|
||||||
|
for _, patch := range p.loadedPatches {
|
||||||
target, err := m.GetById(patch.OrgId())
|
target, err := m.GetById(patch.OrgId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ go 1.15
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
replace sigs.k8s.io/kustomize/kyaml v0.9.4 => ../../../kyaml
|
replace sigs.k8s.io/kustomize/kyaml => ../../../kyaml
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,8 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
|
||||||
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=
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ go 1.15
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/evanphx/json-patch v4.5.0+incompatible
|
github.com/evanphx/json-patch v4.5.0+incompatible
|
||||||
sigs.k8s.io/kustomize/api v0.6.6
|
sigs.k8s.io/kustomize/api v0.6.8
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3
|
sigs.k8s.io/kustomize/kyaml v0.10.5
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
|
||||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
@@ -510,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
@@ -532,10 +533,10 @@ k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl
|
|||||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6 h1:Da5JBSFqA22R5Q1mHiVD4+vgs1j8OwTXcT+l6bbrVzk=
|
sigs.k8s.io/kustomize/api v0.6.8 h1:LWdCuSy58Ls2xxyp5BLW655zPcJyT3bOpGcOtuHzt4A=
|
||||||
sigs.k8s.io/kustomize/api v0.6.6/go.mod h1:3TxKEyaxwOIfHmRbQF14hDUSRmVQI0iSn8qDA5zaO/0=
|
sigs.k8s.io/kustomize/api v0.6.8/go.mod h1:XOt24UrCkv0x63eT5JVaph4Kqf5EVU2UBAXo6SPBaAY=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3 h1:ARSJUMN/c3k31DYxRfZ+vp/UepUQjg9zCwny7Oj908I=
|
sigs.k8s.io/kustomize/kyaml v0.10.5 h1:PbJcsZsEM7O3hHtUWTR+4WkHVbQRW9crSy75or1gRbI=
|
||||||
sigs.k8s.io/kustomize/kyaml v0.10.3/go.mod h1:RA+iCHA2wPCOfv6uG6TfXXWhYsHpgErq/AljxWKuxtg=
|
sigs.k8s.io/kustomize/kyaml v0.10.5/go.mod h1:P6Oy/ah/GZMKzJMIJA2a3/bc8YrBkuL5kJji13PSIzY=
|
||||||
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=
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user