mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 18:40:55 +00:00
Compare commits
234 Commits
api/v0.8.1
...
api/v0.8.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
768132f65f | ||
|
|
6a708bcc23 | ||
|
|
d8182f8d81 | ||
|
|
99b6a5920e | ||
|
|
8877c81468 | ||
|
|
88911bbb61 | ||
|
|
01c477570a | ||
|
|
f8dad80a79 | ||
|
|
240cda089a | ||
|
|
c94c193b5b | ||
|
|
9989b5fc84 | ||
|
|
aeba50488b | ||
|
|
9c43518a15 | ||
|
|
9d50890174 | ||
|
|
3af1ae4159 | ||
|
|
5100568b0c | ||
|
|
aa5b4814d6 | ||
|
|
264b3ff338 | ||
|
|
a40c74e545 | ||
|
|
f61b075d3b | ||
|
|
629d822604 | ||
|
|
bf64f109b9 | ||
|
|
5f93fc53f4 | ||
|
|
0fe3f303e8 | ||
|
|
7825050b18 | ||
|
|
ed688a87e4 | ||
|
|
629fdee26a | ||
|
|
ca58ce775a | ||
|
|
0990d96c52 | ||
|
|
94c45e0f9f | ||
|
|
ca527a8e4c | ||
|
|
fa0b237178 | ||
|
|
a9bcf7187a | ||
|
|
a49d429909 | ||
|
|
c63288024d | ||
|
|
f374a12f24 | ||
|
|
c7156d0586 | ||
|
|
d3b7d3ab70 | ||
|
|
197bb9d9e3 | ||
|
|
fa96878cfc | ||
|
|
558995536d | ||
|
|
3255c73c71 | ||
|
|
fd486c1f23 | ||
|
|
b0a40e2752 | ||
|
|
ccb95ab269 | ||
|
|
e6b52e7295 | ||
|
|
4a6ec9063d | ||
|
|
c3beadacd9 | ||
|
|
5f3bd4b4c2 | ||
|
|
e77c284924 | ||
|
|
5ed2067be9 | ||
|
|
7b38ce4ef2 | ||
|
|
700a112b28 | ||
|
|
e05ce0f05b | ||
|
|
b8cfa3ca9b | ||
|
|
26a8455717 | ||
|
|
710db98dbf | ||
|
|
0d152c4784 | ||
|
|
1729c95135 | ||
|
|
6f6d41f17f | ||
|
|
3ff5263ff6 | ||
|
|
5bb668533f | ||
|
|
eb48b1b718 | ||
|
|
1f837fdfec | ||
|
|
1301384670 | ||
|
|
a9c20a2eb7 | ||
|
|
297bdc3825 | ||
|
|
831f99c95b | ||
|
|
5247aa5750 | ||
|
|
74d5646526 | ||
|
|
2f6a611e62 | ||
|
|
d0dbc3e87b | ||
|
|
235101a614 | ||
|
|
123a5d6e56 | ||
|
|
e4bbd04a43 | ||
|
|
75120b2a92 | ||
|
|
cb423ad300 | ||
|
|
c81b5bd3c2 | ||
|
|
b3cec39c25 | ||
|
|
5fc6cab49f | ||
|
|
c636ee616b | ||
|
|
f96ac2d61e | ||
|
|
a513c56d88 | ||
|
|
ed3ab9f532 | ||
|
|
bab8c34c1f | ||
|
|
839fd2b971 | ||
|
|
26e9b8b3b8 | ||
|
|
ddfb4ff02d | ||
|
|
a5e6295923 | ||
|
|
e2e495027d | ||
|
|
397744f436 | ||
|
|
9e8e7a7fe9 | ||
|
|
4d66f9a093 | ||
|
|
81cac9b633 | ||
|
|
43edc6dd7f | ||
|
|
f313cca52b | ||
|
|
243e7cca1f | ||
|
|
b9c36caa1c | ||
|
|
711b4ff4bb | ||
|
|
8d72528eb5 | ||
|
|
6590cce5c1 | ||
|
|
12c0360ba3 | ||
|
|
8e8fa5409d | ||
|
|
5af35f4f1a | ||
|
|
412e73cf76 | ||
|
|
ec27642e2f | ||
|
|
7165b1ec40 | ||
|
|
6dd50de7a4 | ||
|
|
a8b851f84a | ||
|
|
9c4966ccc8 | ||
|
|
d0bb1cd0fa | ||
|
|
102cf87f36 | ||
|
|
584a6c2a86 | ||
|
|
03c6f8fff4 | ||
|
|
90de9b78df | ||
|
|
34f1f2967e | ||
|
|
9a9df7436e | ||
|
|
c036830c70 | ||
|
|
ebbd0c7b5a | ||
|
|
7264a3a65d | ||
|
|
f3a958bbf7 | ||
|
|
14bf6f8a27 | ||
|
|
60c8a0498b | ||
|
|
774d768e7b | ||
|
|
efef397acf | ||
|
|
5793653630 | ||
|
|
4ee3d05bd8 | ||
|
|
a1df3e030f | ||
|
|
4e0332551a | ||
|
|
216ab488a6 | ||
|
|
722b0131f0 | ||
|
|
93dd571df9 | ||
|
|
a7000dd9c6 | ||
|
|
5c4b5b1bf0 | ||
|
|
8e57ee9111 | ||
|
|
60bd8d15d9 | ||
|
|
1d524b6fbe | ||
|
|
e9c97a4c4e | ||
|
|
48c89cb698 | ||
|
|
af1e692a5e | ||
|
|
57e7db0423 | ||
|
|
7fb6fa0f35 | ||
|
|
50c3875354 | ||
|
|
efc03bf329 | ||
|
|
9785bda7be | ||
|
|
29bfdfc1ef | ||
|
|
4f72cb8d00 | ||
|
|
a45e90b1e4 | ||
|
|
6b6bc45f2c | ||
|
|
e4a34f2a48 | ||
|
|
4a2ed901b3 | ||
|
|
ba67bc0f18 | ||
|
|
be8d60fb9f | ||
|
|
d9d5bb83f0 | ||
|
|
cfa7645d3b | ||
|
|
2e6ef91a7c | ||
|
|
508f294e0c | ||
|
|
a81ebe9842 | ||
|
|
c92fb809c6 | ||
|
|
043e8c36e5 | ||
|
|
7965195c29 | ||
|
|
4263d18c1a | ||
|
|
827fb1e1da | ||
|
|
03c77cee9b | ||
|
|
2db34e7127 | ||
|
|
821b14bfd1 | ||
|
|
33b4735f98 | ||
|
|
bbebd1e56a | ||
|
|
c9d9348944 | ||
|
|
555c4cb279 | ||
|
|
3da90dbde7 | ||
|
|
4ac0f59b8a | ||
|
|
2b9c69f964 | ||
|
|
437c960d86 | ||
|
|
131aba8f14 | ||
|
|
ada02703cf | ||
|
|
f96dfb5772 | ||
|
|
57b3e70cef | ||
|
|
f4fbcc6fb4 | ||
|
|
867da9631a | ||
|
|
cd2b0fce7e | ||
|
|
66504c263c | ||
|
|
bce4f75fc5 | ||
|
|
8b082aff5a | ||
|
|
48e4cad72e | ||
|
|
30e53a992b | ||
|
|
2df9f85a20 | ||
|
|
01733d970a | ||
|
|
ac178c539c | ||
|
|
61dcb3f548 | ||
|
|
6f15b1e56d | ||
|
|
9a94c5ecd3 | ||
|
|
2ba148d9b5 | ||
|
|
5a0e193002 | ||
|
|
3265f64cd5 | ||
|
|
c2b1ab8303 | ||
|
|
7dd0ade0f9 | ||
|
|
316e4314ed | ||
|
|
324353eaf6 | ||
|
|
6361c3b1b7 | ||
|
|
f7d13ade35 | ||
|
|
99e82890e1 | ||
|
|
4a35bfa84c | ||
|
|
27f28d5fe0 | ||
|
|
c04cf01b45 | ||
|
|
5614852b33 | ||
|
|
4f23ae5e1a | ||
|
|
3bd088a77c | ||
|
|
fe30a9321a | ||
|
|
c715b82ad7 | ||
|
|
44d308cbba | ||
|
|
c9e7f627fe | ||
|
|
00fa7e636c | ||
|
|
c7a504c9cf | ||
|
|
516ff1fa56 | ||
|
|
81562a7a37 | ||
|
|
ba0baa828c | ||
|
|
420f03d429 | ||
|
|
6cf48442df | ||
|
|
8cf7bc67bb | ||
|
|
48d6af6e38 | ||
|
|
0309a0fb07 | ||
|
|
d7b29455ab | ||
|
|
a414f75f1b | ||
|
|
1c3832f897 | ||
|
|
3ec62c6e26 | ||
|
|
c7ee4c281e | ||
|
|
471ff0c4bb | ||
|
|
cd0d416a11 | ||
|
|
d203c2328a | ||
|
|
ec0e42709a | ||
|
|
abae65d8f1 | ||
|
|
054f18701a | ||
|
|
a167084ccf |
29
Makefile
29
Makefile
@@ -3,8 +3,11 @@
|
||||
#
|
||||
# Makefile for kustomize CLI and API.
|
||||
|
||||
MYGOBIN := $(shell go env GOPATH)/bin
|
||||
SHELL := /usr/bin/env bash
|
||||
MYGOBIN = $(shell go env GOBIN)
|
||||
ifeq ($(MYGOBIN),)
|
||||
MYGOBIN = $(shell go env GOPATH)/bin
|
||||
endif
|
||||
export PATH := $(MYGOBIN):$(PATH)
|
||||
MODULES := '"cmd/config" "api/" "kustomize/" "kyaml/"'
|
||||
|
||||
@@ -26,8 +29,7 @@ verify-kustomize: \
|
||||
lint-kustomize \
|
||||
test-unit-kustomize-all \
|
||||
test-examples-kustomize-against-HEAD \
|
||||
test-examples-kustomize-against-3.9 \
|
||||
test-examples-kustomize-against-3.8
|
||||
test-examples-kustomize-against-4.0
|
||||
|
||||
# The following target referenced by a file in
|
||||
# https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-sigs/kustomize
|
||||
@@ -39,8 +41,7 @@ prow-presubmit-check: \
|
||||
test-unit-cmd-all \
|
||||
test-go-mod \
|
||||
test-examples-kustomize-against-HEAD \
|
||||
test-examples-kustomize-against-3.9 \
|
||||
test-examples-kustomize-against-3.8
|
||||
test-examples-kustomize-against-4.0
|
||||
|
||||
.PHONY: verify-kustomize-e2e
|
||||
verify-kustomize-e2e: test-examples-e2e-kustomize
|
||||
@@ -95,7 +96,7 @@ $(MYGOBIN)/prchecker:
|
||||
go install .
|
||||
|
||||
# Build from local source.
|
||||
$(MYGOBIN)/kustomize:
|
||||
$(MYGOBIN)/kustomize: build-kustomize-api
|
||||
cd kustomize; \
|
||||
go install .
|
||||
|
||||
@@ -104,7 +105,7 @@ install-tools: \
|
||||
$(MYGOBIN)/goimports \
|
||||
$(MYGOBIN)/golangci-lint-kustomize \
|
||||
$(MYGOBIN)/gorepomod \
|
||||
$(MYGOBIN)/helm \
|
||||
$(MYGOBIN)/helmV3 \
|
||||
$(MYGOBIN)/k8scopy \
|
||||
$(MYGOBIN)/mdrip \
|
||||
$(MYGOBIN)/pluginator \
|
||||
@@ -281,12 +282,8 @@ test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip
|
||||
./hack/testExamplesAgainstKustomize.sh HEAD
|
||||
|
||||
.PHONY:
|
||||
test-examples-kustomize-against-3.9: $(MYGOBIN)/mdrip
|
||||
./hack/testExamplesAgainstKustomize.sh v3.9.3
|
||||
|
||||
.PHONY:
|
||||
test-examples-kustomize-against-3.8: $(MYGOBIN)/mdrip
|
||||
./hack/testExamplesAgainstKustomize.sh v3.8.10
|
||||
test-examples-kustomize-against-4.0: $(MYGOBIN)/mdrip
|
||||
./hack/testExamplesAgainstKustomize.sh v4@v4.0.5
|
||||
|
||||
# linux only.
|
||||
# This is for testing an example plugin that
|
||||
@@ -326,17 +323,13 @@ $(MYGOBIN)/helmV3:
|
||||
( \
|
||||
set -e; \
|
||||
d=$(shell mktemp -d); cd $$d; \
|
||||
tgzFile=helm-v3.4.0-linux-amd64.tar.gz; \
|
||||
tgzFile=helm-v3.5.3-linux-amd64.tar.gz; \
|
||||
wget https://get.helm.sh/$$tgzFile; \
|
||||
tar -xvzf $$tgzFile; \
|
||||
mv linux-amd64/helm $(MYGOBIN)/helmV3; \
|
||||
rm -rf $$d \
|
||||
)
|
||||
|
||||
# Default version of helm is v3.
|
||||
$(MYGOBIN)/helm: $(MYGOBIN)/helmV3
|
||||
ln -s $(MYGOBIN)/helmV3 $(MYGOBIN)/helm
|
||||
|
||||
$(MYGOBIN)/kind:
|
||||
( \
|
||||
set -e; \
|
||||
|
||||
@@ -12,3 +12,4 @@ aliases:
|
||||
- mortent
|
||||
- phanimarupaka
|
||||
- Shell32-Natsu
|
||||
- natasha41575
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type HashTransformerPlugin struct {
|
||||
hasher ifc.KunstructuredHasher
|
||||
hasher ifc.KustHasher
|
||||
}
|
||||
|
||||
func (p *HashTransformerPlugin) Config(
|
||||
@@ -24,7 +24,7 @@ func (p *HashTransformerPlugin) Config(
|
||||
func (p *HashTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
for _, res := range m.Resources() {
|
||||
if res.NeedHashSuffix() {
|
||||
h, err := p.hasher.Hash(res)
|
||||
h, err := res.Hash(p.hasher)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package builtins
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -16,7 +15,6 @@ import (
|
||||
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/yaml"
|
||||
@@ -25,243 +23,285 @@ import (
|
||||
// HelmChartInflationGeneratorPlugin is a plugin to generate resources
|
||||
// from a remote or local helm chart.
|
||||
type HelmChartInflationGeneratorPlugin struct {
|
||||
h *resmap.PluginHelpers
|
||||
types.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
runHelmCommand func([]string) ([]byte, error)
|
||||
types.HelmChartArgs
|
||||
h *resmap.PluginHelpers
|
||||
types.HelmGlobals
|
||||
types.HelmChart
|
||||
tmpDir string
|
||||
}
|
||||
|
||||
var KustomizePlugin HelmChartInflationGeneratorPlugin
|
||||
|
||||
const (
|
||||
valuesMergeOptionMerge = "merge"
|
||||
valuesMergeOptionOverride = "override"
|
||||
valuesMergeOptionReplace = "replace"
|
||||
)
|
||||
|
||||
var legalMergeOptions = []string{
|
||||
valuesMergeOptionMerge,
|
||||
valuesMergeOptionOverride,
|
||||
valuesMergeOptionReplace,
|
||||
}
|
||||
|
||||
// Config uses the input plugin configurations `config` to setup the generator
|
||||
// options
|
||||
func (p *HelmChartInflationGeneratorPlugin) Config(h *resmap.PluginHelpers, config []byte) error {
|
||||
func (p *HelmChartInflationGeneratorPlugin) Config(
|
||||
h *resmap.PluginHelpers, config []byte) (err error) {
|
||||
if h.GeneralConfig() == nil {
|
||||
return fmt.Errorf("unable to access general config")
|
||||
}
|
||||
if !h.GeneralConfig().HelmConfig.Enabled {
|
||||
return fmt.Errorf("must specify --enable-helm")
|
||||
}
|
||||
if h.GeneralConfig().HelmConfig.Command == "" {
|
||||
return fmt.Errorf("must specify --helm-command")
|
||||
}
|
||||
p.h = h
|
||||
err := yaml.Unmarshal(config, p)
|
||||
if err != nil {
|
||||
return err
|
||||
if err = yaml.Unmarshal(config, p); err != nil {
|
||||
return
|
||||
}
|
||||
tmpDir, err := filesys.NewTmpConfirmedDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.tmpDir = string(tmpDir)
|
||||
if p.ChartName == "" {
|
||||
return fmt.Errorf("chartName cannot be empty")
|
||||
}
|
||||
if p.ChartHome == "" {
|
||||
p.ChartHome = filepath.Join(p.tmpDir, "chart")
|
||||
}
|
||||
if p.ChartRepoName == "" {
|
||||
p.ChartRepoName = "stable"
|
||||
}
|
||||
if p.HelmBin == "" {
|
||||
p.HelmBin = "helm"
|
||||
}
|
||||
if p.HelmHome == "" {
|
||||
p.HelmHome = filepath.Join(p.tmpDir, ".helm")
|
||||
}
|
||||
if p.Values == "" {
|
||||
p.Values = filepath.Join(p.ChartHome, p.ChartName, "values.yaml")
|
||||
}
|
||||
if p.ValuesMerge == "" {
|
||||
p.ValuesMerge = "override"
|
||||
}
|
||||
// runHelmCommand will run `helm` command with args provided. Return stdout
|
||||
// and error if there is any.
|
||||
p.runHelmCommand = func(args []string) ([]byte, error) {
|
||||
stdout := new(bytes.Buffer)
|
||||
stderr := new(bytes.Buffer)
|
||||
cmd := exec.Command(p.HelmBin, args...)
|
||||
cmd.Stdout = stdout
|
||||
cmd.Stderr = stderr
|
||||
cmd.Env = append(cmd.Env,
|
||||
fmt.Sprintf("HELM_CONFIG_HOME=%s", p.HelmHome),
|
||||
fmt.Sprintf("HELM_CACHE_HOME=%s/.cache", p.HelmHome),
|
||||
fmt.Sprintf("HELM_DATA_HOME=%s/.data", p.HelmHome),
|
||||
)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return stdout.Bytes(),
|
||||
errors.Wrap(
|
||||
fmt.Errorf("failed to run command %s %s", p.HelmBin, strings.Join(args, " ")),
|
||||
stderr.String(),
|
||||
)
|
||||
}
|
||||
return stdout.Bytes(), nil
|
||||
}
|
||||
return nil
|
||||
return p.validateArgs()
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// not override, merge, none
|
||||
if !(p.ValuesMerge == "none" || p.ValuesMerge == "no" || p.ValuesMerge == "false") {
|
||||
var pValues []byte
|
||||
var err error
|
||||
|
||||
if filepath.IsAbs(p.Values) {
|
||||
pValues, err = ioutil.ReadFile(p.Values)
|
||||
} else {
|
||||
pValues, err = p.h.Loader().Load(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
|
||||
}
|
||||
b, err := yaml.Marshal(p.ValuesLocal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path, err := p.writeValuesBytes(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.Values = path
|
||||
return nil
|
||||
}
|
||||
|
||||
// copyValues will copy the relative values file into the temp directory
|
||||
// to avoid messing up with CWD.
|
||||
func (p *HelmChartInflationGeneratorPlugin) copyValues() error {
|
||||
// only copy when the values path is not absolute
|
||||
if filepath.IsAbs(p.Values) {
|
||||
// This uses the real file system since tmpDir may be used
|
||||
// by the helm subprocess. Cannot use a chroot jail or fake
|
||||
// filesystem since we allow the user to use previously
|
||||
// downloaded charts. This is safe since this plugin is
|
||||
// owned by kustomize.
|
||||
func (p *HelmChartInflationGeneratorPlugin) establishTmpDir() (err error) {
|
||||
if p.tmpDir != "" {
|
||||
// already done.
|
||||
return nil
|
||||
}
|
||||
// we must use use loader to read values file
|
||||
b, err := p.h.Loader().Load(p.Values)
|
||||
if err != nil {
|
||||
p.tmpDir, err = ioutil.TempDir("", "kustomize-helm-")
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) validateArgs() (err error) {
|
||||
if p.Name == "" {
|
||||
return fmt.Errorf("chart name cannot be empty")
|
||||
}
|
||||
|
||||
// ChartHome might be consulted by the plugin (to read
|
||||
// values files below it), so it must be located under
|
||||
// the loader root (unless root restrictions are
|
||||
// disabled, in which case this can be an absolute path).
|
||||
if p.ChartHome == "" {
|
||||
p.ChartHome = "charts"
|
||||
}
|
||||
|
||||
// The ValuesFile may be consulted by the plugin, so it must
|
||||
// be under the loader root (unless root restrictions are
|
||||
// disabled).
|
||||
if p.ValuesFile == "" {
|
||||
p.ValuesFile = filepath.Join(p.ChartHome, p.Name, "values.yaml")
|
||||
}
|
||||
|
||||
if err = p.errIfIllegalValuesMerge(); err != nil {
|
||||
return err
|
||||
}
|
||||
path, err := p.writeValuesBytes(b)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
// ConfigHome is not loaded by the plugin, and can be located anywhere.
|
||||
if p.ConfigHome == "" {
|
||||
if err = p.establishTmpDir(); err != nil {
|
||||
return errors.Wrap(
|
||||
err, "unable to create tmp dir for HELM_CONFIG_HOME")
|
||||
}
|
||||
p.ConfigHome = filepath.Join(p.tmpDir, "helm")
|
||||
}
|
||||
p.Values = path
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) writeValuesBytes(b []byte) (string, error) {
|
||||
path := filepath.Join(p.ChartHome, p.ChartName, "kustomize-values.yaml")
|
||||
err := ioutil.WriteFile(path, b, 0644)
|
||||
func (p *HelmChartInflationGeneratorPlugin) errIfIllegalValuesMerge() error {
|
||||
if p.ValuesMerge == "" {
|
||||
// Use the default.
|
||||
p.ValuesMerge = valuesMergeOptionOverride
|
||||
return nil
|
||||
}
|
||||
for _, opt := range legalMergeOptions {
|
||||
if p.ValuesMerge == opt {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("valuesMerge must be one of %v", legalMergeOptions)
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) absChartHome() string {
|
||||
if filepath.IsAbs(p.ChartHome) {
|
||||
return p.ChartHome
|
||||
}
|
||||
return filepath.Join(p.h.Loader().Root(), p.ChartHome)
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) runHelmCommand(
|
||||
args []string) ([]byte, error) {
|
||||
stdout := new(bytes.Buffer)
|
||||
stderr := new(bytes.Buffer)
|
||||
cmd := exec.Command(p.h.GeneralConfig().HelmConfig.Command, args...)
|
||||
cmd.Stdout = stdout
|
||||
cmd.Stderr = stderr
|
||||
env := []string{
|
||||
fmt.Sprintf("HELM_CONFIG_HOME=%s", p.ConfigHome),
|
||||
fmt.Sprintf("HELM_CACHE_HOME=%s/.cache", p.ConfigHome),
|
||||
fmt.Sprintf("HELM_DATA_HOME=%s/.data", p.ConfigHome)}
|
||||
cmd.Env = append(os.Environ(), env...)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
helm := p.h.GeneralConfig().HelmConfig.Command
|
||||
err = errors.Wrap(
|
||||
fmt.Errorf(
|
||||
"unable to run: '%s %s' with env=%s (is '%s' installed?)",
|
||||
helm, strings.Join(args, " "), env, helm),
|
||||
stderr.String(),
|
||||
)
|
||||
}
|
||||
return stdout.Bytes(), err
|
||||
}
|
||||
|
||||
// createNewMergedValuesFile replaces/merges original values file with ValuesInline.
|
||||
func (p *HelmChartInflationGeneratorPlugin) createNewMergedValuesFile() (
|
||||
path string, err error) {
|
||||
if p.ValuesMerge == valuesMergeOptionMerge ||
|
||||
p.ValuesMerge == valuesMergeOptionOverride {
|
||||
if err = p.replaceValuesInline(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
var b []byte
|
||||
b, err = yaml.Marshal(p.ValuesInline)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return path, nil
|
||||
return p.writeValuesBytes(b)
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) replaceValuesInline() error {
|
||||
pValues, err := p.h.Loader().Load(p.ValuesFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chValues := make(map[string]interface{})
|
||||
if err = yaml.Unmarshal(pValues, &chValues); err != nil {
|
||||
return err
|
||||
}
|
||||
switch p.ValuesMerge {
|
||||
case valuesMergeOptionOverride:
|
||||
err = mergo.Merge(
|
||||
&chValues, p.ValuesInline, mergo.WithOverride)
|
||||
case valuesMergeOptionMerge:
|
||||
err = mergo.Merge(&chValues, p.ValuesInline)
|
||||
}
|
||||
p.ValuesInline = chValues
|
||||
return err
|
||||
}
|
||||
|
||||
// copyValuesFile to avoid branching. TODO: get rid of this.
|
||||
func (p *HelmChartInflationGeneratorPlugin) copyValuesFile() (string, error) {
|
||||
b, err := p.h.Loader().Load(p.ValuesFile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return p.writeValuesBytes(b)
|
||||
}
|
||||
|
||||
// Write a absolute path file in the tmp file system.
|
||||
func (p *HelmChartInflationGeneratorPlugin) writeValuesBytes(
|
||||
b []byte) (string, error) {
|
||||
if err := p.establishTmpDir(); err != nil {
|
||||
return "", fmt.Errorf("cannot create tmp dir to write helm values")
|
||||
}
|
||||
path := filepath.Join(p.tmpDir, p.Name+"-kustomize-values.yaml")
|
||||
return path, ioutil.WriteFile(path, b, 0644)
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) cleanup() {
|
||||
if p.tmpDir != "" {
|
||||
os.RemoveAll(p.tmpDir)
|
||||
}
|
||||
}
|
||||
|
||||
// Generate implements generator
|
||||
func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) {
|
||||
// cleanup
|
||||
defer os.RemoveAll(p.tmpDir)
|
||||
// check helm version. we only support V3
|
||||
err := p.checkHelmVersion()
|
||||
if err != nil {
|
||||
func (p *HelmChartInflationGeneratorPlugin) Generate() (rm resmap.ResMap, err error) {
|
||||
defer p.cleanup()
|
||||
if err = p.checkHelmVersion(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// pull the chart
|
||||
if !p.checkLocalChart() {
|
||||
_, err := p.runHelmCommand(p.getPullCommandArgs())
|
||||
if err != nil {
|
||||
if path, exists := p.chartExistsLocally(); !exists {
|
||||
if p.Repo == "" {
|
||||
return nil, fmt.Errorf(
|
||||
"no repo specified for pull, no chart found at '%s'", path)
|
||||
}
|
||||
if _, err := p.runHelmCommand(p.pullCommand()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// inflator config valuesLocal
|
||||
if len(p.ValuesLocal) > 0 {
|
||||
err := p.useValuesLocal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(p.ValuesInline) > 0 {
|
||||
p.ValuesFile, err = p.createNewMergedValuesFile()
|
||||
} else {
|
||||
err := p.copyValues()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.ValuesFile, err = p.copyValuesFile()
|
||||
}
|
||||
|
||||
// render the charts
|
||||
stdout, err := p.runHelmCommand(p.getTemplateCommandArgs())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var stdout []byte
|
||||
stdout, err = p.runHelmCommand(p.templateCommand())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p.h.ResmapFactory().NewResMapFromBytes(stdout)
|
||||
rm, err = p.h.ResmapFactory().NewResMapFromBytes(stdout)
|
||||
if err == nil {
|
||||
return rm, nil
|
||||
}
|
||||
// try to remove the contents before first "---" because
|
||||
// helm may produce messages to stdout before it
|
||||
stdoutStr := string(stdout)
|
||||
if idx := strings.Index(stdoutStr, "---"); idx != -1 {
|
||||
return p.h.ResmapFactory().NewResMapFromBytes([]byte(stdoutStr[idx:]))
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) getTemplateCommandArgs() []string {
|
||||
func (p *HelmChartInflationGeneratorPlugin) templateCommand() []string {
|
||||
args := []string{"template"}
|
||||
if p.ReleaseName != "" {
|
||||
args = append(args, p.ReleaseName)
|
||||
}
|
||||
args = append(args, filepath.Join(p.ChartHome, p.ChartName))
|
||||
if p.ReleaseNamespace != "" {
|
||||
args = append(args, "--namespace", p.ReleaseNamespace)
|
||||
args = append(args, filepath.Join(p.absChartHome(), p.Name))
|
||||
if p.ValuesFile != "" {
|
||||
args = append(args, "--values", p.ValuesFile)
|
||||
}
|
||||
if p.Values != "" {
|
||||
args = append(args, "--values", p.Values)
|
||||
if p.ReleaseName == "" {
|
||||
// AFAICT, this doesn't work as intended due to a bug in helm.
|
||||
// See https://github.com/helm/helm/issues/6019
|
||||
// I've tried placing the flag before and after the name argument.
|
||||
args = append(args, "--generate-name")
|
||||
}
|
||||
args = append(args, p.ExtraArgs...)
|
||||
return args
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) getPullCommandArgs() []string {
|
||||
args := []string{"pull", "--untar", "--untardir", p.ChartHome}
|
||||
chartName := fmt.Sprintf("%s/%s", p.ChartRepoName, p.ChartName)
|
||||
if p.ChartVersion != "" {
|
||||
args = append(args, "--version", p.ChartVersion)
|
||||
func (p *HelmChartInflationGeneratorPlugin) pullCommand() []string {
|
||||
args := []string{
|
||||
"pull",
|
||||
"--untar",
|
||||
"--untardir", p.absChartHome(),
|
||||
"--repo", p.Repo,
|
||||
p.Name}
|
||||
if p.Version != "" {
|
||||
args = append(args, "--version", p.Version)
|
||||
}
|
||||
if p.ChartRepoURL != "" {
|
||||
args = append(args, "--repo", p.ChartRepoURL)
|
||||
chartName = p.ChartName
|
||||
}
|
||||
|
||||
args = append(args, chartName)
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
// checkLocalChart will return true if the chart does exist in
|
||||
// chartExistsLocally will return true if the chart does exist in
|
||||
// local chart home.
|
||||
func (p *HelmChartInflationGeneratorPlugin) checkLocalChart() bool {
|
||||
path := filepath.Join(p.ChartHome, p.ChartName)
|
||||
func (p *HelmChartInflationGeneratorPlugin) chartExistsLocally() (string, bool) {
|
||||
path := filepath.Join(p.absChartHome(), p.Name)
|
||||
s, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
return "", false
|
||||
}
|
||||
return s.IsDir()
|
||||
return path, s.IsDir()
|
||||
}
|
||||
|
||||
// checkHelmVersion will return an error if the helm version is not V3
|
||||
@@ -270,11 +310,17 @@ func (p *HelmChartInflationGeneratorPlugin) checkHelmVersion() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := regexp.Compile(`v\d+(\.\d+)+`)
|
||||
r, err := regexp.Compile(`v?\d+(\.\d+)+`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v := string(r.Find(stdout))[1:]
|
||||
v := r.FindString(string(stdout))
|
||||
if v == "" {
|
||||
return fmt.Errorf("cannot find version string in %s", string(stdout))
|
||||
}
|
||||
if v[0] == 'v' {
|
||||
v = v[1:]
|
||||
}
|
||||
majorVersion := strings.Split(v, ".")[0]
|
||||
if majorVersion != "3" {
|
||||
return fmt.Errorf("this plugin requires helm V3 but got v%s", v)
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
package builtins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filters/imagetag"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
@@ -49,139 +45,6 @@ func (p *ImageTagTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ImageTagTransformerPlugin) mutateImage(in interface{}) (interface{}, error) {
|
||||
original, ok := in.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("image path is not of type string but %T", in)
|
||||
}
|
||||
|
||||
if !isImageMatched(original, p.ImageTag.Name) {
|
||||
return original, nil
|
||||
}
|
||||
name, tag := split(original)
|
||||
if p.ImageTag.NewName != "" {
|
||||
name = p.ImageTag.NewName
|
||||
}
|
||||
if p.ImageTag.NewTag != "" {
|
||||
tag = ":" + p.ImageTag.NewTag
|
||||
}
|
||||
if p.ImageTag.Digest != "" {
|
||||
tag = "@" + p.ImageTag.Digest
|
||||
}
|
||||
return name + tag, nil
|
||||
}
|
||||
|
||||
// findAndReplaceImage replaces the image name and
|
||||
// tags inside one object.
|
||||
// It searches the object for container session
|
||||
// then loops though all images inside containers
|
||||
// session, finds matched ones and update the
|
||||
// image name and tag name
|
||||
func (p *ImageTagTransformerPlugin) findAndReplaceImage(obj map[string]interface{}) error {
|
||||
paths := []string{"containers", "initContainers"}
|
||||
updated := false
|
||||
for _, path := range paths {
|
||||
containers, found := obj[path]
|
||||
if found && containers != nil {
|
||||
if _, err := p.updateContainers(containers); err != nil {
|
||||
return err
|
||||
}
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
if !updated {
|
||||
return p.findContainers(obj)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ImageTagTransformerPlugin) updateContainers(in interface{}) (interface{}, error) {
|
||||
containers, ok := in.([]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf(
|
||||
"containers path is not of type []interface{} but %T", in)
|
||||
}
|
||||
for i := range containers {
|
||||
container := containers[i].(map[string]interface{})
|
||||
containerImage, found := container["image"]
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
imageName := containerImage.(string)
|
||||
if isImageMatched(imageName, p.ImageTag.Name) {
|
||||
newImage, err := p.mutateImage(imageName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
container["image"] = newImage
|
||||
}
|
||||
}
|
||||
return containers, nil
|
||||
}
|
||||
|
||||
func (p *ImageTagTransformerPlugin) findContainers(obj map[string]interface{}) error {
|
||||
for key := range obj {
|
||||
switch typedV := obj[key].(type) {
|
||||
case map[string]interface{}:
|
||||
err := p.findAndReplaceImage(typedV)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case []interface{}:
|
||||
for i := range typedV {
|
||||
item := typedV[i]
|
||||
typedItem, ok := item.(map[string]interface{})
|
||||
if ok {
|
||||
err := p.findAndReplaceImage(typedItem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isImageMatched(s, t string) bool {
|
||||
// Tag values are limited to [a-zA-Z0-9_.{}-].
|
||||
// Some tools like Bazel rules_k8s allow tag patterns with {} characters.
|
||||
// More info: https://github.com/bazelbuild/rules_k8s/pull/423
|
||||
pattern, _ := regexp.Compile("^" + t + "(@sha256)?(:[a-zA-Z0-9_.{}-]*)?$")
|
||||
return pattern.MatchString(s)
|
||||
}
|
||||
|
||||
// split separates and returns the name and tag parts
|
||||
// from the image string using either colon `:` or at `@` separators.
|
||||
// Note that the returned tag keeps its separator.
|
||||
func split(imageName string) (name string, tag string) {
|
||||
// check if image name contains a domain
|
||||
// if domain is present, ignore domain and check for `:`
|
||||
ic := -1
|
||||
if slashIndex := strings.Index(imageName, "/"); slashIndex < 0 {
|
||||
ic = strings.LastIndex(imageName, ":")
|
||||
} else {
|
||||
lastIc := strings.LastIndex(imageName[slashIndex:], ":")
|
||||
// set ic only if `:` is present
|
||||
if lastIc > 0 {
|
||||
ic = slashIndex + lastIc
|
||||
}
|
||||
}
|
||||
ia := strings.LastIndex(imageName, "@")
|
||||
if ic < 0 && ia < 0 {
|
||||
return imageName, ""
|
||||
}
|
||||
|
||||
i := ic
|
||||
if ia > 0 {
|
||||
i = ia
|
||||
}
|
||||
|
||||
name = imageName[:i]
|
||||
tag = imageName[i:]
|
||||
return
|
||||
}
|
||||
|
||||
func NewImageTagTransformerPlugin() resmap.TransformerPlugin {
|
||||
return &ImageTagTransformerPlugin{}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,10 @@ func (p *NamespaceTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
continue
|
||||
}
|
||||
r.StorePreviousId()
|
||||
err := r.ApplyFilter(namespace.Filter{
|
||||
if err := r.ApplyFilter(namespace.Filter{
|
||||
Namespace: p.Namespace,
|
||||
FsSlice: p.FieldSpecs,
|
||||
})
|
||||
if err != nil {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
matches := m.GetMatchingResourcesByCurrentId(r.CurId().Equals)
|
||||
|
||||
@@ -28,45 +28,48 @@ func (p *PatchStrategicMergeTransformerPlugin) Config(
|
||||
return fmt.Errorf("empty file path and empty patch content")
|
||||
}
|
||||
if len(p.Paths) != 0 {
|
||||
for _, onePath := range p.Paths {
|
||||
// The following oddly attempts to interpret a path string as an
|
||||
// actual patch (instead of as a path to a file containing a patch).
|
||||
// All tests pass if this code is commented out. This code should
|
||||
// be deleted; the user should use the Patches field which
|
||||
// exists for this purpose (inline patch declaration).
|
||||
res, err := h.ResmapFactory().RF().SliceFromBytes([]byte(onePath))
|
||||
if err == nil {
|
||||
p.loadedPatches = append(p.loadedPatches, res...)
|
||||
continue
|
||||
}
|
||||
res, err = h.ResmapFactory().RF().SliceFromPatches(
|
||||
h.Loader(), []types.PatchStrategicMerge{onePath})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.loadedPatches = append(p.loadedPatches, res...)
|
||||
}
|
||||
}
|
||||
if p.Patches != "" {
|
||||
res, err := h.ResmapFactory().RF().SliceFromBytes([]byte(p.Patches))
|
||||
patches, err := loadFromPaths(h, p.Paths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.loadedPatches = append(p.loadedPatches, res...)
|
||||
p.loadedPatches = append(p.loadedPatches, patches...)
|
||||
}
|
||||
if p.Patches != "" {
|
||||
patches, err := h.ResmapFactory().RF().SliceFromBytes([]byte(p.Patches))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.loadedPatches = append(p.loadedPatches, patches...)
|
||||
}
|
||||
|
||||
if len(p.loadedPatches) == 0 {
|
||||
return fmt.Errorf(
|
||||
"patch appears to be empty; files=%v, Patch=%s", p.Paths, p.Patches)
|
||||
}
|
||||
// Merge the patches, looking for conflicts.
|
||||
_, err = h.ResmapFactory().ConflatePatches(p.loadedPatches)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadFromPaths(
|
||||
h *resmap.PluginHelpers,
|
||||
paths []types.PatchStrategicMerge) (
|
||||
result []*resource.Resource, err error) {
|
||||
var patches []*resource.Resource
|
||||
for _, path := range paths {
|
||||
// For legacy reasons, attempt to treat the path string as
|
||||
// actual patch content.
|
||||
patches, err = h.ResmapFactory().RF().SliceFromBytes([]byte(path))
|
||||
if err != nil {
|
||||
// Failing that, treat it as a file path.
|
||||
patches, err = h.ResmapFactory().RF().SliceFromPatches(
|
||||
h.Loader(), []types.PatchStrategicMerge{path})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
result = append(result, patches...)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *PatchStrategicMergeTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
for _, patch := range p.loadedPatches {
|
||||
target, err := m.GetById(patch.OrgId())
|
||||
|
||||
@@ -21,6 +21,7 @@ type PatchTransformerPlugin struct {
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PatchTransformerPlugin) Config(
|
||||
@@ -60,6 +61,12 @@ func (p *PatchTransformerPlugin) Config(
|
||||
}
|
||||
if errSM == nil {
|
||||
p.loadedPatch = patchSM
|
||||
if p.Options["allowNameChange"] {
|
||||
p.loadedPatch.SetAllowNameChange("true")
|
||||
}
|
||||
if p.Options["allowKindChange"] {
|
||||
p.loadedPatch.SetAllowKindChange("true")
|
||||
}
|
||||
} else {
|
||||
p.decodedPatch = patchJson
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (fltr Filter) filter(obj *yaml.RNode) error {
|
||||
// found the field -- set its value
|
||||
return fltr.SetValue(obj)
|
||||
}
|
||||
if obj.IsTaggedNull() {
|
||||
if obj.IsTaggedNull() || obj.IsNil() {
|
||||
return nil
|
||||
}
|
||||
switch obj.YNode().Kind {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package nameref
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -11,7 +10,6 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kyaml/filtersutil"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
@@ -186,11 +184,7 @@ func (f Filter) recordTheReferral(referral *resource.Resource) {
|
||||
|
||||
// getRoleRefGvk returns a Gvk in the roleRef field. Return error
|
||||
// if the roleRef, roleRef/apiGroup or roleRef/kind is missing.
|
||||
func getRoleRefGvk(res json.Marshaler) (*resid.Gvk, error) {
|
||||
n, err := filtersutil.GetRNode(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
func getRoleRefGvk(n *yaml.RNode) (*resid.Gvk, error) {
|
||||
roleRef, err := n.Pipe(yaml.Lookup("roleRef"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -276,7 +270,7 @@ func (f Filter) roleRefFilter() sieveFunc {
|
||||
if !strings.HasSuffix(f.NameFieldToUpdate.Path, "roleRef/name") {
|
||||
return acceptAll
|
||||
}
|
||||
roleRefGvk, err := getRoleRefGvk(f.Referrer)
|
||||
roleRefGvk, err := getRoleRefGvk(f.Referrer.AsRNode())
|
||||
if err != nil {
|
||||
return acceptAll
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ map:
|
||||
}
|
||||
tc.filter.Referrer = referrer
|
||||
|
||||
resMapFactory := resmap.NewFactory(factory, nil)
|
||||
resMapFactory := resmap.NewFactory(factory)
|
||||
candidatesRes, err := factory.SliceFromBytesWithNames(
|
||||
tc.originalNames, []byte(tc.candidates))
|
||||
if err != nil {
|
||||
@@ -334,7 +334,7 @@ metadata:
|
||||
}
|
||||
tc.filter.Referrer = referrer
|
||||
|
||||
resMapFactory := resmap.NewFactory(factory, nil)
|
||||
resMapFactory := resmap.NewFactory(factory)
|
||||
candidatesRes, err := factory.SliceFromBytesWithNames(
|
||||
tc.originalNames, []byte(tc.candidates))
|
||||
if err != nil {
|
||||
@@ -751,7 +751,7 @@ ref:
|
||||
}
|
||||
tc.filter.Referrer = referrer
|
||||
|
||||
resMapFactory := resmap.NewFactory(factory, nil)
|
||||
resMapFactory := resmap.NewFactory(factory)
|
||||
candidatesRes, err := factory.SliceFromBytesWithNames(
|
||||
tc.originalNames, []byte(tc.candidates))
|
||||
if err != nil {
|
||||
|
||||
@@ -118,7 +118,6 @@ func (ns Filter) roleBindingHack(obj *yaml.RNode, meta yaml.ResourceMeta) error
|
||||
|
||||
// add the namespace to each "subject" with name: default
|
||||
err = obj.VisitElements(func(o *yaml.RNode) error {
|
||||
// copied from kunstruct based kustomize NamespaceTransformer plugin
|
||||
// The only case we need to force the namespace
|
||||
// if for the "service account". "default" is
|
||||
// kind of hardcoded here for right now.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package patchstrategicmerge
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml/merge2"
|
||||
@@ -29,7 +28,7 @@ func (pf Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !konfig.FlagEnableKyamlDefaultValue || r != nil {
|
||||
if r != nil {
|
||||
result = append(result, r)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,12 +723,12 @@ spec:
|
||||
- name: consul
|
||||
image: "dashicorp/consul:1.9.1"
|
||||
ports:
|
||||
- containerPort: 8500
|
||||
name: http
|
||||
- containerPort: 8301
|
||||
protocol: "TCP"
|
||||
- containerPort: 8301
|
||||
protocol: "UDP"
|
||||
- containerPort: 8500
|
||||
name: http
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
4
api/filters/replacement/doc.go
Normal file
4
api/filters/replacement/doc.go
Normal file
@@ -0,0 +1,4 @@
|
||||
// Package replacement contains a kio.Filter implementation of the kustomize
|
||||
// replacement transformer (accepts sources and looks for targets to replace
|
||||
// their values with values from the sources).
|
||||
package replacement
|
||||
68
api/filters/replacement/example_test.go
Normal file
68
api/filters/replacement/example_test.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package replacement
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
func ExampleFilter() {
|
||||
f := Filter{}
|
||||
err := yaml.Unmarshal([]byte(`
|
||||
replacements:
|
||||
- source:
|
||||
kind: Foo2
|
||||
fieldPath: spec.replicas
|
||||
targets:
|
||||
- select:
|
||||
kind: Foo1
|
||||
fieldPaths:
|
||||
- spec.replicas`), &f)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = kio.Pipeline{
|
||||
Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
|
||||
apiVersion: example.com/v1
|
||||
kind: Foo1
|
||||
metadata:
|
||||
name: instance
|
||||
spec:
|
||||
replicas: 3
|
||||
---
|
||||
apiVersion: example.com/v1
|
||||
kind: Foo2
|
||||
metadata:
|
||||
name: instance
|
||||
spec:
|
||||
replicas: 99
|
||||
`)}},
|
||||
Filters: []kio.Filter{f},
|
||||
Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
|
||||
}.Execute()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// apiVersion: example.com/v1
|
||||
// kind: Foo1
|
||||
// metadata:
|
||||
// name: instance
|
||||
// spec:
|
||||
// replicas: 99
|
||||
// ---
|
||||
// apiVersion: example.com/v1
|
||||
// kind: Foo2
|
||||
// metadata:
|
||||
// name: instance
|
||||
// spec:
|
||||
// replicas: 99
|
||||
}
|
||||
185
api/filters/replacement/replacement.go
Normal file
185
api/filters/replacement/replacement.go
Normal file
@@ -0,0 +1,185 @@
|
||||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package replacement
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
type Filter struct {
|
||||
Replacements []types.Replacement
|
||||
}
|
||||
|
||||
// Filter replaces values of targets with values from sources
|
||||
func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
for _, r := range f.Replacements {
|
||||
if r.Source == nil || r.Targets == nil {
|
||||
return nil, fmt.Errorf("replacements must specify a source and at least one target")
|
||||
}
|
||||
value, err := getReplacement(nodes, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nodes, err = applyReplacement(nodes, value, r.Targets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func applyReplacement(nodes []*yaml.RNode, value *yaml.RNode, targets []*types.TargetSelector) ([]*yaml.RNode, error) {
|
||||
for _, t := range targets {
|
||||
if t.Select == nil {
|
||||
return nil, fmt.Errorf("target must specify resources to select")
|
||||
}
|
||||
if len(t.FieldPaths) == 0 {
|
||||
t.FieldPaths = []string{types.DefaultReplacementFieldPath}
|
||||
}
|
||||
for _, n := range nodes {
|
||||
nodeId := getKrmId(n)
|
||||
if t.Select.KrmId.Match(nodeId) && !rejectId(t.Reject, nodeId) {
|
||||
err := applyToNode(n, value, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func rejectId(rejects []*types.Selector, nodeId *types.KrmId) bool {
|
||||
for _, r := range rejects {
|
||||
if r.KrmId.Match(nodeId) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func applyToNode(node *yaml.RNode, value *yaml.RNode, target *types.TargetSelector) error {
|
||||
for _, fp := range target.FieldPaths {
|
||||
fieldPath := strings.Split(fp, ".")
|
||||
var t *yaml.RNode
|
||||
var err error
|
||||
if target.Options != nil && target.Options.Create {
|
||||
t, err = node.Pipe(yaml.LookupCreate(value.YNode().Kind, fieldPath...))
|
||||
} else {
|
||||
t, err = node.Pipe(yaml.Lookup(fieldPath...))
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != nil {
|
||||
if err = setTargetValue(target.Options, t, value); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setTargetValue(options *types.FieldOptions, t *yaml.RNode, value *yaml.RNode) error {
|
||||
if options != nil && options.Delimiter != "" {
|
||||
|
||||
if t.YNode().Kind != yaml.ScalarNode {
|
||||
return fmt.Errorf("delimiter option can only be used with scalar nodes")
|
||||
}
|
||||
|
||||
tv := strings.Split(t.YNode().Value, options.Delimiter)
|
||||
v := yaml.GetValue(value)
|
||||
// TODO: Add a way to remove an element
|
||||
switch {
|
||||
case options.Index < 0: // prefix
|
||||
tv = append([]string{v}, tv...)
|
||||
case options.Index >= len(tv): // suffix
|
||||
tv = append(tv, v)
|
||||
default: // replace an element
|
||||
tv[options.Index] = v
|
||||
}
|
||||
value.YNode().Value = strings.Join(tv, options.Delimiter)
|
||||
}
|
||||
t.SetYNode(value.YNode())
|
||||
return nil
|
||||
}
|
||||
|
||||
func getReplacement(nodes []*yaml.RNode, r *types.Replacement) (*yaml.RNode, error) {
|
||||
source, err := selectSourceNode(nodes, r.Source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if r.Source.FieldPath == "" {
|
||||
r.Source.FieldPath = types.DefaultReplacementFieldPath
|
||||
}
|
||||
fieldPath := strings.Split(r.Source.FieldPath, ".")
|
||||
|
||||
rn, err := source.Pipe(yaml.Lookup(fieldPath...))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !rn.IsNilOrEmpty() {
|
||||
return getRefinedValue(r.Source.Options, rn)
|
||||
}
|
||||
return rn, nil
|
||||
}
|
||||
|
||||
func getRefinedValue(options *types.FieldOptions, rn *yaml.RNode) (*yaml.RNode, error) {
|
||||
if options == nil || options.Delimiter == "" {
|
||||
return rn, nil
|
||||
}
|
||||
if rn.YNode().Kind != yaml.ScalarNode {
|
||||
return nil, fmt.Errorf("delimiter option can only be used with scalar nodes")
|
||||
}
|
||||
value := strings.Split(yaml.GetValue(rn), options.Delimiter)
|
||||
if options.Index >= len(value) || options.Index < 0 {
|
||||
return nil, fmt.Errorf("options.index %d is out of bounds for value %s", options.Index, yaml.GetValue(rn))
|
||||
}
|
||||
n := rn.Copy()
|
||||
n.YNode().Value = value[options.Index]
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// selectSourceNode finds the node that matches the selector, returning
|
||||
// an error if multiple or none are found
|
||||
func selectSourceNode(nodes []*yaml.RNode, selector *types.SourceSelector) (*yaml.RNode, error) {
|
||||
var matches []*yaml.RNode
|
||||
for _, n := range nodes {
|
||||
if selector.KrmId.Match(getKrmId(n)) {
|
||||
if len(matches) > 0 {
|
||||
return nil, fmt.Errorf("more than one match for source %v", selector)
|
||||
}
|
||||
matches = append(matches, n)
|
||||
}
|
||||
}
|
||||
if len(matches) == 0 {
|
||||
return nil, fmt.Errorf("found no matches for source %v", selector)
|
||||
}
|
||||
return matches[0], nil
|
||||
}
|
||||
|
||||
func getKrmId(n *yaml.RNode) *types.KrmId {
|
||||
ns, err := n.GetNamespace()
|
||||
if err != nil {
|
||||
// Resource has no metadata (no apiVersion, kind, nor metadata field).
|
||||
// In this case, it cannot be selected.
|
||||
return &types.KrmId{}
|
||||
}
|
||||
apiVersion := n.Field(yaml.APIVersionField)
|
||||
var group, version string
|
||||
if apiVersion != nil {
|
||||
group, version = resid.ParseGroupVersion(yaml.GetValue(apiVersion.Value))
|
||||
}
|
||||
return &types.KrmId{
|
||||
Gvk: resid.Gvk{Group: group, Version: version, Kind: n.GetKind()},
|
||||
Name: n.GetName(),
|
||||
Namespace: ns,
|
||||
}
|
||||
}
|
||||
1365
api/filters/replacement/replacement_test.go
Normal file
1365
api/filters/replacement/replacement_test.go
Normal file
File diff suppressed because it is too large
Load Diff
14
api/go.mod
14
api/go.mod
@@ -1,20 +1,16 @@
|
||||
module sigs.k8s.io/kustomize/api
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible
|
||||
github.com/go-errors/errors v1.0.1
|
||||
github.com/go-openapi/spec v0.19.5
|
||||
github.com/golangci/golangci-lint v1.21.0
|
||||
github.com/google/go-cmp v0.3.0
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/imdario/mergo v0.3.5
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/imdario/mergo v0.3.12
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/stretchr/testify v1.4.0
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.10
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17
|
||||
sigs.k8s.io/yaml v1.2.0
|
||||
)
|
||||
|
||||
223
api/go.sum
223
api/go.sum
@@ -1,29 +1,20 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/OpenPeeDeeP/depguard v1.0.1 h1:VlW4R6jmBIv3/u1JNlawEvJMM4J+dPORPaZasQee8Us=
|
||||
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
|
||||
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bombsimon/wsl v1.2.5 h1:9gTOkIwVtoDZywvX802SDHokeX4kW1cKnV8ZTVAPkRs=
|
||||
github.com/bombsimon/wsl v1.2.5/go.mod h1:43lEF/i0kpXbLCeDXL9LMT8c92HyBywXb0AsgMHYngM=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
@@ -31,13 +22,10 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -45,26 +33,17 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/dustmop/soup v1.1.2-0.20190516214245-38228baa104e/go.mod h1:CgNC6SGbT+Xb8wGGvzilttZL1mc5sQ/5KkcxsZttMIk=
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db h1:GYXWx7Vr3+zv833u+8IoXbNnQY0AdXsxAgI0kX7xcwA=
|
||||
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db/go.mod h1:+sE8vrLDS2M0pZkBk0wy6+nLdKexVDrl/jBqQOTDThA=
|
||||
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-lintpack/lintpack v0.5.2 h1:DI5mA3+eKdWeJ40nU4d6Wc26qmdG8RCi/btYq0TuRN0=
|
||||
github.com/go-lintpack/lintpack v0.5.2/go.mod h1:NwZuYi2nUHho8XEIZ6SIxihrnPoqBTDqfpXvXAN0sXM=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
|
||||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
|
||||
github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
@@ -111,117 +90,43 @@ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+
|
||||
github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
|
||||
github.com/go-openapi/validate v0.19.8/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-toolsmith/astcast v1.0.0 h1:JojxlmI6STnFVG9yOImLeGREv8W2ocNUM+iOhR6jE7g=
|
||||
github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4=
|
||||
github.com/go-toolsmith/astcopy v1.0.0 h1:OMgl1b1MEpjFQ1m5ztEO06rz5CUd3oBv9RF7+DyvdG8=
|
||||
github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ=
|
||||
github.com/go-toolsmith/astequal v0.0.0-20180903214952-dcb477bfacd6/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
|
||||
github.com/go-toolsmith/astequal v1.0.0 h1:4zxD8j3JRFNyLN46lodQuqz3xdKSrur7U/sr0SDS/gQ=
|
||||
github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
|
||||
github.com/go-toolsmith/astfmt v0.0.0-20180903215011-8f8ee99c3086/go.mod h1:mP93XdblcopXwlyN4X4uodxXQhldPGZbcEJIimQHrkg=
|
||||
github.com/go-toolsmith/astfmt v1.0.0 h1:A0vDDXt+vsvLEdbMFJAUBI/uTbRw1ffOPnxsILnFL6k=
|
||||
github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw=
|
||||
github.com/go-toolsmith/astinfo v0.0.0-20180906194353-9809ff7efb21/go.mod h1:dDStQCHtmZpYOmjRP/8gHHnCCch3Zz3oEgCdZVdtweU=
|
||||
github.com/go-toolsmith/astp v0.0.0-20180903215135-0af7e3c24f30/go.mod h1:SV2ur98SGypH1UjcPpCatrV5hPazG6+IfNHbkDXBRrk=
|
||||
github.com/go-toolsmith/astp v1.0.0 h1:alXE75TXgcmupDsMK1fRAy0YUzLzqPVvBKoyWV+KPXg=
|
||||
github.com/go-toolsmith/astp v1.0.0/go.mod h1:RSyrtpVlfTFGDYRbrjyWP1pYu//tSFcvdYrA8meBmLI=
|
||||
github.com/go-toolsmith/pkgload v0.0.0-20181119091011-e9e65178eee8/go.mod h1:WoMrjiy4zvdS+Bg6z9jZH82QXwkcgCBX6nOfnmdaHks=
|
||||
github.com/go-toolsmith/pkgload v1.0.0 h1:4DFWWMXVfbcN5So1sBNW9+yeiMqLFGl1wFLTL5R0Tgg=
|
||||
github.com/go-toolsmith/pkgload v1.0.0/go.mod h1:5eFArkbO80v7Z0kdngIxsRXRMTaX4Ilcwuh3clNrQJc=
|
||||
github.com/go-toolsmith/strparse v1.0.0 h1:Vcw78DnpCAKlM20kSbAyO4mPfJn/lyYA4BJUDxe2Jb4=
|
||||
github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
|
||||
github.com/go-toolsmith/typep v1.0.0 h1:zKymWyA1TRYvqYrYDrfEMZULyrhcnGY3x7LDKU2XQaA=
|
||||
github.com/go-toolsmith/typep v1.0.0/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU=
|
||||
github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM=
|
||||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b h1:ekuhfTjngPhisSjOJ0QWKpPQE8/rbknHaes6WVJj5Hw=
|
||||
github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 h1:23T5iq8rbUYlhpt5DB4XJkc6BU31uODLD1o1gKvZmD0=
|
||||
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4=
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM=
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk=
|
||||
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 h1:YYWNAGTKWhKpcLLt7aSj/odlKrSrelQwlovBpDuf19w=
|
||||
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0=
|
||||
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613 h1:9kfjN3AdxcbsZBf8NjltjWihK2QfBBBZuv91cMFfDHw=
|
||||
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8=
|
||||
github.com/golangci/goconst v0.0.0-20180610141641-041c5f2b40f3 h1:pe9JHs3cHHDQgOFXJJdYkK6fLz2PWyYtP4hthoCMvs8=
|
||||
github.com/golangci/goconst v0.0.0-20180610141641-041c5f2b40f3/go.mod h1:JXrF4TWy4tXYn62/9x8Wm/K/dm06p8tCKwFRDPZG/1o=
|
||||
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee h1:J2XAy40+7yz70uaOiMbNnluTg7gyQhtGqLQncQh+4J8=
|
||||
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee/go.mod h1:ozx7R9SIwqmqf5pRP90DhR2Oay2UIjGuKheCBCNwAYU=
|
||||
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks=
|
||||
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
|
||||
github.com/golangci/golangci-lint v1.21.0 h1:HxAxpR8Z0M8omihvQdsD3PF0qPjlqYqp2vMJzstoKeI=
|
||||
github.com/golangci/golangci-lint v1.21.0/go.mod h1:phxpHK52q7SE+5KpPnti4oZTdFCEsn/tKN+nFvCKXfk=
|
||||
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc h1:gLLhTLMk2/SutryVJ6D4VZCU3CUqr8YloG7FPIBWFpI=
|
||||
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc/go.mod h1:e5tpTHCfVze+7EpLEozzMB3eafxo2KT5veNg1k6byQU=
|
||||
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 h1:MfyDlzVjl1hoaPzPD4Gpb/QgoRfSBR0jdhwGyAWwMSA=
|
||||
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg=
|
||||
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA=
|
||||
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o=
|
||||
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770 h1:EL/O5HGrF7Jaq0yNhBLucz9hTuRzj2LdwGBOaENgxIk=
|
||||
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA=
|
||||
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21 h1:leSNB7iYzLYSSx3J/s5sVf4Drkc68W2wm4Ixh/mr0us=
|
||||
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21/go.mod h1:tf5+bzsHdTM0bsB7+8mt0GUMvjCgwLpTapNZHU8AajI=
|
||||
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0 h1:HVfrLniijszjS1aiNg8JbBMO2+E1WIQ+j/gL4SQqGPg=
|
||||
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0/go.mod h1:qOQCunEYvmd/TLamH+7LlVccLvUH5kZNhbCgTHoBbp4=
|
||||
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 h1:zwtduBRr5SSWhqsYNgcuWO2kFlpdOZbP0+yRjmvPGys=
|
||||
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3 h1:JVnpOZS+qxli+rgVl98ILOXVNbW+kb5wcxeGx8ShUIw=
|
||||
github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
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/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
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/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
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/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
@@ -230,39 +135,18 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
|
||||
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
|
||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
|
||||
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb h1:RHba4YImhrUVQDHUCe2BNSOz4tVy2yGyXhvYDvxGgeE=
|
||||
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
|
||||
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0=
|
||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
|
||||
github.com/mozilla/tls-observatory v0.0.0-20190404164649-a3c1b6cfecfd/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E=
|
||||
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/paulmach/orb v0.1.3/go.mod h1:VFlX/8C+IQ1p6FTRRKzKoOPJnvEtA5G0Veuqwbu//Vk=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
@@ -274,72 +158,33 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d h1:K6eOUihrFLdZjZnA4XlRp864fmWXv9YTIk7VPLhRacA=
|
||||
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA=
|
||||
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d h1:BzRvVq1EHuIjxpijCEKpAxzKUUMurOQ4sknehIATRh8=
|
||||
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d/go.mod h1:w5+eXa0mYznDkHaMCXA4XYffjlH+cy1oyKbfzJXa2Do=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
||||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM=
|
||||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
|
||||
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041 h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc=
|
||||
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sourcegraph/go-diff v0.5.1 h1:gO6i5zugwzo1RVTvgvfwCOSVegNuvnNi6bAD1QCmkHs=
|
||||
github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34cd2MNlA9u1mE=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
|
||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
|
||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=
|
||||
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ultraware/funlen v0.0.2 h1:Av96YVBwwNSe4MLR7iI/BIa3VyI7/djnto/pK3Uxbdo=
|
||||
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
||||
github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg=
|
||||
github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
|
||||
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 h1:ChMKTho2hWKpks/nD/FL2KqM1wuVt62oJeiE8+eFpGs=
|
||||
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
|
||||
github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
|
||||
@@ -349,27 +194,19 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -378,11 +215,8 @@ golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -390,44 +224,25 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c h1:Vco5b+cuG5NNfORVxZy6bYZQ7rsigisU1WQFkvQ0L5E=
|
||||
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181117154741-2ddaf7f79a09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190110163146-51295c7ec13a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e h1:aZzprAO9/8oim3qStq3wc1Xuxx4QmAGriC4VU4ojemQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
@@ -437,34 +252,20 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.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.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
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.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
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=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/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/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I=
|
||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo=
|
||||
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/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.10 h1:caAxDDkaXZp+0kDsZVik4leFJV8LCy09PdVqpaoNeF4=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.10/go.mod h1:K9yg1k/HB/6xNOf5VH3LhTo1DK9/5ykSZO5uIv+Y/1k=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17 h1:4zrV0ym5AYa0e512q7K3Wp1u7mzoWW0xR3UHJcGWGIg=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17/go.mod h1:mlQFagmkm1P+W4lZJbJ/yaxMd8PqMRSC4cPcfUVt5Hg=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4 h1:JPJh2pk3+X4lXAkZIk2RuE/7/FoK9maXw+TNPJhVS/c=
|
||||
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
|
||||
|
||||
@@ -20,12 +20,12 @@ func SortArrayAndComputeHash(s []string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return Encode(Hash(string(data)))
|
||||
return encode(hex256(string(data)))
|
||||
}
|
||||
|
||||
// Copied from https://github.com/kubernetes/kubernetes
|
||||
// /blob/master/pkg/kubectl/util/hash/hash.go
|
||||
func Encode(hex string) (string, error) {
|
||||
func encode(hex string) (string, error) {
|
||||
if len(hex) < 10 {
|
||||
return "", fmt.Errorf(
|
||||
"input length must be at least 10")
|
||||
@@ -48,23 +48,18 @@ func Encode(hex string) (string, error) {
|
||||
return string(enc), nil
|
||||
}
|
||||
|
||||
// Hash returns the hex form of the sha256 of the argument.
|
||||
func Hash(data string) string {
|
||||
// hex256 returns the hex form of the sha256 of the argument.
|
||||
func hex256(data string) string {
|
||||
return fmt.Sprintf("%x", sha256.Sum256([]byte(data)))
|
||||
}
|
||||
|
||||
// HashRNode returns the hash value of input RNode
|
||||
func HashRNode(node *yaml.RNode) (string, error) {
|
||||
// get node kind
|
||||
kindNode, err := node.Pipe(yaml.FieldMatcher{Name: "kind"})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
kind := kindNode.YNode().Value
|
||||
// Hasher computes the hash of an RNode.
|
||||
type Hasher struct{}
|
||||
|
||||
// calculate hash for different kinds
|
||||
encoded := ""
|
||||
switch kind {
|
||||
// Hash returns a hash of the argument.
|
||||
func (h *Hasher) Hash(node *yaml.RNode) (r string, err error) {
|
||||
var encoded string
|
||||
switch node.GetKind() {
|
||||
case "ConfigMap":
|
||||
encoded, err = encodeConfigMap(node)
|
||||
case "Secret":
|
||||
@@ -77,10 +72,11 @@ func HashRNode(node *yaml.RNode) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return Encode(Hash(encoded))
|
||||
return encode(hex256(encoded))
|
||||
}
|
||||
|
||||
func getNodeValues(node *yaml.RNode, paths []string) (map[string]interface{}, error) {
|
||||
func getNodeValues(
|
||||
node *yaml.RNode, paths []string) (map[string]interface{}, error) {
|
||||
values := make(map[string]interface{})
|
||||
for _, p := range paths {
|
||||
vn, err := node.Pipe(yaml.Lookup(p))
|
||||
@@ -117,8 +113,11 @@ func encodeConfigMap(node *yaml.RNode) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m := map[string]interface{}{"kind": "ConfigMap", "name": values["metadata/name"],
|
||||
"data": values["data"]}
|
||||
m := map[string]interface{}{
|
||||
"kind": "ConfigMap",
|
||||
"name": values["metadata/name"],
|
||||
"data": values["data"],
|
||||
}
|
||||
if _, ok := values["binaryData"].(map[string]interface{}); ok {
|
||||
m["binaryData"] = values["binaryData"]
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ func TestSortArrayAndComputeHash(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHash(t *testing.T) {
|
||||
func Test_hex256(t *testing.T) {
|
||||
// hash the empty string to be sure that sha256 is being used
|
||||
expect := "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
sum := Hash("")
|
||||
sum := hex256("")
|
||||
if expect != sum {
|
||||
t.Errorf("expected hash %q but got %q", expect, sum)
|
||||
}
|
||||
@@ -56,7 +56,7 @@ kind: ConfigMap`, "6ct58987ht", ""},
|
||||
{"one key", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
data:
|
||||
data:
|
||||
one: ""`, "9g67k2htb6", ""},
|
||||
// three keys (tests sorting order)
|
||||
{"three keys", `
|
||||
@@ -93,17 +93,17 @@ data:
|
||||
binaryData:
|
||||
two: ""`, "698h7c7t9m", ""},
|
||||
}
|
||||
|
||||
h := &Hasher{}
|
||||
for _, c := range cases {
|
||||
node, err := yaml.Parse(c.cmYaml)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h, err := HashRNode(node)
|
||||
hashed, err := h.Hash(node)
|
||||
if SkipRest(t, c.desc, err, c.err) {
|
||||
continue
|
||||
}
|
||||
if c.hash != h {
|
||||
if c.hash != hashed {
|
||||
t.Errorf("case %q, expect hash %q but got %q", c.desc, c.hash, h)
|
||||
}
|
||||
}
|
||||
@@ -154,35 +154,34 @@ type: my-type
|
||||
data:
|
||||
one: ""`, "74bd68bm66", ""},
|
||||
}
|
||||
|
||||
h := &Hasher{}
|
||||
for _, c := range cases {
|
||||
node, err := yaml.Parse(c.secretYaml)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h, err := HashRNode(node)
|
||||
hashed, err := h.Hash(node)
|
||||
if SkipRest(t, c.desc, err, c.err) {
|
||||
continue
|
||||
}
|
||||
if c.hash != h {
|
||||
if c.hash != hashed {
|
||||
t.Errorf("case %q, expect hash %q but got %q", c.desc, c.hash, h)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnstructuredHash(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
unstructured string
|
||||
hash string
|
||||
err string
|
||||
func TestBasicHash(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
res string
|
||||
hash string
|
||||
err string
|
||||
}{
|
||||
{"minimal", `
|
||||
"minimal": {`
|
||||
apiVersion: test/v1
|
||||
kind: TestResource
|
||||
metadata:
|
||||
name: my-resource`, "244782mkb7", ""},
|
||||
{"with spec", `
|
||||
"with spec": {`
|
||||
apiVersion: test/v1
|
||||
kind: TestResource
|
||||
metadata:
|
||||
@@ -191,19 +190,22 @@ spec:
|
||||
foo: 1
|
||||
bar: abc`, "59m2mdccg4", ""},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
node, err := yaml.Parse(c.unstructured)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h, err := HashRNode(node)
|
||||
if SkipRest(t, c.desc, err, c.err) {
|
||||
continue
|
||||
}
|
||||
if c.hash != h {
|
||||
t.Errorf("case %q, expect hash %q but got %q", c.desc, c.hash, h)
|
||||
}
|
||||
h := &Hasher{}
|
||||
for n := range cases {
|
||||
c := cases[n]
|
||||
t.Run(n, func(t *testing.T) {
|
||||
node, err := yaml.Parse(c.res)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hashed, err := h.Hash(node)
|
||||
if SkipRest(t, n, err, c.err) {
|
||||
return
|
||||
}
|
||||
if c.hash != hashed {
|
||||
t.Errorf("case %q, expect hash %q but got %q", n, c.hash, h)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +224,7 @@ kind: ConfigMap`, `{"data":"","kind":"ConfigMap","name":""}`, ""},
|
||||
{"one key", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
data:
|
||||
data:
|
||||
one: ""`, `{"data":{"one":""},"kind":"ConfigMap","name":""}`, ""},
|
||||
// three keys (tests sorting order)
|
||||
{"three keys", `
|
||||
@@ -334,9 +336,10 @@ data:
|
||||
}
|
||||
}
|
||||
|
||||
// SkipRest returns true if there was a non-nil error or if we expected an error that didn't happen,
|
||||
// and logs the appropriate error on the test object.
|
||||
// The return value indicates whether we should skip the rest of the test case due to the error result.
|
||||
// SkipRest returns true if there was a non-nil error or if we expected an
|
||||
// error that didn't happen, and logs the appropriate error on the test object.
|
||||
// The return value indicates whether we should skip the rest of the test case
|
||||
// due to the error result.
|
||||
func SkipRest(t *testing.T, desc string, err error, contains string) bool {
|
||||
if err != nil {
|
||||
if len(contains) == 0 {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
package ifc
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
// Validator provides functions to validate annotations and labels
|
||||
@@ -38,92 +38,10 @@ type Loader interface {
|
||||
Cleanup() error
|
||||
}
|
||||
|
||||
// Kunstructured represents a Kubernetes Resource Model object.
|
||||
type Kunstructured interface {
|
||||
// Several uses.
|
||||
Copy() Kunstructured
|
||||
|
||||
// GetAnnotations returns the k8s annotations.
|
||||
GetAnnotations() map[string]string
|
||||
|
||||
// GetData returns a top-level "data" field, as in a ConfigMap.
|
||||
GetDataMap() map[string]string
|
||||
|
||||
// GetData returns a top-level "binaryData" field, as in a ConfigMap.
|
||||
GetBinaryDataMap() map[string]string
|
||||
|
||||
// Used by ResAccumulator and ReplacementTransformer.
|
||||
GetFieldValue(string) (interface{}, error)
|
||||
|
||||
// Used by Resource.OrgId
|
||||
GetGvk() resid.Gvk
|
||||
|
||||
// Used by resource.Factory.SliceFromBytes
|
||||
GetKind() string
|
||||
|
||||
// GetLabels returns the k8s labels.
|
||||
GetLabels() map[string]string
|
||||
|
||||
// Used by Resource.CurId and resource factory.
|
||||
GetName() string
|
||||
|
||||
// Used by special case code in
|
||||
// ResMap.SubsetThatCouldBeReferencedByResource
|
||||
GetSlice(path string) ([]interface{}, error)
|
||||
|
||||
// GetString returns the value of a string field.
|
||||
// Used by Resource.GetNamespace
|
||||
GetString(string) (string, error)
|
||||
|
||||
// Several uses.
|
||||
Map() map[string]interface{}
|
||||
|
||||
// Used by Resource.AsYAML and Resource.String
|
||||
MarshalJSON() ([]byte, error)
|
||||
|
||||
// Used by resWrangler.Select
|
||||
MatchesAnnotationSelector(selector string) (bool, error)
|
||||
|
||||
// Used by resWrangler.Select
|
||||
MatchesLabelSelector(selector string) (bool, error)
|
||||
|
||||
// SetAnnotations replaces the k8s annotations.
|
||||
SetAnnotations(map[string]string)
|
||||
|
||||
// SetDataMap sets a top-level "data" field, as in a ConfigMap.
|
||||
SetDataMap(map[string]string)
|
||||
|
||||
// SetDataMap sets a top-level "binaryData" field, as in a ConfigMap.
|
||||
SetBinaryDataMap(map[string]string)
|
||||
// Used by PatchStrategicMergeTransformer.
|
||||
SetGvk(resid.Gvk)
|
||||
|
||||
// SetLabels replaces the k8s labels.
|
||||
SetLabels(map[string]string)
|
||||
|
||||
// SetName changes the name.
|
||||
SetName(string)
|
||||
|
||||
// SetNamespace changes the namespace.
|
||||
SetNamespace(string)
|
||||
|
||||
// Needed, for now, by kyaml/filtersutil.ApplyToJSON.
|
||||
UnmarshalJSON([]byte) error
|
||||
}
|
||||
|
||||
// KunstructuredFactory makes instances of Kunstructured.
|
||||
type KunstructuredFactory interface {
|
||||
SliceFromBytes([]byte) ([]Kunstructured, error)
|
||||
FromMap(m map[string]interface{}) Kunstructured
|
||||
Hasher() KunstructuredHasher
|
||||
MakeConfigMap(kvLdr KvLoader, args *types.ConfigMapArgs) (Kunstructured, error)
|
||||
MakeSecret(kvLdr KvLoader, args *types.SecretArgs) (Kunstructured, error)
|
||||
}
|
||||
|
||||
// KunstructuredHasher returns a hash of the argument
|
||||
// KustHasher returns a hash of the argument
|
||||
// or an error.
|
||||
type KunstructuredHasher interface {
|
||||
Hash(Kunstructured) (string, error)
|
||||
type KustHasher interface {
|
||||
Hash(*yaml.RNode) (string, error)
|
||||
}
|
||||
|
||||
// See core.v1.SecretTypeOpaque
|
||||
|
||||
@@ -25,7 +25,7 @@ type OpenAPIDefinition struct {
|
||||
Dependencies []string
|
||||
}
|
||||
|
||||
type myProperties map[string]spec.Schema
|
||||
type myProperties = map[string]spec.Schema
|
||||
type nameToApiMap map[string]OpenAPIDefinition
|
||||
|
||||
// LoadConfigFromCRDs parse CRD schemas from paths into a TransformerConfig
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
@@ -521,17 +520,9 @@ func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}).ResMap(),
|
||||
// TODO(#3304): DECISION - kyaml better; not a bug.
|
||||
expectedErr: konfig.IfApiMachineryElseKyaml(
|
||||
`updating name reference in 'rules/resourceNames' field of `+
|
||||
`'rbac.authorization.k8s.io_v1_ClusterRole|~X|cr'`+
|
||||
`: considering field 'rules/resourceNames' of object
|
||||
{"apiVersion": "rbac.authorization.k8s.io/v1", "kind": "ClusterRole", "metadata": {
|
||||
"name": "cr"}, "rules": [{"resourceNames": {"foo": "bar"}, "resources": ["secrets"]}]}
|
||||
: visit traversal on path: [resourceNames]: path config error; no 'name' field in node`,
|
||||
`updating name reference in 'rules/resourceNames' field of `+
|
||||
`'rbac.authorization.k8s.io_v1_ClusterRole|~X|cr'`+
|
||||
`: considering field 'rules/resourceNames' of object
|
||||
expectedErr: `updating name reference in 'rules/resourceNames' field of ` +
|
||||
`'rbac.authorization.k8s.io_v1_ClusterRole|~X|cr'` +
|
||||
`: considering field 'rules/resourceNames' of object
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -541,7 +532,7 @@ rules:
|
||||
foo: bar
|
||||
resources:
|
||||
- secrets
|
||||
: visit traversal on path: [resourceNames]: path config error; no 'name' field in node`)},
|
||||
: visit traversal on path: [resourceNames]: path config error; no 'name' field in node`},
|
||||
}
|
||||
|
||||
nrt := newNameReferenceTransformer(builtinconfig.MakeDefaultConfig().NameReference)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
resmaptest_test "sigs.k8s.io/kustomize/api/testutils/resmaptest"
|
||||
@@ -121,12 +120,7 @@ func TestRefVarTransformer(t *testing.T) {
|
||||
"slice": []interface{}{5}, // noticeably *not* a []string
|
||||
}}).ResMap(),
|
||||
},
|
||||
// TODO(#3304): DECISION - kyaml better; not a bug.
|
||||
errMessage: konfig.IfApiMachineryElseKyaml(
|
||||
`considering field 'data/slice' of object
|
||||
{"apiVersion": "v1", "data": {"slice": [5]}, "kind": "ConfigMap", "metadata": {"name": "cm1"}}
|
||||
: invalid value type expect a string`,
|
||||
`considering field 'data/slice' of object
|
||||
errMessage: `considering field 'data/slice' of object
|
||||
apiVersion: v1
|
||||
data:
|
||||
slice:
|
||||
@@ -135,7 +129,6 @@ kind: ConfigMap
|
||||
metadata:
|
||||
name: cm1
|
||||
: invalid value type expect a string`,
|
||||
),
|
||||
},
|
||||
"var replacement in nil": {
|
||||
given: given{
|
||||
|
||||
@@ -352,6 +352,7 @@ func TestResolveVarsWithNoambiguation(t *testing.T) {
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "sub-backendOne",
|
||||
"annotations": map[string]interface{}{
|
||||
"config.kubernetes.io/previousKinds": "Service",
|
||||
"config.kubernetes.io/previousNames": "backendOne",
|
||||
"config.kubernetes.io/previousNamespaces": "default",
|
||||
"config.kubernetes.io/prefixes": "sub-",
|
||||
@@ -399,7 +400,8 @@ func find(name string, resMap resmap.ResMap) *resource.Resource {
|
||||
func getCommand(r *resource.Resource) string {
|
||||
var m map[string]interface{}
|
||||
var c []interface{}
|
||||
m, _ = r.Map()["spec"].(map[string]interface{})
|
||||
resourceMap, _ := r.Map()
|
||||
m, _ = resourceMap["spec"].(map[string]interface{})
|
||||
m, _ = m["template"].(map[string]interface{})
|
||||
m, _ = m["spec"].(map[string]interface{})
|
||||
c, _ = m["containers"].([]interface{})
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright 2020 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package conflict
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
)
|
||||
|
||||
type cdFactory struct{}
|
||||
|
||||
var _ resource.ConflictDetectorFactory = &cdFactory{}
|
||||
|
||||
// NewFactory returns a new conflict detector factory.
|
||||
func NewFactory() resource.ConflictDetectorFactory {
|
||||
return &cdFactory{}
|
||||
}
|
||||
|
||||
// New returns an instance of smPatchMergeOnlyDetector.
|
||||
func (c cdFactory) New(_ resid.Gvk) (resource.ConflictDetector, error) {
|
||||
return &smPatchMergeOnlyDetector{}, nil
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2020 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package conflict
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
)
|
||||
|
||||
// smPatchMergeOnlyDetector ignores conflicts,
|
||||
// but does real strategic merge patching.
|
||||
// This is part of an effort to eliminate dependence on
|
||||
// apimachinery package to allow kustomize integration
|
||||
// into kubectl (#2506 and #1500)
|
||||
type smPatchMergeOnlyDetector struct{}
|
||||
|
||||
var _ resource.ConflictDetector = &smPatchMergeOnlyDetector{}
|
||||
|
||||
func (c *smPatchMergeOnlyDetector) HasConflict(
|
||||
_, _ *resource.Resource) (bool, error) {
|
||||
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(
|
||||
r, patch *resource.Resource) (*resource.Resource, error) {
|
||||
err := r.ApplySmPatch(patch)
|
||||
return r, err
|
||||
}
|
||||
@@ -4,8 +4,9 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
server "sigs.k8s.io/kustomize/api/internal/crawl/backend"
|
||||
"strconv"
|
||||
|
||||
server "sigs.k8s.io/kustomize/api/internal/crawl/backend"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -81,7 +81,7 @@ func (gc githubCrawler) Crawl(ctx context.Context,
|
||||
output chan<- crawler.CrawledDocument, seen utils.SeenMap) error {
|
||||
|
||||
ranges := []RangeWithin{
|
||||
RangeWithin{
|
||||
{
|
||||
start: uint64(0),
|
||||
end: githubMaxFileSize,
|
||||
},
|
||||
|
||||
@@ -96,6 +96,6 @@ func TestRangeSizes(t *testing.T) {
|
||||
returnedResult := RangeSizes(s)
|
||||
expectedResult := RangeWithin{uint64(2365), uint64(10000)}
|
||||
if !reflect.DeepEqual(returnedResult, expectedResult) {
|
||||
t.Errorf("RangeSizes expected (%v), got (%v)",expectedResult, returnedResult)
|
||||
t.Errorf("RangeSizes expected (%v), got (%v)", expectedResult, returnedResult)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module sigs.k8s.io/kustomize/api/internal/crawl
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
|
||||
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bombsimon/wsl v1.2.5/go.mod h1:43lEF/i0kpXbLCeDXL9LMT8c92HyBywXb0AsgMHYngM=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
@@ -28,13 +22,10 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -42,23 +33,18 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/dustmop/soup v1.1.2-0.20190516214245-38228baa104e/go.mod h1:CgNC6SGbT+Xb8wGGvzilttZL1mc5sQ/5KkcxsZttMIk=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5 h1:U2HtkBseC1FNBmDr0TR2tKltL6FxoY+niDAlj5M8TK8=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db/go.mod h1:+sE8vrLDS2M0pZkBk0wy6+nLdKexVDrl/jBqQOTDThA=
|
||||
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-lintpack/lintpack v0.5.2/go.mod h1:NwZuYi2nUHho8XEIZ6SIxihrnPoqBTDqfpXvXAN0sXM=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
|
||||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
|
||||
github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
@@ -105,22 +91,7 @@ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+
|
||||
github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
|
||||
github.com/go-openapi/validate v0.19.8/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4=
|
||||
github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ=
|
||||
github.com/go-toolsmith/astequal v0.0.0-20180903214952-dcb477bfacd6/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
|
||||
github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
|
||||
github.com/go-toolsmith/astfmt v0.0.0-20180903215011-8f8ee99c3086/go.mod h1:mP93XdblcopXwlyN4X4uodxXQhldPGZbcEJIimQHrkg=
|
||||
github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw=
|
||||
github.com/go-toolsmith/astinfo v0.0.0-20180906194353-9809ff7efb21/go.mod h1:dDStQCHtmZpYOmjRP/8gHHnCCch3Zz3oEgCdZVdtweU=
|
||||
github.com/go-toolsmith/astp v0.0.0-20180903215135-0af7e3c24f30/go.mod h1:SV2ur98SGypH1UjcPpCatrV5hPazG6+IfNHbkDXBRrk=
|
||||
github.com/go-toolsmith/astp v1.0.0/go.mod h1:RSyrtpVlfTFGDYRbrjyWP1pYu//tSFcvdYrA8meBmLI=
|
||||
github.com/go-toolsmith/pkgload v0.0.0-20181119091011-e9e65178eee8/go.mod h1:WoMrjiy4zvdS+Bg6z9jZH82QXwkcgCBX6nOfnmdaHks=
|
||||
github.com/go-toolsmith/pkgload v1.0.0/go.mod h1:5eFArkbO80v7Z0kdngIxsRXRMTaX4Ilcwuh3clNrQJc=
|
||||
github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
|
||||
github.com/go-toolsmith/typep v1.0.0/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU=
|
||||
github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM=
|
||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
@@ -128,64 +99,39 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4=
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk=
|
||||
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0=
|
||||
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8=
|
||||
github.com/golangci/goconst v0.0.0-20180610141641-041c5f2b40f3/go.mod h1:JXrF4TWy4tXYn62/9x8Wm/K/dm06p8tCKwFRDPZG/1o=
|
||||
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee/go.mod h1:ozx7R9SIwqmqf5pRP90DhR2Oay2UIjGuKheCBCNwAYU=
|
||||
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
|
||||
github.com/golangci/golangci-lint v1.21.0/go.mod h1:phxpHK52q7SE+5KpPnti4oZTdFCEsn/tKN+nFvCKXfk=
|
||||
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc/go.mod h1:e5tpTHCfVze+7EpLEozzMB3eafxo2KT5veNg1k6byQU=
|
||||
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg=
|
||||
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o=
|
||||
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA=
|
||||
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21/go.mod h1:tf5+bzsHdTM0bsB7+8mt0GUMvjCgwLpTapNZHU8AajI=
|
||||
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0/go.mod h1:qOQCunEYvmd/TLamH+7LlVccLvUH5kZNhbCgTHoBbp4=
|
||||
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE=
|
||||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
|
||||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
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/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
@@ -194,30 +140,18 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
|
||||
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
|
||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
|
||||
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0=
|
||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
|
||||
github.com/mozilla/tls-observatory v0.0.0-20190404164649-a3c1b6cfecfd/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/paulmach/orb v0.1.3/go.mod h1:VFlX/8C+IQ1p6FTRRKzKoOPJnvEtA5G0Veuqwbu//Vk=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
@@ -229,58 +163,34 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA=
|
||||
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d/go.mod h1:w5+eXa0mYznDkHaMCXA4XYffjlH+cy1oyKbfzJXa2Do=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
||||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
|
||||
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34cd2MNlA9u1mE=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
||||
github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
|
||||
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
|
||||
github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
|
||||
@@ -290,26 +200,18 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -318,11 +220,8 @@ golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -330,42 +229,25 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181117154741-2ddaf7f79a09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190110163146-51295c7ec13a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
@@ -375,27 +257,20 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.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.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
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.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
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=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
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/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.9 h1:n3WNdvPPReRNDxW+XXd2JlyZ8EII721I21D1DBpBVBE=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.9/go.mod h1:K9yg1k/HB/6xNOf5VH3LhTo1DK9/5ykSZO5uIv+Y/1k=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17 h1:4zrV0ym5AYa0e512q7K3Wp1u7mzoWW0xR3UHJcGWGIg=
|
||||
sigs.k8s.io/kustomize/kyaml v0.10.17/go.mod h1:mlQFagmkm1P+W4lZJbJ/yaxMd8PqMRSC4cPcfUVt5Hg=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
|
||||
|
||||
@@ -191,7 +191,8 @@ func (idx *index) Put(uniqueID string, doc interface{}) error {
|
||||
}
|
||||
|
||||
if exists {
|
||||
docBytes, err := json.Marshal(doc)
|
||||
var docBytes []byte
|
||||
docBytes, err = json.Marshal(doc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -204,12 +205,14 @@ func (idx *index) Put(uniqueID string, doc interface{}) error {
|
||||
Body: bytes.NewReader(body),
|
||||
DocumentID: uniqueID,
|
||||
}
|
||||
res, err := req.Do(idx.ctx, idx.client)
|
||||
var res *esapi.Response
|
||||
res, err = req.Do(idx.ctx, idx.client)
|
||||
|
||||
err = idx.responseErrorOrNil("could not update document",
|
||||
res, err, ignoreResponseBody)
|
||||
} else {
|
||||
body, err := json.Marshal(doc)
|
||||
var body []byte
|
||||
body, err = json.Marshal(doc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -219,7 +222,8 @@ func (idx *index) Put(uniqueID string, doc interface{}) error {
|
||||
Body: bytes.NewReader(body),
|
||||
DocumentID: uniqueID,
|
||||
}
|
||||
res, err := req.Do(idx.ctx, idx.client)
|
||||
var res *esapi.Response
|
||||
res, err = req.Do(idx.ctx, idx.client)
|
||||
|
||||
err = idx.responseErrorOrNil("could not insert document",
|
||||
res, err, ignoreResponseBody)
|
||||
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
. "sigs.k8s.io/kustomize/api/internal/plugins/execplugin"
|
||||
pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/utils"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
fLdr "sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
|
||||
func TestExecPluginConfig(t *testing.T) {
|
||||
@@ -32,8 +32,7 @@ s/$BAR/bar baz/g
|
||||
t.Fatal(err)
|
||||
}
|
||||
pvd := provider.NewDefaultDepProvider()
|
||||
rf := resmap.NewFactory(
|
||||
pvd.GetResourceFactory(), pvd.GetConflictDetectorFactory())
|
||||
rf := resmap.NewFactory(pvd.GetResourceFactory())
|
||||
pluginConfig := rf.RF().FromMap(
|
||||
map[string]interface{}{
|
||||
"apiVersion": "someteam.example.com/v1",
|
||||
@@ -46,10 +45,13 @@ s/$BAR/bar baz/g
|
||||
})
|
||||
|
||||
pluginConfig.RemoveBuildAnnotations()
|
||||
p := NewExecPlugin(
|
||||
pLdr.AbsolutePluginPath(
|
||||
konfig.DisabledPluginConfig(),
|
||||
pluginConfig.OrgId()))
|
||||
pc := types.DisabledPluginConfig()
|
||||
loader := pLdr.NewLoader(pc, rf, fSys)
|
||||
pluginPath, err := loader.AbsolutePluginPath(pluginConfig.OrgId())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
p := NewExecPlugin(pluginPath)
|
||||
// Not checking to see if the plugin is executable,
|
||||
// because this test does not run it.
|
||||
// This tests only covers sending configuration
|
||||
@@ -60,7 +62,9 @@ s/$BAR/bar baz/g
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
p.Config(resmap.NewPluginHelpers(ldr, pvd.GetFieldValidator(), rf), yaml)
|
||||
p.Config(
|
||||
resmap.NewPluginHelpers(ldr, pvd.GetFieldValidator(), rf, pc),
|
||||
yaml)
|
||||
|
||||
expected := "someteam.example.com/v1/sedtransformer/SedTransformer"
|
||||
if !strings.HasSuffix(p.Path(), expected) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/ifc"
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/builtinhelpers"
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/execplugin"
|
||||
@@ -29,11 +30,21 @@ import (
|
||||
type Loader struct {
|
||||
pc *types.PluginConfig
|
||||
rf *resmap.Factory
|
||||
fs filesys.FileSystem
|
||||
|
||||
// absolutePluginHome caches the location of a valid plugin root directory.
|
||||
// It should only be set once the directory's existence has been confirmed.
|
||||
absolutePluginHome string
|
||||
}
|
||||
|
||||
func NewLoader(
|
||||
pc *types.PluginConfig, rf *resmap.Factory) *Loader {
|
||||
return &Loader{pc: pc, rf: rf}
|
||||
pc *types.PluginConfig, rf *resmap.Factory, fs filesys.FileSystem) *Loader {
|
||||
return &Loader{pc: pc, rf: rf, fs: fs}
|
||||
}
|
||||
|
||||
// Config provides the global (not plugin specific) PluginConfig data.
|
||||
func (l *Loader) Config() *types.PluginConfig {
|
||||
return l.pc
|
||||
}
|
||||
|
||||
func (l *Loader) LoadGenerators(
|
||||
@@ -95,13 +106,47 @@ func relativePluginPath(id resid.ResId) string {
|
||||
strings.ToLower(id.Kind))
|
||||
}
|
||||
|
||||
func AbsolutePluginPath(pc *types.PluginConfig, id resid.ResId) string {
|
||||
return filepath.Join(
|
||||
pc.AbsPluginHome, relativePluginPath(id), id.Kind)
|
||||
func (l *Loader) AbsolutePluginPath(id resid.ResId) (string, error) {
|
||||
pluginHome, err := l.absPluginHome()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(pluginHome, relativePluginPath(id), id.Kind), nil
|
||||
}
|
||||
|
||||
func (l *Loader) absolutePluginPath(id resid.ResId) string {
|
||||
return AbsolutePluginPath(l.pc, id)
|
||||
// absPluginHome is the home of kustomize Exec and Go plugins.
|
||||
// Kustomize plugin configuration files are k8s-style objects
|
||||
// containing the fields 'apiVersion' and 'kind', e.g.
|
||||
// apiVersion: apps/v1
|
||||
// kind: Deployment
|
||||
// kustomize reads plugin configuration data from a file path
|
||||
// specified in the 'generators:' or 'transformers:' field of a
|
||||
// kustomization file. For Exec and Go plugins, kustomize
|
||||
// uses this data to both locate the plugin and configure it.
|
||||
// Each Exec or Go plugin (its code, its tests, its supporting data
|
||||
// files, etc.) must be housed in its own directory at
|
||||
// ${absPluginHome}/${pluginApiVersion}/LOWERCASE(${pluginKind})
|
||||
// where
|
||||
// - ${absPluginHome} is an absolute path, defined below.
|
||||
// - ${pluginApiVersion} is taken from the plugin config file.
|
||||
// - ${pluginKind} is taken from the plugin config file.
|
||||
func (l *Loader) absPluginHome() (string, error) {
|
||||
// External plugins are disabled--return the dummy plugin root.
|
||||
if l.pc.PluginRestrictions != types.PluginRestrictionsNone {
|
||||
return konfig.NoPluginHomeSentinal, nil
|
||||
}
|
||||
// We've already determined plugin home--use the cached value.
|
||||
if l.absolutePluginHome != "" {
|
||||
return l.absolutePluginHome, nil
|
||||
}
|
||||
|
||||
// Check default locations for a valid plugin root, and cache it if found.
|
||||
dir, err := konfig.DefaultAbsPluginHome(l.fs)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
l.absolutePluginHome = dir
|
||||
return l.absolutePluginHome, nil
|
||||
}
|
||||
|
||||
func isBuiltinPlugin(res *resource.Resource) bool {
|
||||
@@ -148,7 +193,7 @@ func (l *Loader) loadAndConfigurePlugin(
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "marshalling yaml from res %s", res.OrgId())
|
||||
}
|
||||
err = c.Config(resmap.NewPluginHelpers(ldr, v, l.rf), yaml)
|
||||
err = c.Config(resmap.NewPluginHelpers(ldr, v, l.rf, l.pc), yaml)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err, "plugin %s fails configuration", res.OrgId())
|
||||
@@ -176,10 +221,13 @@ func (l *Loader) loadPlugin(res *resource.Resource) (resmap.Configurable, error)
|
||||
}
|
||||
|
||||
func (l *Loader) loadExecOrGoPlugin(resId resid.ResId) (resmap.Configurable, error) {
|
||||
absPluginPath, err := l.AbsolutePluginPath(resId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// First try to load the plugin as an executable.
|
||||
p := execplugin.NewExecPlugin(l.absolutePluginPath(resId))
|
||||
err := p.ErrIfNotExecutable()
|
||||
if err == nil {
|
||||
p := execplugin.NewExecPlugin(absPluginPath)
|
||||
if err = p.ErrIfNotExecutable(); err == nil {
|
||||
return p, nil
|
||||
}
|
||||
if !os.IsNotExist(err) {
|
||||
@@ -193,7 +241,7 @@ func (l *Loader) loadExecOrGoPlugin(resId resid.ResId) (resmap.Configurable, err
|
||||
return nil, err
|
||||
}
|
||||
// Failing the above, try loading it as a Go plugin.
|
||||
c, err := l.loadGoPlugin(resId)
|
||||
c, err := l.loadGoPlugin(resId, absPluginPath+".so")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -208,12 +256,11 @@ func (l *Loader) loadExecOrGoPlugin(resId resid.ResId) (resmap.Configurable, err
|
||||
// as a Loader instance variable. So make it a package variable.
|
||||
var registry = make(map[string]resmap.Configurable)
|
||||
|
||||
func (l *Loader) loadGoPlugin(id resid.ResId) (resmap.Configurable, error) {
|
||||
func (l *Loader) loadGoPlugin(id resid.ResId, absPath string) (resmap.Configurable, error) {
|
||||
regId := relativePluginPath(id)
|
||||
if c, ok := registry[regId]; ok {
|
||||
return copyPlugin(c), nil
|
||||
}
|
||||
absPath := l.absolutePluginPath(id) + ".so"
|
||||
if !utils.FileExists(absPath) {
|
||||
return nil, fmt.Errorf(
|
||||
"expected file with Go object code at: %s", absPath)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
. "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
@@ -51,11 +50,11 @@ func TestLoader(t *testing.T) {
|
||||
BuildGoPlugin("someteam.example.com", "v1", "SomeServiceGenerator")
|
||||
defer th.Reset()
|
||||
p := provider.NewDefaultDepProvider()
|
||||
rmF := resmap.NewFactory(
|
||||
p.GetResourceFactory(), p.GetConflictDetectorFactory())
|
||||
rmF := resmap.NewFactory(p.GetResourceFactory())
|
||||
fsys := filesys.MakeFsInMemory()
|
||||
fLdr, err := loader.NewLoader(
|
||||
loader.RestrictionRootOnly,
|
||||
filesys.Separator, filesys.MakeFsInMemory())
|
||||
filesys.Separator, fsys)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -67,11 +66,8 @@ func TestLoader(t *testing.T) {
|
||||
for _, behavior := range []types.BuiltinPluginLoadingOptions{
|
||||
/* types.BploUseStaticallyLinked,
|
||||
types.BploLoadFromFileSys */} {
|
||||
c, err := konfig.EnabledPluginConfig(behavior)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pLdr := NewLoader(c, rmF)
|
||||
c := types.EnabledPluginConfig(behavior)
|
||||
pLdr := NewLoader(c, rmF, fsys)
|
||||
if pLdr == nil {
|
||||
t.Fatal("expect non-nil loader")
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func GoBin() string {
|
||||
// has her ${g}/${v}/$lower(${k})/${k}.go files.
|
||||
func DeterminePluginSrcRoot(fSys filesys.FileSystem) (string, error) {
|
||||
return konfig.FirstDirThatExistsElseError(
|
||||
"source directory", fSys, []konfig.NotedFunc{
|
||||
"plugin src root", fSys, []konfig.NotedFunc{
|
||||
{
|
||||
Note: "relative to unit test",
|
||||
F: func() string {
|
||||
|
||||
@@ -6,6 +6,7 @@ package target
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -377,10 +378,17 @@ func (kt *KustTarget) accumulateDirectory(
|
||||
return nil, errors.Wrapf(
|
||||
err, "couldn't make target for path '%s'", ldr.Root())
|
||||
}
|
||||
err = openapi.SetSchemaVersion(subKt.Kustomization().OpenAPI, false)
|
||||
var bytes []byte
|
||||
path := ldr.Root()
|
||||
if openApiPath, exists := subKt.Kustomization().OpenAPI["path"]; exists {
|
||||
bytes, err = ldr.Load(filepath.Join(path, openApiPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = openapi.SetSchema(subKt.Kustomization().OpenAPI, bytes, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err, "couldn't set openapi version for path '%s'", ldr.Root())
|
||||
return nil, err
|
||||
}
|
||||
if isComponent && subKt.kustomization.Kind != types.ComponentKind {
|
||||
return nil, fmt.Errorf(
|
||||
@@ -435,7 +443,10 @@ func (kt *KustTarget) configureBuiltinPlugin(
|
||||
err, "builtin %s marshal", bpt)
|
||||
}
|
||||
}
|
||||
err = p.Config(resmap.NewPluginHelpers(kt.ldr, kt.validator, kt.rFactory), y)
|
||||
err = p.Config(
|
||||
resmap.NewPluginHelpers(
|
||||
kt.ldr, kt.validator, kt.rFactory, kt.pLdr.Config()),
|
||||
y)
|
||||
if err != nil {
|
||||
return errors.Wrapf(
|
||||
err, "trouble configuring builtin %s with config: `\n%s`", bpt, string(y))
|
||||
|
||||
@@ -112,16 +112,22 @@ var generatorConfigurators = map[builtinhelpers.BuiltinPluginType]func(
|
||||
return
|
||||
},
|
||||
|
||||
builtinhelpers.HelmChartInflationGenerator: func(kt *KustTarget, bpt builtinhelpers.BuiltinPluginType, f gFactory) (
|
||||
builtinhelpers.HelmChartInflationGenerator: func(
|
||||
kt *KustTarget, bpt builtinhelpers.BuiltinPluginType, f gFactory) (
|
||||
result []resmap.Generator, err error) {
|
||||
var c struct {
|
||||
types.HelmChartArgs
|
||||
types.HelmGlobals
|
||||
types.HelmChart
|
||||
}
|
||||
for _, args := range kt.kustomization.HelmChartInflationGenerator {
|
||||
c.HelmChartArgs = args
|
||||
var globals types.HelmGlobals
|
||||
if kt.kustomization.HelmGlobals != nil {
|
||||
globals = *kt.kustomization.HelmGlobals
|
||||
}
|
||||
for _, chart := range kt.kustomization.HelmCharts {
|
||||
c.HelmGlobals = globals
|
||||
c.HelmChart = chart
|
||||
p := f()
|
||||
err := kt.configureBuiltinPlugin(p, c, bpt)
|
||||
if err != nil {
|
||||
if err = kt.configureBuiltinPlugin(p, c, bpt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, p)
|
||||
@@ -201,14 +207,16 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func(
|
||||
return
|
||||
}
|
||||
var c struct {
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
}
|
||||
for _, pc := range kt.kustomization.Patches {
|
||||
c.Target = pc.Target
|
||||
c.Patch = pc.Patch
|
||||
c.Path = pc.Path
|
||||
c.Options = pc.Options
|
||||
p := f()
|
||||
err = kt.configureBuiltinPlugin(p, c, bpt)
|
||||
if err != nil {
|
||||
@@ -221,6 +229,31 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func(
|
||||
builtinhelpers.LabelTransformer: func(
|
||||
kt *KustTarget, bpt builtinhelpers.BuiltinPluginType, f tFactory, tc *builtinconfig.TransformerConfig) (
|
||||
result []resmap.Transformer, err error) {
|
||||
for _, label := range kt.kustomization.Labels {
|
||||
var c struct {
|
||||
Labels map[string]string
|
||||
FieldSpecs []types.FieldSpec
|
||||
}
|
||||
c.Labels = label.Pairs
|
||||
fss := types.FsSlice(label.FieldSpecs)
|
||||
// merge the custom fieldSpecs with the default
|
||||
if label.IncludeSelectors {
|
||||
fss, err = fss.MergeAll(tc.CommonLabels)
|
||||
} else {
|
||||
// only add to metadata by default
|
||||
fss, err = fss.MergeOne(types.FieldSpec{Path: "metadata/labels", CreateIfNotPresent: true})
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.FieldSpecs = fss
|
||||
p := f()
|
||||
err = kt.configureBuiltinPlugin(p, c, bpt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, p)
|
||||
}
|
||||
var c struct {
|
||||
Labels map[string]string
|
||||
FieldSpecs []types.FieldSpec
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
pLdr "sigs.k8s.io/kustomize/api/internal/plugins/loader"
|
||||
"sigs.k8s.io/kustomize/api/internal/target"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
fLdr "sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
|
||||
func makeAndLoadKustTarget(
|
||||
@@ -36,12 +36,11 @@ func makeKustTargetWithRf(
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rf := resmap.NewFactory(
|
||||
pvd.GetResourceFactory(), pvd.GetConflictDetectorFactory())
|
||||
pc := konfig.DisabledPluginConfig()
|
||||
rf := resmap.NewFactory(pvd.GetResourceFactory())
|
||||
pc := types.DisabledPluginConfig()
|
||||
return target.NewKustTarget(
|
||||
ldr,
|
||||
valtest_test.MakeFakeValidator(),
|
||||
rf,
|
||||
pLdr.NewLoader(pc, rf))
|
||||
pLdr.NewLoader(pc, rf, fSys))
|
||||
}
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
package target
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
)
|
||||
|
||||
// multiTransformer contains a list of transformers.
|
||||
type multiTransformer struct {
|
||||
transformers []resmap.Transformer
|
||||
checkConflictEnabled bool
|
||||
transformers []resmap.Transformer
|
||||
}
|
||||
|
||||
var _ resmap.Transformer = &multiTransformer{}
|
||||
@@ -20,8 +17,8 @@ var _ resmap.Transformer = &multiTransformer{}
|
||||
// newMultiTransformer constructs a multiTransformer.
|
||||
func newMultiTransformer(t []resmap.Transformer) resmap.Transformer {
|
||||
r := &multiTransformer{
|
||||
transformers: make([]resmap.Transformer, len(t)),
|
||||
checkConflictEnabled: false}
|
||||
transformers: make([]resmap.Transformer, len(t)),
|
||||
}
|
||||
copy(r.transformers, t)
|
||||
return r
|
||||
}
|
||||
@@ -29,45 +26,11 @@ func newMultiTransformer(t []resmap.Transformer) resmap.Transformer {
|
||||
// Transform applies the member transformers in order to the resources,
|
||||
// optionally detecting and erroring on commutation conflict.
|
||||
func (o *multiTransformer) Transform(m resmap.ResMap) error {
|
||||
if o.checkConflictEnabled {
|
||||
return o.transformWithCheckConflict(m)
|
||||
}
|
||||
return o.transform(m)
|
||||
}
|
||||
|
||||
func (o *multiTransformer) transform(m resmap.ResMap) error {
|
||||
for _, t := range o.transformers {
|
||||
err := t.Transform(m)
|
||||
if err != nil {
|
||||
if err := t.Transform(m); err != nil {
|
||||
return err
|
||||
}
|
||||
m.DropEmpties()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Of the len(o.transformers)! possible transformer orderings, compare to a reversed order.
|
||||
// A spot check to perform when the transformations are supposed to be commutative.
|
||||
// Fail if there's a difference in the result.
|
||||
func (o *multiTransformer) transformWithCheckConflict(m resmap.ResMap) error {
|
||||
mcopy := m.DeepCopy()
|
||||
err := o.transform(m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.reverseTransformers()
|
||||
err = o.transform(mcopy)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = m.ErrorIfNotEqualSets(mcopy)
|
||||
if err != nil {
|
||||
return fmt.Errorf("found conflict between different patches\n%v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *multiTransformer) reverseTransformers() {
|
||||
for i, j := 0, len(o.transformers)-1; i < j; i, j = i+1, j-1 {
|
||||
o.transformers[i], o.transformers[j] = o.transformers[j], o.transformers[i]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// +build tools
|
||||
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// This file exists to automatically trigger installs
|
||||
// of the given tools, and is the official 'unofficial'
|
||||
// way to declare a dependence on a Go binary until
|
||||
// some better technique comes along.
|
||||
|
||||
package tools
|
||||
|
||||
import (
|
||||
// for code generation
|
||||
_ "golang.org/x/tools/cmd/stringer"
|
||||
// for lint checks
|
||||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
// REMOVED pluginator from this process, and leaving
|
||||
// this note to discourage its reintroduction,
|
||||
// because pluginator depends on the api, forcing
|
||||
// major version increments in pluginator with each
|
||||
// api release to allow this trick to work and not
|
||||
// introduce cycles.
|
||||
// _ "sigs.k8s.io/kustomize/cmd/pluginator/v2"
|
||||
)
|
||||
@@ -1,108 +0,0 @@
|
||||
// Copyright 2020 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package wrappy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/hasher"
|
||||
"sigs.k8s.io/kustomize/api/ifc"
|
||||
"sigs.k8s.io/kustomize/api/internal/generators"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
"sigs.k8s.io/kustomize/kyaml/filtersutil"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
// WNodeFactory makes instances of WNode.
|
||||
//
|
||||
// These instances in turn adapt
|
||||
// sigs.k8s.io/kustomize/kyaml/yaml.RNode
|
||||
// to implement ifc.Unstructured.
|
||||
// This factory is meant to implement ifc.KunstructuredFactory.
|
||||
//
|
||||
// This implementation should be thin, as both WNode and WNodeFactory must be
|
||||
// factored away (deleted) along with ifc.Kunstructured in favor of direct use
|
||||
// of RNode methods upon completion of
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/2506.
|
||||
//
|
||||
// See also api/krusty/internal/provider/depprovider.go
|
||||
type WNodeFactory struct {
|
||||
}
|
||||
|
||||
var _ ifc.KunstructuredFactory = (*WNodeFactory)(nil)
|
||||
|
||||
func (k *WNodeFactory) SliceFromBytes(bs []byte) ([]ifc.Kunstructured, error) {
|
||||
yamlRNodes, err := kio.FromBytes(bs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []ifc.Kunstructured
|
||||
for i := range yamlRNodes {
|
||||
rn := yamlRNodes[i]
|
||||
meta, err := rn.GetValidatedMetadata()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !shouldDropObject(meta) {
|
||||
if foundNil, path := rn.HasNilEntryInList(); foundNil {
|
||||
return nil, fmt.Errorf("empty item at %v in object %v", path, rn)
|
||||
}
|
||||
result = append(result, FromRNode(rn))
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// shouldDropObject returns true if the resource should not be accumulated.
|
||||
func shouldDropObject(m yaml.ResourceMeta) bool {
|
||||
_, y := m.ObjectMeta.Annotations[konfig.IgnoredByKustomizeAnnotation]
|
||||
return y
|
||||
}
|
||||
|
||||
func (k *WNodeFactory) FromMap(m map[string]interface{}) ifc.Kunstructured {
|
||||
rn, err := FromMap(m)
|
||||
if err != nil {
|
||||
// TODO(#WNodeFactory): handle or bubble error"
|
||||
panic(err)
|
||||
}
|
||||
return rn
|
||||
}
|
||||
|
||||
// kustHash computes a hash of an unstructured object.
|
||||
type kustHash struct{}
|
||||
|
||||
// Hash returns a hash of the given object
|
||||
func (h *kustHash) Hash(m ifc.Kunstructured) (string, error) {
|
||||
node, err := filtersutil.GetRNode(m)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hasher.HashRNode(node)
|
||||
}
|
||||
|
||||
func (k *WNodeFactory) Hasher() ifc.KunstructuredHasher {
|
||||
return &kustHash{}
|
||||
}
|
||||
|
||||
// MakeConfigMap makes a wrapped configmap.
|
||||
func (k *WNodeFactory) MakeConfigMap(
|
||||
ldr ifc.KvLoader, args *types.ConfigMapArgs) (ifc.Kunstructured, error) {
|
||||
rn, err := generators.MakeConfigMap(ldr, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return FromRNode(rn), nil
|
||||
}
|
||||
|
||||
// MakeSecret makes a wrapped secret.
|
||||
func (k *WNodeFactory) MakeSecret(
|
||||
ldr ifc.KvLoader, args *types.SecretArgs) (ifc.Kunstructured, error) {
|
||||
rn, err := generators.MakeSecret(ldr, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return FromRNode(rn), nil
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
// Copyright 2020 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package wrappy_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
. "sigs.k8s.io/kustomize/api/internal/wrappy"
|
||||
)
|
||||
|
||||
func TestHasher(t *testing.T) {
|
||||
input := `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: foo
|
||||
data:
|
||||
one: ""
|
||||
binaryData:
|
||||
two: ""
|
||||
`
|
||||
expect := "698h7c7t9m"
|
||||
|
||||
factory := &WNodeFactory{}
|
||||
k, err := factory.SliceFromBytes([]byte(input))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
hasher := factory.Hasher()
|
||||
result, err := hasher.Hash(k[0])
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result != expect {
|
||||
t.Fatalf("expect %s but got %s", expect, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSliceFromBytes(t *testing.T) {
|
||||
factory := &WNodeFactory{}
|
||||
testConfigMap :=
|
||||
map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "winnie",
|
||||
},
|
||||
}
|
||||
testConfigMapList :=
|
||||
map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMapList",
|
||||
"items": []interface{}{
|
||||
testConfigMap,
|
||||
testConfigMap,
|
||||
},
|
||||
}
|
||||
testDeploymentSpec := map[string]interface{}{
|
||||
"template": map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
"hostAliases": []interface{}{
|
||||
map[string]interface{}{
|
||||
"hostnames": []interface{}{
|
||||
"a.example.com",
|
||||
},
|
||||
"ip": "8.8.8.8",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
testDeploymentA := map[string]interface{}{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "deployment-a",
|
||||
},
|
||||
"spec": testDeploymentSpec,
|
||||
}
|
||||
testDeploymentB := map[string]interface{}{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "deployment-b",
|
||||
},
|
||||
"spec": testDeploymentSpec,
|
||||
}
|
||||
testDeploymentList :=
|
||||
map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "DeploymentList",
|
||||
"items": []interface{}{
|
||||
testDeploymentA,
|
||||
testDeploymentB,
|
||||
},
|
||||
}
|
||||
|
||||
type expected struct {
|
||||
out []map[string]interface{}
|
||||
isErr bool
|
||||
}
|
||||
|
||||
testCases := map[string]struct {
|
||||
input []byte
|
||||
exp expected
|
||||
}{
|
||||
"garbage": {
|
||||
input: []byte("garbageIn: garbageOut"),
|
||||
exp: expected{
|
||||
isErr: true,
|
||||
},
|
||||
},
|
||||
"noBytes": {
|
||||
input: []byte{},
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"goodJson": {
|
||||
input: []byte(`
|
||||
{"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"winnie"}}
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{testConfigMap},
|
||||
},
|
||||
},
|
||||
"goodYaml1": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{testConfigMap},
|
||||
},
|
||||
},
|
||||
"goodYaml2": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{testConfigMap, testConfigMap},
|
||||
},
|
||||
},
|
||||
"localConfigYaml": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie-skip
|
||||
annotations:
|
||||
# this annotation causes the Resource to be ignored by kustomize
|
||||
config.kubernetes.io/local-config: ""
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{testConfigMap},
|
||||
},
|
||||
},
|
||||
"garbageInOneOfTwoObjects": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
---
|
||||
WOOOOOOOOOOOOOOOOOOOOOOOOT: woot
|
||||
`),
|
||||
exp: expected{
|
||||
isErr: true,
|
||||
},
|
||||
},
|
||||
"emptyObjects": {
|
||||
input: []byte(`
|
||||
---
|
||||
#a comment
|
||||
|
||||
---
|
||||
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"Missing .metadata.name in object": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
annotations:
|
||||
foo: bar
|
||||
`),
|
||||
exp: expected{
|
||||
isErr: true,
|
||||
},
|
||||
},
|
||||
"nil value in list": {
|
||||
input: []byte(`
|
||||
apiVersion: builtin
|
||||
kind: ConfigMapGenerator
|
||||
metadata:
|
||||
name: kube100-site
|
||||
labels:
|
||||
app: web
|
||||
testList:
|
||||
- testA
|
||||
-
|
||||
`),
|
||||
exp: expected{
|
||||
isErr: true,
|
||||
},
|
||||
},
|
||||
"List": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: List
|
||||
items:
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{
|
||||
testConfigMap,
|
||||
testConfigMap},
|
||||
},
|
||||
},
|
||||
"ConfigMapList": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMapList
|
||||
items:
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: winnie
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{testConfigMapList},
|
||||
},
|
||||
},
|
||||
"listWithAnchors": {
|
||||
input: []byte(`
|
||||
apiVersion: v1
|
||||
kind: DeploymentList
|
||||
items:
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: deployment-a
|
||||
spec: &hostAliases
|
||||
template:
|
||||
spec:
|
||||
hostAliases:
|
||||
- hostnames:
|
||||
- a.example.com
|
||||
ip: 8.8.8.8
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: deployment-b
|
||||
spec:
|
||||
<<: *hostAliases
|
||||
`),
|
||||
exp: expected{
|
||||
out: []map[string]interface{}{testDeploymentList},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for n := range testCases {
|
||||
tc := testCases[n]
|
||||
t.Run(n, func(t *testing.T) {
|
||||
rs, err := factory.SliceFromBytes(tc.input)
|
||||
if err != nil {
|
||||
assert.True(t, tc.exp.isErr)
|
||||
return
|
||||
}
|
||||
assert.False(t, tc.exp.isErr)
|
||||
assert.Equal(t, len(tc.exp.out), len(rs))
|
||||
for i := range rs {
|
||||
assert.Equal(
|
||||
t, fmt.Sprintf("%v", tc.exp.out[i]), fmt.Sprintf("%v", rs[i].Map()))
|
||||
if n != "listWithAnchors" {
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/3271
|
||||
if !reflect.DeepEqual(tc.exp.out[i], rs[i].Map()) {
|
||||
t.Fatalf("%s:\nexpected: %v\n actual: %v",
|
||||
n, tc.exp.out[i], rs[i].Map())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
// Copyright 2020 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package wrappy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/ifc"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
// WNode implements ifc.Kunstructured using yaml.RNode.
|
||||
//
|
||||
// It exists only to help manage a switch from
|
||||
// kunstruct.UnstructAdapter to yaml.RNode as the core
|
||||
// representation of KRM objects in kustomize.
|
||||
//
|
||||
// It's got a silly name because we don't want it around for long,
|
||||
// and want its use to be obvious.
|
||||
type WNode struct {
|
||||
node *yaml.RNode
|
||||
}
|
||||
|
||||
var _ ifc.Kunstructured = (*WNode)(nil)
|
||||
|
||||
func NewWNode() *WNode {
|
||||
return FromRNode(yaml.NewRNode(nil))
|
||||
}
|
||||
|
||||
func FromMap(m map[string]interface{}) (*WNode, error) {
|
||||
n, err := yaml.FromMap(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return FromRNode(n), nil
|
||||
}
|
||||
|
||||
func FromRNode(node *yaml.RNode) *WNode {
|
||||
return &WNode{node: node}
|
||||
}
|
||||
|
||||
func (wn *WNode) AsRNode() *yaml.RNode {
|
||||
return wn.node
|
||||
}
|
||||
|
||||
func (wn *WNode) demandMetaData(label string) yaml.ResourceMeta {
|
||||
meta, err := wn.node.GetMeta()
|
||||
if err != nil {
|
||||
// Log and die since interface doesn't allow error.
|
||||
log.Fatalf("for %s', expected valid resource: %v", label, err)
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
||||
// Copy implements ifc.Kunstructured.
|
||||
func (wn *WNode) Copy() ifc.Kunstructured {
|
||||
return &WNode{node: wn.node.Copy()}
|
||||
}
|
||||
|
||||
// GetAnnotations implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetAnnotations() map[string]string {
|
||||
return wn.demandMetaData("GetAnnotations").Annotations
|
||||
}
|
||||
|
||||
// convertSliceIndex traverses the items in `fields` and find
|
||||
// if there is a slice index in the item and change it to a
|
||||
// valid Lookup field path. For example, 'ports[0]' will be
|
||||
// converted to 'ports' and '0'.
|
||||
func convertSliceIndex(fields []string) []string {
|
||||
var res []string
|
||||
for _, s := range fields {
|
||||
if !strings.HasSuffix(s, "]") {
|
||||
res = append(res, s)
|
||||
continue
|
||||
}
|
||||
re := regexp.MustCompile(`^(.*)\[(\d+)\]$`)
|
||||
groups := re.FindStringSubmatch(s)
|
||||
if len(groups) == 0 {
|
||||
// no match, add to result
|
||||
res = append(res, s)
|
||||
continue
|
||||
}
|
||||
if groups[1] != "" {
|
||||
res = append(res, groups[1])
|
||||
}
|
||||
res = append(res, groups[2])
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// GetFieldValue implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetFieldValue(path string) (interface{}, error) {
|
||||
fields := convertSliceIndex(strings.Split(path, "."))
|
||||
rn, err := wn.node.Pipe(yaml.Lookup(fields...))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if rn == nil {
|
||||
return nil, NoFieldError{path}
|
||||
}
|
||||
yn := rn.YNode()
|
||||
|
||||
// If this is an alias node, resolve it
|
||||
if yn.Kind == yaml.AliasNode {
|
||||
yn = yn.Alias
|
||||
}
|
||||
|
||||
// Return value as map for DocumentNode and MappingNode kinds
|
||||
if yn.Kind == yaml.DocumentNode || yn.Kind == yaml.MappingNode {
|
||||
var result map[string]interface{}
|
||||
if err := yn.Decode(&result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
// Return value as slice for SequenceNode kind
|
||||
if yn.Kind == yaml.SequenceNode {
|
||||
var result []interface{}
|
||||
if err := yn.Decode(&result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
if yn.Kind != yaml.ScalarNode {
|
||||
return nil, fmt.Errorf("expected ScalarNode, got Kind=%d", yn.Kind)
|
||||
}
|
||||
|
||||
// TODO: When doing kustomize var replacement, which is likely a
|
||||
// a primary use of this function and the reason it returns interface{}
|
||||
// rather than string, we do conversion from Nodes to Go types and back
|
||||
// to nodes. We should figure out how to do replacement using raw nodes,
|
||||
// assuming we keep the var feature in kustomize.
|
||||
// The other end of this is: refvar.go:updateNodeValue.
|
||||
switch yn.Tag {
|
||||
case yaml.NodeTagString:
|
||||
return yn.Value, nil
|
||||
case yaml.NodeTagInt:
|
||||
return strconv.Atoi(yn.Value)
|
||||
case yaml.NodeTagFloat:
|
||||
return strconv.ParseFloat(yn.Value, 64)
|
||||
case yaml.NodeTagBool:
|
||||
return strconv.ParseBool(yn.Value)
|
||||
default:
|
||||
// Possibly this should be an error or log.
|
||||
return yn.Value, nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetGvk implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetGvk() resid.Gvk {
|
||||
meta := wn.demandMetaData("GetGvk")
|
||||
g, v := resid.ParseGroupVersion(meta.APIVersion)
|
||||
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)
|
||||
}
|
||||
|
||||
// GetBinaryDataMap implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetBinaryDataMap() map[string]string {
|
||||
return wn.node.GetBinaryDataMap()
|
||||
}
|
||||
|
||||
// SetBinaryDataMap implements ifc.Kunstructured.
|
||||
func (wn *WNode) SetBinaryDataMap(m map[string]string) {
|
||||
wn.node.SetBinaryDataMap(m)
|
||||
}
|
||||
|
||||
// GetKind implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetKind() string {
|
||||
return wn.demandMetaData("GetKind").Kind
|
||||
}
|
||||
|
||||
// GetLabels implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetLabels() map[string]string {
|
||||
return wn.demandMetaData("GetLabels").Labels
|
||||
}
|
||||
|
||||
// GetName implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetName() string {
|
||||
return wn.demandMetaData("GetName").Name
|
||||
}
|
||||
|
||||
// GetSlice implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetSlice(path string) ([]interface{}, error) {
|
||||
value, err := wn.GetFieldValue(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if sliceValue, ok := value.([]interface{}); ok {
|
||||
return sliceValue, nil
|
||||
}
|
||||
return nil, fmt.Errorf("node %s is not a slice", path)
|
||||
}
|
||||
|
||||
// GetSlice implements ifc.Kunstructured.
|
||||
func (wn *WNode) GetString(path string) (string, error) {
|
||||
value, err := wn.GetFieldValue(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if v, ok := value.(string); ok {
|
||||
return v, nil
|
||||
}
|
||||
return "", fmt.Errorf("node %s is not a string: %v", path, value)
|
||||
}
|
||||
|
||||
// Map implements ifc.Kunstructured.
|
||||
func (wn *WNode) Map() map[string]interface{} {
|
||||
return wn.node.Map()
|
||||
}
|
||||
|
||||
// MarshalJSON implements ifc.Kunstructured.
|
||||
func (wn *WNode) MarshalJSON() ([]byte, error) {
|
||||
return wn.node.MarshalJSON()
|
||||
}
|
||||
|
||||
// MatchesAnnotationSelector implements ifc.Kunstructured.
|
||||
func (wn *WNode) MatchesAnnotationSelector(selector string) (bool, error) {
|
||||
return wn.node.MatchesAnnotationSelector(selector)
|
||||
}
|
||||
|
||||
// MatchesLabelSelector implements ifc.Kunstructured.
|
||||
func (wn *WNode) MatchesLabelSelector(selector string) (bool, error) {
|
||||
return wn.node.MatchesLabelSelector(selector)
|
||||
}
|
||||
|
||||
// SetAnnotations implements ifc.Kunstructured.
|
||||
func (wn *WNode) SetAnnotations(annotations map[string]string) {
|
||||
if err := wn.node.SetAnnotations(annotations); err != nil {
|
||||
log.Fatal(err) // interface doesn't allow error.
|
||||
}
|
||||
}
|
||||
|
||||
// SetGvk implements ifc.Kunstructured.
|
||||
func (wn *WNode) SetGvk(gvk resid.Gvk) {
|
||||
wn.setMapField(yaml.NewScalarRNode(gvk.Kind), yaml.KindField)
|
||||
wn.setMapField(yaml.NewScalarRNode(gvk.ApiVersion()), yaml.APIVersionField)
|
||||
}
|
||||
|
||||
// SetLabels implements ifc.Kunstructured.
|
||||
func (wn *WNode) SetLabels(labels map[string]string) {
|
||||
if err := wn.node.SetLabels(labels); err != nil {
|
||||
log.Fatal(err) // interface doesn't allow error.
|
||||
}
|
||||
}
|
||||
|
||||
// SetName implements ifc.Kunstructured.
|
||||
func (wn *WNode) SetName(name string) {
|
||||
wn.setMapField(yaml.NewScalarRNode(name), yaml.MetadataField, yaml.NameField)
|
||||
}
|
||||
|
||||
// SetNamespace implements ifc.Kunstructured.
|
||||
func (wn *WNode) SetNamespace(ns string) {
|
||||
if err := wn.node.SetNamespace(ns); err != nil {
|
||||
log.Fatal(err) // interface doesn't allow error.
|
||||
}
|
||||
}
|
||||
|
||||
func (wn *WNode) setMapField(value *yaml.RNode, path ...string) {
|
||||
if err := wn.node.SetMapField(value, path...); err != nil {
|
||||
// Log and die since interface doesn't allow error.
|
||||
log.Fatalf("failed to set field %v: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements ifc.Kunstructured.
|
||||
func (wn *WNode) UnmarshalJSON(data []byte) error {
|
||||
return wn.node.UnmarshalJSON(data)
|
||||
}
|
||||
|
||||
type NoFieldError struct {
|
||||
Field string
|
||||
}
|
||||
|
||||
func (e NoFieldError) Error() string {
|
||||
return fmt.Sprintf("no field named '%s'", e.Field)
|
||||
}
|
||||
@@ -1,667 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package wrappy
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
kyaml "sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
const (
|
||||
deploymentLittleJson = `{"apiVersion":"apps/v1","kind":"Deployment",` +
|
||||
`"metadata":{"name":"homer","namespace":"simpsons"}}`
|
||||
|
||||
deploymentBiggerJson = `
|
||||
{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": {
|
||||
"name": "homer",
|
||||
"namespace": "simpsons",
|
||||
"labels": {
|
||||
"fruit": "apple",
|
||||
"veggie": "carrot"
|
||||
},
|
||||
"annotations": {
|
||||
"area": "51",
|
||||
"greeting": "Take me to your leader."
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"env": [
|
||||
{
|
||||
"name": "CM_FOO",
|
||||
"valueFrom": {
|
||||
"configMapKeyRef": {
|
||||
"key": "somekey",
|
||||
"name": "myCm"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SECRET_FOO",
|
||||
"valueFrom": {
|
||||
"secretKeyRef": {
|
||||
"key": "someKey",
|
||||
"name": "mySecret"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"image": "nginx:1.7.9",
|
||||
"name": "nginx"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
bigMapYaml = `Kind: Service
|
||||
complextree:
|
||||
- field1:
|
||||
- boolfield: true
|
||||
floatsubfield: 1.01
|
||||
intsubfield: 1010
|
||||
stringsubfield: idx1010
|
||||
- boolfield: false
|
||||
floatsubfield: 1.011
|
||||
intsubfield: 1011
|
||||
stringsubfield: idx1011
|
||||
field2:
|
||||
- boolfield: true
|
||||
floatsubfield: 1.02
|
||||
intsubfield: 1020
|
||||
stringsubfield: idx1020
|
||||
- boolfield: false
|
||||
floatsubfield: 1.021
|
||||
intsubfield: 1021
|
||||
stringsubfield: idx1021
|
||||
- field1:
|
||||
- boolfield: true
|
||||
floatsubfield: 1.11
|
||||
intsubfield: 1110
|
||||
stringsubfield: idx1110
|
||||
- boolfield: false
|
||||
floatsubfield: 1.111
|
||||
intsubfield: 1111
|
||||
stringsubfield: idx1111
|
||||
field2:
|
||||
- boolfield: true
|
||||
floatsubfield: 1.112
|
||||
intsubfield: 1120
|
||||
stringsubfield: idx1120
|
||||
- boolfield: false
|
||||
floatsubfield: 1.1121
|
||||
intsubfield: 1121
|
||||
stringsubfield: idx1121
|
||||
metadata:
|
||||
labels:
|
||||
app: application-name
|
||||
name: service-name
|
||||
spec:
|
||||
ports:
|
||||
port: 80
|
||||
that:
|
||||
- idx0
|
||||
- idx1
|
||||
- idx2
|
||||
- idx3
|
||||
these:
|
||||
- field1:
|
||||
- idx010
|
||||
- idx011
|
||||
field2:
|
||||
- idx020
|
||||
- idx021
|
||||
- field1:
|
||||
- idx110
|
||||
- idx111
|
||||
field2:
|
||||
- idx120
|
||||
- idx121
|
||||
- field1:
|
||||
- idx210
|
||||
- idx211
|
||||
field2:
|
||||
- idx220
|
||||
- idx221
|
||||
this:
|
||||
is:
|
||||
aBool: true
|
||||
aFloat: 1.001
|
||||
aNilValue: null
|
||||
aNumber: 1000
|
||||
anEmptyMap: {}
|
||||
anEmptySlice: []
|
||||
those:
|
||||
- field1: idx0foo
|
||||
field2: idx0bar
|
||||
- field1: idx1foo
|
||||
field2: idx1bar
|
||||
- field1: idx2foo
|
||||
field2: idx2bar
|
||||
`
|
||||
)
|
||||
|
||||
func makeBigMap() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"Kind": "Service",
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": map[string]interface{}{
|
||||
"app": "application-name",
|
||||
},
|
||||
"name": "service-name",
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"ports": map[string]interface{}{
|
||||
"port": int64(80),
|
||||
},
|
||||
},
|
||||
"this": map[string]interface{}{
|
||||
"is": map[string]interface{}{
|
||||
"aNumber": int64(1000),
|
||||
"aFloat": float64(1.001),
|
||||
"aNilValue": nil,
|
||||
"aBool": true,
|
||||
"anEmptyMap": map[string]interface{}{},
|
||||
"anEmptySlice": []interface{}{},
|
||||
/*
|
||||
TODO: test for unrecognizable (e.g. a function)
|
||||
"unrecognizable": testing.InternalExample{
|
||||
Name: "fooBar",
|
||||
},
|
||||
*/
|
||||
},
|
||||
},
|
||||
"that": []interface{}{
|
||||
"idx0",
|
||||
"idx1",
|
||||
"idx2",
|
||||
"idx3",
|
||||
},
|
||||
"those": []interface{}{
|
||||
map[string]interface{}{
|
||||
"field1": "idx0foo",
|
||||
"field2": "idx0bar",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"field1": "idx1foo",
|
||||
"field2": "idx1bar",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"field1": "idx2foo",
|
||||
"field2": "idx2bar",
|
||||
},
|
||||
},
|
||||
"these": []interface{}{
|
||||
map[string]interface{}{
|
||||
"field1": []interface{}{"idx010", "idx011"},
|
||||
"field2": []interface{}{"idx020", "idx021"},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"field1": []interface{}{"idx110", "idx111"},
|
||||
"field2": []interface{}{"idx120", "idx121"},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"field1": []interface{}{"idx210", "idx211"},
|
||||
"field2": []interface{}{"idx220", "idx221"},
|
||||
},
|
||||
},
|
||||
"complextree": []interface{}{
|
||||
map[string]interface{}{
|
||||
"field1": []interface{}{
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1010",
|
||||
"intsubfield": int64(1010),
|
||||
"floatsubfield": float64(1.010),
|
||||
"boolfield": true,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1011",
|
||||
"intsubfield": int64(1011),
|
||||
"floatsubfield": float64(1.011),
|
||||
"boolfield": false,
|
||||
},
|
||||
},
|
||||
"field2": []interface{}{
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1020",
|
||||
"intsubfield": int64(1020),
|
||||
"floatsubfield": float64(1.020),
|
||||
"boolfield": true,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1021",
|
||||
"intsubfield": int64(1021),
|
||||
"floatsubfield": float64(1.021),
|
||||
"boolfield": false,
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"field1": []interface{}{
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1110",
|
||||
"intsubfield": int64(1110),
|
||||
"floatsubfield": float64(1.110),
|
||||
"boolfield": true,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1111",
|
||||
"intsubfield": int64(1111),
|
||||
"floatsubfield": float64(1.111),
|
||||
"boolfield": false,
|
||||
},
|
||||
},
|
||||
"field2": []interface{}{
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1120",
|
||||
"intsubfield": int64(1120),
|
||||
"floatsubfield": float64(1.1120),
|
||||
"boolfield": true,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"stringsubfield": "idx1121",
|
||||
"intsubfield": int64(1121),
|
||||
"floatsubfield": float64(1.1121),
|
||||
"boolfield": false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestBasicYamlOperationFromMap(t *testing.T) {
|
||||
bytes, err := yaml.Marshal(makeBigMap())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected yaml.Marshal err: %v", err)
|
||||
}
|
||||
if string(bytes) != bigMapYaml {
|
||||
t.Fatalf("unexpected string equality")
|
||||
}
|
||||
rNode, err := kyaml.Parse(string(bytes))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected yaml.Marshal err: %v", err)
|
||||
}
|
||||
rNodeString := rNode.MustString()
|
||||
// The result from MustString has more indentation
|
||||
// than bigMapYaml.
|
||||
rNodeStrings := strings.Split(rNodeString, "\n")
|
||||
bigMapStrings := strings.Split(bigMapYaml, "\n")
|
||||
if len(rNodeStrings) != len(bigMapStrings) {
|
||||
t.Fatalf("line count mismatch")
|
||||
}
|
||||
for i := range rNodeStrings {
|
||||
s1 := strings.TrimSpace(rNodeStrings[i])
|
||||
s2 := strings.TrimSpace(bigMapStrings[i])
|
||||
if s1 != s2 {
|
||||
t.Fatalf("expected '%s'=='%s'", s1, s2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRoundTripJSON(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
err := wn.UnmarshalJSON([]byte(deploymentLittleJson))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected UnmarshalJSON err: %v", err)
|
||||
}
|
||||
data, err := wn.MarshalJSON()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected MarshalJSON err: %v", err)
|
||||
}
|
||||
actual := string(data)
|
||||
if actual != deploymentLittleJson {
|
||||
t.Fatalf("expected %s, got %s", deploymentLittleJson, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGettingFields(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
err := wn.UnmarshalJSON([]byte(deploymentBiggerJson))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
gvk := wn.GetGvk()
|
||||
expected := "apps"
|
||||
actual := gvk.Group
|
||||
if expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
expected = "v1"
|
||||
actual = gvk.Version
|
||||
if expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
expected = "Deployment"
|
||||
actual = gvk.Kind
|
||||
if expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
actual = wn.GetKind()
|
||||
if expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
expected = "homer"
|
||||
actual = wn.GetName()
|
||||
if expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
actualMap := wn.GetLabels()
|
||||
v, ok := actualMap["fruit"]
|
||||
if !ok || v != "apple" {
|
||||
t.Fatalf("unexpected labels '%v'", actualMap)
|
||||
}
|
||||
actualMap = wn.GetAnnotations()
|
||||
v, ok = actualMap["greeting"]
|
||||
if !ok || v != "Take me to your leader." {
|
||||
t.Fatalf("unexpected annotations '%v'", actualMap)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFieldValueReturnsMap(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
expected := map[string]interface{}{
|
||||
"fruit": "apple",
|
||||
"veggie": "carrot",
|
||||
}
|
||||
actual, err := wn.GetFieldValue("metadata.labels")
|
||||
if err != nil {
|
||||
t.Fatalf("error getting field value: %v", err)
|
||||
}
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
t.Fatalf("actual map does not deep equal expected map:\n%v", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFieldValueReturnsStuff(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
expected := []interface{}{
|
||||
map[string]interface{}{
|
||||
"env": []interface{}{
|
||||
map[string]interface{}{
|
||||
"name": "CM_FOO",
|
||||
"valueFrom": map[string]interface{}{
|
||||
"configMapKeyRef": map[string]interface{}{
|
||||
"key": "somekey",
|
||||
"name": "myCm",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"name": "SECRET_FOO",
|
||||
"valueFrom": map[string]interface{}{
|
||||
"secretKeyRef": map[string]interface{}{
|
||||
"key": "someKey",
|
||||
"name": "mySecret",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"image": string("nginx:1.7.9"),
|
||||
"name": string("nginx"),
|
||||
},
|
||||
}
|
||||
actual, err := wn.GetFieldValue("spec.template.spec.containers")
|
||||
if err != nil {
|
||||
t.Fatalf("error getting field value: %v", err)
|
||||
}
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
t.Fatalf("actual map does not deep equal expected map:\n%v", diff)
|
||||
}
|
||||
// Cannot go deeper yet.
|
||||
_, err = wn.GetFieldValue("spec.template.spec.containers.env")
|
||||
if err == nil {
|
||||
t.Fatalf("expected err %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFieldValueReturnsSlice(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{}{"idx0", "idx1", "idx2", "idx3"}
|
||||
actual, err := wn.GetFieldValue("that")
|
||||
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 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) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
actual, err := wn.GetFieldValue("metadata.labels.fruit")
|
||||
if err != nil {
|
||||
t.Fatalf("error getting field value: %v", err)
|
||||
}
|
||||
v, ok := actual.(string)
|
||||
if !ok || v != "apple" {
|
||||
t.Fatalf("unexpected value '%v'", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFieldValueResolvesAlias(t *testing.T) {
|
||||
yamlWithAlias := `
|
||||
foo: &a theValue
|
||||
bar: *a
|
||||
`
|
||||
rNode, err := kyaml.Parse(yamlWithAlias)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected yaml parse error: %v", err)
|
||||
}
|
||||
wn := FromRNode(rNode)
|
||||
actual, err := wn.GetFieldValue("bar")
|
||||
if err != nil {
|
||||
t.Fatalf("error getting field value: %v", err)
|
||||
}
|
||||
v, ok := actual.(string)
|
||||
if !ok || v != "theValue" {
|
||||
t.Fatalf("unexpected value '%v'", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetString(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
expected := "carrot"
|
||||
actual, err := wn.GetString("metadata.labels.veggie")
|
||||
if err != nil {
|
||||
t.Fatalf("error getting string: %v", err)
|
||||
}
|
||||
if expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSlice(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{}{"idx0", "idx1", "idx2", "idx3"}
|
||||
actual, err := wn.GetSlice("that")
|
||||
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 TestMapEmpty(t *testing.T) {
|
||||
assert.Equal(t, 0, len(NewWNode().Map()))
|
||||
}
|
||||
|
||||
func TestMap(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentLittleJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "homer",
|
||||
"namespace": "simpsons",
|
||||
},
|
||||
}
|
||||
|
||||
actual := wn.Map()
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
t.Fatalf("actual map does not deep equal expected map:\n%v", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetName(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
wn.SetName("marge")
|
||||
if expected, actual := "marge", wn.GetName(); expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetNamespace(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
wn.SetNamespace("flanders")
|
||||
meta, _ := wn.node.GetMeta()
|
||||
if expected, actual := "flanders", meta.Namespace; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetLabels(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
wn.SetLabels(map[string]string{
|
||||
"label1": "foo",
|
||||
"label2": "bar",
|
||||
})
|
||||
labels := wn.GetLabels()
|
||||
if expected, actual := 2, len(labels); expected != actual {
|
||||
t.Fatalf("expected '%d', got '%d'", expected, actual)
|
||||
}
|
||||
if expected, actual := "foo", labels["label1"]; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
if expected, actual := "bar", labels["label2"]; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAnnotations(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
wn.SetAnnotations(map[string]string{
|
||||
"annotation1": "foo",
|
||||
"annotation2": "bar",
|
||||
})
|
||||
annotations := wn.GetAnnotations()
|
||||
if expected, actual := 2, len(annotations); expected != actual {
|
||||
t.Fatalf("expected '%d', got '%d'", expected, actual)
|
||||
}
|
||||
if expected, actual := "foo", annotations["annotation1"]; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
if expected, actual := "bar", annotations["annotation2"]; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetGvk(t *testing.T) {
|
||||
wn := NewWNode()
|
||||
if err := wn.UnmarshalJSON([]byte(deploymentBiggerJson)); err != nil {
|
||||
t.Fatalf("unexpected unmarshaljson err: %v", err)
|
||||
}
|
||||
wn.SetGvk(resid.GvkFromString("grp_ver_knd"))
|
||||
gvk := wn.GetGvk()
|
||||
if expected, actual := "grp", gvk.Group; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
if expected, actual := "ver", gvk.Version; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
if expected, actual := "knd", gvk.Kind; expected != actual {
|
||||
t.Fatalf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,8 @@ nameReference:
|
||||
- path: spec/volumes/projected/sources/configMap/name
|
||||
version: v1
|
||||
kind: Pod
|
||||
- path: template/spec/volumes/configMap/name
|
||||
kind: PodTemplate
|
||||
- path: spec/template/spec/volumes/configMap/name
|
||||
kind: Deployment
|
||||
- path: spec/template/spec/containers/env/valueFrom/configMapKeyRef/name
|
||||
@@ -128,6 +130,8 @@ nameReference:
|
||||
kind: Role
|
||||
- path: rules/resourceNames
|
||||
kind: ClusterRole
|
||||
- path: metadata/annotations/nginx.ingress.kubernetes.io\/fastcgi-params-configmap
|
||||
kind: Ingress
|
||||
|
||||
- kind: Secret
|
||||
version: v1
|
||||
|
||||
@@ -19,5 +19,8 @@ namespace:
|
||||
group: apiregistration.k8s.io
|
||||
kind: APIService
|
||||
create: true
|
||||
- path: spec/conversion/webhook/clientConfig/service/namespace
|
||||
group: apiextensions.k8s.io
|
||||
kind: CustomResourceDefinition
|
||||
`
|
||||
)
|
||||
|
||||
@@ -19,31 +19,7 @@ func DefaultKustomizationFileName() string {
|
||||
return RecognizedKustomizationFileNames()[0]
|
||||
}
|
||||
|
||||
// IfApiMachineryElseKyaml returns true if executing the apimachinery code
|
||||
// path, else we're executing the kyaml code paths.
|
||||
func IfApiMachineryElseKyaml(s1, s2 string) string {
|
||||
if !FlagEnableKyamlDefaultValue {
|
||||
return s1
|
||||
}
|
||||
return s2
|
||||
}
|
||||
|
||||
const (
|
||||
// FlagEnableKyamlDefaultValue is the default value for the --enable_kyaml
|
||||
// flag. This value is also used in unit tests. See provider.DepProvider.
|
||||
//
|
||||
// TODO(#3588): Delete this constant.
|
||||
//
|
||||
// All tests should pass for either true or false values
|
||||
// of this constant, without having to check its value.
|
||||
// In the cases where there's a different outcome, either decide
|
||||
// that the difference is acceptable, or make the difference go away.
|
||||
//
|
||||
// Historically, tests passed for enable_kyaml == false, i.e. using
|
||||
// apimachinery libs. This doesn't mean the code was better, it just
|
||||
// means regression tests preserved those outcomes.
|
||||
FlagEnableKyamlDefaultValue = true
|
||||
|
||||
// An environment variable to consult for kustomization
|
||||
// configuration data. See:
|
||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
|
||||
@@ -41,32 +41,6 @@ const (
|
||||
NoPluginHomeSentinal = "/No/non-builtin/plugins!"
|
||||
)
|
||||
|
||||
func EnabledPluginConfig(b types.BuiltinPluginLoadingOptions) (*types.PluginConfig, error) {
|
||||
dir, err := DefaultAbsPluginHome(filesys.MakeFsOnDisk())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return MakePluginConfig(types.PluginRestrictionsNone, b, dir), nil
|
||||
}
|
||||
|
||||
func DisabledPluginConfig() *types.PluginConfig {
|
||||
return MakePluginConfig(
|
||||
types.PluginRestrictionsBuiltinsOnly,
|
||||
types.BploUseStaticallyLinked,
|
||||
NoPluginHomeSentinal)
|
||||
}
|
||||
|
||||
func MakePluginConfig(
|
||||
pr types.PluginRestrictions,
|
||||
b types.BuiltinPluginLoadingOptions,
|
||||
home string) *types.PluginConfig {
|
||||
return &types.PluginConfig{
|
||||
PluginRestrictions: pr,
|
||||
AbsPluginHome: home,
|
||||
BpLoadingOptions: b,
|
||||
}
|
||||
}
|
||||
|
||||
type NotedFunc struct {
|
||||
Note string
|
||||
F func() string
|
||||
@@ -77,7 +51,7 @@ type NotedFunc struct {
|
||||
// the home of kustomize plugins.
|
||||
func DefaultAbsPluginHome(fSys filesys.FileSystem) (string, error) {
|
||||
return FirstDirThatExistsElseError(
|
||||
"plugin home directory", fSys, []NotedFunc{
|
||||
"plugin root", fSys, []NotedFunc{
|
||||
{
|
||||
Note: "homed in $" + KustomizePluginHomeEnv,
|
||||
F: func() string {
|
||||
@@ -87,9 +61,11 @@ func DefaultAbsPluginHome(fSys filesys.FileSystem) (string, error) {
|
||||
{
|
||||
Note: "homed in $" + XdgConfigHomeEnv,
|
||||
F: func() string {
|
||||
return filepath.Join(
|
||||
os.Getenv(XdgConfigHomeEnv),
|
||||
ProgramName, RelPluginHome)
|
||||
if root := os.Getenv(XdgConfigHomeEnv); root != "" {
|
||||
return filepath.Join(root, ProgramName, RelPluginHome)
|
||||
}
|
||||
// do not look in "kustomize/plugin" if XdgConfigHomeEnv is unset
|
||||
return ""
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -118,11 +94,14 @@ func FirstDirThatExistsElseError(
|
||||
pathFuncs []NotedFunc) (string, error) {
|
||||
var nope []types.Pair
|
||||
for _, dt := range pathFuncs {
|
||||
dir := dt.F()
|
||||
if fSys.Exists(dir) {
|
||||
return dir, nil
|
||||
if dir := dt.F(); dir != "" {
|
||||
if fSys.Exists(dir) {
|
||||
return dir, nil
|
||||
}
|
||||
nope = append(nope, types.Pair{Key: dt.Note, Value: dir})
|
||||
} else {
|
||||
nope = append(nope, types.Pair{Key: dt.Note, Value: "<no value>"})
|
||||
}
|
||||
nope = append(nope, types.Pair{Key: dt.Note, Value: dir})
|
||||
}
|
||||
return "", types.NewErrUnableToFind(what, nope)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
@@ -28,6 +30,34 @@ func TestDefaultAbsPluginHome_NoKustomizePluginHomeEnv(t *testing.T) {
|
||||
if !types.IsErrUnableToFind(err) {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
for _, expectedMsg := range []string{
|
||||
"unable to find plugin root - tried:",
|
||||
"('<no value>'; homed in $KUSTOMIZE_PLUGIN_HOME)",
|
||||
"; homed in $XDG_CONFIG_HOME)",
|
||||
"/.config/kustomize/plugin'; homed in default value of $XDG_CONFIG_HOME)",
|
||||
"/kustomize/plugin'; homed in home directory)",
|
||||
} {
|
||||
assert.Contains(t, err.Error(), expectedMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultAbsPluginHome_EmptyKustomizePluginHomeEnv(t *testing.T) {
|
||||
keep, isSet := os.LookupEnv(KustomizePluginHomeEnv)
|
||||
os.Setenv(KustomizePluginHomeEnv, "")
|
||||
|
||||
_, err := DefaultAbsPluginHome(filesys.MakeFsInMemory())
|
||||
if !isSet {
|
||||
_ = os.Unsetenv(KustomizePluginHomeEnv)
|
||||
} else {
|
||||
_ = os.Setenv(KustomizePluginHomeEnv, keep)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatalf("expected err")
|
||||
}
|
||||
if !types.IsErrUnableToFind(err) {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
assert.Contains(t, err.Error(), "('<no value>'; homed in $KUSTOMIZE_PLUGIN_HOME)")
|
||||
}
|
||||
|
||||
func TestDefaultAbsPluginHome_WithKustomizePluginHomeEnv(t *testing.T) {
|
||||
@@ -89,6 +119,25 @@ func TestDefaultAbsPluginHomeNoConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultAbsPluginHomeEmptyXdgConfig(t *testing.T) {
|
||||
keep, isSet := os.LookupEnv(XdgConfigHomeEnv)
|
||||
os.Setenv(XdgConfigHomeEnv, "")
|
||||
if isSet {
|
||||
_ = os.Unsetenv(XdgConfigHomeEnv)
|
||||
}
|
||||
_, err := DefaultAbsPluginHome(filesys.MakeFsInMemory())
|
||||
if isSet {
|
||||
os.Setenv(XdgConfigHomeEnv, keep)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatalf("expected err")
|
||||
}
|
||||
if !types.IsErrUnableToFind(err) {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
assert.Contains(t, err.Error(), "('<no value>'; homed in $XDG_CONFIG_HOME)")
|
||||
}
|
||||
|
||||
func TestDefaultAbsPluginHomeNoXdgWithDotConfig(t *testing.T) {
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
configDir := filepath.Join(
|
||||
|
||||
@@ -15,19 +15,19 @@ import (
|
||||
|
||||
func TestTargetMustHaveKustomizationFile(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/service.yaml", `
|
||||
th.WriteF("service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: aService
|
||||
`)
|
||||
th.WriteF("/app/deeper/service.yaml", `
|
||||
th.WriteF("deeper/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: anotherService
|
||||
`)
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error")
|
||||
}
|
||||
@@ -39,27 +39,27 @@ metadata:
|
||||
func TestTargetMustHaveOnlyOneKustomizationFile(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
for _, n := range konfig.RecognizedKustomizationFileNames() {
|
||||
th.WriteF(filepath.Join("/app", n), `
|
||||
th.WriteF(filepath.Join(".", n), `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
`)
|
||||
}
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "Found multiple kustomization files under: /app") {
|
||||
if !strings.Contains(err.Error(), "Found multiple kustomization files") {
|
||||
t.Fatalf("unexpected error: %q", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBaseMustHaveKustomizationFile(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- base
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -70,7 +70,7 @@ spec:
|
||||
ports:
|
||||
- port: 7002
|
||||
`)
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error")
|
||||
}
|
||||
@@ -81,11 +81,11 @@ spec:
|
||||
|
||||
func TestResourceNotFound(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error")
|
||||
}
|
||||
@@ -96,11 +96,11 @@ resources:
|
||||
|
||||
func TestResourceHasAnchor(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- ingress.yaml
|
||||
`)
|
||||
th.WriteF("/app/ingress.yaml", `
|
||||
th.WriteF("ingress.yaml", `
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
@@ -125,7 +125,7 @@ spec:
|
||||
- host: www.xyz.me
|
||||
http: *xxx_rules
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func writeMediumBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namePrefix: baseprefix-
|
||||
commonLabels:
|
||||
foo: bar
|
||||
@@ -20,7 +20,7 @@ resources:
|
||||
- deployment/deployment.yaml
|
||||
- service/service.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/service/service.yaml", `
|
||||
th.WriteF("base/service/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -33,7 +33,7 @@ spec:
|
||||
selector:
|
||||
app: mungebot
|
||||
`)
|
||||
th.WriteF("/app/base/deployment/deployment.yaml", `
|
||||
th.WriteF("base/deployment/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -61,7 +61,7 @@ spec:
|
||||
func TestMediumBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeMediumBase(th)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -115,7 +115,7 @@ spec:
|
||||
func TestMediumOverlay(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeMediumBase(th)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
namePrefix: test-infra-
|
||||
commonLabels:
|
||||
app: mungebot
|
||||
@@ -140,24 +140,24 @@ images:
|
||||
- name: nginx
|
||||
newTag: 1.8.0`)
|
||||
|
||||
th.WriteF("/app/overlay/configmap/db.env", `
|
||||
th.WriteF("overlay/configmap/db.env", `
|
||||
DB_USERNAME=admin
|
||||
DB_PASSWORD=somepw
|
||||
`)
|
||||
th.WriteF("/app/overlay/configmap/units.ini", `
|
||||
th.WriteF("overlay/configmap/units.ini", `
|
||||
LENGTH=kilometer
|
||||
ENERGY=electronvolt
|
||||
`)
|
||||
th.WriteF("/app/overlay/configmap/food.ini", `
|
||||
th.WriteF("overlay/configmap/food.ini", `
|
||||
FRUIT=banana
|
||||
LEGUME=chickpea
|
||||
`)
|
||||
th.WriteF("/app/overlay/configmap/dummy.txt",
|
||||
th.WriteF("overlay/configmap/dummy.txt",
|
||||
`Lorem ipsum dolor sit amet, consectetur
|
||||
adipiscing elit, sed do eiusmod tempor
|
||||
incididunt ut labore et dolore magna aliqua.
|
||||
`)
|
||||
th.WriteF("/app/overlay/deployment/deployment.yaml", `
|
||||
th.WriteF("overlay/deployment/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -190,7 +190,7 @@ spec:
|
||||
name: app-env
|
||||
name: app-env
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -292,7 +292,8 @@ metadata:
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod tempor\nincididunt ut labore et dolore magna aliqua. \n"
|
||||
nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod
|
||||
tempor\nincididunt ut labore et dolore magna aliqua. \n"
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
func TestOrderPreserved(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namePrefix: b-
|
||||
resources:
|
||||
- namespace.yaml
|
||||
@@ -22,50 +22,50 @@ resources:
|
||||
- service.yaml
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: myService
|
||||
`)
|
||||
th.WriteF("/app/base/namespace.yaml", `
|
||||
th.WriteF("base/namespace.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: myNs
|
||||
`)
|
||||
th.WriteF("/app/base/role.yaml", `
|
||||
th.WriteF("base/role.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: myRole
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDep
|
||||
`)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
namePrefix: p-
|
||||
resources:
|
||||
- ../base
|
||||
- service.yaml
|
||||
- namespace.yaml
|
||||
`)
|
||||
th.WriteF("/app/prod/service.yaml", `
|
||||
th.WriteF("prod/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: myService2
|
||||
`)
|
||||
th.WriteF("/app/prod/namespace.yaml", `
|
||||
th.WriteF("prod/namespace.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: myNs2
|
||||
`)
|
||||
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
||||
m := th.Run("prod", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
@@ -101,17 +101,17 @@ metadata:
|
||||
|
||||
func TestBaseInResourceList(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
namePrefix: b-
|
||||
resources:
|
||||
- ../base
|
||||
`)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namePrefix: a-
|
||||
resources:
|
||||
- service.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -120,7 +120,7 @@ spec:
|
||||
selector:
|
||||
backend: bungie
|
||||
`)
|
||||
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
||||
m := th.Run("prod", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@@ -181,7 +181,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeSmallBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namePrefix: a-
|
||||
commonLabels:
|
||||
app: myApp
|
||||
@@ -189,7 +189,7 @@ resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -200,7 +200,7 @@ spec:
|
||||
ports:
|
||||
- port: 7002
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -220,7 +220,7 @@ spec:
|
||||
func TestSmallBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeSmallBase(th)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -260,7 +260,7 @@ spec:
|
||||
func TestSmallOverlay(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeSmallBase(th)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
namePrefix: b-
|
||||
commonLabels:
|
||||
env: prod
|
||||
@@ -275,15 +275,15 @@ images:
|
||||
newTag: 1.8.0
|
||||
`)
|
||||
|
||||
th.WriteF("/app/overlay/configmap/app.env", `
|
||||
th.WriteF("overlay/configmap/app.env", `
|
||||
DB_USERNAME=admin
|
||||
DB_PASSWORD=somepw
|
||||
`)
|
||||
th.WriteF("/app/overlay/configmap/app-init.ini", `
|
||||
th.WriteF("overlay/configmap/app-init.ini", `
|
||||
FOO=bar
|
||||
BAR=baz
|
||||
`)
|
||||
th.WriteF("/app/overlay/deployment/deployment.yaml", `
|
||||
th.WriteF("overlay/deployment/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -291,7 +291,7 @@ metadata:
|
||||
spec:
|
||||
replicas: 1000
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -347,7 +347,7 @@ spec:
|
||||
func TestSharedPatchDisAllowed(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeSmallBase(th)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
commonLabels:
|
||||
env: prod
|
||||
resources:
|
||||
@@ -355,7 +355,7 @@ resources:
|
||||
patchesStrategicMerge:
|
||||
- ../shared/deployment-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/shared/deployment-patch.yaml", `
|
||||
th.WriteF("shared/deployment-patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -363,14 +363,14 @@ metadata:
|
||||
spec:
|
||||
replicas: 1000
|
||||
`)
|
||||
err := th.RunWithErr("/app/overlay", func() Options {
|
||||
err := th.RunWithErr("overlay", func() Options {
|
||||
o := th.MakeDefaultOptions()
|
||||
o.LoadRestrictions = types.LoadRestrictionsRootOnly
|
||||
return o
|
||||
}())
|
||||
if !strings.Contains(
|
||||
err.Error(),
|
||||
"security; file '/app/shared/deployment-patch.yaml' is not in or below '/app/overlay'") {
|
||||
"security; file '/shared/deployment-patch.yaml' is not in or below '/overlay'") {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
}
|
||||
@@ -378,7 +378,7 @@ spec:
|
||||
func TestSharedPatchAllowed(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeSmallBase(th)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
commonLabels:
|
||||
env: prod
|
||||
resources:
|
||||
@@ -386,7 +386,7 @@ resources:
|
||||
patchesStrategicMerge:
|
||||
- ../shared/deployment-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/shared/deployment-patch.yaml", `
|
||||
th.WriteF("shared/deployment-patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -394,7 +394,7 @@ metadata:
|
||||
spec:
|
||||
replicas: 1000
|
||||
`)
|
||||
m := th.Run("/app/overlay", func() Options {
|
||||
m := th.Run("overlay", func() Options {
|
||||
o := th.MakeDefaultOptions()
|
||||
o.LoadRestrictions = types.LoadRestrictionsNone
|
||||
return o
|
||||
@@ -444,7 +444,7 @@ spec:
|
||||
func TestSmallOverlayJSONPatch(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeSmallBase(th)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesJson6902:
|
||||
@@ -455,12 +455,12 @@ patchesJson6902:
|
||||
path: service-patch.yaml
|
||||
`)
|
||||
|
||||
th.WriteF("/app/overlay/service-patch.yaml", `
|
||||
th.WriteF("overlay/service-patch.yaml", `
|
||||
- op: add
|
||||
path: /spec/selector/backend
|
||||
value: beagle
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -41,37 +41,37 @@ import (
|
||||
|
||||
func TestBaseReuseNameConflict(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/component1/base", `
|
||||
th.WriteK("component1/base", `
|
||||
resources:
|
||||
- ../../shared
|
||||
|
||||
namePrefix: component1-
|
||||
`)
|
||||
th.WriteK("/app/component1/overlay", `
|
||||
th.WriteK("component1/overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
namePrefix: overlay-
|
||||
`)
|
||||
|
||||
th.WriteK("/app/component2/base", `
|
||||
th.WriteK("component2/base", `
|
||||
resources:
|
||||
- ../../shared
|
||||
|
||||
namePrefix: component2-
|
||||
`)
|
||||
th.WriteK("/app/component2/overlay", `
|
||||
th.WriteK("component2/overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
namePrefix: overlay-
|
||||
`)
|
||||
|
||||
th.WriteK("/app/shared", `
|
||||
th.WriteK("shared", `
|
||||
resources:
|
||||
- resources.yaml
|
||||
`)
|
||||
th.WriteF("/app/shared/resources.yaml", `
|
||||
th.WriteF("shared/resources.yaml", `
|
||||
---
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
@@ -111,13 +111,13 @@ spec:
|
||||
claimName: postgres
|
||||
`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- component1/overlay
|
||||
- component2/overlay
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
|
||||
@@ -11,26 +11,6 @@ import (
|
||||
|
||||
func TestBasicIO_1(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
opts := th.MakeDefaultOptions()
|
||||
if !opts.UseKyaml {
|
||||
// This test won't pass under apimachinery, because in the bowels of
|
||||
// that code (see GetAnnotations in v0.17.0 of
|
||||
// k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go)
|
||||
// an error returned from NestedStringMap is discarded, and an
|
||||
// empty annotation map is silently returned, making this test fail
|
||||
// The swallowed error arises from code like:
|
||||
// var v interface{}
|
||||
// v = true
|
||||
// if str, ok := v.(string); ok {
|
||||
// save the value in a map (doesn't happen)
|
||||
// } else {
|
||||
// return an error (that is then ignored by GetAnnotations)
|
||||
// }
|
||||
// The error happens when any annotation value can be interpreted as
|
||||
// a boolean or number. Such annotations cannot be successfully applied
|
||||
// to an object in a cluster unless they are quoted.
|
||||
t.SkipNow()
|
||||
}
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- service.yaml
|
||||
@@ -47,7 +27,7 @@ metadata:
|
||||
spec:
|
||||
clusterIP: None
|
||||
`)
|
||||
m := th.Run(".", opts)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
// The annotations are sorted by key, hence the order change.
|
||||
// Quotes are added intentionally.
|
||||
th.AssertActualEqualsExpected(
|
||||
|
||||
@@ -32,13 +32,13 @@ func TestChartInflatorPlugin(t *testing.T) {
|
||||
PrepExecPlugin("someteam.example.com", "v1", "ChartInflator")
|
||||
defer th.Reset()
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
generators:
|
||||
- chartInflator.yaml
|
||||
namePrefix: LOOOOOOOONG-
|
||||
`)
|
||||
|
||||
th.WriteF("/app/chartInflator.yaml", `
|
||||
th.WriteF("./chartInflator.yaml", `
|
||||
apiVersion: someteam.example.com/v1
|
||||
kind: ChartInflator
|
||||
metadata:
|
||||
@@ -46,7 +46,7 @@ metadata:
|
||||
chartName: minecraft
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeOptionsPluginsEnabled())
|
||||
m := th.Run(".", th.MakeOptionsPluginsEnabled())
|
||||
chartName := regexp.MustCompile("chart: minecraft-[0-9.]+")
|
||||
th.AssertActualEqualsExpectedWithTweak(m,
|
||||
func(x []byte) []byte {
|
||||
|
||||
@@ -27,11 +27,11 @@ spec:
|
||||
`
|
||||
|
||||
func writeStatefulSetBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- statefulset.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/statefulset.yaml", `
|
||||
th.WriteF("base/statefulset.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
@@ -56,15 +56,15 @@ spec:
|
||||
}
|
||||
|
||||
func writeHTTPSOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/https", `
|
||||
th.WriteK("https", `
|
||||
resources:
|
||||
- ../base
|
||||
- https-svc.yaml
|
||||
patchesStrategicMerge:
|
||||
- sts-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/https/https-svc.yaml", httpsService)
|
||||
th.WriteF("/app/https/sts-patch.yaml", `
|
||||
th.WriteF("https/https-svc.yaml", httpsService)
|
||||
th.WriteF("https/sts-patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
@@ -75,8 +75,8 @@ spec:
|
||||
}
|
||||
|
||||
func writeHTTPSTransformerRaw(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/https/service/https-svc.yaml", httpsService)
|
||||
th.WriteF("/app/https/transformer/transformer.yaml", `
|
||||
th.WriteF("https/service/https-svc.yaml", httpsService)
|
||||
th.WriteF("https/transformer/transformer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PatchTransformer
|
||||
metadata:
|
||||
@@ -97,11 +97,11 @@ patch: |-
|
||||
}
|
||||
|
||||
func writeHTTPSTransformerBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/https/service", `
|
||||
th.WriteK("https/service", `
|
||||
resources:
|
||||
- https-svc.yaml
|
||||
`)
|
||||
th.WriteK("/app/https/transformer", `
|
||||
th.WriteK("https/transformer", `
|
||||
resources:
|
||||
- transformer.yaml
|
||||
`)
|
||||
@@ -109,7 +109,7 @@ resources:
|
||||
}
|
||||
|
||||
func writeConfigFromEnvOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/config", `
|
||||
th.WriteK("config", `
|
||||
resources:
|
||||
- ../base
|
||||
configMapGenerator:
|
||||
@@ -121,7 +121,7 @@ generatorOptions:
|
||||
patchesStrategicMerge:
|
||||
- sts-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/config/sts-patch.yaml", `
|
||||
th.WriteF("config/sts-patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
@@ -138,7 +138,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeConfigFromEnvTransformerRaw(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/config/map/generator.yaml", `
|
||||
th.WriteF("config/map/generator.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: ConfigMapGenerator
|
||||
metadata:
|
||||
@@ -148,7 +148,7 @@ options:
|
||||
literals:
|
||||
- MY_ENV=foo
|
||||
`)
|
||||
th.WriteF("/app/config/transformer/transformer.yaml", `
|
||||
th.WriteF("config/transformer/transformer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PatchTransformer
|
||||
metadata:
|
||||
@@ -174,11 +174,11 @@ patch: |-
|
||||
`)
|
||||
}
|
||||
func writeConfigFromEnvTransformerBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/config/map", `
|
||||
th.WriteK("config/map", `
|
||||
resources:
|
||||
- generator.yaml
|
||||
`)
|
||||
th.WriteK("/app/config/transformer", `
|
||||
th.WriteK("config/transformer", `
|
||||
resources:
|
||||
- transformer.yaml
|
||||
`)
|
||||
@@ -186,13 +186,13 @@ resources:
|
||||
}
|
||||
|
||||
func writeTolerationsOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/tolerations", `
|
||||
th.WriteK("tolerations", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- sts-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/tolerations/sts-patch.yaml", `
|
||||
th.WriteF("tolerations/sts-patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
@@ -208,7 +208,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeTolerationsTransformerRaw(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/tolerations/transformer.yaml", `
|
||||
th.WriteF("tolerations/transformer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PatchTransformer
|
||||
metadata:
|
||||
@@ -234,7 +234,7 @@ patch: |-
|
||||
}
|
||||
|
||||
func writeTolerationsTransformerBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/tolerations", `
|
||||
th.WriteK("tolerations", `
|
||||
resources:
|
||||
- transformer.yaml
|
||||
`)
|
||||
@@ -242,7 +242,7 @@ resources:
|
||||
}
|
||||
|
||||
func writeStorageOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/storage", `
|
||||
th.WriteK("storage", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesJson6902:
|
||||
@@ -253,13 +253,13 @@ patchesJson6902:
|
||||
name: my-sts
|
||||
path: sts-patch.json
|
||||
`)
|
||||
th.WriteF("/app/storage/sts-patch.json", `
|
||||
th.WriteF("storage/sts-patch.json", `
|
||||
[{"op": "replace", "path": "/spec/volumeClaimTemplates/0/spec/storageClassName", "value": "my-sc"}]
|
||||
`)
|
||||
}
|
||||
|
||||
func writeStorageTransformerRaw(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/storage/transformer.yaml", `
|
||||
th.WriteF("storage/transformer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PatchTransformer
|
||||
metadata:
|
||||
@@ -275,7 +275,7 @@ patch: |-
|
||||
}
|
||||
|
||||
func writeStorageTransformerBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/storage", `
|
||||
th.WriteK("storage", `
|
||||
resources:
|
||||
- transformer.yaml
|
||||
`)
|
||||
@@ -358,12 +358,12 @@ func TestComplexComposition_Dev_Failure(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeStatefulSetBase(th)
|
||||
writePatchingOverlays(th)
|
||||
th.WriteK("/app/dev", `
|
||||
th.WriteK("dev", `
|
||||
resources:
|
||||
- ../storage
|
||||
- ../config
|
||||
`)
|
||||
err := th.RunWithErr("/app/dev", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("dev", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("Expected resource accumulation error")
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func TestComplexComposition_Dev_SuccessWithRawTransformers(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeStatefulSetBase(th)
|
||||
writePatchingTransformersRaw(th)
|
||||
th.WriteK("/app/dev", `
|
||||
th.WriteK("dev", `
|
||||
resources:
|
||||
- ../base
|
||||
generators:
|
||||
@@ -419,7 +419,7 @@ transformers:
|
||||
- ../config/transformer/transformer.yaml
|
||||
- ../storage/transformer.yaml
|
||||
`)
|
||||
m := th.Run("/app/dev", func() Options {
|
||||
m := th.Run("dev", func() Options {
|
||||
o := th.MakeDefaultOptions()
|
||||
o.LoadRestrictions = types.LoadRestrictionsNone
|
||||
return o
|
||||
@@ -431,7 +431,7 @@ func TestComplexComposition_Dev_SuccessWithBaseTransformers(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeStatefulSetBase(th)
|
||||
writePatchingTransformerBases(th)
|
||||
th.WriteK("/app/dev", `
|
||||
th.WriteK("dev", `
|
||||
resources:
|
||||
- ../base
|
||||
generators:
|
||||
@@ -440,7 +440,7 @@ transformers:
|
||||
- ../config/transformer
|
||||
- ../storage
|
||||
`)
|
||||
m := th.Run("/app/dev", th.MakeDefaultOptions())
|
||||
m := th.Run("dev", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, devDesiredResult)
|
||||
}
|
||||
|
||||
@@ -448,13 +448,13 @@ func TestComplexComposition_Prod_Failure(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeStatefulSetBase(th)
|
||||
writePatchingOverlays(th)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../config
|
||||
- ../tolerations
|
||||
- ../https
|
||||
`)
|
||||
err := th.RunWithErr("/app/prod", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("prod", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("Expected resource accumulation error")
|
||||
}
|
||||
@@ -517,7 +517,7 @@ func TestComplexComposition_Prod_SuccessWithRawTransformers(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeStatefulSetBase(th)
|
||||
writePatchingTransformersRaw(th)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
- ../https/service/https-svc.yaml
|
||||
@@ -528,7 +528,7 @@ transformers:
|
||||
- ../https/transformer/transformer.yaml
|
||||
- ../tolerations/transformer.yaml
|
||||
`)
|
||||
m := th.Run("/app/prod", func() Options {
|
||||
m := th.Run("prod", func() Options {
|
||||
o := th.MakeDefaultOptions()
|
||||
o.LoadRestrictions = types.LoadRestrictionsNone
|
||||
return o
|
||||
@@ -540,7 +540,7 @@ func TestComplexComposition_Prod_SuccessWithBaseTransformers(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeStatefulSetBase(th)
|
||||
writePatchingTransformerBases(th)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
- ../https/service
|
||||
@@ -551,6 +551,6 @@ transformers:
|
||||
- ../https/transformer
|
||||
- ../tolerations
|
||||
`)
|
||||
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
||||
m := th.Run("prod", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, prodDesiredResult)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func writeK(path string, content string) FileGen {
|
||||
}
|
||||
|
||||
func writeTestBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deploy.yaml
|
||||
configMapGenerator:
|
||||
@@ -42,7 +42,7 @@ configMapGenerator:
|
||||
- testValue=purple
|
||||
- otherValue=green
|
||||
`)
|
||||
th.WriteF("/app/base/deploy.yaml", `
|
||||
th.WriteF("base/deploy.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -53,7 +53,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeTestComponent(th kusttest_test.Harness) {
|
||||
th.WriteC("/app/comp", `
|
||||
th.WriteC("comp", `
|
||||
namePrefix: comp-
|
||||
replicas:
|
||||
- name: storefront
|
||||
@@ -67,7 +67,7 @@ configMapGenerator:
|
||||
- testValue=blue
|
||||
- compValue=red
|
||||
`)
|
||||
th.WriteF("/app/comp/stub.yaml", `
|
||||
th.WriteF("comp/stub.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -78,7 +78,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeOverlayProd(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
- db
|
||||
@@ -90,7 +90,7 @@ components:
|
||||
}
|
||||
|
||||
func writeDB(th kusttest_test.Harness) {
|
||||
deployment("db", "/app/prod/db")(th)
|
||||
deployment("db", "prod/db")(th)
|
||||
}
|
||||
|
||||
func deployment(name string, path string) FileGen {
|
||||
@@ -114,7 +114,7 @@ func TestComponent(t *testing.T) {
|
||||
// resources that come before it in the resources list of the parent Kustomization.
|
||||
"basic-component": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent, writeOverlayProd},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -149,14 +149,14 @@ spec:
|
||||
},
|
||||
"multiple-components": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent, writeDB,
|
||||
writeC("/app/additionalcomp", `
|
||||
writeC("additionalcomp", `
|
||||
configMapGenerator:
|
||||
- name: my-configmap
|
||||
behavior: merge
|
||||
literals:
|
||||
- otherValue=orange
|
||||
`),
|
||||
writeK("/app/prod", `
|
||||
writeK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
- db
|
||||
@@ -166,7 +166,7 @@ components:
|
||||
- ../additionalcomp
|
||||
`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -201,7 +201,7 @@ spec:
|
||||
},
|
||||
"nested-components": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent, writeDB,
|
||||
writeC("/app/additionalcomp", `
|
||||
writeC("additionalcomp", `
|
||||
components:
|
||||
- ../comp
|
||||
configMapGenerator:
|
||||
@@ -210,7 +210,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- otherValue=orange
|
||||
`),
|
||||
writeK("/app/prod", `
|
||||
writeK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
- db
|
||||
@@ -219,7 +219,7 @@ components:
|
||||
- ../additionalcomp
|
||||
`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -256,13 +256,13 @@ spec:
|
||||
// without being affected by the component in another branch of the resource tree
|
||||
"basic-component-with-repeated-base": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent, writeOverlayProd,
|
||||
writeK("/app/repeated", `
|
||||
writeK("repeated", `
|
||||
resources:
|
||||
- ../base
|
||||
- ../prod
|
||||
`),
|
||||
},
|
||||
runPath: "/app/repeated",
|
||||
runPath: "repeated",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -312,7 +312,7 @@ spec:
|
||||
},
|
||||
"applying-component-directly-should-be-same-as-kustomization": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent,
|
||||
writeC("/app/direct-component", `
|
||||
writeC("direct-component", `
|
||||
resources:
|
||||
- ../base
|
||||
configMapGenerator:
|
||||
@@ -323,7 +323,7 @@ configMapGenerator:
|
||||
- testValue=blue
|
||||
`),
|
||||
},
|
||||
runPath: "/app/direct-component",
|
||||
runPath: "direct-component",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -344,7 +344,7 @@ metadata:
|
||||
},
|
||||
"missing-optional-component-api-version": {
|
||||
input: []FileGen{writeTestBase, writeOverlayProd,
|
||||
writeF("/app/comp/"+konfig.DefaultKustomizationFileName(), `
|
||||
writeF("comp/"+konfig.DefaultKustomizationFileName(), `
|
||||
kind: Component
|
||||
configMapGenerator:
|
||||
- name: my-configmap
|
||||
@@ -353,7 +353,7 @@ configMapGenerator:
|
||||
- otherValue=orange
|
||||
`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -382,25 +382,25 @@ spec:
|
||||
// accumulator when "comp-b" is accumulated. In practice we could use simple Kustomizations for this example.
|
||||
"components-can-add-the-same-base-if-the-first-renames-resources": {
|
||||
input: []FileGen{writeTestBase,
|
||||
deployment("proxy", "/app/comp-a/proxy.yaml"),
|
||||
writeC("/app/comp-a", `
|
||||
deployment("proxy", "comp-a/proxy.yaml"),
|
||||
writeC("comp-a", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
nameSuffix: "-a"
|
||||
`),
|
||||
writeC("/app/comp-b", `
|
||||
writeC("comp-b", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
nameSuffix: "-b"
|
||||
`),
|
||||
writeK("/app/prod", `
|
||||
writeK("prod", `
|
||||
components:
|
||||
- ../comp-a
|
||||
- ../comp-b`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedOutput: `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
@@ -436,34 +436,34 @@ metadata:
|
||||
|
||||
"multiple-bases-can-add-the-same-component-if-it-doesn-not-define-named-entities": {
|
||||
input: []FileGen{
|
||||
writeC("/app/comp", `
|
||||
writeC("comp", `
|
||||
namespace: prod
|
||||
`),
|
||||
writeK("/app/base-a", `
|
||||
writeK("base-a", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
|
||||
components:
|
||||
- ../comp
|
||||
`),
|
||||
deployment("proxy-a", "/app/base-a/proxy.yaml"),
|
||||
writeK("/app/base-b", `
|
||||
deployment("proxy-a", "base-a/proxy.yaml"),
|
||||
writeK("base-b", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
|
||||
components:
|
||||
- ../comp
|
||||
`),
|
||||
deployment("proxy-b", "/app/base-b/proxy.yaml"),
|
||||
writeK("/app/prod", `
|
||||
deployment("proxy-b", "base-b/proxy.yaml"),
|
||||
writeK("prod", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
- ../base-a
|
||||
- ../base-b
|
||||
`),
|
||||
deployment("proxy-prod", "/app/prod/proxy.yaml"),
|
||||
deployment("proxy-prod", "prod/proxy.yaml"),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
// Note that the namepsace has not been applied to proxy-prod because it was not in scope when the
|
||||
// component was applied
|
||||
expectedOutput: `
|
||||
@@ -513,30 +513,30 @@ func TestComponentErrors(t *testing.T) {
|
||||
}{
|
||||
"components-cannot-be-added-to-resources": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent,
|
||||
writeK("/app/compinres", `
|
||||
writeK("compinres", `
|
||||
resources:
|
||||
- ../base
|
||||
- ../comp
|
||||
`),
|
||||
},
|
||||
runPath: "app/compinres",
|
||||
expectedError: "expected kind != 'Component' for path '/app/comp'",
|
||||
runPath: "compinres",
|
||||
expectedError: "expected kind != 'Component' for path '/comp'",
|
||||
},
|
||||
"kustomizations-cannot-be-added-to-components": {
|
||||
input: []FileGen{writeTestBase, writeTestComponent,
|
||||
writeK("/app/kustincomponents", `
|
||||
writeK("kustincomponents", `
|
||||
components:
|
||||
- ../base
|
||||
- ../comp
|
||||
`),
|
||||
},
|
||||
runPath: "/app/kustincomponents",
|
||||
runPath: "kustincomponents",
|
||||
expectedError: "accumulating components: accumulateDirectory: \"expected kind 'Component' for path " +
|
||||
"'/app/base' but got 'Kustomization'",
|
||||
"'/base' but got 'Kustomization'",
|
||||
},
|
||||
"files-cannot-be-added-to-components-list": {
|
||||
input: []FileGen{writeTestBase,
|
||||
writeF("/app/filesincomponents/stub.yaml", `
|
||||
writeF("filesincomponents/stub.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -544,18 +544,18 @@ metadata:
|
||||
spec:
|
||||
replicas: 1
|
||||
`),
|
||||
writeK("/app/filesincomponents", `
|
||||
writeK("filesincomponents", `
|
||||
components:
|
||||
- stub.yaml
|
||||
- ../comp
|
||||
`),
|
||||
},
|
||||
runPath: "/app/filesincomponents",
|
||||
expectedError: "'/app/filesincomponents/stub.yaml' must be a directory to be a root",
|
||||
runPath: "filesincomponents",
|
||||
expectedError: "'/filesincomponents/stub.yaml' must be a directory to be a root",
|
||||
},
|
||||
"invalid-component-api-version": {
|
||||
input: []FileGen{writeTestBase, writeOverlayProd,
|
||||
writeF("/app/comp/"+konfig.DefaultKustomizationFileName(), `
|
||||
writeF("comp/"+konfig.DefaultKustomizationFileName(), `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Component
|
||||
configMapGenerator:
|
||||
@@ -565,22 +565,22 @@ configMapGenerator:
|
||||
- otherValue=orange
|
||||
`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedError: "apiVersion for Component should be kustomize.config.k8s.io/v1alpha1",
|
||||
},
|
||||
"components-cannot-add-the-same-resource": {
|
||||
input: []FileGen{writeTestBase,
|
||||
writeC("/app/comp-a", `
|
||||
writeC("comp-a", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
`),
|
||||
deployment("proxy", "/app/comp-a/proxy.yaml"),
|
||||
writeC("/app/comp-b", `
|
||||
deployment("proxy", "comp-a/proxy.yaml"),
|
||||
writeC("comp-b", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
`),
|
||||
deployment("proxy", "/app/comp-b/proxy.yaml"),
|
||||
writeK("/app/prod", `
|
||||
deployment("proxy", "comp-b/proxy.yaml"),
|
||||
writeK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
@@ -588,49 +588,49 @@ components:
|
||||
- ../comp-a
|
||||
- ../comp-b`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedError: "may not add resource with an already registered id: ~G_v1_Deployment|~X|proxy",
|
||||
},
|
||||
"components-cannot-add-the-same-base": {
|
||||
input: []FileGen{writeTestBase,
|
||||
deployment("proxy", "/app/comp-a/proxy.yaml"),
|
||||
writeC("/app/comp-a", `
|
||||
deployment("proxy", "comp-a/proxy.yaml"),
|
||||
writeC("comp-a", `
|
||||
resources:
|
||||
- ../base
|
||||
`),
|
||||
writeC("/app/comp-b", `
|
||||
writeC("comp-b", `
|
||||
resources:
|
||||
- ../base
|
||||
`),
|
||||
writeK("/app/prod", `
|
||||
writeK("prod", `
|
||||
components:
|
||||
- ../comp-a
|
||||
- ../comp-b`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedError: "may not add resource with an already registered id: ~G_v1_Deployment|~X|storefront",
|
||||
},
|
||||
"components-cannot-add-bases-containing-the-same-resource": {
|
||||
input: []FileGen{writeTestBase,
|
||||
writeC("/app/comp-a", `
|
||||
writeC("comp-a", `
|
||||
resources:
|
||||
- ../base-a
|
||||
`),
|
||||
writeK("/app/base-a", `
|
||||
writeK("base-a", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
`),
|
||||
deployment("proxy", "/app/base-a/proxy.yaml"),
|
||||
writeC("/app/comp-b", `
|
||||
deployment("proxy", "base-a/proxy.yaml"),
|
||||
writeC("comp-b", `
|
||||
resources:
|
||||
- ../base-b
|
||||
`),
|
||||
writeK("/app/base-b", `
|
||||
writeK("base-b", `
|
||||
resources:
|
||||
- proxy.yaml
|
||||
`),
|
||||
deployment("proxy", "/app/base-b/proxy.yaml"),
|
||||
writeK("/app/prod", `
|
||||
deployment("proxy", "base-b/proxy.yaml"),
|
||||
writeK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
@@ -638,7 +638,7 @@ components:
|
||||
- ../comp-a
|
||||
- ../comp-b`),
|
||||
},
|
||||
runPath: "/app/prod",
|
||||
runPath: "prod",
|
||||
expectedError: "may not add resource with an already registered id: ~G_v1_Deployment|~X|proxy",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
@@ -123,7 +122,7 @@ metadata:
|
||||
// to compare the result.
|
||||
func TestGeneratorBasics(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
namePrefix: blah-
|
||||
configMapGenerator:
|
||||
- name: bob
|
||||
@@ -132,6 +131,7 @@ configMapGenerator:
|
||||
- vegetable=broccoli
|
||||
envs:
|
||||
- foo.env
|
||||
env: bar.env
|
||||
files:
|
||||
- passphrase=phrase.dat
|
||||
- forces.txt
|
||||
@@ -153,26 +153,33 @@ secretGenerator:
|
||||
files:
|
||||
- passphrase=phrase.dat
|
||||
- forces.txt
|
||||
env: bar.env
|
||||
`)
|
||||
th.WriteF("/app/foo.env", `
|
||||
th.WriteF("foo.env", `
|
||||
MOUNTAIN=everest
|
||||
OCEAN=pacific
|
||||
`)
|
||||
th.WriteF("/app/phrase.dat", `
|
||||
th.WriteF("bar.env", `
|
||||
BIRD=falcon
|
||||
`)
|
||||
th.WriteF("phrase.dat", `
|
||||
Life is short.
|
||||
But the years are long.
|
||||
Not while the evil days come not.
|
||||
`)
|
||||
th.WriteF("/app/forces.txt", `
|
||||
th.WriteF("forces.txt", `
|
||||
gravitational
|
||||
electromagnetic
|
||||
strong nuclear
|
||||
weak nuclear
|
||||
`)
|
||||
opts := th.MakeDefaultOptions()
|
||||
m := th.Run("/app", opts)
|
||||
expFmt := `apiVersion: v1
|
||||
m := th.Run(".", opts)
|
||||
th.AssertActualEqualsExpected(
|
||||
m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
BIRD: falcon
|
||||
MOUNTAIN: everest
|
||||
OCEAN: pacific
|
||||
forces.txt: |2
|
||||
@@ -190,11 +197,12 @@ data:
|
||||
vegetable: broccoli
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blah-bob-d87t8m8tgm
|
||||
name: blah-bob-g9df72cd5b
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
druid_segmentCache_locations: '[{"path": "var/druid/segment-cache", "maxSize": 32000000000, "freeSpacePercent": 1.0}]'
|
||||
druid_segmentCache_locations: '[{"path": "var/druid/segment-cache", "maxSize":
|
||||
32000000000, "freeSpacePercent": 1.0}]'
|
||||
v2: '[{"path": "var/druid/segment-cache"}]'
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
@@ -202,38 +210,28 @@ metadata:
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
BIRD: ZmFsY29u
|
||||
MOUNTAIN: ZXZlcmVzdA==
|
||||
OCEAN: cGFjaWZpYw==
|
||||
forces.txt: %s
|
||||
forces.txt: |
|
||||
CmdyYXZpdGF0aW9uYWwKZWxlY3Ryb21hZ25ldGljCnN0cm9uZyBudWNsZWFyCndlYWsgbn
|
||||
VjbGVhcgo=
|
||||
fruit: YXBwbGU=
|
||||
passphrase: %s
|
||||
passphrase: |
|
||||
CkxpZmUgaXMgc2hvcnQuCkJ1dCB0aGUgeWVhcnMgYXJlIGxvbmcuCk5vdCB3aGlsZSB0aG
|
||||
UgZXZpbCBkYXlzIGNvbWUgbm90Lgo=
|
||||
vegetable: YnJvY2NvbGk=
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: blah-bob-%s
|
||||
name: blah-bob-58g62h555c
|
||||
type: Opaque
|
||||
`
|
||||
th.AssertActualEqualsExpected(
|
||||
m,
|
||||
// TODO(#3304): DECISION - kyaml better; not a bug.
|
||||
opts.IfApiMachineryElseKyaml(
|
||||
fmt.Sprintf(
|
||||
expFmt,
|
||||
`CmdyYXZpdGF0aW9uYWwKZWxlY3Ryb21hZ25ldGljCnN0cm9uZyBudWNsZWFyCndlYWsgbnVjbGVhcgo=`,
|
||||
`CkxpZmUgaXMgc2hvcnQuCkJ1dCB0aGUgeWVhcnMgYXJlIGxvbmcuCk5vdCB3aGlsZSB0aGUgZXZpbCBkYXlzIGNvbWUgbm90Lgo=`,
|
||||
`ftht6hfgmb`),
|
||||
fmt.Sprintf(
|
||||
expFmt, `|
|
||||
CmdyYXZpdGF0aW9uYWwKZWxlY3Ryb21hZ25ldGljCnN0cm9uZyBudWNsZWFyCndlYWsgbn
|
||||
VjbGVhcgo=`, `|
|
||||
CkxpZmUgaXMgc2hvcnQuCkJ1dCB0aGUgeWVhcnMgYXJlIGxvbmcuCk5vdCB3aGlsZSB0aG
|
||||
UgZXZpbCBkYXlzIGNvbWUgbm90Lgo=`, `9t25t44gg4`)))
|
||||
`)
|
||||
}
|
||||
|
||||
// TODO: These should be errors instead.
|
||||
func TestGeneratorRepeatsInKustomization(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
namePrefix: blah-
|
||||
configMapGenerator:
|
||||
- name: bob
|
||||
@@ -249,13 +247,13 @@ configMapGenerator:
|
||||
files:
|
||||
- nobles=nobility.txt
|
||||
`)
|
||||
th.WriteF("/app/forces.txt", `
|
||||
th.WriteF("forces.txt", `
|
||||
gravitational
|
||||
electromagnetic
|
||||
strong nuclear
|
||||
weak nuclear
|
||||
`)
|
||||
th.WriteF("/app/nobility.txt", `
|
||||
th.WriteF("nobility.txt", `
|
||||
helium
|
||||
neon
|
||||
argon
|
||||
@@ -263,7 +261,7 @@ krypton
|
||||
xenon
|
||||
radon
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -363,8 +361,8 @@ func manyHellos(count int) (result []byte) {
|
||||
|
||||
func TestGeneratorOverlaysBinaryData(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/base/data.bin", string(manyHellos(30)))
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteF("base/data.bin", string(manyHellos(30)))
|
||||
th.WriteK("base", `
|
||||
namePrefix: p1-
|
||||
configMapGenerator:
|
||||
- name: com1
|
||||
@@ -372,14 +370,14 @@ configMapGenerator:
|
||||
files:
|
||||
- data.bin
|
||||
`)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
configMapGenerator:
|
||||
- name: com1
|
||||
behavior: merge
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
binaryData:
|
||||
@@ -396,7 +394,7 @@ metadata:
|
||||
|
||||
func TestGeneratorOverlays(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base1", `
|
||||
th.WriteK("base1", `
|
||||
namePrefix: p1-
|
||||
configMapGenerator:
|
||||
- name: com1
|
||||
@@ -404,7 +402,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- from=base
|
||||
`)
|
||||
th.WriteK("/app/base2", `
|
||||
th.WriteK("base2", `
|
||||
namePrefix: p2-
|
||||
configMapGenerator:
|
||||
- name: com2
|
||||
@@ -412,7 +410,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- from=base
|
||||
`)
|
||||
th.WriteK("/app/overlay/o1", `
|
||||
th.WriteK("overlay/o1", `
|
||||
resources:
|
||||
- ../../base1
|
||||
configMapGenerator:
|
||||
@@ -421,7 +419,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- from=overlay
|
||||
`)
|
||||
th.WriteK("/app/overlay/o2", `
|
||||
th.WriteK("overlay/o2", `
|
||||
resources:
|
||||
- ../../base2
|
||||
configMapGenerator:
|
||||
@@ -430,7 +428,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- from=overlay
|
||||
`)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- o1
|
||||
- o2
|
||||
@@ -441,7 +439,7 @@ configMapGenerator:
|
||||
- foo=bar
|
||||
- baz=qux
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -464,24 +462,24 @@ metadata:
|
||||
func TestConfigMapGeneratorMergeNamePrefix(t *testing.T) {
|
||||
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
configMapGenerator:
|
||||
- name: cm
|
||||
behavior: create
|
||||
literals:
|
||||
- foo=bar
|
||||
`)
|
||||
th.WriteK("/app/o1", `
|
||||
th.WriteK("o1", `
|
||||
resources:
|
||||
- ../base
|
||||
namePrefix: o1-
|
||||
`)
|
||||
th.WriteK("/app/o2", `
|
||||
th.WriteK("o2", `
|
||||
resources:
|
||||
- ../base
|
||||
nameSuffix: -o2
|
||||
`)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- o1
|
||||
- o2
|
||||
@@ -495,7 +493,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- big=crunch
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -517,11 +515,11 @@ metadata:
|
||||
|
||||
func TestConfigMapGeneratorLiteralNewline(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
generators:
|
||||
- configmaps.yaml
|
||||
`)
|
||||
th.WriteF("/app/configmaps.yaml", `
|
||||
th.WriteF("configmaps.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: ConfigMapGenerator
|
||||
metadata:
|
||||
@@ -535,7 +533,7 @@ literals:
|
||||
behavior
|
||||
---
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(
|
||||
m, `
|
||||
apiVersion: v1
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func writeBaseWithCrd(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
crds:
|
||||
@@ -23,7 +23,7 @@ resources:
|
||||
|
||||
namePrefix: x-
|
||||
`)
|
||||
th.WriteF("/app/base/bee.yaml", `
|
||||
th.WriteF("base/bee.yaml", `
|
||||
apiVersion: v1beta1
|
||||
kind: Bee
|
||||
metadata:
|
||||
@@ -31,7 +31,7 @@ metadata:
|
||||
spec:
|
||||
action: fly
|
||||
`)
|
||||
th.WriteF("/app/base/mykind.yaml", `
|
||||
th.WriteF("base/mykind.yaml", `
|
||||
apiVersion: jingfang.example.com/v1
|
||||
kind: MyKind
|
||||
metadata:
|
||||
@@ -42,7 +42,7 @@ spec:
|
||||
beeRef:
|
||||
name: bee
|
||||
`)
|
||||
th.WriteF("/app/base/secret.yaml", `
|
||||
th.WriteF("base/secret.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
@@ -50,7 +50,7 @@ metadata:
|
||||
data:
|
||||
PATH: yellowBrickRoad
|
||||
`)
|
||||
th.WriteF("/app/base/mycrd.json", `
|
||||
th.WriteF("base/mycrd.json", `
|
||||
{
|
||||
"github.com/example/pkg/apis/jingfang/v1beta1.Bee": {
|
||||
"Schema": {
|
||||
@@ -227,7 +227,7 @@ data:
|
||||
func TestCrdBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeBaseWithCrd(th)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -258,7 +258,7 @@ spec:
|
||||
func TestCrdWithOverlay(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeBaseWithCrd(th)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namePrefix: prod-
|
||||
@@ -267,7 +267,7 @@ resources:
|
||||
patchesStrategicMerge:
|
||||
- bee.yaml
|
||||
`)
|
||||
th.WriteF("/app/overlay/bee.yaml", `
|
||||
th.WriteF("overlay/bee.yaml", `
|
||||
apiVersion: v1beta1
|
||||
kind: Bee
|
||||
metadata:
|
||||
@@ -275,7 +275,7 @@ metadata:
|
||||
spec:
|
||||
action: makehoney
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
@@ -306,7 +306,7 @@ spec:
|
||||
|
||||
func TestCrdWithContainers(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/crd/containers", `
|
||||
th.WriteK("crd/containers", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
@@ -316,7 +316,7 @@ images:
|
||||
newName: registry.gitlab.com/test
|
||||
newTag: latest
|
||||
`)
|
||||
th.WriteF("/app/crd/containers/crd.yaml", `
|
||||
th.WriteF("crd/containers/crd.yaml", `
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
@@ -337,7 +337,7 @@ spec:
|
||||
containers:
|
||||
description: Containers allows injecting additional containers
|
||||
`)
|
||||
m := th.Run("/app/crd/containers", th.MakeDefaultOptions())
|
||||
m := th.Run("crd/containers", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func makeBaseReferencingCustomConfig(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namePrefix: x-
|
||||
commonLabels:
|
||||
app: myApp
|
||||
@@ -35,7 +35,7 @@ configurations:
|
||||
- config/defaults.yaml
|
||||
- config/custom.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/giraffes.yaml", `
|
||||
th.WriteF("base/giraffes.yaml", `
|
||||
kind: Giraffe
|
||||
metadata:
|
||||
name: april
|
||||
@@ -50,7 +50,7 @@ spec:
|
||||
diet: acacia
|
||||
location: SE
|
||||
`)
|
||||
th.WriteF("/app/base/gorilla.yaml", `
|
||||
th.WriteF("base/gorilla.yaml", `
|
||||
kind: Gorilla
|
||||
metadata:
|
||||
name: koko
|
||||
@@ -58,7 +58,7 @@ spec:
|
||||
diet: bambooshoots
|
||||
location: SW
|
||||
`)
|
||||
th.WriteF("/app/base/animalPark.yaml", `
|
||||
th.WriteF("base/animalPark.yaml", `
|
||||
apiVersion: foo
|
||||
kind: AnimalPark
|
||||
metadata:
|
||||
@@ -77,8 +77,8 @@ spec:
|
||||
func TestCustomConfig(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeBaseReferencingCustomConfig(th)
|
||||
th.WriteLegacyConfigs("/app/base/config/defaults.yaml")
|
||||
th.WriteF("/app/base/config/custom.yaml", `
|
||||
th.WriteLegacyConfigs("base/config/defaults.yaml")
|
||||
th.WriteF("base/config/custom.yaml", `
|
||||
nameReference:
|
||||
- kind: Gorilla
|
||||
fieldSpecs:
|
||||
@@ -92,7 +92,7 @@ varReference:
|
||||
- path: spec/food
|
||||
kind: AnimalPark
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: foo
|
||||
kind: AnimalPark
|
||||
@@ -141,11 +141,11 @@ spec:
|
||||
func TestCustomConfigWithDefaultOverspecification(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeBaseReferencingCustomConfig(th)
|
||||
th.WriteLegacyConfigs("/app/base/config/defaults.yaml")
|
||||
th.WriteLegacyConfigs("base/config/defaults.yaml")
|
||||
// Specifying namePrefix here conflicts with (is the same as)
|
||||
// the defaults written above. This is intentional in the
|
||||
// test to assure duplicate config doesn't cause problems.
|
||||
th.WriteF("/app/base/config/custom.yaml", `
|
||||
th.WriteF("base/config/custom.yaml", `
|
||||
namePrefix:
|
||||
- path: metadata/name
|
||||
nameReference:
|
||||
@@ -161,7 +161,7 @@ varReference:
|
||||
- path: spec/food
|
||||
kind: AnimalPark
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: foo
|
||||
kind: AnimalPark
|
||||
@@ -210,8 +210,8 @@ spec:
|
||||
func TestFixedBug605_BaseCustomizationAvailableInOverlay(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeBaseReferencingCustomConfig(th)
|
||||
th.WriteLegacyConfigs("/app/base/config/defaults.yaml")
|
||||
th.WriteF("/app/base/config/custom.yaml", `
|
||||
th.WriteLegacyConfigs("base/config/defaults.yaml")
|
||||
th.WriteF("base/config/custom.yaml", `
|
||||
nameReference:
|
||||
- kind: Gorilla
|
||||
fieldSpecs:
|
||||
@@ -228,7 +228,7 @@ varReference:
|
||||
apiVersion: foo
|
||||
kind: AnimalPark
|
||||
`)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
namePrefix: o-
|
||||
commonLabels:
|
||||
movie: planetOfTheApes
|
||||
@@ -238,7 +238,7 @@ resources:
|
||||
- ../base
|
||||
- ursus.yaml
|
||||
`)
|
||||
th.WriteF("/app/overlay/ursus.yaml", `
|
||||
th.WriteF("overlay/ursus.yaml", `
|
||||
kind: Gorilla
|
||||
metadata:
|
||||
name: ursus
|
||||
@@ -247,7 +247,7 @@ spec:
|
||||
location: Arizona
|
||||
`)
|
||||
// The following replaces the gorillaRef in the AnimalPark.
|
||||
th.WriteF("/app/overlay/animalPark.yaml", `
|
||||
th.WriteF("overlay/animalPark.yaml", `
|
||||
apiVersion: foo
|
||||
kind: AnimalPark
|
||||
metadata:
|
||||
@@ -256,7 +256,7 @@ spec:
|
||||
gorillaRef:
|
||||
name: ursus
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: foo
|
||||
kind: AnimalPark
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestCustomNamePrefixer(t *testing.T) {
|
||||
PrepBuiltin("PrefixSuffixTransformer")
|
||||
defer th.Reset()
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- role.yaml
|
||||
@@ -25,7 +25,7 @@ resources:
|
||||
transformers:
|
||||
- prefixer.yaml
|
||||
`)
|
||||
th.WriteF("/app/prefixer.yaml", `
|
||||
th.WriteF("prefixer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PrefixSuffixTransformer
|
||||
metadata:
|
||||
@@ -37,7 +37,7 @@ fieldSpecs:
|
||||
- kind: Service
|
||||
path: metadata/name
|
||||
`)
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -52,20 +52,20 @@ spec:
|
||||
- name: whatever
|
||||
image: whatever
|
||||
`)
|
||||
th.WriteF("/app/role.yaml", `
|
||||
th.WriteF("role.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: myRole
|
||||
`)
|
||||
th.WriteF("/app/service.yaml", `
|
||||
th.WriteF("service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: myService
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestReusableCustomTransformers(t *testing.T) {
|
||||
// First write three custom configurations for builtin plugins.
|
||||
|
||||
// A custom name prefixer that only touches Deployments and Services.
|
||||
th.WriteF("/app/mytransformers/deploymentServicePrefixer.yaml", `
|
||||
th.WriteF("mytransformers/deploymentServicePrefixer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PrefixSuffixTransformer
|
||||
metadata:
|
||||
@@ -37,7 +37,7 @@ fieldSpecs:
|
||||
`)
|
||||
|
||||
// A custom annotator exclusively annotating Roles.
|
||||
th.WriteF("/app/mytransformers/roleAnnotator.yaml", `
|
||||
th.WriteF("mytransformers/roleAnnotator.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: AnnotationsTransformer
|
||||
metadata:
|
||||
@@ -55,7 +55,7 @@ fieldSpecs:
|
||||
// and only labels them at their top metadata level
|
||||
// exclusively. It does not modify selectors or
|
||||
// add labels to pods in the template.
|
||||
th.WriteF("/app/mytransformers/deploymentLabeller.yaml", `
|
||||
th.WriteF("mytransformers/deploymentLabeller.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: LabelTransformer
|
||||
metadata:
|
||||
@@ -73,7 +73,7 @@ fieldSpecs:
|
||||
// all happen to be plugin configurations. This makes
|
||||
// these plugins re-usable as a group in any number of other
|
||||
// kustomizations.
|
||||
th.WriteK("/app/mytransformers", `
|
||||
th.WriteK("mytransformers", `
|
||||
resources:
|
||||
- deploymentServicePrefixer.yaml
|
||||
- roleAnnotator.yaml
|
||||
@@ -82,7 +82,7 @@ resources:
|
||||
|
||||
// Finally, define the kustomization for the (arbitrarily named)
|
||||
// staging environment.
|
||||
th.WriteK("/app/staging", `
|
||||
th.WriteK("staging", `
|
||||
|
||||
# Bring in the custom transformers.
|
||||
transformers:
|
||||
@@ -104,7 +104,7 @@ resources:
|
||||
- role.yaml
|
||||
- service.yaml
|
||||
`)
|
||||
th.WriteF("/app/staging/deployment.yaml", `
|
||||
th.WriteF("staging/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -119,20 +119,20 @@ spec:
|
||||
- name: whatever
|
||||
image: whatever
|
||||
`)
|
||||
th.WriteF("/app/staging/role.yaml", `
|
||||
th.WriteF("staging/role.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: myRole
|
||||
`)
|
||||
th.WriteF("/app/staging/service.yaml", `
|
||||
th.WriteF("staging/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: myService
|
||||
`)
|
||||
|
||||
m := th.Run("/app/staging", th.MakeDefaultOptions())
|
||||
m := th.Run("staging", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -59,12 +59,12 @@ spec:
|
||||
const patchJsonRestartPolicy = `[{"op": "add", "path": "/spec/template/spec/restartPolicy", "value": "Always"}]`
|
||||
|
||||
func writeDeploymentBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -80,33 +80,33 @@ spec:
|
||||
}
|
||||
|
||||
func writeProbeOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/probe", `
|
||||
th.WriteK("probe", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/probe/dep-patch.yaml", patchAddProbe)
|
||||
th.WriteF("probe/dep-patch.yaml", patchAddProbe)
|
||||
}
|
||||
|
||||
func writeDNSOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/dns", `
|
||||
th.WriteK("dns", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/dns/dep-patch.yaml", patchDnsPolicy)
|
||||
th.WriteF("dns/dep-patch.yaml", patchDnsPolicy)
|
||||
}
|
||||
|
||||
func writeRestartOverlay(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/restart", `
|
||||
th.WriteK("restart", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/restart/dep-patch.yaml", patchRestartPolicy)
|
||||
th.WriteF("restart/dep-patch.yaml", patchRestartPolicy)
|
||||
}
|
||||
|
||||
// Here's a composite kustomization, that combines multiple overlays
|
||||
@@ -129,14 +129,14 @@ func TestIssue1251_CompositeDiamond_Failure(t *testing.T) {
|
||||
writeDNSOverlay(th)
|
||||
writeRestartOverlay(th)
|
||||
|
||||
th.WriteK("/app/composite", `
|
||||
th.WriteK("composite", `
|
||||
resources:
|
||||
- ../probe
|
||||
- ../dns
|
||||
- ../restart
|
||||
`)
|
||||
|
||||
err := th.RunWithErr("/app/composite", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("composite", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("Expected resource accumulation error")
|
||||
}
|
||||
@@ -176,7 +176,7 @@ func TestIssue1251_Patches_Overlayed(t *testing.T) {
|
||||
|
||||
// dns overlays probe.
|
||||
writeDNSOverlay(th)
|
||||
th.WriteK("/app/dns", `
|
||||
th.WriteK("dns", `
|
||||
resources:
|
||||
- ../probe
|
||||
patchesStrategicMerge:
|
||||
@@ -185,14 +185,14 @@ patchesStrategicMerge:
|
||||
|
||||
// restart overlays dns.
|
||||
writeRestartOverlay(th)
|
||||
th.WriteK("/app/restart", `
|
||||
th.WriteK("restart", `
|
||||
resources:
|
||||
- ../dns
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
|
||||
m := th.Run("/app/restart", th.MakeDefaultOptions())
|
||||
m := th.Run("restart", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expectedPatchedDeployment)
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ func TestIssue1251_Patches_Local(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeDeploymentBase(th)
|
||||
|
||||
th.WriteK("/app/composite", `
|
||||
th.WriteK("composite", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
@@ -208,20 +208,20 @@ patchesStrategicMerge:
|
||||
- patchDnsPolicy.yaml
|
||||
- patchRestartPolicy.yaml
|
||||
`)
|
||||
th.WriteF("/app/composite/patchRestartPolicy.yaml", patchRestartPolicy)
|
||||
th.WriteF("/app/composite/patchDnsPolicy.yaml", patchDnsPolicy)
|
||||
th.WriteF("/app/composite/patchAddProbe.yaml", patchAddProbe)
|
||||
th.WriteF("composite/patchRestartPolicy.yaml", patchRestartPolicy)
|
||||
th.WriteF("composite/patchDnsPolicy.yaml", patchDnsPolicy)
|
||||
th.WriteF("composite/patchAddProbe.yaml", patchAddProbe)
|
||||
|
||||
m := th.Run("/app/composite", th.MakeDefaultOptions())
|
||||
m := th.Run("composite", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expectedPatchedDeployment)
|
||||
}
|
||||
|
||||
func definePatchDirStructure(th kusttest_test.Harness) {
|
||||
writeDeploymentBase(th)
|
||||
|
||||
th.WriteF("/app/patches/patchRestartPolicy.yaml", patchRestartPolicy)
|
||||
th.WriteF("/app/patches/patchDnsPolicy.yaml", patchDnsPolicy)
|
||||
th.WriteF("/app/patches/patchAddProbe.yaml", patchAddProbe)
|
||||
th.WriteF("patches/patchRestartPolicy.yaml", patchRestartPolicy)
|
||||
th.WriteF("patches/patchDnsPolicy.yaml", patchDnsPolicy)
|
||||
th.WriteF("patches/patchAddProbe.yaml", patchAddProbe)
|
||||
}
|
||||
|
||||
// Fails due to file load restrictor.
|
||||
@@ -229,7 +229,7 @@ func TestIssue1251_Patches_ProdVsDev_Failure(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
definePatchDirStructure(th)
|
||||
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
@@ -237,13 +237,13 @@ patchesStrategicMerge:
|
||||
- ../patches/patchDnsPolicy.yaml
|
||||
`)
|
||||
|
||||
err := th.RunWithErr("/app/prod", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("prod", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected error")
|
||||
}
|
||||
if !strings.Contains(
|
||||
err.Error(),
|
||||
"security; file '/app/patches/patchAddProbe.yaml' is not in or below '/app/prod'") {
|
||||
"security; file '/patches/patchAddProbe.yaml' is not in or below '/prod'") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ func TestIssue1251_Patches_ProdVsDev(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
definePatchDirStructure(th)
|
||||
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
@@ -312,13 +312,13 @@ patchesStrategicMerge:
|
||||
opts := th.MakeDefaultOptions()
|
||||
opts.LoadRestrictions = types.LoadRestrictionsNone
|
||||
|
||||
m := th.Run("/app/prod", opts)
|
||||
m := th.Run("prod", opts)
|
||||
th.AssertActualEqualsExpected(m, prodDevMergeResult1)
|
||||
|
||||
th = kusttest_test.MakeHarness(t)
|
||||
definePatchDirStructure(th)
|
||||
|
||||
th.WriteK("/app/dev", `
|
||||
th.WriteK("dev", `
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
@@ -326,7 +326,7 @@ patchesStrategicMerge:
|
||||
- ../patches/patchRestartPolicy.yaml
|
||||
`)
|
||||
|
||||
m = th.Run("/app/dev", opts)
|
||||
m = th.Run("dev", opts)
|
||||
th.AssertActualEqualsExpected(m, prodDevMergeResult2)
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ func TestIssue1251_Plugins_ProdVsDev(t *testing.T) {
|
||||
defer th.Reset()
|
||||
|
||||
defineTransformerDirStructure(th)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
resources:
|
||||
- ../base
|
||||
transformers:
|
||||
@@ -344,11 +344,11 @@ transformers:
|
||||
- ../patches/addDnsPolicy
|
||||
`)
|
||||
|
||||
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
||||
m := th.Run("prod", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, prodDevMergeResult1)
|
||||
|
||||
defineTransformerDirStructure(th)
|
||||
th.WriteK("/app/dev", `
|
||||
th.WriteK("dev", `
|
||||
resources:
|
||||
- ../base
|
||||
transformers:
|
||||
@@ -356,7 +356,7 @@ transformers:
|
||||
- ../patches/addDnsPolicy
|
||||
`)
|
||||
|
||||
m = th.Run("/app/dev", th.MakeDefaultOptions())
|
||||
m = th.Run("dev", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, prodDevMergeResult2)
|
||||
}
|
||||
|
||||
@@ -368,13 +368,13 @@ func TestIssue1251_Plugins_Local(t *testing.T) {
|
||||
writeDeploymentBase(th.Harness)
|
||||
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/composite", "addDnsPolicy", patchJsonDnsPolicy)
|
||||
th, "composite", "addDnsPolicy", patchJsonDnsPolicy)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/composite", "addRestartPolicy", patchJsonRestartPolicy)
|
||||
th, "composite", "addRestartPolicy", patchJsonRestartPolicy)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/composite", "addProbe", patchJsonAddProbe)
|
||||
th, "composite", "addProbe", patchJsonAddProbe)
|
||||
|
||||
th.WriteK("/app/composite", `
|
||||
th.WriteK("composite", `
|
||||
resources:
|
||||
- ../base
|
||||
transformers:
|
||||
@@ -382,7 +382,7 @@ transformers:
|
||||
- addRestartPolicyConfig.yaml
|
||||
- addProbeConfig.yaml
|
||||
`)
|
||||
m := th.Run("/app/composite", th.MakeDefaultOptions())
|
||||
m := th.Run("composite", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expectedPatchedDeployment)
|
||||
}
|
||||
|
||||
@@ -410,50 +410,50 @@ func TestIssue1251_Plugins_Bundled(t *testing.T) {
|
||||
defer th.Reset()
|
||||
writeDeploymentBase(th.Harness)
|
||||
|
||||
th.WriteK("/app/patches", `
|
||||
th.WriteK("patches", `
|
||||
resources:
|
||||
- addDnsPolicyConfig.yaml
|
||||
- addRestartPolicyConfig.yaml
|
||||
- addProbeConfig.yaml
|
||||
`)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/patches", "addDnsPolicy", patchJsonDnsPolicy)
|
||||
th, "patches", "addDnsPolicy", patchJsonDnsPolicy)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/patches", "addRestartPolicy", patchJsonRestartPolicy)
|
||||
th, "patches", "addRestartPolicy", patchJsonRestartPolicy)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/patches", "addProbe", patchJsonAddProbe)
|
||||
th, "patches", "addProbe", patchJsonAddProbe)
|
||||
|
||||
th.WriteK("/app/composite", `
|
||||
th.WriteK("composite", `
|
||||
resources:
|
||||
- ../base
|
||||
transformers:
|
||||
- ../patches
|
||||
`)
|
||||
m := th.Run("/app/composite", th.MakeDefaultOptions())
|
||||
m := th.Run("composite", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expectedPatchedDeployment)
|
||||
}
|
||||
|
||||
func defineTransformerDirStructure(th *kusttest_test.HarnessEnhanced) {
|
||||
writeDeploymentBase(th.Harness)
|
||||
|
||||
th.WriteK("/app/patches/addDnsPolicy", `
|
||||
th.WriteK("patches/addDnsPolicy", `
|
||||
resources:
|
||||
- addDnsPolicyConfig.yaml
|
||||
`)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/patches/addDnsPolicy", "addDnsPolicy", patchJsonDnsPolicy)
|
||||
th, "patches/addDnsPolicy", "addDnsPolicy", patchJsonDnsPolicy)
|
||||
|
||||
th.WriteK("/app/patches/addRestartPolicy", `
|
||||
th.WriteK("patches/addRestartPolicy", `
|
||||
resources:
|
||||
- addRestartPolicyConfig.yaml
|
||||
`)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/patches/addRestartPolicy", "addRestartPolicy", patchJsonRestartPolicy)
|
||||
th, "patches/addRestartPolicy", "addRestartPolicy", patchJsonRestartPolicy)
|
||||
|
||||
th.WriteK("/app/patches/addProbe", `
|
||||
th.WriteK("patches/addProbe", `
|
||||
resources:
|
||||
- addProbeConfig.yaml
|
||||
`)
|
||||
writeJsonTransformerPluginConfig(
|
||||
th, "/app/patches/addProbe", "addProbe", patchJsonAddProbe)
|
||||
th, "patches/addProbe", "addProbe", patchJsonAddProbe)
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ import (
|
||||
// base
|
||||
//
|
||||
func writeDiamondBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deploy.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/deploy.yaml", `
|
||||
th.WriteF("base/deploy.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -46,7 +46,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeKirk(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/kirk", `
|
||||
th.WriteK("kirk", `
|
||||
namePrefix: kirk-
|
||||
resources:
|
||||
- ../base
|
||||
@@ -54,7 +54,7 @@ resources:
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/kirk/dep-patch.yaml", `
|
||||
th.WriteF("kirk/dep-patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -62,7 +62,7 @@ metadata:
|
||||
spec:
|
||||
type: Confident
|
||||
`)
|
||||
th.WriteF("/app/kirk/configmap.yaml", `
|
||||
th.WriteF("kirk/configmap.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
@@ -73,14 +73,14 @@ data:
|
||||
}
|
||||
|
||||
func writeSpock(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/spock", `
|
||||
th.WriteK("spock", `
|
||||
namePrefix: spock-
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/spock/dep-patch.yaml", `
|
||||
th.WriteF("spock/dep-patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -91,14 +91,14 @@ spec:
|
||||
}
|
||||
|
||||
func writeBones(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/bones", `
|
||||
th.WriteK("bones", `
|
||||
namePrefix: bones-
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- dep-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/bones/dep-patch.yaml", `
|
||||
th.WriteF("bones/dep-patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -109,7 +109,7 @@ spec:
|
||||
}
|
||||
|
||||
func writeTenants(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/tenants", `
|
||||
th.WriteK("tenants", `
|
||||
namePrefix: t-
|
||||
resources:
|
||||
- ../kirk
|
||||
@@ -119,7 +119,7 @@ resources:
|
||||
patchesStrategicMerge:
|
||||
- bones-patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/tenants/bones-patch.yaml", `
|
||||
th.WriteF("tenants/bones-patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -127,7 +127,7 @@ metadata:
|
||||
spec:
|
||||
mood: Cantankerous
|
||||
`)
|
||||
th.WriteF("/app/tenants/configMap.yaml", `
|
||||
th.WriteF("tenants/configMap.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
@@ -145,7 +145,7 @@ func TestBasicDiamond(t *testing.T) {
|
||||
writeSpock(th)
|
||||
writeBones(th)
|
||||
writeTenants(th)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
namePrefix: prod-
|
||||
resources:
|
||||
- ../tenants
|
||||
@@ -154,7 +154,7 @@ patchesStrategicMerge:
|
||||
`)
|
||||
// The patch only has to be specific enough
|
||||
// to match the item.
|
||||
th.WriteF("/app/prod/patches.yaml", `
|
||||
th.WriteF("prod/patches.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -177,7 +177,7 @@ data:
|
||||
zone: twilight
|
||||
`)
|
||||
|
||||
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
||||
m := th.Run("prod", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -11,19 +11,19 @@ import (
|
||||
|
||||
func TestIssue596AllowDirectoriesThatAreSubstringsOfEachOther(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base", "")
|
||||
th.WriteK("/app/overlays/aws", `
|
||||
th.WriteK("base", "")
|
||||
th.WriteK("overlays/aws", `
|
||||
resources:
|
||||
- ../../base
|
||||
`)
|
||||
th.WriteK("/app/overlays/aws-nonprod", `
|
||||
th.WriteK("overlays/aws-nonprod", `
|
||||
resources:
|
||||
- ../aws
|
||||
`)
|
||||
th.WriteK("/app/overlays/aws-sandbox2.us-east-1", `
|
||||
th.WriteK("overlays/aws-sandbox2.us-east-1", `
|
||||
resources:
|
||||
- ../aws-nonprod
|
||||
`)
|
||||
m := th.Run("/app/overlays/aws-sandbox2.us-east-1", th.MakeDefaultOptions())
|
||||
m := th.Run("overlays/aws-sandbox2.us-east-1", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, "")
|
||||
}
|
||||
|
||||
43
api/krusty/duplicatekeys_test.go
Normal file
43
api/krusty/duplicatekeys_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
)
|
||||
|
||||
func TestDuplicateKeys(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- resources.yaml
|
||||
`)
|
||||
th.WriteF("resources.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: podinfo
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: podinfo
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: podinfod
|
||||
image: ghcr.io/stefanprodan/podinfo:5.0.3
|
||||
command:
|
||||
- ./podinfo
|
||||
env:
|
||||
- name: PODINFO_UI_COLOR
|
||||
value: "#34577c"
|
||||
env:
|
||||
- name: PODINFO_UI_COLOR
|
||||
value: "#34577c"
|
||||
`)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
_, err := m.AsYaml()
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "mapping key \"env\" already defined")
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func makeCommonFileForExtendedPatchTest(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -61,7 +61,7 @@ spec:
|
||||
name: configmap-in-base
|
||||
name: configmap-in-base
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -91,7 +91,7 @@ spec:
|
||||
func TestExtendedPatchNameSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -100,7 +100,7 @@ patches:
|
||||
target:
|
||||
name: busybox
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -108,7 +108,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -193,7 +193,7 @@ spec:
|
||||
func TestExtendedPatchGvkSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -202,7 +202,7 @@ patches:
|
||||
target:
|
||||
kind: Deployment
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -210,7 +210,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -295,7 +295,7 @@ spec:
|
||||
func TestExtendedPatchLabelSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -304,7 +304,7 @@ patches:
|
||||
target:
|
||||
labelSelector: app=nginx
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -312,7 +312,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -397,7 +397,7 @@ spec:
|
||||
func TestExtendedPatchNameGvkSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -407,7 +407,7 @@ patches:
|
||||
name: busybox
|
||||
kind: Deployment
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -415,7 +415,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -498,7 +498,7 @@ spec:
|
||||
func TestExtendedPatchNameLabelSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -508,7 +508,7 @@ patches:
|
||||
name: .*
|
||||
labelSelector: app=busybox
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -516,7 +516,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -601,7 +601,7 @@ spec:
|
||||
func TestExtendedPatchGvkLabelSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -611,7 +611,7 @@ patches:
|
||||
kind: Deployment
|
||||
labelSelector: app=busybox
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -619,7 +619,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -702,7 +702,7 @@ spec:
|
||||
func TestExtendedPatchNameGvkLabelSelector(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -713,7 +713,7 @@ patches:
|
||||
kind: Deployment
|
||||
labelSelector: app=busybox
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -721,7 +721,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -804,7 +804,7 @@ spec:
|
||||
func TestExtendedPatchNoMatch(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -813,7 +813,7 @@ patches:
|
||||
target:
|
||||
name: no-match
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -821,7 +821,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -902,14 +902,14 @@ spec:
|
||||
func TestExtendedPatchWithoutTarget(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -917,7 +917,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -1000,7 +1000,7 @@ spec:
|
||||
func TestExtendedPatchNoMatchMultiplePatch(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -1013,7 +1013,7 @@ patches:
|
||||
name: busybox
|
||||
kind: Job
|
||||
`)
|
||||
th.WriteF("/app/base/patch.yaml", `
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1021,7 +1021,7 @@ metadata:
|
||||
annotations:
|
||||
new-key: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -1102,7 +1102,7 @@ spec:
|
||||
func TestExtendedPatchMultiplePatchOverlapping(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
@@ -1115,7 +1115,7 @@ patches:
|
||||
name: busybox
|
||||
kind: Deployment
|
||||
`)
|
||||
th.WriteF("/app/base/patch1.yaml", `
|
||||
th.WriteF("base/patch1.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1123,7 +1123,7 @@ metadata:
|
||||
annotations:
|
||||
new-key-from-patch1: new-value
|
||||
`)
|
||||
th.WriteF("/app/base/patch2.yaml", `
|
||||
th.WriteF("base/patch2.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1131,7 +1131,7 @@ metadata:
|
||||
annotations:
|
||||
new-key-from-patch2: new-value
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
)
|
||||
|
||||
func TestFnExecGenerator(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
// Function plugins should not need the env setup done by MakeEnhancedHarness
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- short_secret.yaml
|
||||
generators:
|
||||
@@ -19,7 +19,7 @@ generators:
|
||||
`)
|
||||
|
||||
// Create some additional resource just to make sure everything is added
|
||||
th.WriteF("/app/short_secret.yaml", `
|
||||
th.WriteF("short_secret.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
@@ -33,7 +33,7 @@ stringData:
|
||||
- mkdir /mnt/vda
|
||||
`)
|
||||
|
||||
th.WriteF("/app/gener.yaml", `
|
||||
th.WriteF("gener.yaml", `
|
||||
kind: executable
|
||||
metadata:
|
||||
name: demo
|
||||
@@ -45,7 +45,7 @@ spec:
|
||||
`)
|
||||
o := th.MakeOptionsPluginsEnabled()
|
||||
o.PluginConfig.FnpLoadingOptions.EnableExec = true
|
||||
m := th.Run("/app", o)
|
||||
m := th.Run(".", o)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
@@ -92,17 +92,17 @@ func skipIfNoDocker(t *testing.T) {
|
||||
func TestFnContainerGenerator(t *testing.T) {
|
||||
skipIfNoDocker(t)
|
||||
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
// Function plugins should not need the env setup done by MakeEnhancedHarness
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- short_secret.yaml
|
||||
generators:
|
||||
- gener.yaml
|
||||
`)
|
||||
// Create generator config
|
||||
th.WriteF("/app/gener.yaml", `
|
||||
th.WriteF("gener.yaml", `
|
||||
apiVersion: examples.config.kubernetes.io/v1beta1
|
||||
kind: CockroachDB
|
||||
metadata:
|
||||
@@ -115,7 +115,7 @@ spec:
|
||||
replicas: 3
|
||||
`)
|
||||
// Create some additional resource just to make sure everything is added
|
||||
th.WriteF("/app/short_secret.yaml", `
|
||||
th.WriteF("short_secret.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
@@ -128,7 +128,7 @@ stringData:
|
||||
bootcmd:
|
||||
- mkdir /mnt/vda
|
||||
`)
|
||||
m := th.Run("/app", th.MakeOptionsPluginsEnabled())
|
||||
m := th.Run(".", th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
@@ -308,10 +308,10 @@ spec:
|
||||
func TestFnContainerTransformer(t *testing.T) {
|
||||
skipIfNoDocker(t)
|
||||
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
// Function plugins should not need the env setup done by MakeEnhancedHarness
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- data.yaml
|
||||
transformers:
|
||||
@@ -319,7 +319,7 @@ transformers:
|
||||
- transf2.yaml
|
||||
`)
|
||||
|
||||
th.WriteF("/app/data.yaml", `
|
||||
th.WriteF("data.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -343,7 +343,7 @@ spec:
|
||||
`)
|
||||
// This transformer should add resource reservations based on annotation in data.yaml
|
||||
// See https://github.com/kubernetes-sigs/kustomize/tree/master/functions/examples/injection-tshirt-sizes
|
||||
th.WriteF("/app/transf1.yaml", `
|
||||
th.WriteF("transf1.yaml", `
|
||||
apiVersion: examples.config.kubernetes.io/v1beta1
|
||||
kind: Validator
|
||||
metadata:
|
||||
@@ -355,7 +355,7 @@ metadata:
|
||||
`)
|
||||
// This transformer will check resources without and won't do any changes
|
||||
// See https://github.com/kubernetes-sigs/kustomize/tree/master/functions/examples/validator-kubeval
|
||||
th.WriteF("/app/transf2.yaml", `
|
||||
th.WriteF("transf2.yaml", `
|
||||
apiVersion: examples.config.kubernetes.io/v1beta1
|
||||
kind: Kubeval
|
||||
metadata:
|
||||
@@ -375,7 +375,7 @@ spec:
|
||||
kubernetesVersion: "1.16.0"
|
||||
schemaLocation: "file:///schemas"
|
||||
`)
|
||||
m := th.Run("/app", th.MakeOptionsPluginsEnabled())
|
||||
m := th.Run(".", th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -408,10 +408,10 @@ spec:
|
||||
func TestFnContainerTransformerWithConfig(t *testing.T) {
|
||||
skipIfNoDocker(t)
|
||||
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
// Function plugins should not need the env setup done by MakeEnhancedHarness
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- data1.yaml
|
||||
- data2.yaml
|
||||
@@ -419,18 +419,18 @@ transformers:
|
||||
- label_namespace.yaml
|
||||
`)
|
||||
|
||||
th.WriteF("/app/data1.yaml", `apiVersion: v1
|
||||
th.WriteF("data1.yaml", `apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: my-namespace
|
||||
`)
|
||||
th.WriteF("/app/data2.yaml", `apiVersion: v1
|
||||
th.WriteF("data2.yaml", `apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: another-namespace
|
||||
`)
|
||||
|
||||
th.WriteF("/app/label_namespace.yaml", `apiVersion: v1
|
||||
th.WriteF("label_namespace.yaml", `apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: label_namespace
|
||||
@@ -443,7 +443,7 @@ data:
|
||||
label_value: function-test
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeOptionsPluginsEnabled())
|
||||
m := th.Run(".", th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
@@ -468,10 +468,10 @@ metadata:
|
||||
func TestFnContainerEnvVars(t *testing.T) {
|
||||
skipIfNoDocker(t)
|
||||
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
// Function plugins should not need the env setup done by MakeEnhancedHarness
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
generators:
|
||||
- gener.yaml
|
||||
`)
|
||||
@@ -479,7 +479,7 @@ generators:
|
||||
// TODO: cheange image to gcr.io/kpt-functions/templater:stable
|
||||
// when https://github.com/GoogleContainerTools/kpt-functions-catalog/pull/103
|
||||
// is merged
|
||||
th.WriteF("/app/gener.yaml", `
|
||||
th.WriteF("gener.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
@@ -499,7 +499,7 @@ data:
|
||||
data:
|
||||
value: '{{ env "TESTTEMPLATE" }}'
|
||||
`)
|
||||
m := th.Run("/app", th.MakeOptionsPluginsEnabled())
|
||||
m := th.Run(".", th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func TestSimpleBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("app/base", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namePrefix: team-foo-
|
||||
@@ -27,7 +27,7 @@ resources:
|
||||
- deployment.yaml
|
||||
- networkpolicy.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("app/base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -40,7 +40,7 @@ spec:
|
||||
selector:
|
||||
app: nginx
|
||||
`)
|
||||
th.WriteF("/app/base/networkpolicy.yaml", `
|
||||
th.WriteF("app/base/networkpolicy.yaml", `
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
@@ -55,7 +55,7 @@ spec:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("app/base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -72,7 +72,7 @@ spec:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("app/base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@@ -149,7 +149,7 @@ spec:
|
||||
}
|
||||
|
||||
func makeBaseWithGenerators(th kusttest_test.Harness) {
|
||||
th.WriteK("/app", `
|
||||
th.WriteK("app", `
|
||||
namePrefix: team-foo-
|
||||
commonLabels:
|
||||
app: mynginx
|
||||
@@ -170,7 +170,7 @@ secretGenerator:
|
||||
- username=admin
|
||||
- password=somepw
|
||||
`)
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("app/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -196,7 +196,7 @@ spec:
|
||||
name: configmap-in-base
|
||||
name: configmap-in-base
|
||||
`)
|
||||
th.WriteF("/app/service.yaml", `
|
||||
th.WriteF("app/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -214,7 +214,7 @@ spec:
|
||||
func TestBaseWithGeneratorsAlone(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeBaseWithGenerators(th)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run("app", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -305,7 +305,7 @@ type: Opaque
|
||||
func TestMergeAndReplaceGenerators(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeBaseWithGenerators(th)
|
||||
th.WriteF("/overlay/deployment.yaml", `
|
||||
th.WriteF("overlay/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -322,7 +322,7 @@ spec:
|
||||
name: configmap-in-overlay
|
||||
name: configmap-in-overlay
|
||||
`)
|
||||
th.WriteK("/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
namePrefix: staging-
|
||||
commonLabels:
|
||||
env: staging
|
||||
@@ -345,7 +345,7 @@ secretGenerator:
|
||||
literals:
|
||||
- proxy=haproxy
|
||||
`)
|
||||
m := th.Run("/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -457,7 +457,7 @@ metadata:
|
||||
|
||||
func TestGeneratingIntoNamespaces(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK("app", `
|
||||
configMapGenerator:
|
||||
- name: test
|
||||
namespace: default
|
||||
@@ -479,7 +479,7 @@ secretGenerator:
|
||||
- username=admin
|
||||
- password=somepw
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run("app", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -523,7 +523,7 @@ type: Opaque
|
||||
// and namespace left to default
|
||||
func TestConfigMapGeneratingIntoSameNamespace(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK("app", `
|
||||
configMapGenerator:
|
||||
- name: test
|
||||
namespace: default
|
||||
@@ -533,7 +533,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- key=value
|
||||
`)
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("app", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected error")
|
||||
}
|
||||
@@ -546,7 +546,7 @@ configMapGenerator:
|
||||
// and namespace left to default
|
||||
func TestSecretGeneratingIntoSameNamespace(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK("app", `
|
||||
secretGenerator:
|
||||
- name: test
|
||||
namespace: default
|
||||
@@ -558,7 +558,7 @@ secretGenerator:
|
||||
- username=admin
|
||||
- password=somepw
|
||||
`)
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("app", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected error")
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestSecretGenerator(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
secretGenerator:
|
||||
- name: bob
|
||||
literals:
|
||||
@@ -23,12 +23,12 @@ secretGenerator:
|
||||
envs:
|
||||
- foo.env
|
||||
`)
|
||||
th.WriteF("/app/foo.env", `
|
||||
th.WriteF("foo.env", `
|
||||
MOUNTAIN=everest
|
||||
OCEAN=pacific
|
||||
`)
|
||||
th.WriteF("/app/phrase.dat", "dat phrase")
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
th.WriteF("phrase.dat", "dat phrase")
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -47,7 +47,7 @@ type: Opaque
|
||||
|
||||
func TestGeneratorOptionsWithBases(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
generatorOptions:
|
||||
@@ -59,7 +59,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- foo=bar
|
||||
`)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
@@ -73,7 +73,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- fruit=apple
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
|
||||
@@ -14,9 +14,8 @@ import (
|
||||
// GVKN shouldn't change with default options
|
||||
func TestKeepOriginalGVKN(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("apps/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -27,15 +26,13 @@ spec:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
`)
|
||||
|
||||
th.WriteF("apps/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
`)
|
||||
|
||||
th.WriteK("apps", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -44,10 +41,9 @@ patches:
|
||||
target:
|
||||
kind: Deployment
|
||||
`)
|
||||
|
||||
m := th.Run("apps", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -64,9 +60,8 @@ spec:
|
||||
// These tests document behavior that will change
|
||||
func TestChangeName(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("apps/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -77,15 +72,13 @@ spec:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
`)
|
||||
|
||||
th.WriteF("apps/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: new-name
|
||||
`)
|
||||
|
||||
th.WriteK("apps", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -93,18 +86,16 @@ patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// name should become `new-name`
|
||||
m := th.Run("apps", options)
|
||||
m := th.Run(".", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
name: new-name
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
@@ -116,9 +107,8 @@ spec:
|
||||
|
||||
func TestChangeKind(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("apps/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -129,32 +119,27 @@ spec:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
`)
|
||||
|
||||
th.WriteF("apps/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: old-name
|
||||
`)
|
||||
|
||||
th.WriteK("apps", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowKindChange: true
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// kind should become `StatefulSet`
|
||||
m := th.Run("apps", options)
|
||||
m := th.Run(".", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: old-name
|
||||
spec:
|
||||
@@ -168,9 +153,8 @@ spec:
|
||||
|
||||
func TestChangeNameAndKind(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("apps/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -181,35 +165,30 @@ spec:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
`)
|
||||
|
||||
th.WriteF("apps/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
`)
|
||||
|
||||
th.WriteK("apps", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
allowKindChange: true
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// kind should become `StatefulSet`
|
||||
// name should become `new-name`
|
||||
m := th.Run("apps", options)
|
||||
m := th.Run(".", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: old-name
|
||||
name: new-name
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
@@ -219,14 +198,12 @@ spec:
|
||||
`)
|
||||
}
|
||||
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/3280
|
||||
// Should be able to refer to a resource with either its
|
||||
// original GVKN or its current one
|
||||
func TestPatchOriginalName(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -238,7 +215,7 @@ spec:
|
||||
image: nginx
|
||||
`)
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: new-name
|
||||
@@ -246,13 +223,13 @@ metadata:
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
`)
|
||||
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
@@ -260,24 +237,20 @@ patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// name should become `new-name`
|
||||
m := th.Run("overlay", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
@@ -290,9 +263,8 @@ spec:
|
||||
|
||||
func TestPatchNewName(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -304,7 +276,7 @@ spec:
|
||||
image: nginx
|
||||
`)
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: new-name
|
||||
@@ -312,13 +284,13 @@ metadata:
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
`)
|
||||
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
@@ -326,27 +298,34 @@ patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// depPatch cannot find target with the name `new-name`
|
||||
// because base/patch.yaml can't yet edit the name
|
||||
assert.Error(t, th.RunWithErr("overlay", options))
|
||||
m := th.Run("overlay", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
`)
|
||||
}
|
||||
|
||||
func TestPatchOriginalNameAndKind(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -358,7 +337,7 @@ spec:
|
||||
image: nginx
|
||||
`)
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
@@ -366,13 +345,14 @@ metadata:
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
allowKindChange: true
|
||||
`)
|
||||
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
@@ -380,25 +360,20 @@ patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// kind should become `StatefulSet`
|
||||
// name should become `new-name`
|
||||
m := th.Run("overlay", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: old-name
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
@@ -411,9 +386,8 @@ spec:
|
||||
|
||||
func TestPatchNewNameAndKind(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -425,7 +399,7 @@ spec:
|
||||
image: nginx
|
||||
`)
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
@@ -433,13 +407,14 @@ metadata:
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
allowKindChange: true
|
||||
`)
|
||||
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
@@ -447,29 +422,36 @@ patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// depPatch cannot find target with kind `StatefulSet` and name `new-name`
|
||||
// because base/patch.yaml can't yet edit the kind or name
|
||||
assert.Error(t, th.RunWithErr("overlay", options))
|
||||
m := th.Run("overlay", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
`)
|
||||
}
|
||||
|
||||
// Use original name, but new kind
|
||||
// Should fail, even after #3280 is done, because this ID is invalid
|
||||
func TestPatchOriginalNameAndNewKind(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: old-name
|
||||
@@ -481,7 +463,7 @@ spec:
|
||||
image: nginx
|
||||
`)
|
||||
th.WriteF("base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: new-name
|
||||
@@ -489,13 +471,14 @@ metadata:
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
options:
|
||||
allowNameChange: true
|
||||
allowKindChange: true
|
||||
`)
|
||||
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
@@ -503,17 +486,14 @@ patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: new-name
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// depPatch cannot find target with kind `Deployment` and name `new-name`
|
||||
// because the resource never had this GVKN
|
||||
assert.Error(t, th.RunWithErr("overlay", options))
|
||||
@@ -552,13 +532,12 @@ spec:
|
||||
|
||||
func TestBaseReuseNameAndKindConflict(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteK("/app/shared", `
|
||||
th.WriteK("shared", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/shared/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("shared/deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: my-deploy
|
||||
@@ -570,53 +549,139 @@ spec:
|
||||
image: nginx
|
||||
`)
|
||||
|
||||
th.WriteK("/app/component1/base", `
|
||||
th.WriteK("component1/base", `
|
||||
resources:
|
||||
- ../../shared
|
||||
`)
|
||||
th.WriteK("/app/component1/overlay", `
|
||||
th.WriteK("component1/overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
namePrefix: overlay-
|
||||
`)
|
||||
|
||||
th.WriteK("/app/component2/base", `
|
||||
th.WriteK("component2/base", `
|
||||
resources:
|
||||
- ../../shared
|
||||
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: Deployment
|
||||
name: my-deploy
|
||||
options:
|
||||
allowNameChange: true
|
||||
allowKindChange: true
|
||||
`)
|
||||
th.WriteF("/app/component2/base/patch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
th.WriteF("component2/base/patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: my-stateful-set
|
||||
`)
|
||||
th.WriteK("/app/component2/overlay", `
|
||||
th.WriteK("component2/overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
namePrefix: overlay-
|
||||
`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- component1/overlay
|
||||
- component2/overlay
|
||||
`)
|
||||
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AllowResourceIdChanges = true
|
||||
|
||||
// Error occurs when app/component2/base tries to load the shared resources
|
||||
// because the kind is not (yet) allowed to change yet
|
||||
// so it loads a second Deployment with the name my-deploy
|
||||
// instead of a StatefulSet as specified by the patch.
|
||||
// Will be fixed by #3280.
|
||||
assert.Error(t, th.RunWithErr("overlay", options))
|
||||
m := th.Run(".", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: overlay-my-deploy
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: overlay-my-stateful-set
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
`)
|
||||
}
|
||||
|
||||
func TestNameReferenceAfterGvknChange(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("configMap.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: old-name
|
||||
`)
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: new-name
|
||||
`)
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: deploy
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- valueFrom:
|
||||
configMapKeyRef:
|
||||
name: old-name
|
||||
key: somekey
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: old-name
|
||||
key: somekey
|
||||
`)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- configMap.yaml
|
||||
- deployment.yaml
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
target:
|
||||
kind: ConfigMap
|
||||
options:
|
||||
allowNameChange: true
|
||||
`)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: new-name
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: deploy
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- valueFrom:
|
||||
configMapKeyRef:
|
||||
key: somekey
|
||||
name: new-name
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
key: somekey
|
||||
name: new-name
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
package krusty_test
|
||||
|
||||
/*
|
||||
import (
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
)
|
||||
|
||||
var expected string = `
|
||||
const expectedHelm = `
|
||||
apiVersion: v1
|
||||
data:
|
||||
rcon-password: Q0hBTkdFTUUh
|
||||
@@ -18,36 +17,19 @@ kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
app: test-minecraft
|
||||
chart: minecraft-1.2.0
|
||||
chart: minecraft-3.1.3
|
||||
heritage: Helm
|
||||
release: test
|
||||
name: test-minecraft
|
||||
type: Opaque
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
annotations:
|
||||
volume.alpha.kubernetes.io/storage-class: default
|
||||
labels:
|
||||
app: test-minecraft
|
||||
chart: minecraft-1.2.0
|
||||
heritage: Helm
|
||||
release: test
|
||||
name: test-minecraft-datadir
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations: {}
|
||||
labels:
|
||||
app: test-minecraft
|
||||
chart: minecraft-1.2.0
|
||||
chart: minecraft-3.1.3
|
||||
heritage: Helm
|
||||
release: test
|
||||
name: test-minecraft
|
||||
@@ -59,45 +41,43 @@ spec:
|
||||
targetPort: minecraft
|
||||
selector:
|
||||
app: test-minecraft
|
||||
type: LoadBalancer
|
||||
type: ClusterIP
|
||||
`
|
||||
|
||||
func TestHelmChartInflationGenerator(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
func TestHelmChartInflationGeneratorOld(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
|
||||
defer th.Reset()
|
||||
if err := th.ErrIfNoHelm(); err != nil {
|
||||
t.Skip("skipping: " + err.Error())
|
||||
}
|
||||
|
||||
th.WriteK(th.GetRoot(), `
|
||||
helmChartInflationGenerator:
|
||||
- chartName: minecraft
|
||||
chartRepoUrl: https://kubernetes-charts.storage.googleapis.com
|
||||
chartVersion: v1.2.0
|
||||
chartRepoUrl: https://itzg.github.io/minecraft-server-charts
|
||||
chartVersion: 3.1.3
|
||||
releaseName: test
|
||||
releaseNamespace: testNamespace
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expected)
|
||||
m := th.Run(th.GetRoot(), th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, expectedHelm)
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGenerator(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
|
||||
defer th.Reset()
|
||||
if err := th.ErrIfNoHelm(); err != nil {
|
||||
t.Skip("skipping: " + err.Error())
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGeneratorAsPlugin(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
generators:
|
||||
- helm.yaml
|
||||
th.WriteK(th.GetRoot(), `
|
||||
helmCharts:
|
||||
- name: minecraft
|
||||
repo: https://itzg.github.io/minecraft-server-charts
|
||||
version: 3.1.3
|
||||
releaseName: test
|
||||
`)
|
||||
|
||||
th.WriteF("/app/helm.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: HelmChartInflationGenerator
|
||||
metadata:
|
||||
name: myMap
|
||||
chartName: minecraft
|
||||
chartRepoUrl: https://kubernetes-charts.storage.googleapis.com
|
||||
chartVersion: v1.2.0
|
||||
releaseName: test
|
||||
releaseNamespace: testNamespace
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expected)
|
||||
m := th.Run(th.GetRoot(), th.MakeOptionsPluginsEnabled())
|
||||
th.AssertActualEqualsExpected(m, expectedHelm)
|
||||
}
|
||||
*/
|
||||
|
||||
93
api/krusty/inlinelabels_test.go
Normal file
93
api/krusty/inlinelabels_test.go
Normal file
@@ -0,0 +1,93 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
const resources string = `apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: my-deployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: my-deployment
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8080
|
||||
---
|
||||
apiVersion: example.dev/v1
|
||||
kind: MyCRD
|
||||
metadata:
|
||||
name: crd
|
||||
`
|
||||
|
||||
func TestKustomizationLabels(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeResourcesForPatchTest(th)
|
||||
th.WriteK("/app", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
labels:
|
||||
- pairs:
|
||||
foo: bar
|
||||
- pairs:
|
||||
a: b
|
||||
includeSelectors: true
|
||||
- pairs:
|
||||
c: d
|
||||
fields:
|
||||
- path: spec/selector
|
||||
group: example.dev
|
||||
version: v1
|
||||
kind: MyCRD
|
||||
create: true
|
||||
`)
|
||||
th.WriteF("/app/deployment.yaml", resources)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
a: b
|
||||
c: d
|
||||
foo: bar
|
||||
name: my-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
a: b
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
a: b
|
||||
spec:
|
||||
containers:
|
||||
- livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8080
|
||||
name: my-deployment
|
||||
---
|
||||
apiVersion: example.dev/v1
|
||||
kind: MyCRD
|
||||
metadata:
|
||||
labels:
|
||||
a: b
|
||||
c: d
|
||||
foo: bar
|
||||
name: crd
|
||||
spec:
|
||||
selector:
|
||||
c: d
|
||||
`)
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func makeResourcesForPatchTest(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -41,7 +41,7 @@ spec:
|
||||
func TestStrategicMergePatchInline(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeResourcesForPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -58,7 +58,7 @@ patchesStrategicMerge:
|
||||
- name: nginx
|
||||
image: image1
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -90,7 +90,7 @@ spec:
|
||||
func TestJSONPatchInline(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeResourcesForPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -105,7 +105,7 @@ patchesJson6902:
|
||||
path: /spec/template/spec/containers/0/image
|
||||
value: image1
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -137,7 +137,7 @@ spec:
|
||||
func TestExtendedPatchInlineJSON(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeResourcesForPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -150,7 +150,7 @@ patches:
|
||||
path: /spec/template/spec/containers/0/image
|
||||
value: image1
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -182,7 +182,7 @@ spec:
|
||||
func TestExtendedPatchInlineYAML(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeResourcesForPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -202,7 +202,7 @@ patches:
|
||||
- name: nginx
|
||||
image: image1
|
||||
`)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -13,14 +13,14 @@ func TestInlineTransformer(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
|
||||
th.WriteF("/app/resource.yaml", `
|
||||
th.WriteF("resource.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: whatever
|
||||
data: {}
|
||||
`)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- resource.yaml
|
||||
transformers:
|
||||
@@ -44,7 +44,7 @@ metadata:
|
||||
namespace: test
|
||||
`
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expected)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestInlineGenerator(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
generators:
|
||||
- |-
|
||||
apiVersion: builtin
|
||||
@@ -74,6 +74,6 @@ metadata:
|
||||
name: mymap-kfd8tf729k
|
||||
`
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, expected)
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ import (
|
||||
// Ref: Issue #3455
|
||||
func TestIntermediateName(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/gcp", `
|
||||
th.WriteK("gcp", `
|
||||
namePrefix: gcp-
|
||||
resources:
|
||||
- ../emea
|
||||
patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("/app/gcp/depPatch.yaml", `
|
||||
th.WriteF("gcp/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -28,21 +28,21 @@ metadata:
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
th.WriteK("/app/emea", `
|
||||
th.WriteK("emea", `
|
||||
namePrefix: emea-
|
||||
resources:
|
||||
- ../prod
|
||||
`)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
namePrefix: prod-
|
||||
resources:
|
||||
- ../base
|
||||
`)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -53,7 +53,7 @@ spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
m := th.Run("/app/gcp", th.MakeDefaultOptions())
|
||||
m := th.Run("gcp", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -72,14 +72,14 @@ spec:
|
||||
// transformations) have the same name, there is no conflict
|
||||
func TestIntermediateNameSameNameDifferentLayer(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/gcp", `
|
||||
th.WriteK("gcp", `
|
||||
namePrefix: gcp-
|
||||
resources:
|
||||
- ../emea
|
||||
patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("/app/gcp/depPatch.yaml", `
|
||||
th.WriteF("gcp/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -87,13 +87,13 @@ metadata:
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
th.WriteK("/app/emea", `
|
||||
th.WriteK("emea", `
|
||||
namePrefix: emea-
|
||||
resources:
|
||||
- ../prod
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/emea/deployment.yaml", `
|
||||
th.WriteF("emea/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -104,16 +104,16 @@ spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
namePrefix: prod-
|
||||
resources:
|
||||
- ../base
|
||||
`)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -124,7 +124,7 @@ spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
m := th.Run("/app/gcp", th.MakeDefaultOptions())
|
||||
m := th.Run("gcp", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -153,14 +153,14 @@ spec:
|
||||
// instead of prod-foo
|
||||
func TestIntermediateNameAmbiguous(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/gcp", `
|
||||
th.WriteK("gcp", `
|
||||
namePrefix: gcp-
|
||||
resources:
|
||||
- ../emea
|
||||
patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("/app/gcp/depPatch.yaml", `
|
||||
th.WriteF("gcp/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -168,13 +168,13 @@ metadata:
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
th.WriteK("/app/emea", `
|
||||
th.WriteK("emea", `
|
||||
namePrefix: emea-
|
||||
resources:
|
||||
- ../prod
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/emea/deployment.yaml", `
|
||||
th.WriteF("emea/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -185,16 +185,16 @@ spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
th.WriteK("/app/prod", `
|
||||
th.WriteK("prod", `
|
||||
namePrefix: prod-
|
||||
resources:
|
||||
- ../base
|
||||
`)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -205,7 +205,7 @@ spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
err := th.RunWithErr("/app/gcp", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("gcp", th.MakeDefaultOptions())
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -220,13 +220,13 @@ namePrefix: project-
|
||||
resources:
|
||||
- app`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK("app", `
|
||||
resources:
|
||||
- resources/deployment.yaml
|
||||
- resources/xql
|
||||
`)
|
||||
|
||||
th.WriteK("/app/resources/xql", `
|
||||
th.WriteK("app/resources/xql", `
|
||||
resources:
|
||||
- xql-zero
|
||||
- xql-one
|
||||
@@ -234,12 +234,12 @@ configurations:
|
||||
- ./kustomizeconfig.yaml
|
||||
`)
|
||||
|
||||
th.WriteF("/app/resources/xql/kustomizeconfig.yaml", `
|
||||
th.WriteF("app/resources/xql/kustomizeconfig.yaml", `
|
||||
varReference:
|
||||
- path: spec/template/spec/containers/env/valueFrom/secretKeyRef/name
|
||||
`)
|
||||
|
||||
th.WriteK("/app/resources/xql/xql-one", `
|
||||
th.WriteK("app/resources/xql/xql-one", `
|
||||
namePrefix: xql-one-
|
||||
resources:
|
||||
- ../../../../bases/xql
|
||||
@@ -258,11 +258,11 @@ vars:
|
||||
fieldpath: metadata.name
|
||||
`)
|
||||
|
||||
th.WriteF("/app/resources/xql/xql-one/config/xql-one-secret.env", `
|
||||
th.WriteF("app/resources/xql/xql-one/config/xql-one-secret.env", `
|
||||
arg=1
|
||||
`)
|
||||
|
||||
th.WriteK("/app/resources/xql/xql-zero", `
|
||||
th.WriteK("app/resources/xql/xql-zero", `
|
||||
namePrefix: xql-zero-
|
||||
resources:
|
||||
- ../../../../bases/xql
|
||||
@@ -281,7 +281,7 @@ vars:
|
||||
fieldpath: metadata.name
|
||||
`)
|
||||
|
||||
th.WriteF("/app/resources/xql/xql-zero/config/xql-zero-secret.env", `
|
||||
th.WriteF("app/resources/xql/xql-zero/config/xql-zero-secret.env", `
|
||||
arg=0
|
||||
`)
|
||||
|
||||
@@ -320,7 +320,7 @@ spec:
|
||||
key: password
|
||||
`)
|
||||
|
||||
th.WriteK("/bases/xql", `
|
||||
th.WriteK("bases/xql", `
|
||||
secretGenerator:
|
||||
- name: xql-secret
|
||||
envs:
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestKeepEmptyArray(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/resources.yaml", `
|
||||
th.WriteF("resources.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -24,11 +24,11 @@ spec:
|
||||
imagePullPolicy: IfNotPresent
|
||||
imagePullSecrets: []`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- resources.yaml`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -5,6 +5,7 @@ package krusty
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/builtins"
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
@@ -35,7 +36,7 @@ type Kustomizer struct {
|
||||
func MakeKustomizer(o *Options) *Kustomizer {
|
||||
return &Kustomizer{
|
||||
options: o,
|
||||
depProvider: provider.NewDepProvider(o.UseKyaml),
|
||||
depProvider: provider.NewDepProvider(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +52,7 @@ func MakeKustomizer(o *Options) *Kustomizer {
|
||||
// and Run can be called on each of them).
|
||||
func (b *Kustomizer) Run(
|
||||
fSys filesys.FileSystem, path string) (resmap.ResMap, error) {
|
||||
resmapFactory := resmap.NewFactory(
|
||||
b.depProvider.GetResourceFactory(),
|
||||
b.depProvider.GetConflictDetectorFactory())
|
||||
resmapFactory := resmap.NewFactory(b.depProvider.GetResourceFactory())
|
||||
lr := fLdr.RestrictionNone
|
||||
if b.options.LoadRestrictions == types.LoadRestrictionsRootOnly {
|
||||
lr = fLdr.RestrictionRootOnly
|
||||
@@ -67,13 +66,21 @@ func (b *Kustomizer) Run(
|
||||
ldr,
|
||||
b.depProvider.GetFieldValidator(),
|
||||
resmapFactory,
|
||||
pLdr.NewLoader(b.options.PluginConfig, resmapFactory),
|
||||
// The plugin configs are always located on disk, regardless of the fSys passed in
|
||||
pLdr.NewLoader(b.options.PluginConfig, resmapFactory, filesys.MakeFsOnDisk()),
|
||||
)
|
||||
err = kt.Load()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = openapi.SetSchemaVersion(kt.Kustomization().OpenAPI, true)
|
||||
var bytes []byte
|
||||
if openApiPath, exists := kt.Kustomization().OpenAPI["path"]; exists {
|
||||
bytes, err = ldr.Load(filepath.Join(ldr.Root(), openApiPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = openapi.SetSchema(kt.Kustomization().OpenAPI, bytes, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestAddManagedbyLabel(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/service.yaml", `
|
||||
th.WriteF("service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -20,7 +20,7 @@ spec:
|
||||
ports:
|
||||
- port: 7002
|
||||
`)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
@@ -28,7 +28,7 @@ resources:
|
||||
`)
|
||||
options := th.MakeDefaultOptions()
|
||||
options.AddManagedbyLabel = true
|
||||
m := th.Run("/app", options)
|
||||
m := th.Run(".", options)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func makeCommonFileForMergeEnvFromTest(th kusttest_test.Harness) {
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -33,7 +33,7 @@ spec:
|
||||
func TestMergeEnvFrom(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForMergeEnvFromTest(th)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
@@ -52,7 +52,7 @@ patchesStrategicMerge:
|
||||
- configMapRef:
|
||||
name: another-config
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -73,7 +73,7 @@ spec:
|
||||
func TestMergeEnvFromViaJsonInline(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFileForMergeEnvFromTest(th)
|
||||
th.WriteK("app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
patches:
|
||||
@@ -87,7 +87,7 @@ patches:
|
||||
configMapRef:
|
||||
name: another-config
|
||||
`)
|
||||
m := th.Run("app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
32
api/krusty/multibytecharacter_test.go
Normal file
32
api/krusty/multibytecharacter_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
)
|
||||
|
||||
func TestMultibyteCharInConfigMap(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- resources.yaml
|
||||
`)
|
||||
th.WriteF("resources.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: game-config
|
||||
data:
|
||||
key: あ
|
||||
`)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
key: あ
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: game-config
|
||||
`)
|
||||
}
|
||||
@@ -4,8 +4,6 @@
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
@@ -237,6 +235,7 @@ metadata:
|
||||
`)
|
||||
}
|
||||
|
||||
// Goal is to remove " emptyDir: {}" with a patch.
|
||||
func TestRemoveEmptyDirWithPatchesAtSameLevel(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("base", `
|
||||
@@ -300,7 +299,9 @@ spec:
|
||||
`)
|
||||
opts := th.MakeDefaultOptions()
|
||||
m := th.Run("overlay", opts)
|
||||
expFmt := `apiVersion: apps/v1
|
||||
th.AssertActualEqualsExpected(
|
||||
m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx
|
||||
@@ -315,21 +316,11 @@ spec:
|
||||
name: nginx
|
||||
- image: sidecar:latest
|
||||
name: sidecar
|
||||
volumes:%s
|
||||
name: nginx-persistent-storage
|
||||
`
|
||||
th.AssertActualEqualsExpected(
|
||||
// TODO(#3394): Should be possible to delete emptyDir with a patch.
|
||||
// TODO(#3304): DECISION - still a bug, emptyDir should be deleted.
|
||||
m, opts.IfApiMachineryElseKyaml(
|
||||
fmt.Sprintf(expFmt, `
|
||||
volumes:
|
||||
- gcePersistentDisk:
|
||||
pdName: nginx-persistent-storage`),
|
||||
fmt.Sprintf(expFmt, `
|
||||
- emptyDir: {}
|
||||
gcePersistentDisk:
|
||||
pdName: nginx-persistent-storage`),
|
||||
))
|
||||
pdName: nginx-persistent-storage
|
||||
name: nginx-persistent-storage
|
||||
`)
|
||||
}
|
||||
|
||||
func TestSimpleMultiplePatches(t *testing.T) {
|
||||
@@ -506,7 +497,7 @@ metadata:
|
||||
}
|
||||
|
||||
func makeCommonFilesForMultiplePatchTests(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namePrefix: team-foo-
|
||||
commonLabels:
|
||||
app: mynginx
|
||||
@@ -522,7 +513,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- foo=bar
|
||||
`)
|
||||
th.WriteF("/app/base/deployment.yaml", `
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -548,7 +539,7 @@ spec:
|
||||
name: configmap-in-base
|
||||
name: configmap-in-base
|
||||
`)
|
||||
th.WriteF("/app/base/service.yaml", `
|
||||
th.WriteF("base/service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -561,7 +552,7 @@ spec:
|
||||
selector:
|
||||
app: nginx
|
||||
`)
|
||||
th.WriteK("/app/overlay/staging", `
|
||||
th.WriteK("overlay/staging", `
|
||||
namePrefix: staging-
|
||||
commonLabels:
|
||||
env: staging
|
||||
@@ -580,7 +571,7 @@ configMapGenerator:
|
||||
func TestMultiplePatchesNoConflict(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFilesForMultiplePatchTests(th)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||
th.WriteF("overlay/staging/deployment-patch1.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -602,7 +593,7 @@ spec:
|
||||
name: configmap-in-overlay
|
||||
name: configmap-in-overlay
|
||||
`)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", `
|
||||
th.WriteF("overlay/staging/deployment-patch2.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -616,7 +607,7 @@ spec:
|
||||
- name: ANOTHERENV
|
||||
value: FOO
|
||||
`)
|
||||
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay/staging", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -715,10 +706,10 @@ metadata:
|
||||
`)
|
||||
}
|
||||
|
||||
func TestMultiplePatchesWithConflict(t *testing.T) {
|
||||
func TestNonCommutablePatches(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFilesForMultiplePatchTests(th)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||
th.WriteF("overlay/staging/deployment-patch1.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -739,7 +730,7 @@ spec:
|
||||
name: configmap-in-overlay
|
||||
name: configmap-in-overlay
|
||||
`)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", `
|
||||
th.WriteF("overlay/staging/deployment-patch2.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -753,12 +744,10 @@ spec:
|
||||
- name: ENABLE_FEATURE_FOO
|
||||
value: FALSE
|
||||
`)
|
||||
opts := th.MakeDefaultOptions()
|
||||
if opts.UseKyaml {
|
||||
// kyaml doesn't try to detect conflicts in patches
|
||||
// (so ENABLE_FEATURE_FOO FALSE wins).
|
||||
m := th.Run("/app/overlay/staging", opts)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
// kyaml doesn't try to detect conflicts in patches
|
||||
// (so ENABLE_FEATURE_FOO FALSE wins).
|
||||
m := th.Run("overlay/staging", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -852,16 +841,6 @@ metadata:
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultiplePatchesWithOnePatchDeleteDirective(t *testing.T) {
|
||||
@@ -889,30 +868,28 @@ spec:
|
||||
- $patch: delete
|
||||
name: sidecar
|
||||
`
|
||||
cases := []struct {
|
||||
name string
|
||||
cases := map[string]struct {
|
||||
patch1 string
|
||||
patch2 string
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
name: "Patch with delete directive first",
|
||||
"Patch with delete directive first": {
|
||||
patch1: deletePatch,
|
||||
patch2: additivePatch,
|
||||
},
|
||||
{
|
||||
name: "Patch with delete directive second",
|
||||
"Patch with delete directive second": {
|
||||
patch1: additivePatch,
|
||||
patch2: deletePatch,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
for name := range cases {
|
||||
c := cases[name]
|
||||
t.Run(name, func(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFilesForMultiplePatchTests(th)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", c.patch1)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", c.patch2)
|
||||
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||
th.WriteF("overlay/staging/deployment-patch1.yaml", c.patch1)
|
||||
th.WriteF("overlay/staging/deployment-patch2.yaml", c.patch2)
|
||||
m := th.Run("overlay/staging", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1005,7 +982,7 @@ metadata:
|
||||
func TestMultiplePatchesBothWithPatchDeleteDirective(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
makeCommonFilesForMultiplePatchTests(th)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||
th.WriteF("overlay/staging/deployment-patch1.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1017,7 +994,7 @@ spec:
|
||||
- $patch: delete
|
||||
name: sidecar
|
||||
`)
|
||||
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", `
|
||||
th.WriteF("overlay/staging/deployment-patch2.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1029,12 +1006,10 @@ spec:
|
||||
- $patch: delete
|
||||
name: nginx
|
||||
`)
|
||||
opt := th.MakeDefaultOptions()
|
||||
if opt.UseKyaml {
|
||||
// kyaml doesn't fail on conflicts in patches; both containers
|
||||
// (nginx and sidecar) are deleted per this patching instruction.
|
||||
m := th.Run("/app/overlay/staging", opt)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
// kyaml doesn't fail on conflicts in patches; both containers
|
||||
// (nginx and sidecar) are deleted per this patching instruction.
|
||||
m := th.Run("overlay/staging", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -1112,17 +1087,6 @@ metadata:
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test for #3513
|
||||
@@ -1191,25 +1155,184 @@ spec:
|
||||
- image: dashicorp/consul:1.9.1
|
||||
name: consul
|
||||
ports:
|
||||
- containerPort: 8500
|
||||
name: http
|
||||
- containerPort: 8501
|
||||
name: https
|
||||
- containerPort: 8301
|
||||
name: serflan-tcp
|
||||
protocol: TCP
|
||||
- containerPort: 8301
|
||||
name: serflan-udp
|
||||
protocol: UDP
|
||||
- containerPort: 8302
|
||||
name: serfwan
|
||||
- containerPort: 8300
|
||||
name: server
|
||||
- containerPort: 8600
|
||||
name: dns-tcp
|
||||
protocol: TCP
|
||||
- containerPort: 8600
|
||||
name: dns-udp
|
||||
protocol: UDP
|
||||
- containerPort: 8500
|
||||
name: http
|
||||
- containerPort: 8501
|
||||
name: https
|
||||
- containerPort: 8302
|
||||
name: serfwan
|
||||
- containerPort: 8300
|
||||
name: server
|
||||
`)
|
||||
}
|
||||
|
||||
// test for #3616
|
||||
func TestSmpDeleteOnResource(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- workloads.yaml
|
||||
patches:
|
||||
- patch: |
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: rule1
|
||||
$patch: delete
|
||||
`)
|
||||
th.WriteF("workloads.yaml", `
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
labels:
|
||||
role: alert-rules
|
||||
name: rule1
|
||||
spec:
|
||||
groups:
|
||||
- name: rabbitmq.rules
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
labels:
|
||||
role: alert-rules
|
||||
name: rule2
|
||||
spec:
|
||||
groups:
|
||||
- name: rabbitmq.rules
|
||||
`)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
labels:
|
||||
role: alert-rules
|
||||
name: rule2
|
||||
spec:
|
||||
groups:
|
||||
- name: rabbitmq.rules
|
||||
`)
|
||||
}
|
||||
|
||||
// test for #3620
|
||||
func TestPatchPortHasNoProtocol(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- service.yaml
|
||||
patchesStrategicMerge:
|
||||
- patch.yaml
|
||||
`)
|
||||
th.WriteF("service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
spec:
|
||||
ports:
|
||||
- port: 30900
|
||||
targetPort: 30900
|
||||
protocol: TCP
|
||||
type: NodePort
|
||||
`)
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
labels:
|
||||
service: web
|
||||
spec:
|
||||
ports:
|
||||
- port: 30900
|
||||
targetPort: 30900
|
||||
selector:
|
||||
service: web
|
||||
`)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
service: web
|
||||
name: web
|
||||
spec:
|
||||
ports:
|
||||
- port: 30900
|
||||
protocol: TCP
|
||||
targetPort: 30900
|
||||
selector:
|
||||
service: web
|
||||
type: NodePort
|
||||
`)
|
||||
}
|
||||
|
||||
// test for #3620
|
||||
func TestPatchAddNewServicePort(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- service.yaml
|
||||
patchesStrategicMerge:
|
||||
- patch.yaml
|
||||
`)
|
||||
th.WriteF("service.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
spec:
|
||||
ports:
|
||||
- port: 30900
|
||||
targetPort: 30900
|
||||
protocol: TCP
|
||||
type: NodePort
|
||||
`)
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
labels:
|
||||
service: web
|
||||
spec:
|
||||
ports:
|
||||
- port: 30901
|
||||
targetPort: 30901
|
||||
selector:
|
||||
service: web
|
||||
`)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
service: web
|
||||
name: web
|
||||
spec:
|
||||
ports:
|
||||
- port: 30901
|
||||
targetPort: 30901
|
||||
- port: 30900
|
||||
protocol: TCP
|
||||
targetPort: 30900
|
||||
selector:
|
||||
service: web
|
||||
type: NodePort
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
@@ -265,9 +264,9 @@ kind: ServiceAccount
|
||||
metadata:
|
||||
name: external-dns
|
||||
`)
|
||||
opts := th.MakeDefaultOptions()
|
||||
m := th.Run(".", opts)
|
||||
expFmt := `
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(
|
||||
m, `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -353,7 +352,7 @@ spec:
|
||||
volumes:
|
||||
- name: azure-config-file
|
||||
secret:
|
||||
secretName: azure-config-file-%s
|
||||
secretName: azure-config-file-66cc4224mm
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -366,13 +365,18 @@ metadata:
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
azure.json: %s
|
||||
azure.json: |
|
||||
ewoJInRlbmFudElkIjogIlhYWFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIiwKCS
|
||||
JzdWJzY3JpcHRpb25JZCI6ICJYWFhYWC1YWFhYWFgtWFhYWFgtWFhYWFhYLVhYWFhYWCIs
|
||||
CgkicmVzb3VyY2VHcm91cCI6ICJETlMtRVVXLVhYWC1SRyIsCgkidXNlTWFuYWdlZElkZW
|
||||
50aXR5RXh0ZW5zaW9uIjogdHJ1ZSwKCSJ1c2VyQXNzaWduZWRJZGVudGl0eUlEIjogIlhY
|
||||
WFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIgp9Cg==
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
app: external-dns
|
||||
instance: public
|
||||
name: azure-config-file-%s
|
||||
name: azure-config-file-66cc4224mm
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
---
|
||||
@@ -461,7 +465,7 @@ spec:
|
||||
volumes:
|
||||
- name: azure-config-file
|
||||
secret:
|
||||
secretName: azure-config-file-private-%s
|
||||
secretName: azure-config-file-private-66cc4224mm
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -474,53 +478,32 @@ metadata:
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
azure.json: %s
|
||||
azure.json: |
|
||||
ewoJInRlbmFudElkIjogIlhYWFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIiwKCS
|
||||
JzdWJzY3JpcHRpb25JZCI6ICJYWFhYWC1YWFhYWFgtWFhYWFgtWFhYWFhYLVhYWFhYWCIs
|
||||
CgkicmVzb3VyY2VHcm91cCI6ICJETlMtRVVXLVhYWC1SRyIsCgkidXNlTWFuYWdlZElkZW
|
||||
50aXR5RXh0ZW5zaW9uIjogdHJ1ZSwKCSJ1c2VyQXNzaWduZWRJZGVudGl0eUlEIjogIlhY
|
||||
WFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIgp9Cg==
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
app: external-dns
|
||||
instance: private
|
||||
name: azure-config-file-private-%s
|
||||
name: azure-config-file-private-66cc4224mm
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
`
|
||||
const (
|
||||
nameHashKyaml = "66cc4224mm"
|
||||
contentKyaml = `|
|
||||
ewoJInRlbmFudElkIjogIlhYWFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIiwKCS
|
||||
JzdWJzY3JpcHRpb25JZCI6ICJYWFhYWC1YWFhYWFgtWFhYWFgtWFhYWFhYLVhYWFhYWCIs
|
||||
CgkicmVzb3VyY2VHcm91cCI6ICJETlMtRVVXLVhYWC1SRyIsCgkidXNlTWFuYWdlZElkZW
|
||||
50aXR5RXh0ZW5zaW9uIjogdHJ1ZSwKCSJ1c2VyQXNzaWduZWRJZGVudGl0eUlEIjogIlhY
|
||||
WFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIgp9Cg==`
|
||||
nameHashApiMach = "g2k4bkgt4d"
|
||||
// nolint: lll
|
||||
contentApiMach = `ewoJInRlbmFudElkIjogIlhYWFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIiwKCSJzdWJzY3JpcHRpb25JZCI6ICJYWFhYWC1YWFhYWFgtWFhYWFgtWFhYWFhYLVhYWFhYWCIsCgkicmVzb3VyY2VHcm91cCI6ICJETlMtRVVXLVhYWC1SRyIsCgkidXNlTWFuYWdlZElkZW50aXR5RXh0ZW5zaW9uIjogdHJ1ZSwKCSJ1c2VyQXNzaWduZWRJZGVudGl0eUlEIjogIlhYWFhYLVhYWFhYWC1YWFhYWC1YWFhYWFgtWFhYWFhYIgp9Cg==`
|
||||
)
|
||||
th.AssertActualEqualsExpected(
|
||||
m,
|
||||
// TODO(#3304): DECISION - kyaml better; not a bug.
|
||||
opts.IfApiMachineryElseKyaml(
|
||||
fmt.Sprintf(expFmt,
|
||||
nameHashApiMach,
|
||||
contentApiMach, nameHashApiMach,
|
||||
nameHashApiMach,
|
||||
contentApiMach, nameHashApiMach),
|
||||
fmt.Sprintf(expFmt,
|
||||
nameHashKyaml,
|
||||
contentKyaml, nameHashKyaml,
|
||||
nameHashKyaml,
|
||||
contentKyaml, nameHashKyaml)))
|
||||
`)
|
||||
}
|
||||
|
||||
func TestEmptyFieldSpecValue(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
generators:
|
||||
- generators.yaml
|
||||
configurations:
|
||||
- kustomizeconfig.yaml
|
||||
`)
|
||||
th.WriteF("/app/generators.yaml", `
|
||||
th.WriteF("generators.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: ConfigMapGenerator
|
||||
metadata:
|
||||
@@ -530,7 +513,7 @@ labels:
|
||||
literals:
|
||||
- this_is_a_secret_name=
|
||||
`)
|
||||
th.WriteF("/app/kustomizeconfig.yaml", `
|
||||
th.WriteF("kustomizeconfig.yaml", `
|
||||
nameReference:
|
||||
- kind: Secret
|
||||
version: v1
|
||||
@@ -538,7 +521,7 @@ nameReference:
|
||||
- path: data/this_is_a_secret_name
|
||||
kind: ConfigMap
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestNamespacedGenerator(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
configMapGenerator:
|
||||
@@ -34,7 +34,7 @@ secretGenerator:
|
||||
literals:
|
||||
- password.txt=anotherSecret
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -74,7 +74,7 @@ type: Opaque
|
||||
|
||||
func TestNamespacedGeneratorWithOverlays(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
namespace: base
|
||||
|
||||
configMapGenerator:
|
||||
@@ -82,7 +82,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- base=apple
|
||||
`)
|
||||
th.WriteK("/app/overlay", `
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
@@ -94,7 +94,7 @@ configMapGenerator:
|
||||
literals:
|
||||
- overlay=peach
|
||||
`)
|
||||
m := th.Run("/app/overlay", th.MakeDefaultOptions())
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func TestNamespacedSecrets(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/secrets.yaml", `
|
||||
th.WriteF("secrets.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
@@ -33,7 +33,7 @@ data:
|
||||
`)
|
||||
|
||||
// This should find the proper secret.
|
||||
th.WriteF("/app/role.yaml", `
|
||||
th.WriteF("role.yaml", `
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
@@ -45,7 +45,7 @@ rules:
|
||||
verbs: ["get"]
|
||||
`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- secrets.yaml
|
||||
- role.yaml
|
||||
@@ -55,7 +55,7 @@ resources:
|
||||
// The ClusterRole (by def) is not in a namespace,
|
||||
// and in this case applies to *any* Secret resource
|
||||
// named "dummy"
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
@@ -306,6 +306,19 @@ kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: crds.my.org
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: namespace.crds.my.org
|
||||
spec:
|
||||
conversion:
|
||||
strategy: Webhook
|
||||
webhook:
|
||||
clientConfig:
|
||||
service:
|
||||
name: crd-svc
|
||||
namespace: random
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -407,6 +420,19 @@ kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: crds.my.org
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: namespace.crds.my.org
|
||||
spec:
|
||||
conversion:
|
||||
strategy: Webhook
|
||||
webhook:
|
||||
clientConfig:
|
||||
service:
|
||||
name: crd-svc
|
||||
namespace: newnamespace
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -722,14 +748,14 @@ func TestVariablesDisambiguatedWithNamespace(t *testing.T) {
|
||||
func TestAddNamePrefixWithNamespace(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
th.WriteF("/app/serviceaccount.yaml", `
|
||||
th.WriteF("serviceaccount.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: prometheus
|
||||
`)
|
||||
|
||||
th.WriteF("/app/clusterrolebinding.yaml", `
|
||||
th.WriteF("clusterrolebinding.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
@@ -744,7 +770,7 @@ subjects:
|
||||
namespace: iter8-monitoring
|
||||
`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
namePrefix: iter8-
|
||||
namespace: iter8-monitoring
|
||||
resources:
|
||||
@@ -752,7 +778,7 @@ resources:
|
||||
- serviceaccount.yaml
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/2640
|
||||
func TestNameUpdateInRoleRef(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/rbac.yaml", `
|
||||
th.WriteF("rbac.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -61,7 +61,7 @@ subjects:
|
||||
name: default
|
||||
`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
namespace: foo
|
||||
resources:
|
||||
- rbac.yaml
|
||||
@@ -78,7 +78,7 @@ patches:
|
||||
name: my-role
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
@@ -138,7 +138,7 @@ subjects:
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/3073
|
||||
func TestNameUpdateInRoleRef2(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/workloads.yaml", `
|
||||
th.WriteF("workloads.yaml", `
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -198,7 +198,7 @@ subjects:
|
||||
name: myapp
|
||||
`)
|
||||
|
||||
th.WriteF("/app/suffixTransformer.yaml", `
|
||||
th.WriteF("suffixTransformer.yaml", `
|
||||
apiVersion: builtin
|
||||
kind: PrefixSuffixTransformer
|
||||
metadata:
|
||||
@@ -213,7 +213,7 @@ fieldSpecs:
|
||||
name: myapp
|
||||
`)
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
@@ -224,7 +224,7 @@ namespace: test
|
||||
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestNullValues1(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -32,13 +32,13 @@ spec:
|
||||
image: image
|
||||
name: example
|
||||
`)
|
||||
th.WriteF("/app/kustomization.yaml", `
|
||||
th.WriteF("kustomization.yaml", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestNumericCommonLabels(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
|
||||
// A basic deployment just used to put labels into
|
||||
th.WriteF("/app/default/deployment.yaml", `
|
||||
th.WriteF("default/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -24,14 +24,14 @@ metadata:
|
||||
// Combine these custom transformers in one kustomization file.
|
||||
// This kustomization file has a string-valued commonLabel that
|
||||
// should always be quoted to remain a string
|
||||
th.WriteK("/app/default", `
|
||||
th.WriteK("default", `
|
||||
commonLabels:
|
||||
version: "1"
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
|
||||
m := th.Run("/app/default", th.MakeDefaultOptions())
|
||||
m := th.Run("default", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
234
api/krusty/openapicustomschema_test.go
Normal file
234
api/krusty/openapicustomschema_test.go
Normal file
@@ -0,0 +1,234 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
"sigs.k8s.io/kustomize/kyaml/openapi"
|
||||
)
|
||||
|
||||
func writeTestSchema(th kusttest_test.Harness, filepath string) {
|
||||
bytes, _ := ioutil.ReadFile("testdata/customschema.json")
|
||||
th.WriteF(filepath+"mycrd_schema.json", string(bytes))
|
||||
}
|
||||
|
||||
func writeCustomResource(th kusttest_test.Harness, filepath string) {
|
||||
th.WriteF(filepath, `
|
||||
apiVersion: example.com/v1alpha1
|
||||
kind: MyCRD
|
||||
metadata:
|
||||
name: service
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: server
|
||||
command: example
|
||||
ports:
|
||||
- name: grpc
|
||||
protocol: TCP
|
||||
containerPort: 8080
|
||||
`)
|
||||
}
|
||||
|
||||
func writeTestComponentWithCustomSchema(th kusttest_test.Harness) {
|
||||
writeTestSchema(th, "comp/")
|
||||
openapi.ResetOpenAPI()
|
||||
th.WriteC("comp", `
|
||||
openapi:
|
||||
path: mycrd_schema.json
|
||||
`)
|
||||
th.WriteF("comp/stub.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: stub
|
||||
spec:
|
||||
replicas: 1
|
||||
`)
|
||||
}
|
||||
|
||||
const customSchemaPatch = `
|
||||
patchesStrategicMerge:
|
||||
- |-
|
||||
apiVersion: example.com/v1alpha1
|
||||
kind: MyCRD
|
||||
metadata:
|
||||
name: service
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: nginx
|
||||
`
|
||||
|
||||
const patchedCustomResource = `
|
||||
apiVersion: example.com/v1alpha1
|
||||
kind: MyCRD
|
||||
metadata:
|
||||
name: service
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- command: example
|
||||
image: nginx
|
||||
name: server
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: grpc
|
||||
protocol: TCP
|
||||
`
|
||||
|
||||
// Test for issue #2825
|
||||
func TestCustomOpenApiFieldBasicUsage(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
openapi:
|
||||
path: mycrd_schema.json
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "mycrd.yaml")
|
||||
writeTestSchema(th, "./")
|
||||
openapi.ResetOpenAPI()
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, patchedCustomResource)
|
||||
}
|
||||
|
||||
// Error if user tries to specify both builtin version
|
||||
// and custom schema
|
||||
func TestCustomOpenApiFieldBothPathAndVersion(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
openapi:
|
||||
version: v1.20.4
|
||||
path: mycrd_schema.json
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "mycrd.yaml")
|
||||
writeTestSchema(th, "./")
|
||||
openapi.ResetOpenAPI()
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t,
|
||||
"builtin version and custom schema provided, cannot use both",
|
||||
err.Error())
|
||||
}
|
||||
|
||||
// Test for if the filepath specified is not found
|
||||
func TestCustomOpenApiFieldFileNotFound(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
openapi:
|
||||
path: mycrd_schema.json
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "mycrd.yaml")
|
||||
openapi.ResetOpenAPI()
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t,
|
||||
"'/mycrd_schema.json' doesn't exist",
|
||||
err.Error())
|
||||
}
|
||||
|
||||
func TestCustomOpenApiFieldFromBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
openapi:
|
||||
path: mycrd_schema.json
|
||||
`)
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "base/mycrd.yaml")
|
||||
writeTestSchema(th, "base/")
|
||||
openapi.ResetOpenAPI()
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, patchedCustomResource)
|
||||
assert.Equal(t, "using custom schema from file provided",
|
||||
openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestCustomOpenApiFieldFromOverlay(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
`)
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
openapi:
|
||||
path: mycrd_schema.json
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "base/mycrd.yaml")
|
||||
writeTestSchema(th, "overlay/")
|
||||
openapi.ResetOpenAPI()
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, patchedCustomResource)
|
||||
assert.Equal(t, "using custom schema from file provided",
|
||||
openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestCustomOpenApiFieldOverlayTakesPrecedence(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
openapi.ResetOpenAPI()
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
openapi:
|
||||
path: mycrd_schema.json
|
||||
`)
|
||||
th.WriteK("overlay", `
|
||||
resources:
|
||||
- ../base
|
||||
openapi:
|
||||
version: v1.20.4
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "base/mycrd.yaml")
|
||||
writeTestSchema(th, "base/")
|
||||
openapi.ResetOpenAPI()
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: example.com/v1alpha1
|
||||
kind: MyCRD
|
||||
metadata:
|
||||
name: service
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: server
|
||||
`)
|
||||
assert.Equal(t, "v1204", openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestCustomOpenAPIFieldFromComponent(t *testing.T) {
|
||||
input := []FileGen{
|
||||
writeTestBase,
|
||||
writeTestComponentWithCustomSchema,
|
||||
writeOverlayProd}
|
||||
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
for _, f := range input {
|
||||
f(th)
|
||||
}
|
||||
openapi.ResetOpenAPI()
|
||||
th.Run("prod", th.MakeDefaultOptions())
|
||||
assert.Equal(t, "using custom schema from file provided", openapi.GetSchemaVersion())
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
@@ -11,13 +14,13 @@ import (
|
||||
|
||||
func TestOpenApiFieldBasicUsage(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
openapi:
|
||||
version: v1.18.8
|
||||
version: v1.20.4
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -29,7 +32,7 @@ spec:
|
||||
- image: whatever
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -41,18 +44,18 @@ spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
assert.Equal(t, "v1188", openapi.GetSchemaVersion())
|
||||
assert.Equal(t, "v1204", openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestOpenApiFieldNotBuiltin(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
openapi:
|
||||
version: v1.14.1
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -64,7 +67,7 @@ spec:
|
||||
- image: whatever
|
||||
`)
|
||||
|
||||
err := th.RunWithErr("/app", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error")
|
||||
}
|
||||
@@ -72,11 +75,11 @@ spec:
|
||||
|
||||
func TestOpenApiFieldDefaultVersion(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("/app/deployment.yaml", `
|
||||
th.WriteF("deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -88,7 +91,7 @@ spec:
|
||||
- image: whatever
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -102,200 +105,3 @@ spec:
|
||||
`)
|
||||
assert.Equal(t, kubernetesapi.DefaultOpenAPI, openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestOpenApiFieldFromBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("base", `
|
||||
openapi:
|
||||
version: v1.19.0
|
||||
namePrefix: a-
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
th.WriteK("overlay", `
|
||||
namePrefix: b-
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeployment
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: b-a-myDeployment
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
assert.Equal(t, "v1190", openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestOpenApiFieldFromOverlay(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("base", `
|
||||
namePrefix: a-
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
th.WriteK("overlay", `
|
||||
openapi:
|
||||
version: v1.18.8
|
||||
namePrefix: b-
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeployment
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: b-a-myDeployment
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
assert.Equal(t, "v1188", openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestOpenApiFieldOverlayTakesPrecedence(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("base", `
|
||||
openapi:
|
||||
version: v1.19.0
|
||||
namePrefix: a-
|
||||
resources:
|
||||
- deployment.yaml
|
||||
`)
|
||||
th.WriteF("base/deployment.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
th.WriteK("overlay", `
|
||||
openapi:
|
||||
version: v1.18.8
|
||||
namePrefix: b-
|
||||
resources:
|
||||
- ../base
|
||||
patchesStrategicMerge:
|
||||
- depPatch.yaml
|
||||
`)
|
||||
th.WriteF("overlay/depPatch.yaml", `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeployment
|
||||
spec:
|
||||
replicas: 999
|
||||
`)
|
||||
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: b-a-myDeployment
|
||||
spec:
|
||||
replicas: 999
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: whatever
|
||||
`)
|
||||
assert.Equal(t, "v1188", openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func TestOpenAPIFieldFromComponentDefault(t *testing.T) {
|
||||
input := []FileGen{writeTestBase, writeTestComponent, writeOverlayProd}
|
||||
runPath := "/app/prod"
|
||||
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
for _, f := range input {
|
||||
f(th)
|
||||
}
|
||||
th.Run(runPath, th.MakeDefaultOptions())
|
||||
assert.Equal(t, kubernetesapi.DefaultOpenAPI, openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
func writeTestComponentWithOlderOpenAPIVersion(th kusttest_test.Harness) {
|
||||
th.WriteC("/app/comp", `
|
||||
openapi:
|
||||
version: v1.18.8
|
||||
`)
|
||||
th.WriteF("/app/comp/stub.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: stub
|
||||
spec:
|
||||
replicas: 1
|
||||
`)
|
||||
}
|
||||
|
||||
func TestOpenAPIFieldFromComponent(t *testing.T) {
|
||||
input := []FileGen{
|
||||
writeTestBase,
|
||||
writeTestComponentWithOlderOpenAPIVersion,
|
||||
writeOverlayProd}
|
||||
runPath := "/app/prod"
|
||||
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
for _, f := range input {
|
||||
f(th)
|
||||
}
|
||||
th.Run(runPath, th.MakeDefaultOptions())
|
||||
assert.Equal(t, "v1188", openapi.GetSchemaVersion())
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package krusty
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/builtinhelpers"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
|
||||
@@ -33,37 +32,19 @@ type Options struct {
|
||||
|
||||
// Options related to kustomize plugins.
|
||||
PluginConfig *types.PluginConfig
|
||||
|
||||
// TODO(#3588): Delete this field (it's always true).
|
||||
// When true, use kyaml/ packages to manipulate KRM yaml.
|
||||
// When false, use k8sdeps/ instead (uses k8s.io/api* packages).
|
||||
UseKyaml bool
|
||||
|
||||
// When true, allow name and kind changing via a patch
|
||||
// When false, patch name/kind don't overwrite target name/kind
|
||||
AllowResourceIdChanges bool
|
||||
}
|
||||
|
||||
// MakeDefaultOptions returns a default instance of Options.
|
||||
func MakeDefaultOptions() *Options {
|
||||
return &Options{
|
||||
DoLegacyResourceSort: false,
|
||||
AddManagedbyLabel: false,
|
||||
LoadRestrictions: types.LoadRestrictionsRootOnly,
|
||||
DoPrune: false,
|
||||
PluginConfig: konfig.DisabledPluginConfig(),
|
||||
UseKyaml: konfig.FlagEnableKyamlDefaultValue,
|
||||
AllowResourceIdChanges: false,
|
||||
DoLegacyResourceSort: false,
|
||||
AddManagedbyLabel: false,
|
||||
LoadRestrictions: types.LoadRestrictionsRootOnly,
|
||||
DoPrune: false,
|
||||
PluginConfig: types.DisabledPluginConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
func (o Options) IfApiMachineryElseKyaml(s1, s2 string) string {
|
||||
if !o.UseKyaml {
|
||||
return s1
|
||||
}
|
||||
return s2
|
||||
}
|
||||
|
||||
// GetBuiltinPluginNames returns a list of builtin plugin names
|
||||
func GetBuiltinPluginNames() []string {
|
||||
var ret []string
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
@@ -57,7 +56,6 @@ spec:
|
||||
|
||||
func TestPodDisruptionBudgetMerging(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
opts := th.MakeDefaultOptions()
|
||||
th.WriteF("pdb-patch.yaml", `
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
@@ -97,26 +95,7 @@ patches:
|
||||
resources:
|
||||
- my_file.yaml
|
||||
`)
|
||||
m := th.Run(".", opts)
|
||||
expFmt := `
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
labels:
|
||||
faceit-pdb: default
|
||||
name: championships-api
|
||||
spec:
|
||||
maxUnavailable: %s
|
||||
---
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
labels:
|
||||
faceit-pdb: default
|
||||
name: championships-api-2
|
||||
spec:
|
||||
maxUnavailable: %s
|
||||
`
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
// In a PodDisruptionBudget, the fields maxUnavailable
|
||||
// minAvailable are mutually exclusive, and both can hold
|
||||
// either an integer, i.e. 10, or string that has to be
|
||||
@@ -126,9 +105,23 @@ spec:
|
||||
// the percent sign, quotes can be added and the API server will
|
||||
// accept it, but they don't have to be added.
|
||||
th.AssertActualEqualsExpected(
|
||||
m,
|
||||
// TODO(#3304): DECISION - kyaml better; not a bug.
|
||||
opts.IfApiMachineryElseKyaml(
|
||||
fmt.Sprintf(expFmt, `"1"`, `"1"`),
|
||||
fmt.Sprintf(expFmt, `1`, `1`)))
|
||||
m, `
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
labels:
|
||||
faceit-pdb: default
|
||||
name: championships-api
|
||||
spec:
|
||||
maxUnavailable: 1
|
||||
---
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
labels:
|
||||
faceit-pdb: default
|
||||
name: championships-api-2
|
||||
spec:
|
||||
maxUnavailable: 1
|
||||
`)
|
||||
}
|
||||
|
||||
177
api/krusty/repeatbase_test.go
Normal file
177
api/krusty/repeatbase_test.go
Normal file
@@ -0,0 +1,177 @@
|
||||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package krusty_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
)
|
||||
|
||||
// This is broken since kustomize v3.9.3.
|
||||
// See https://github.com/kubernetes-sigs/kustomize/issues/3609 for details.
|
||||
|
||||
// Here is a structure of a kustomization of one resource inheriting from
|
||||
// two bases. One of those bases is shared between the canary base and the
|
||||
// final resource. This is named canary as it is a simple pattern to
|
||||
// duplicate a resource that can be used with canary deployments.
|
||||
//
|
||||
// base
|
||||
// | deployment.yaml
|
||||
// | kustomization.yaml
|
||||
// canary
|
||||
// | deployment-canary-patch.yaml
|
||||
// | kustomization.yaml
|
||||
// mango
|
||||
// | deployment-mango-patch.yaml
|
||||
// | deployment-mango-canary-patch.yaml
|
||||
// | kustomization.yaml
|
||||
func TestRepeatBase(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: banana
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
component: banana
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: banana
|
||||
spec:
|
||||
containers:
|
||||
- name: banana
|
||||
image: image
|
||||
`)
|
||||
|
||||
th.WriteK("canary", `
|
||||
resources:
|
||||
- ../base
|
||||
patches:
|
||||
- patch: |
|
||||
- op: replace
|
||||
path: /metadata/name
|
||||
value: banana-canary
|
||||
target:
|
||||
kind: Deployment
|
||||
- path: deployment-canary-patch.yaml
|
||||
`)
|
||||
th.WriteF("canary/deployment-canary-patch.yaml", `
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: banana-canary
|
||||
labels:
|
||||
type: canary
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
component: banana
|
||||
type: canary
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: banana
|
||||
type: canary
|
||||
spec:
|
||||
containers:
|
||||
- name: banana
|
||||
image: image-canary
|
||||
`)
|
||||
|
||||
th.WriteK("mango", `
|
||||
nameSuffix: -mango
|
||||
resources:
|
||||
- ../base
|
||||
- ../canary
|
||||
patches:
|
||||
- path: deployment-mango-base-patch.yaml
|
||||
- path: deployment-mango-canary-patch.yaml
|
||||
`)
|
||||
th.WriteF("mango/deployment-mango-base-patch.yaml", `
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: banana
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: banana
|
||||
image: image-mango
|
||||
`)
|
||||
th.WriteF("mango/deployment-mango-canary-patch.yaml", `
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: banana-canary
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: banana
|
||||
image: image-canary-mango
|
||||
`)
|
||||
|
||||
err := th.RunWithErr("mango", th.MakeDefaultOptions())
|
||||
if !strings.Contains(
|
||||
err.Error(), "multiple matches for Id apps_v1_Deployment|~X|banana; failed to find unique target for patch") {
|
||||
t.Fatalf("Unexpected err: %v", err)
|
||||
}
|
||||
|
||||
// Uncomenting the following makes it work with kustomize v3.9.2 and bellow.
|
||||
|
||||
// m := th.Run("/app", th.MakeDefaultOptions())
|
||||
// th.AssertActualEqualsExpected(m, `
|
||||
//apiVersion: apps/v1
|
||||
//kind: Deployment
|
||||
//metadata:
|
||||
// name: deployment-a
|
||||
//spec:
|
||||
// selector:
|
||||
// matchLabels:
|
||||
// component: deployment
|
||||
// template:
|
||||
// metadata:
|
||||
// labels:
|
||||
// component: deployment
|
||||
// spec:
|
||||
// containers:
|
||||
// - image: image-a
|
||||
// name: container-a
|
||||
//---
|
||||
//apiVersion: apps/v1
|
||||
//kind: Deployment
|
||||
//metadata:
|
||||
// labels:
|
||||
// type: canary
|
||||
// name: deployment-canary-a
|
||||
//spec:
|
||||
// selector:
|
||||
// matchLabels:
|
||||
// component: deployment
|
||||
// type: canary
|
||||
// template:
|
||||
// metadata:
|
||||
// labels:
|
||||
// component: deployment
|
||||
// spec:
|
||||
// containers:
|
||||
// - image: image-canary-a
|
||||
// name: container-a
|
||||
//`)
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func writeBase(th kusttest_test.Harness) {
|
||||
th.WriteK("/app/base", `
|
||||
th.WriteK("base", `
|
||||
resources:
|
||||
- serviceaccount.yaml
|
||||
- rolebinding.yaml
|
||||
@@ -20,13 +20,13 @@ resources:
|
||||
namePrefix: pfx-
|
||||
nameSuffix: -sfx
|
||||
`)
|
||||
th.WriteF("/app/base/serviceaccount.yaml", `
|
||||
th.WriteF("base/serviceaccount.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: serviceaccount
|
||||
`)
|
||||
th.WriteF("/app/base/rolebinding.yaml", `
|
||||
th.WriteF("base/rolebinding.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
@@ -39,7 +39,7 @@ subjects:
|
||||
- kind: ServiceAccount
|
||||
name: serviceaccount
|
||||
`)
|
||||
th.WriteF("/app/base/clusterrolebinding.yaml", `
|
||||
th.WriteF("base/clusterrolebinding.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
@@ -52,7 +52,7 @@ subjects:
|
||||
- kind: ServiceAccount
|
||||
name: serviceaccount
|
||||
`)
|
||||
th.WriteF("/app/base/clusterrole.yaml", `
|
||||
th.WriteF("base/clusterrole.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -66,13 +66,13 @@ rules:
|
||||
|
||||
func writeMidOverlays(th kusttest_test.Harness) {
|
||||
// Mid-level overlays
|
||||
th.WriteK("/app/overlays/a", `
|
||||
th.WriteK("overlays/a", `
|
||||
resources:
|
||||
- ../../base
|
||||
namePrefix: a-
|
||||
nameSuffix: -suffixA
|
||||
`)
|
||||
th.WriteK("/app/overlays/b", `
|
||||
th.WriteK("overlays/b", `
|
||||
resources:
|
||||
- ../../base
|
||||
namePrefix: b-
|
||||
@@ -82,7 +82,7 @@ nameSuffix: -suffixB
|
||||
|
||||
func writeTopOverlay(th kusttest_test.Harness) {
|
||||
// Top overlay, combining the mid-level overlays
|
||||
th.WriteK("/app/combined", `
|
||||
th.WriteK("combined", `
|
||||
resources:
|
||||
- ../overlays/a
|
||||
- ../overlays/b
|
||||
@@ -92,7 +92,7 @@ resources:
|
||||
func TestBase(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeBase(th)
|
||||
m := th.Run("/app/base", th.MakeDefaultOptions())
|
||||
m := th.Run("base", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -143,7 +143,7 @@ func TestMidLevelA(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeBase(th)
|
||||
writeMidOverlays(th)
|
||||
m := th.Run("/app/overlays/a", th.MakeDefaultOptions())
|
||||
m := th.Run("overlays/a", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -194,7 +194,7 @@ func TestMidLevelB(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
writeBase(th)
|
||||
writeMidOverlays(th)
|
||||
m := th.Run("/app/overlays/b", th.MakeDefaultOptions())
|
||||
m := th.Run("overlays/b", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -246,7 +246,7 @@ func TestMultibasesNoConflict(t *testing.T) {
|
||||
writeBase(th)
|
||||
writeMidOverlays(th)
|
||||
writeTopOverlay(th)
|
||||
m := th.Run("/app/combined", th.MakeDefaultOptions())
|
||||
m := th.Run("combined", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -342,7 +342,7 @@ func TestMultibasesWithConflict(t *testing.T) {
|
||||
writeMidOverlays(th)
|
||||
writeTopOverlay(th)
|
||||
|
||||
th.WriteK("/app/overlays/a", `
|
||||
th.WriteK("overlays/a", `
|
||||
namePrefix: a-
|
||||
nameSuffix: -suffixA
|
||||
resources:
|
||||
@@ -351,14 +351,14 @@ resources:
|
||||
`)
|
||||
// Expect an error because this resource in the overlay
|
||||
// matches a resource in the base.
|
||||
th.WriteF("/app/overlays/a/serviceaccount.yaml", `
|
||||
th.WriteF("overlays/a/serviceaccount.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: serviceaccount
|
||||
`)
|
||||
|
||||
err := th.RunWithErr("/app/combined", th.MakeDefaultOptions())
|
||||
err := th.RunWithErr("combined", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected error")
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ func TestRoleBindingAcrossNamespace(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- resource.yaml
|
||||
nameSuffix: -ns2
|
||||
`)
|
||||
th.WriteF("/app/resource.yaml", `
|
||||
th.WriteF("resource.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
@@ -77,7 +77,7 @@ subjects:
|
||||
namespace: ns1
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -145,12 +145,12 @@ func TestRoleBindingAcrossNamespaceWoSubjects(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- resource.yaml
|
||||
nameSuffix: -ns2
|
||||
`)
|
||||
th.WriteF("/app/resource.yaml", `
|
||||
th.WriteF("resource.yaml", `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
@@ -181,7 +181,7 @@ roleRef:
|
||||
name: my-role
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -219,18 +219,18 @@ roleRef:
|
||||
func TestRoleBindingWhenSubjectsAcrossNamespace(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t)
|
||||
defer th.Reset()
|
||||
th.WriteK("/app", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- ./ns1
|
||||
- ./ns2
|
||||
`)
|
||||
th.WriteK("/app/ns1", `
|
||||
th.WriteK("ns1", `
|
||||
namespace: namespace-1
|
||||
resources:
|
||||
- role-ns1.yaml
|
||||
- rolebinding-ns1.yaml
|
||||
`)
|
||||
th.WriteF("/app/ns1/role-ns1.yaml", `
|
||||
th.WriteF("ns1/role-ns1.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
@@ -240,7 +240,7 @@ rules:
|
||||
resources: ["pods"]
|
||||
verbs: ["get"]
|
||||
`)
|
||||
th.WriteF("/app/ns1/rolebinding-ns1.yaml", `
|
||||
th.WriteF("ns1/rolebinding-ns1.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
@@ -254,13 +254,13 @@ subjects:
|
||||
name: testAccount
|
||||
namespace: namespace-2
|
||||
`)
|
||||
th.WriteK("/app/ns2", `
|
||||
th.WriteK("ns2", `
|
||||
namespace: namespace-2
|
||||
resources:
|
||||
- role-ns2.yaml
|
||||
- rolebinding-ns2.yaml
|
||||
`)
|
||||
th.WriteF("/app/ns2/role-ns2.yaml", `
|
||||
th.WriteF("ns2/role-ns2.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
@@ -270,7 +270,7 @@ rules:
|
||||
resources: ["pods"]
|
||||
verbs: ["get"]
|
||||
`)
|
||||
th.WriteF("/app/ns2/rolebinding-ns2.yaml", `
|
||||
th.WriteF("ns2/rolebinding-ns2.yaml", `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
@@ -285,7 +285,7 @@ subjects:
|
||||
namespace: namespace-1
|
||||
`)
|
||||
|
||||
m := th.Run("/app", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestSimple1(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteF("/dep.yaml", `
|
||||
th.WriteF("dep.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -19,7 +19,7 @@ metadata:
|
||||
spec:
|
||||
numReplicas: 1
|
||||
`)
|
||||
th.WriteF("/patch.yaml", `
|
||||
th.WriteF("patch.yaml", `
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -28,13 +28,13 @@ spec:
|
||||
numReplicas: 999
|
||||
`)
|
||||
|
||||
th.WriteK("/", `
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- dep.yaml
|
||||
patchesStrategicMerge:
|
||||
- patch.yaml
|
||||
`)
|
||||
m := th.Run("/", th.MakeDefaultOptions())
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user