mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-26 08:18:17 +00:00
Compare commits
33 Commits
kustomize/
...
release-pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18bd5d9dea | ||
|
|
3aee7a9081 | ||
|
|
abefa2b155 | ||
|
|
5d800f0b0a | ||
|
|
4eb2d5bcc2 | ||
|
|
988af1ff61 | ||
|
|
1617183ea4 | ||
|
|
ee72746481 | ||
|
|
c9e7dc3bfa | ||
|
|
07e0e46ac7 | ||
|
|
404d2d631a | ||
|
|
baa0296a12 | ||
|
|
0f665ac153 | ||
|
|
14b0a65091 | ||
|
|
2d58f8b81c | ||
|
|
9a43ca53cc | ||
|
|
5372fc6f6c | ||
|
|
86bc344057 | ||
|
|
a014f7d414 | ||
|
|
9a94bcb854 | ||
|
|
07634ef098 | ||
|
|
995f88d60c | ||
|
|
334a64676f | ||
|
|
08963ba503 | ||
|
|
326fb689be | ||
|
|
970ce67c34 | ||
|
|
98d1893057 | ||
|
|
b5b11ef6e9 | ||
|
|
d8250c9ee2 | ||
|
|
c950046659 | ||
|
|
b5d5e70bdc | ||
|
|
2e82985380 | ||
|
|
9e226001e3 |
@@ -21,20 +21,16 @@ mv kustomize_*_${opsys}_amd64 kustomize
|
||||
chmod u+x kustomize
|
||||
```
|
||||
|
||||
## Install from the HEAD of master branch
|
||||
## Get and install source for a particular release
|
||||
|
||||
Requires [Go] v1.12 or higher:
|
||||
|
||||
<!-- @installkustomize @testAgainstLatestRelease -->
|
||||
For example
|
||||
```
|
||||
go install sigs.k8s.io/kustomize/v3/cmd/kustomize
|
||||
# Omit the @v3.2.1 to get the default for major version 3
|
||||
GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3@v3.2.1
|
||||
```
|
||||
|
||||
> With [Go v1.12](https://golang.org/doc/go1.12#modules), prefix the above command with `GO111MODULE=on`, e.g.
|
||||
> ```
|
||||
> GO111MODULE=on go install sigs.k8s.io/kustomize/v3/cmd/kustomize
|
||||
> ```
|
||||
> This shouldn't be necessary with [Go v1.13](https://golang.org/doc/go1.13#modules).
|
||||
Use of `GO111MODULE=on` shouldn't be necessary
|
||||
with [Go v1.13](https://golang.org/doc/go1.13#modules).
|
||||
|
||||
### Other methods
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
[rpm]: https://en.wikipedia.org/wiki/Rpm_(software)
|
||||
[strategic-merge]: https://git.k8s.io/community/contributors/devel/sig-api-machinery/strategic-merge-patch.md
|
||||
[target]: #target
|
||||
[transformer]: #transformer
|
||||
[variant]: #variant
|
||||
[variants]: #variant
|
||||
[workflow]: workflows.md
|
||||
|
||||
@@ -52,8 +52,7 @@ kustomize and the plugin_.
|
||||
|
||||
This means a one-time run of
|
||||
```
|
||||
GOPATH=${whatever} go get \
|
||||
sigs.k8s.io/kustomize/cmd/kustomize@${releaseVersion}
|
||||
GOPATH=${whatever} GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3
|
||||
```
|
||||
|
||||
and then a normal development cycle using
|
||||
|
||||
@@ -1,70 +1,151 @@
|
||||
# Versioning
|
||||
|
||||
Running `kustomize` means one is running a
|
||||
particular version of a program, using a
|
||||
particular version of underlying packages, and
|
||||
reading a particular version of a [kustomization]
|
||||
file.
|
||||
particular version of a program (a CLI), using a
|
||||
particular version of underlying packages (a Go
|
||||
API), and reading a particular version of a
|
||||
[kustomization] file.
|
||||
|
||||
## Program Versioning
|
||||
## CLI Program Versioning
|
||||
|
||||
The command `kustomize version` prints a three
|
||||
field version tag (e.g. `v3.0.0`) that aspires to
|
||||
[semantic versioning].
|
||||
|
||||
When enough changes have accumulated to
|
||||
warrant a new release, a [release process]
|
||||
is followed, and the fields in the version
|
||||
number are bumped per semver.
|
||||
This notion of semver applies only to the CLI.
|
||||
|
||||
## Kustomize packages
|
||||
The major version changes when some backward
|
||||
incompatibility appears in how the commands
|
||||
behave.
|
||||
|
||||
At the time of writing, the kustomize program and
|
||||
the packages it uses (and exports) are in the same
|
||||
Go module (see the top level `go.mod` file in the
|
||||
repo).
|
||||
|
||||
[trailing major version indicator]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
|
||||
### Installation
|
||||
|
||||
Thus, they share the module's version number, per
|
||||
its git tag (e.g. `v3.0.0`), whose major verion
|
||||
number matches the [trailing major version
|
||||
indicator] in the module name (e.g. the `/v3` in
|
||||
`sigs.k8s.io/kustomize/v3`).
|
||||
The best method to install kustomize is to
|
||||
download a binary from the [release page].
|
||||
|
||||
The non-internal packages in the Go module
|
||||
`sigs.k8s.io/kustomize/v3`, introduced in
|
||||
[v3.0.0](v3.0.0.md), conform to [semantic
|
||||
versioning].
|
||||
If you want to try minor and patch upgrades in
|
||||
dependencies via `go get -u` (see `help go
|
||||
get`), try something like this:
|
||||
|
||||
```
|
||||
GO111MODULE=on go get -u sigs.k8s.io/kustomize/kustomize/v3@v3.2.1
|
||||
```
|
||||
|
||||
## Go API Versioning
|
||||
|
||||
The public methods in the public packages
|
||||
of module `sigs.k8s.io/kusomize` constitue
|
||||
the _kustomize Go API_.
|
||||
|
||||
#### Version v3 and earlier
|
||||
|
||||
|
||||
[import path]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
|
||||
|
||||
In `v3` (and preceeding major versions), the
|
||||
kustomize program and the API live the same Go
|
||||
module at `sigs.k8s.io/kustomize`, at [import path]
|
||||
`sigs.k8s.io/kustomize/v3`.
|
||||
|
||||
This has been fine for the CLI, but it presents a
|
||||
problem for the Go API.
|
||||
|
||||
[minimal version selection]: https://research.swtch.com/vgo-mvs
|
||||
|
||||
The process around Go modules, in particular the
|
||||
notion of [minimal version selection], demands
|
||||
that the module respect semver.
|
||||
|
||||
Almost all the code in module
|
||||
`sigs.k8s.io/kustomize/v3` is exposed (not in a
|
||||
directory named `internal`). Even a minor
|
||||
refactor changing a method name or argument type
|
||||
in some deeply buried (but still public) method is
|
||||
a backward incompatible change. As a result, Go
|
||||
API semver hasn't been followed (or we'd be at a much
|
||||
higher version number by now).
|
||||
|
||||
Some options are
|
||||
|
||||
- continue to ignore Go API semver and stick to
|
||||
CLI semver (eliminating the usefullness of
|
||||
minimal version selection),
|
||||
|
||||
- obey semver, and increment the module's major
|
||||
version number with every release (drastically
|
||||
reducing the usefullness of minimal version
|
||||
selection - since virtually all releases will
|
||||
be major),
|
||||
|
||||
- slow down change in the huge API in favor of
|
||||
stability, yet somehow continue to deliver
|
||||
features,
|
||||
|
||||
- drastically reduce the API surface, stabilize on
|
||||
semver there, and refactor as needed inside
|
||||
`internal`.
|
||||
|
||||
The last option seems the most appealing.
|
||||
|
||||
Projects using the Go API directly only use about
|
||||
a dozen public methods in ~ten packages. These
|
||||
methods could likely be combined to one or two
|
||||
public packages intentionally designed for general
|
||||
use, analogous to, say,
|
||||
[regexp](https://golang.org/pkg/regexp) or
|
||||
[go-yaml](https://github.com/go-yaml/yaml),
|
||||
reducing the API surface.
|
||||
|
||||
#### Version v4
|
||||
|
||||
With `v4` (i.e. the module dependency path
|
||||
`sigs.k8s.io/kustomize/v4`)
|
||||
two things will happen.
|
||||
|
||||
First, the _kustomize_ program itself (`main.go`
|
||||
and CLI specific code) will have moved out of
|
||||
`sigs.k8s.io/kustomize` and into the new module
|
||||
`sigs.k8s.io/kustomize/kustomize`. This is a
|
||||
submodule in the same repo, and it will retain its
|
||||
current notion of semver (e.g. a backward
|
||||
incompatible change in command behavior will
|
||||
trigger a major version bump). This module will
|
||||
not export packages; it's just home to a `main`
|
||||
package.
|
||||
|
||||
Second, `sigs.k8s.io/kustomize/v4` will start to
|
||||
obey semver with a substantially reduced public
|
||||
surface, informed by current usage. Clients
|
||||
should import packages from this module, i.e.
|
||||
from import paths prefixed by
|
||||
`sigs.k8s.io/kustomize/v4`. The kustomize binary
|
||||
itself is an API client requiring this module.
|
||||
|
||||
The clients and API will evolve independently.
|
||||
|
||||
|
||||
## Kustomization File Versioning
|
||||
|
||||
At the time of writing (circa release of v2.0.0):
|
||||
|
||||
- A [kustomization] file is just a YAML file that
|
||||
can be successfully parsed into a particular Go
|
||||
struct defined in the `kustomize` binary.
|
||||
|
||||
- This struct does not have a version number,
|
||||
which is the same as saying that its version
|
||||
number matches the program's version number,
|
||||
since it's compiled in.
|
||||
The kustomization file is a struct that is part of
|
||||
the kustomize Go API (the `sigs.k8s.io/kustomize`
|
||||
module), but it also evolves as a k8s API object -
|
||||
it has an `apiVersion` field containing its
|
||||
own version number.
|
||||
|
||||
### Field Change Policy
|
||||
|
||||
- A field's meaning cannot be changed.
|
||||
|
||||
- A field may be deprecated, then removed.
|
||||
|
||||
- Deprecation means triggering a _minor_ (semver)
|
||||
version bump in the program, and
|
||||
defining a migration path in a non-fatal
|
||||
error message.
|
||||
|
||||
version bump in the kustomize Go API, and
|
||||
defining a migration path in a non-fatal error
|
||||
message.
|
||||
- Removal means triggering a _major_ (semver)
|
||||
version bump, and fatal error if field encountered
|
||||
(as with any unknown field).
|
||||
version bump in the kustomize Go API, and fatal
|
||||
error if field encountered (as with any unknown
|
||||
field). Likewise a change in `apiVersion`.
|
||||
|
||||
### The `edit fix` Command
|
||||
|
||||
@@ -74,16 +155,12 @@ fields, and writes it out again in the latest
|
||||
format.
|
||||
|
||||
This is a type version upgrade mechanism that
|
||||
works within _major_ program revisions. There is
|
||||
no downgrade capability, as there's no use case
|
||||
for it (see discussion below).
|
||||
works within _major_ API revisions. There is no
|
||||
downgrade capability, as there's no use case for
|
||||
it (see discussion below).
|
||||
|
||||
### Examples
|
||||
|
||||
At the time of writing, in v1.0.x, there were 12
|
||||
minor releases, with backward compatible
|
||||
deprecations fixable via `edit fix`.
|
||||
|
||||
With the 2.0.0 release, there were three field
|
||||
removals:
|
||||
|
||||
@@ -91,13 +168,11 @@ removals:
|
||||
introduced, because the latter offers more
|
||||
general features for image data manipulation.
|
||||
`imageTag` was removed in v2.0.0.
|
||||
|
||||
- `patches` was deprecated and replaced by
|
||||
`patchesStrategicMerge` when `patchesJson6902`
|
||||
was introduced, to make a clearer
|
||||
distinction between patch specification formats.
|
||||
`patches` was removed in v2.0.0.
|
||||
|
||||
- `secretGenerator/commands` was removed
|
||||
due to security concerns in v2.0.0
|
||||
with no deprecation period.
|
||||
@@ -117,10 +192,8 @@ native type signals:
|
||||
|
||||
- its reliability level (alpha vs beta vs
|
||||
generally available),
|
||||
|
||||
- the existence of code to provide default values
|
||||
to fields not present in a serialization,
|
||||
|
||||
- the existence of code to provide both forward
|
||||
and backward conversion between different
|
||||
versions of types.
|
||||
@@ -142,17 +215,13 @@ For CRDs, there's a [proposal] on how to manage
|
||||
versioning (e.g. a remote service can offer type
|
||||
defaulting and conversions).
|
||||
|
||||
### Kustomization file versioning
|
||||
|
||||
The critical difference between k8s API versioning
|
||||
and kustomization file versioning is
|
||||
### Differences
|
||||
|
||||
- A k8s API server is able to go _forward_ and
|
||||
_backward_ in versioning, to work with older
|
||||
clients, over [some range].
|
||||
|
||||
- The `kustomize edit fix` command only moves
|
||||
_forward_ within a _major_ program
|
||||
_forward_ within a _major_ API
|
||||
version.
|
||||
|
||||
At the time of writing, the YAML in a
|
||||
@@ -171,60 +240,26 @@ the following rules.
|
||||
|
||||
Field names with dedicated meaning in k8s
|
||||
(`metadata`, `spec`, `status`, etc.) aren't used.
|
||||
|
||||
This is enforced via code review.
|
||||
|
||||
#### Optional use of k8s `kind` and `apiVersion`
|
||||
#### Default values for k8s `kind` and `apiVersion`
|
||||
|
||||
At the time of writing two [special] k8s
|
||||
resource fields are allowed, but not required, in
|
||||
a kustomization file: [`kind`] and [`apiVersion`].
|
||||
In `v3` or below, the two [special] k8s
|
||||
resource fields [`kind`] and [`apiVersion`] may
|
||||
be omitted from the kustomization file.
|
||||
|
||||
If either field is present, they both must be, and
|
||||
they must have the following values:
|
||||
If either field is present, they both must be.
|
||||
If present, the value of `kind` must be:
|
||||
|
||||
``` yaml
|
||||
kind: Kustomization
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
```
|
||||
> ```
|
||||
> kind: Kustomization
|
||||
> ```
|
||||
|
||||
They are allowed to exist and have specific values
|
||||
in a kustomization file only as a sort of
|
||||
domain-squatting behavior for some future API. A
|
||||
kustomize user gains nothing from adding these
|
||||
fields to a kustomization file.
|
||||
If missing, the value of `apiVersion` defaults to
|
||||
|
||||
### Why not require `kind` and `apiVersion`
|
||||
|
||||
#### Ease of use and setting proper expectations
|
||||
|
||||
Use cases for a kustomization file don't include a
|
||||
server storing muliple k8s kinds and offering
|
||||
version downgrades.
|
||||
|
||||
The kustomization file is more akin to a
|
||||
`Makefile`. A kustomize command can either read a
|
||||
kustomization file, or it cannot, and in the later
|
||||
case will complain as specifically as possible
|
||||
about why (e.g. `unknown field Foo`).
|
||||
|
||||
So requiring a `kind` and `apiVersion` would just
|
||||
be boilerplate in a user's files, and in all the
|
||||
examples and tests.
|
||||
|
||||
Nevertheless, _a user still benefits from a
|
||||
versioning policy_ and has a `fix` command to
|
||||
upgrade files as needed.
|
||||
|
||||
#### We can change our minds
|
||||
|
||||
When/if the kustomization struct graduates to some
|
||||
kind of API status, with an expectation of
|
||||
"versionless" storage and downgrade capability,
|
||||
whatever it looks like at that moment can be
|
||||
locked into `/v1beta1` or `/v1` and the `kind`
|
||||
and `apiVersion` fields can be required from that
|
||||
moment forward.
|
||||
> ```
|
||||
> apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
> ```
|
||||
|
||||
[field change policy]: #field-change-policy
|
||||
[some range]: https://kubernetes.io/docs/reference/using-api/deprecation-policy
|
||||
@@ -235,6 +270,7 @@ moment forward.
|
||||
[special]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
[k8s API]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md
|
||||
[conventions]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md
|
||||
[release page]: https://github.com/kubernetes-sigs/kustomize/releases
|
||||
[release process]: ../releasing/README.md
|
||||
[kustomization]: glossary.md#kustomization
|
||||
[`kind`]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
|
||||
@@ -6,6 +6,7 @@ package loadertest
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
@@ -33,7 +34,7 @@ func NewFakeLoader(initialDir string) FakeLoader {
|
||||
func NewFakeLoaderWithRestrictor(
|
||||
lr loader.LoadRestrictorFunc, initialDir string) FakeLoader {
|
||||
// Create fake filesystem and inject it into initial Loader.
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.Mkdir(initialDir)
|
||||
ldr, err := loader.NewLoader(
|
||||
lr, validators.MakeFakeValidator(), initialDir, fSys)
|
||||
|
||||
@@ -367,10 +367,10 @@ the following flattened structure would look like:
|
||||
"patchesJson6902:path",
|
||||
],
|
||||
"values": [
|
||||
"resources=service.yaml"
|
||||
"resources=deployment.yaml"
|
||||
"configmapGenerator:name=app-configuration"
|
||||
"configmapGenerator:files=config.yaml"
|
||||
"resources=service.yaml",
|
||||
"resources=deployment.yaml",
|
||||
"configmapGenerator:name=app-configuration",
|
||||
"configmapGenerator:files=config.yaml",
|
||||
"patchesJson6902:target:version=v1",
|
||||
"patchesJson6902:target:kind=StatefulSet",
|
||||
"patchesJson6902:target:name=ss-name",
|
||||
|
||||
@@ -303,7 +303,7 @@ func FindRangesForRepoSearch(cache cachedSearch) ([]string, error) {
|
||||
}
|
||||
if nextAccessible < filesAccessible {
|
||||
return nil, fmt.Errorf(
|
||||
"Number of results dropped from %d to %d within range search",
|
||||
"number of results dropped from %d to %d within range search",
|
||||
filesAccessible, nextAccessible)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/gregjones/httpcache"
|
||||
redis_cache "github.com/gregjones/httpcache/redis"
|
||||
rediscache "github.com/gregjones/httpcache/redis"
|
||||
)
|
||||
|
||||
func FromCache(header http.Header) bool {
|
||||
@@ -14,7 +14,7 @@ func FromCache(header http.Header) bool {
|
||||
}
|
||||
|
||||
func NewClient(conn redis.Conn) *http.Client {
|
||||
etagCache := redis_cache.NewWithClient(conn)
|
||||
etagCache := rediscache.NewWithClient(conn)
|
||||
tr := httpcache.NewTransport(etagCache)
|
||||
return &http.Client{
|
||||
Transport: tr,
|
||||
|
||||
@@ -131,15 +131,15 @@ func TestConstructConfigMap(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile(
|
||||
fSys.RPath("configmap", "app.env"),
|
||||
fs.RPath("configmap", "app.env"),
|
||||
[]byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n"))
|
||||
fSys.WriteFile(
|
||||
fSys.RPath("configmap", "app-init.ini"),
|
||||
fs.RPath("configmap", "app-init.ini"),
|
||||
[]byte("FOO=bar\nBAR=baz\n"))
|
||||
fSys.WriteFile(
|
||||
fSys.RPath("configmap", "app.bin"),
|
||||
fs.RPath("configmap", "app.bin"),
|
||||
[]byte{0xff, 0xfd})
|
||||
ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestConstructSecret(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile("/secret/app.env", []byte("DB_USERNAME=admin\nDB_PASSWORD=somepw\n"))
|
||||
fSys.WriteFile("/secret/app-init.ini", []byte("FOO=bar\nBAR=baz\n"))
|
||||
ldr := loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
@@ -108,5 +109,30 @@ func (kf *KunstructuredFactoryImpl) validate(u unstructured.Unstructured) error
|
||||
if u.GetName() == "" {
|
||||
return fmt.Errorf("missing metadata.name in object %v", u)
|
||||
}
|
||||
|
||||
if result, path := checkListItemNil(u.Object); result {
|
||||
return fmt.Errorf("empty item at %v in object %v", path, u)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkListItemNil(in interface{}) (bool, string) {
|
||||
switch v := in.(type) {
|
||||
case map[string]interface{}:
|
||||
for key, s := range v {
|
||||
if result, path := checkListItemNil(s); result {
|
||||
return result, key + "/" + path
|
||||
}
|
||||
}
|
||||
case []interface{}:
|
||||
for index, s := range v {
|
||||
if s == nil {
|
||||
return true, ""
|
||||
}
|
||||
if result, path := checkListItemNil(s); result {
|
||||
return result, "[" + strconv.Itoa(index) + "]/" + path
|
||||
}
|
||||
}
|
||||
}
|
||||
return false, ""
|
||||
}
|
||||
|
||||
@@ -138,6 +138,22 @@ kind: Namespace
|
||||
metadata:
|
||||
annotations:
|
||||
foo: bar
|
||||
`),
|
||||
expectedOut: nil,
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "nil value in list",
|
||||
input: []byte(`
|
||||
apiVersion: builtin
|
||||
kind: ConfigMapGenerator
|
||||
metadata:
|
||||
name: kube100-site
|
||||
labels:
|
||||
app: web
|
||||
testList:
|
||||
- testA
|
||||
-
|
||||
`),
|
||||
expectedOut: nil,
|
||||
expectedErr: true,
|
||||
|
||||
@@ -6,6 +6,12 @@ require (
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/spf13/pflag v1.0.5
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
sigs.k8s.io/kustomize/v3 v3.2.0
|
||||
sigs.k8s.io/yaml v1.1.0
|
||||
)
|
||||
|
||||
// When tagging and releasing this module (the kustomize CLI),
|
||||
// be sure to require a specific version of sig.k8s.io/kustomize
|
||||
// above, and drop the following replace directive.
|
||||
replace sigs.k8s.io/kustomize/v3 v3.2.0 => ../
|
||||
|
||||
224
kustomize/go.sum
224
kustomize/go.sum
@@ -1,29 +1,51 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
github.com/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/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-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/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/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
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/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
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=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.6+incompatible h1:tfrHha8zJ01ywiOEC1miGY8st1/igzWB8OmvPgoYX7w=
|
||||
github.com/emicklei/go-restful v2.9.6+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
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/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 v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db/go.mod h1:+sE8vrLDS2M0pZkBk0wy6+nLdKexVDrl/jBqQOTDThA=
|
||||
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/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
@@ -36,74 +58,161 @@ github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcs
|
||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/go-openapi/swag v0.19.2 h1:jvO6bCMBEilGwMfHhrd61zIID4oIFdwb76V17SM88dE=
|
||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
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/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
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/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE=
|
||||
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
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 v0.0.0-20161109072736-4bd1920723d7 h1:VoRHccBV7zFWlO/I85D1ke/x5Ak9Y7gKm9gkf7LHNhI=
|
||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||
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/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-20181222123516-0b8337e80d98/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
|
||||
github.com/golangci/golangci-lint v1.19.1/go.mod h1:2CEc4Fxx3vxDv7g8DyXkHCBF73AOzAymcJAprs2vCps=
|
||||
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc/go.mod h1:e5tpTHCfVze+7EpLEozzMB3eafxo2KT5veNg1k6byQU=
|
||||
github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217/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/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/gofuzz v0.0.0-20161122191042-44d81051d367 h1:ScAXWS+TR6MZKex+7Z8rneuSJH+FSDqd6ocQyl+ZHo4=
|
||||
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
||||
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9 h1:Dk8DO58y0wXeNG49dRqzf4HrZAK9lFfTgS/FNtB6NlM=
|
||||
github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||
github.com/googleapis/gnostic v0.3.0 h1:CcQijm0XKekKjP/YCz28LXVSpgguuB+nCxaSjCe09y0=
|
||||
github.com/googleapis/gnostic v0.3.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
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/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/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
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/json-iterator/go v0.0.0-20180612202835-f2b4162afba3 h1:/UewZcckqhvnnS0C6r3Sher2hSEbVmM6Ogpcjen08+Y=
|
||||
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
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/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
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-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481 h1:IaSjLMT6WvkoZZjspGxy3rdaTEmWLoRm49WbtVUi9sA=
|
||||
github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/matoous/godox v0.0.0-20190910121045-032ad8106c86/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
|
||||
github.com/mattn/go-colorable v0.1.2/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/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da h1:ZQGIPjr1iTtUPXZFk8WShqb5G+Qg65VHFLtSvmHh+Mw=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/monopole/mdrip v0.2.48/go.mod h1:rzORfdNQ63T/tS95GOFHB+I3OrT+Bjlk8krOc/QiL/8=
|
||||
github.com/mozilla/tls-observatory v0.0.0-20190404164649-a3c1b6cfecfd/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/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 v0.0.0-20170829012221-11459a886d9c h1:Hww8mOyEKTeON4bZn7FrlLismspbPc1teNRUVH7wLQ8=
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
|
||||
github.com/onsi/ginkgo v1.8.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 v0.0.0-20170829124025-dcabb60a477c h1:eSfnfIuwhxZyULg1NNuZycJcYkjYVGYe7FczwQReM6U=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
|
||||
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
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/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/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
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=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
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/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.0.0+incompatible/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/securego/gosec v0.0.0-20190912120752-140048b2a218/go.mod h1:q6oYAujd2qyeU4cJqIri4LBIgdHXGvxWHZ1E29HNFRE=
|
||||
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.2/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
@@ -112,57 +221,125 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
|
||||
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/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/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
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/timakin/bodyclose v0.0.0-20190721030226-87058b9bfcec/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.3/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
|
||||
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/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
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-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-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
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-20170114055629-f2499483f923/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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
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 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
|
||||
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 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/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=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
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-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 h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190621203818-d432491b9138 h1:t8BZD9RDjkm9/h7yYN6kE8oaeov5r9aztkB7zKA5Tkg=
|
||||
golang.org/x/sys v0.0.0-20190621203818-d432491b9138/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190911201528-7ad0cfa0b7b5 h1:SW/0nsKCUaozCUtZTakri5laocGx/5bkDSSLrFUsa5s=
|
||||
golang.org/x/sys v0.0.0-20190911201528-7ad0cfa0b7b5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.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-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/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-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-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-20190911230505-6bfd74cf029c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
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/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
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 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
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=
|
||||
k8s.io/api v0.0.0-20190313235455-40a48860b5ab h1:DG9A67baNpoeweOy2spF1OWHhnVY5KR7/Ek/+U1lVZc=
|
||||
k8s.io/api v0.0.0-20190313235455-40a48860b5ab/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
|
||||
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1 h1:IS7K02iBkQXpCeieSiyJjGoLSdVOv2DbPaWHJ+ZtgKg=
|
||||
@@ -172,12 +349,13 @@ k8s.io/client-go v11.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyod
|
||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92 h1:PgoMI/L1Nu5Vmvgm+vGheLuxKST8h6FMOqggyAFtHPc=
|
||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v0.3.3 h1:niceAagH1tzskmaie/icWd7ci1wbG7Bf2c6YGcQv+3c=
|
||||
k8s.io/klog v0.3.3/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 h1:5sW+fEHvlJI3Ngolx30CmubFulwH28DhKjGf70Xmtco=
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4=
|
||||
sigs.k8s.io/kustomize/v3 v3.2.0 h1:EKcEubO29vCbigcMoNynfyZH+ANWkML2UHWibt1Do7o=
|
||||
sigs.k8s.io/kustomize/v3 v3.2.0/go.mod h1:ztX4zYc/QIww3gSripwF7TBOarBTm5BvyAMem0kCzOE=
|
||||
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/pluginator v1.0.0/go.mod h1:i8HdU5FdH1zDjCKiFf5CNl7slsc0QffyKsY2OuPynJ0=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
|
||||
|
||||
@@ -67,8 +67,9 @@ func NewCmdBuild(
|
||||
pl := plugins.NewLoader(pluginConfig, rf)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "build {path}",
|
||||
Short: "Print configuration per contents of " + pgmconfig.KustomizationFileNames[0],
|
||||
Use: "build {path}",
|
||||
Short: "Print configuration per contents of " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: examples,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@@ -96,7 +97,8 @@ func NewCmdBuild(
|
||||
func (o *Options) Validate(args []string) (err error) {
|
||||
if len(args) > 1 {
|
||||
return errors.New(
|
||||
"specify one path to " + pgmconfig.KustomizationFileNames[0])
|
||||
"specify one path to " +
|
||||
pgmconfig.DefaultKustomizationFileName())
|
||||
}
|
||||
if len(args) == 0 {
|
||||
o.kustomizationPath = loader.CWD
|
||||
|
||||
@@ -26,7 +26,9 @@ func TestBuildValidate(t *testing.T) {
|
||||
{"file", []string{"beans"}, "beans", ""},
|
||||
{"path", []string{"a/b/c"}, "a/b/c", ""},
|
||||
{"path", []string{"too", "many"},
|
||||
"", "specify one path to " + pgmconfig.KustomizationFileNames[0]},
|
||||
"",
|
||||
"specify one path to " +
|
||||
pgmconfig.DefaultKustomizationFileName()},
|
||||
}
|
||||
for _, mycase := range cases {
|
||||
opts := Options{}
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
// NewDefaultCommand returns the default (aka root) command for kustomize command.
|
||||
func NewDefaultCommand() *cobra.Command {
|
||||
fSys := fs.MakeRealFS()
|
||||
fSys := fs.MakeFsOnDisk()
|
||||
stdOut := os.Stdout
|
||||
|
||||
c := &cobra.Command{
|
||||
|
||||
@@ -29,9 +29,9 @@ func TestValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestComplete(t *testing.T) {
|
||||
fsys := fs.MakeFakeFS()
|
||||
fsys.Mkdir("/some/dir")
|
||||
fsys.WriteFile("/some/file", []byte(`some file`))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.Mkdir("/some/dir")
|
||||
fSys.WriteFile("/some/file", []byte(`some file`))
|
||||
|
||||
type testcase struct {
|
||||
dir string
|
||||
@@ -54,7 +54,7 @@ func TestComplete(t *testing.T) {
|
||||
|
||||
for _, tcase := range testcases {
|
||||
o := saveOptions{saveDirectory: tcase.dir}
|
||||
actual := o.Complete(fsys)
|
||||
actual := o.Complete(fSys)
|
||||
if !reflect.DeepEqual(actual, tcase.expect) {
|
||||
t.Fatalf("Expected %v\n but bot %v\n", tcase.expect, actual)
|
||||
}
|
||||
@@ -62,13 +62,13 @@ func TestComplete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRunSave(t *testing.T) {
|
||||
fsys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
o := saveOptions{saveDirectory: "/some/dir"}
|
||||
err := o.RunSave(fsys)
|
||||
err := o.RunSave(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
if !fsys.Exists("/some/dir/nameprefix.yaml") {
|
||||
if !fSys.Exists("/some/dir/nameprefix.yaml") {
|
||||
t.Fatal("default configurations are not successfully save.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func detectResources(fSys fs.FileSystem, uf ifc.KunstructuredFactory, base strin
|
||||
}
|
||||
// If a sub-directory contains an existing kustomization file add the
|
||||
// directory as a resource and do not decend into it.
|
||||
for _, kfilename := range pgmconfig.KustomizationFileNames {
|
||||
for _, kfilename := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
if fSys.Exists(filepath.Join(path, kfilename)) {
|
||||
paths = append(paths, path)
|
||||
return filepath.SkipDir
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
var factory = kunstruct.NewKunstructuredFactoryImpl()
|
||||
|
||||
func readKustomizationFS(t *testing.T, fakeFS fs.FileSystem) *types.Kustomization {
|
||||
kf, err := kustfile.NewKustomizationFile(fakeFS)
|
||||
func readKustomizationFS(t *testing.T, fSys fs.FileSystem) *types.Kustomization {
|
||||
kf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected new error %v", err)
|
||||
}
|
||||
@@ -27,25 +27,25 @@ func readKustomizationFS(t *testing.T, fakeFS fs.FileSystem) *types.Kustomizatio
|
||||
return m
|
||||
}
|
||||
func TestCreateNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
cmd := NewCmdCreate(fakeFS, factory)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
cmd := NewCmdCreate(fSys, factory)
|
||||
err := cmd.RunE(cmd, []string{})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
readKustomizationFS(t, fakeFS)
|
||||
readKustomizationFS(t, fSys)
|
||||
}
|
||||
|
||||
func TestCreateWithResources(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteFile("foo.yaml", []byte(""))
|
||||
fakeFS.WriteFile("bar.yaml", []byte(""))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile("foo.yaml", []byte(""))
|
||||
fSys.WriteFile("bar.yaml", []byte(""))
|
||||
opts := createFlags{resources: "foo.yaml,bar.yaml"}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
expected := []string{"foo.yaml", "bar.yaml"}
|
||||
if !reflect.DeepEqual(m.Resources, expected) {
|
||||
t.Fatalf("expected %+v but got %+v", expected, m.Resources)
|
||||
@@ -53,14 +53,14 @@ func TestCreateWithResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithNamespace(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
want := "foo"
|
||||
opts := createFlags{namespace: want}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
got := m.Namespace
|
||||
if got != want {
|
||||
t.Errorf("want: %s, got: %s", want, got)
|
||||
@@ -68,13 +68,13 @@ func TestCreateWithNamespace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithLabels(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
opts := createFlags{labels: "foo:bar"}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
expected := map[string]string{"foo": "bar"}
|
||||
if !reflect.DeepEqual(m.CommonLabels, expected) {
|
||||
t.Fatalf("expected %+v but got %+v", expected, m.CommonLabels)
|
||||
@@ -82,13 +82,13 @@ func TestCreateWithLabels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithAnnotations(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
opts := createFlags{annotations: "foo:bar"}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
expected := map[string]string{"foo": "bar"}
|
||||
if !reflect.DeepEqual(m.CommonAnnotations, expected) {
|
||||
t.Fatalf("expected %+v but got %+v", expected, m.CommonAnnotations)
|
||||
@@ -96,14 +96,14 @@ func TestCreateWithAnnotations(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithNamePrefix(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
want := "foo-"
|
||||
opts := createFlags{prefix: want}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
got := m.NamePrefix
|
||||
if got != want {
|
||||
t.Errorf("want: %s, got: %s", want, got)
|
||||
@@ -111,68 +111,68 @@ func TestCreateWithNamePrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithNameSuffix(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
opts := createFlags{suffix: "-foo"}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
if m.NameSuffix != "-foo" {
|
||||
t.Errorf("want: -foo, got: %s", m.NameSuffix)
|
||||
}
|
||||
}
|
||||
|
||||
func writeDetectContent(fakeFS fs.FileSystem) {
|
||||
fakeFS.WriteFile("/test.yaml", []byte(`
|
||||
func writeDetectContent(fSys fs.FileSystem) {
|
||||
fSys.WriteFile("/test.yaml", []byte(`
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: test`))
|
||||
fakeFS.WriteFile("/README.md", []byte(`
|
||||
fSys.WriteFile("/README.md", []byte(`
|
||||
# Not a k8s resource
|
||||
This file is not a valid kubernetes object.`))
|
||||
fakeFS.WriteFile("/non-k8s.yaml", []byte(`
|
||||
fSys.WriteFile("/non-k8s.yaml", []byte(`
|
||||
# Not a k8s resource
|
||||
other: yaml
|
||||
foo:
|
||||
- bar
|
||||
- baz`))
|
||||
fakeFS.Mkdir("/sub")
|
||||
fakeFS.WriteFile("/sub/test.yaml", []byte(`
|
||||
fSys.Mkdir("/sub")
|
||||
fSys.WriteFile("/sub/test.yaml", []byte(`
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: test2`))
|
||||
fakeFS.WriteFile("/sub/README.md", []byte(`
|
||||
fSys.WriteFile("/sub/README.md", []byte(`
|
||||
# Not a k8s resource
|
||||
This file in a subdirectory is not a valid kubernetes object.`))
|
||||
fakeFS.WriteFile("/sub/non-k8s.yaml", []byte(`
|
||||
fSys.WriteFile("/sub/non-k8s.yaml", []byte(`
|
||||
# Not a k8s resource
|
||||
other: yaml
|
||||
foo:
|
||||
- bar
|
||||
- baz`))
|
||||
fakeFS.Mkdir("/overlay")
|
||||
fakeFS.WriteFile("/overlay/test.yaml", []byte(`
|
||||
fSys.Mkdir("/overlay")
|
||||
fSys.WriteFile("/overlay/test.yaml", []byte(`
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: test3`))
|
||||
fakeFS.WriteFile("/overlay/kustomization.yaml", []byte(`
|
||||
fSys.WriteFile("/overlay/kustomization.yaml", []byte(`
|
||||
resources:
|
||||
- test.yaml`))
|
||||
}
|
||||
|
||||
func TestCreateWithDetect(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
writeDetectContent(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
writeDetectContent(fSys)
|
||||
opts := createFlags{path: "/", detectResources: true}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
expected := []string{"/test.yaml"}
|
||||
if !reflect.DeepEqual(m.Resources, expected) {
|
||||
t.Fatalf("expected %+v but got %+v", expected, m.Resources)
|
||||
@@ -180,14 +180,14 @@ func TestCreateWithDetect(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithDetectRecursive(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
writeDetectContent(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
writeDetectContent(fSys)
|
||||
opts := createFlags{path: "/", detectResources: true, detectRecursive: true}
|
||||
err := runCreate(opts, fakeFS, factory)
|
||||
err := runCreate(opts, fSys, factory)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected cmd error: %v", err)
|
||||
}
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
expected := []string{"/overlay", "/sub/test.yaml", "/test.yaml"}
|
||||
if !reflect.DeepEqual(m.Resources, expected) {
|
||||
t.Fatalf("expected %+v but got %+v", expected, m.Resources)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -16,20 +17,20 @@ const (
|
||||
)
|
||||
|
||||
func TestAddBaseHappyPath(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
bases := strings.Split(baseDirectoryPaths, ",")
|
||||
for _, base := range bases {
|
||||
fakeFS.Mkdir(base)
|
||||
fSys.Mkdir(base)
|
||||
}
|
||||
fakeFS.WriteTestKustomization()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddBase(fakeFS)
|
||||
cmd := newCmdAddBase(fSys)
|
||||
args := []string{baseDirectoryPaths}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -42,15 +43,15 @@ func TestAddBaseHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddBaseAlreadyThere(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
// Create fake directories
|
||||
bases := strings.Split(baseDirectoryPaths, ",")
|
||||
for _, base := range bases {
|
||||
fakeFS.Mkdir(base)
|
||||
fSys.Mkdir(base)
|
||||
}
|
||||
fakeFS.WriteTestKustomization()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddBase(fakeFS)
|
||||
cmd := newCmdAddBase(fSys)
|
||||
args := []string{baseDirectoryPaths}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
@@ -69,13 +70,12 @@ func TestAddBaseAlreadyThere(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestAddBaseNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdAddBase(fakeFS)
|
||||
cmd := newCmdAddBase(fSys)
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
|
||||
@@ -46,8 +46,9 @@ func newCmdAddAnnotation(fSys fs.FileSystem, v func(map[string]string) error) *c
|
||||
o.kind = annotation
|
||||
o.mapValidator = v
|
||||
cmd := &cobra.Command{
|
||||
Use: "annotation",
|
||||
Short: "Adds one or more commonAnnotations to " + pgmconfig.KustomizationFileNames[0],
|
||||
Use: "annotation",
|
||||
Short: "Adds one or more commonAnnotations to " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
add annotation {annotationKey1:annotationValue1},{annotationKey2:annotationValue2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@@ -66,8 +67,9 @@ func newCmdAddLabel(fSys fs.FileSystem, v func(map[string]string) error) *cobra.
|
||||
o.kind = label
|
||||
o.mapValidator = v
|
||||
cmd := &cobra.Command{
|
||||
Use: "label",
|
||||
Short: "Adds one or more commonLabels to " + pgmconfig.KustomizationFileNames[0],
|
||||
Use: "label",
|
||||
Short: "Adds one or more commonLabels to " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
add label {labelKey1:labelValue1},{labelKey2:labelValue2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -7,15 +7,16 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
|
||||
func makeKustomization(t *testing.T) *types.Kustomization {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
kf, err := kustfile.NewKustomizationFile(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
kf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected new error %v", err)
|
||||
}
|
||||
@@ -49,9 +50,9 @@ func TestRunAddAnnotation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
err := cmd.Execute()
|
||||
v.VerifyNoCall()
|
||||
if err == nil {
|
||||
@@ -63,9 +64,9 @@ func TestAddAnnotationNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationInvalidFormat(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"whatever:whatever"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -78,10 +79,10 @@ func TestAddAnnotationInvalidFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationManyArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"k1:v1,k2:v2,k3:v3,k4:v5"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -91,10 +92,10 @@ func TestAddAnnotationManyArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationValueQuoted(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"k1:\"v1\""}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -104,10 +105,10 @@ func TestAddAnnotationValueQuoted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationValueWithColon(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"k1:\"v1:v2\""}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -117,9 +118,9 @@ func TestAddAnnotationValueWithColon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationNoKey(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{":nokey"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyNoCall()
|
||||
@@ -132,10 +133,10 @@ func TestAddAnnotationNoKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationTooManyColons(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"key:v1:v2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -145,10 +146,10 @@ func TestAddAnnotationTooManyColons(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationNoValue(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"no:,value"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -158,10 +159,10 @@ func TestAddAnnotationNoValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationMultipleArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"this:annotation", "has:spaces"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyNoCall()
|
||||
@@ -174,10 +175,10 @@ func TestAddAnnotationMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddAnnotationForce(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd := newCmdAddAnnotation(fSys, v.Validator)
|
||||
args := []string{"key:foo"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -187,7 +188,7 @@ func TestAddAnnotationForce(t *testing.T) {
|
||||
// trying to add the same annotation again should not work
|
||||
args = []string{"key:bar"}
|
||||
v = validators.MakeHappyMapValidator(t)
|
||||
cmd = newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd = newCmdAddAnnotation(fSys, v.Validator)
|
||||
err = cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
if err == nil {
|
||||
@@ -198,7 +199,7 @@ func TestAddAnnotationForce(t *testing.T) {
|
||||
}
|
||||
// but trying to add it with --force should
|
||||
v = validators.MakeHappyMapValidator(t)
|
||||
cmd = newCmdAddAnnotation(fakeFS, v.Validator)
|
||||
cmd = newCmdAddAnnotation(fSys, v.Validator)
|
||||
cmd.Flag("force").Value.Set("true")
|
||||
err = cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -230,9 +231,9 @@ func TestRunAddLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
err := cmd.Execute()
|
||||
v.VerifyNoCall()
|
||||
if err == nil {
|
||||
@@ -244,9 +245,9 @@ func TestAddLabelNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelInvalidFormat(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{"exclamation!:point"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -259,9 +260,9 @@ func TestAddLabelInvalidFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelNoKey(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{":nokey"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyNoCall()
|
||||
@@ -274,10 +275,10 @@ func TestAddLabelNoKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelTooManyColons(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{"key:v1:v2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -287,10 +288,10 @@ func TestAddLabelTooManyColons(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelNoValue(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{"no,value:"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -300,10 +301,10 @@ func TestAddLabelNoValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelMultipleArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{"this:input", "has:spaces"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyNoCall()
|
||||
@@ -316,10 +317,10 @@ func TestAddLabelMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddLabelForce(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd := newCmdAddLabel(fSys, v.Validator)
|
||||
args := []string{"key:foo"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -329,7 +330,7 @@ func TestAddLabelForce(t *testing.T) {
|
||||
// trying to add the same label again should not work
|
||||
args = []string{"key:bar"}
|
||||
v = validators.MakeHappyMapValidator(t)
|
||||
cmd = newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd = newCmdAddLabel(fSys, v.Validator)
|
||||
err = cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
if err == nil {
|
||||
@@ -340,7 +341,7 @@ func TestAddLabelForce(t *testing.T) {
|
||||
}
|
||||
// but trying to add it with --force should
|
||||
v = validators.MakeHappyMapValidator(t)
|
||||
cmd = newCmdAddLabel(fakeFS, v.Validator)
|
||||
cmd = newCmdAddLabel(fSys, v.Validator)
|
||||
cmd.Flag("force").Value.Set("true")
|
||||
err = cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -19,18 +20,18 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
)
|
||||
|
||||
func TestAddPatchHappyPath(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteFile(patchFileName, []byte(patchFileContent))
|
||||
fakeFS.WriteFile(patchFileName+"another", []byte(patchFileContent))
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile(patchFileName, []byte(patchFileContent))
|
||||
fSys.WriteFile(patchFileName+"another", []byte(patchFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddPatch(fakeFS)
|
||||
cmd := newCmdAddPatch(fSys)
|
||||
args := []string{patchFileName + "*"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -43,11 +44,11 @@ func TestAddPatchHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddPatchAlreadyThere(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteFile(patchFileName, []byte(patchFileContent))
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile(patchFileName, []byte(patchFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddPatch(fakeFS)
|
||||
cmd := newCmdAddPatch(fSys)
|
||||
args := []string{patchFileName}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
@@ -62,9 +63,9 @@ func TestAddPatchAlreadyThere(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddPatchNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdAddPatch(fakeFS)
|
||||
cmd := newCmdAddPatch(fSys)
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -19,18 +20,18 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
)
|
||||
|
||||
func TestAddResourceHappyPath(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
fakeFS.WriteFile(resourceFileName+"another", []byte(resourceFileContent))
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
fSys.WriteFile(resourceFileName+"another", []byte(resourceFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddResource(fakeFS)
|
||||
cmd := newCmdAddResource(fSys)
|
||||
args := []string{resourceFileName + "*"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -43,11 +44,11 @@ func TestAddResourceHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddResourceAlreadyThere(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddResource(fakeFS)
|
||||
cmd := newCmdAddResource(fSys)
|
||||
args := []string{resourceFileName}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
@@ -62,9 +63,9 @@ func TestAddResourceAlreadyThere(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddResourceNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdAddResource(fakeFS)
|
||||
cmd := newCmdAddResource(fSys)
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNewAddConfigMapIsNotNil(t *testing.T) {
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys)
|
||||
if newCmdAddConfigMap(fSys, ldr, nil) == nil {
|
||||
t.Fatal("newCmdAddConfigMap shouldn't be nil")
|
||||
|
||||
@@ -73,14 +73,14 @@ func TestDataConfigValidation_Flags(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandFileSource(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.Create("dir/fa1")
|
||||
fakeFS.Create("dir/fa2")
|
||||
fakeFS.Create("dir/readme")
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.Create("dir/fa1")
|
||||
fSys.Create("dir/fa2")
|
||||
fSys.Create("dir/readme")
|
||||
fa := flagsAndArgs{
|
||||
FileSources: []string{"dir/fa*"},
|
||||
}
|
||||
fa.ExpandFileSource(fakeFS)
|
||||
fa.ExpandFileSource(fSys)
|
||||
expected := []string{
|
||||
"dir/fa1",
|
||||
"dir/fa2",
|
||||
@@ -91,15 +91,15 @@ func TestExpandFileSource(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandFileSourceWithKey(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.Create("dir/faaaaaaaaaabbbbbbbbbccccccccccccccccc")
|
||||
fakeFS.Create("dir/foobar")
|
||||
fakeFS.Create("dir/simplebar")
|
||||
fakeFS.Create("dir/readme")
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.Create("dir/faaaaaaaaaabbbbbbbbbccccccccccccccccc")
|
||||
fSys.Create("dir/foobar")
|
||||
fSys.Create("dir/simplebar")
|
||||
fSys.Create("dir/readme")
|
||||
fa := flagsAndArgs{
|
||||
FileSources: []string{"foo-key=dir/fa*", "bar-key=dir/foobar", "dir/simplebar"},
|
||||
}
|
||||
fa.ExpandFileSource(fakeFS)
|
||||
fa.ExpandFileSource(fSys)
|
||||
expected := []string{
|
||||
"foo-key=dir/faaaaaaaaaabbbbbbbbbccccccccccccccccc",
|
||||
"bar-key=dir/foobar",
|
||||
@@ -111,14 +111,14 @@ func TestExpandFileSourceWithKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandFileSourceWithKeyAndError(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.Create("dir/fa1")
|
||||
fakeFS.Create("dir/fa2")
|
||||
fakeFS.Create("dir/readme")
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.Create("dir/fa1")
|
||||
fSys.Create("dir/fa2")
|
||||
fSys.Create("dir/readme")
|
||||
fa := flagsAndArgs{
|
||||
FileSources: []string{"foo-key=dir/fa*"},
|
||||
}
|
||||
err := fa.ExpandFileSource(fakeFS)
|
||||
err := fa.ExpandFileSource(fSys)
|
||||
if err == nil {
|
||||
t.Fatalf("FileSources should not be correctly expanded: %v", fa.FileSources)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNewCmdAddSecretIsNotNil(t *testing.T) {
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
ldr := loader.NewFileLoaderAtCwd(validators.MakeFakeValidator(), fSys)
|
||||
if newCmdAddSecret(fSys, ldr, nil) == nil {
|
||||
t.Fatal("newCmdAddSecret shouldn't be nil")
|
||||
|
||||
@@ -7,19 +7,20 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
func TestFix(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomizationWith([]byte(`nameprefix: some-prefix-`))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(`nameprefix: some-prefix-`))
|
||||
|
||||
cmd := NewCmdFix(fakeFS)
|
||||
cmd := NewCmdFix(fSys)
|
||||
err := cmd.RunE(cmd, nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ func newCmdRemoveAnnotation(fSys fs.FileSystem, v func([]string) error) *cobra.C
|
||||
o.arrayValidator = v
|
||||
cmd := &cobra.Command{
|
||||
Use: "annotation",
|
||||
Short: "Removes one or more commonAnnotations from " + pgmconfig.KustomizationFileNames[0],
|
||||
Short: "Removes one or more commonAnnotations from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove annotation {annotationKey1},{annotationKey2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@@ -67,7 +68,8 @@ func newCmdRemoveLabel(fSys fs.FileSystem, v func([]string) error) *cobra.Comman
|
||||
o.arrayValidator = v
|
||||
cmd := &cobra.Command{
|
||||
Use: "label",
|
||||
Short: "Removes one or more commonLabels from " + pgmconfig.KustomizationFileNames[0],
|
||||
Short: "Removes one or more commonLabels from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove label {labelKey1},{labelKey2}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -5,27 +5,29 @@ package remove
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func makeKustomizationFS() fs.FileSystem {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
commonLabels := []string{"label1: val1", "label2: val2"}
|
||||
commonAnnotations := []string{"annotation1: val1", "annotation2: val2"}
|
||||
|
||||
fakeFS.WriteTestKustomizationWith([]byte(
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(
|
||||
fmt.Sprintf("commonLabels:\n %s\ncommonAnnotations:\n %s",
|
||||
strings.Join(commonLabels, "\n "), strings.Join(commonAnnotations, "\n "))))
|
||||
return fakeFS
|
||||
return fSys
|
||||
}
|
||||
|
||||
func readKustomizationFS(t *testing.T, fakeFS fs.FileSystem) *types.Kustomization {
|
||||
kf, err := kustfile.NewKustomizationFile(fakeFS)
|
||||
func readKustomizationFS(t *testing.T, fSys fs.FileSystem) *types.Kustomization {
|
||||
kf, err := kustfile.NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected new error %v", err)
|
||||
}
|
||||
@@ -37,8 +39,8 @@ func readKustomizationFS(t *testing.T, fakeFS fs.FileSystem) *types.Kustomizatio
|
||||
}
|
||||
|
||||
func makeKustomization(t *testing.T) *types.Kustomization {
|
||||
fakeFS := makeKustomizationFS()
|
||||
return readKustomizationFS(t, fakeFS)
|
||||
fSys := makeKustomizationFS()
|
||||
return readKustomizationFS(t, fSys)
|
||||
}
|
||||
|
||||
func TestRemoveAnnotation(t *testing.T) {
|
||||
@@ -69,10 +71,10 @@ func TestRemoveAnnotation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationIgnore(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveAnnotation(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveAnnotation(fSys, v.ValidatorArray)
|
||||
cmd.Flag("ignore-non-existence").Value.Set("true")
|
||||
args := []string{"annotation3"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
@@ -84,11 +86,11 @@ func TestRemoveAnnotationIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationNoDefinition(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomizationWith([]byte(""))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveAnnotation(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveAnnotation(fSys, v.ValidatorArray)
|
||||
args := []string{"annotation1,annotation2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -102,11 +104,11 @@ func TestRemoveAnnotationNoDefinition(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationNoDefinitionIgnore(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomizationWith([]byte(""))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
cmd.Flag("ignore-non-existence").Value.Set("true")
|
||||
args := []string{"annotation1,annotation2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
@@ -118,10 +120,10 @@ func TestRemoveAnnotationNoDefinitionIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationNoArgs(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveAnnotation(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveAnnotation(fSys, v.ValidatorArray)
|
||||
err := cmd.Execute()
|
||||
v.VerifyNoCall()
|
||||
|
||||
@@ -134,10 +136,10 @@ func TestRemoveAnnotationNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationInvalidFormat(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdRemoveAnnotation(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveAnnotation(fSys, v.ValidatorArray)
|
||||
args := []string{"nospecialchars%^=@"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -151,10 +153,10 @@ func TestRemoveAnnotationInvalidFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationMultipleArgs(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveAnnotation(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveAnnotation(fSys, v.ValidatorArray)
|
||||
args := []string{"annotation1,annotation2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -163,7 +165,7 @@ func TestRemoveAnnotationMultipleArgs(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
splitArgs := strings.Split(args[0], ",")
|
||||
for _, k := range splitArgs {
|
||||
if _, exist := m.CommonAnnotations[k]; exist {
|
||||
@@ -173,10 +175,10 @@ func TestRemoveAnnotationMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAnnotationMultipleArgsInvalidFormat(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdRemoveAnnotation(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveAnnotation(fSys, v.ValidatorArray)
|
||||
args := []string{"annotation1", "annotation2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyNoCall()
|
||||
@@ -217,10 +219,10 @@ func TestRemoveLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelIgnore(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
cmd.Flag("ignore-non-existence").Value.Set("true")
|
||||
args := []string{"label3"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
@@ -232,11 +234,11 @@ func TestRemoveLabelIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelNoDefinition(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomizationWith([]byte(""))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
args := []string{"label1,label2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -250,11 +252,11 @@ func TestRemoveLabelNoDefinition(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelNoDefinitionIgnore(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomizationWith([]byte(""))
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(""))
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
cmd.Flag("ignore-non-existence").Value.Set("true")
|
||||
args := []string{"label1,label2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
@@ -266,10 +268,10 @@ func TestRemoveLabelNoDefinitionIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelNoArgs(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
err := cmd.Execute()
|
||||
v.VerifyNoCall()
|
||||
|
||||
@@ -282,10 +284,10 @@ func TestRemoveLabelNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelInvalidFormat(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
args := []string{"exclamation!"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -299,10 +301,10 @@ func TestRemoveLabelInvalidFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelMultipleArgs(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeHappyMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
args := []string{"label1,label2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyCall()
|
||||
@@ -311,7 +313,7 @@ func TestRemoveLabelMultipleArgs(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
splitArgs := strings.Split(args[0], ",")
|
||||
for _, k := range splitArgs {
|
||||
if _, exist := m.CommonLabels[k]; exist {
|
||||
@@ -321,10 +323,10 @@ func TestRemoveLabelMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLabelMultipleArgsInvalidFormat(t *testing.T) {
|
||||
fakeFS := makeKustomizationFS()
|
||||
fSys := makeKustomizationFS()
|
||||
|
||||
v := validators.MakeSadMapValidator(t)
|
||||
cmd := newCmdRemoveLabel(fakeFS, v.ValidatorArray)
|
||||
cmd := newCmdRemoveLabel(fSys, v.ValidatorArray)
|
||||
args := []string{"label1", "label2"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
v.VerifyNoCall()
|
||||
|
||||
@@ -25,7 +25,8 @@ func newCmdRemovePatch(fsys fs.FileSystem) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "patch",
|
||||
Short: "Removes one or more patches from " + pgmconfig.KustomizationFileNames[0],
|
||||
Short: "Removes one or more patches from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove patch {filepath}`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/patch"
|
||||
)
|
||||
@@ -20,23 +21,23 @@ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
)
|
||||
|
||||
func makeKustomizationPatchFS() fs.FileSystem {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
patches := []string{"patch1.yaml", "patch2.yaml"}
|
||||
|
||||
fakeFS.WriteTestKustomizationWith([]byte(
|
||||
testutils.WriteTestKustomizationWith(fSys, []byte(
|
||||
fmt.Sprintf("patchesStrategicMerge:\n - %s",
|
||||
strings.Join(patches, "\n - "))))
|
||||
|
||||
for _, p := range patches {
|
||||
fakeFS.WriteFile(p, []byte(patchFileContent))
|
||||
fSys.WriteFile(p, []byte(patchFileContent))
|
||||
}
|
||||
fakeFS.WriteFile("patch3.yaml", []byte(patchFileContent))
|
||||
return fakeFS
|
||||
fSys.WriteFile("patch3.yaml", []byte(patchFileContent))
|
||||
return fSys
|
||||
}
|
||||
|
||||
func TestRemovePatch(t *testing.T) {
|
||||
fakeFS := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fakeFS)
|
||||
fSys := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fSys)
|
||||
args := []string{"patch1.yaml"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
|
||||
@@ -44,7 +45,7 @@ func TestRemovePatch(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
for _, k := range args {
|
||||
if patch.Exist(m.PatchesStrategicMerge, k) {
|
||||
t.Errorf("%s must be deleted", k)
|
||||
@@ -53,8 +54,8 @@ func TestRemovePatch(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemovePatchMultipleArgs(t *testing.T) {
|
||||
fakeFS := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fakeFS)
|
||||
fSys := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fSys)
|
||||
args := []string{"patch1.yaml", "patch2.yaml"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
|
||||
@@ -62,7 +63,7 @@ func TestRemovePatchMultipleArgs(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
for _, k := range args {
|
||||
if patch.Exist(m.PatchesStrategicMerge, k) {
|
||||
t.Errorf("%s must be deleted", k)
|
||||
@@ -71,8 +72,8 @@ func TestRemovePatchMultipleArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemovePatchGlob(t *testing.T) {
|
||||
fakeFS := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fakeFS)
|
||||
fSys := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fSys)
|
||||
args := []string{"patch*.yaml"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
|
||||
@@ -80,15 +81,15 @@ func TestRemovePatchGlob(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
if len(m.PatchesStrategicMerge) != 0 {
|
||||
t.Errorf("all patch must be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemovePatchNotDefinedInKustomization(t *testing.T) {
|
||||
fakeFS := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fakeFS)
|
||||
fSys := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fSys)
|
||||
args := []string{"patch3.yaml"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
|
||||
@@ -96,7 +97,7 @@ func TestRemovePatchNotDefinedInKustomization(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
for _, k := range []string{"patch1.yaml", "patch2.yaml"} {
|
||||
if !patch.Exist(m.PatchesStrategicMerge, k) {
|
||||
t.Errorf("%s must exist", k)
|
||||
@@ -105,8 +106,8 @@ func TestRemovePatchNotDefinedInKustomization(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemovePatchNotExist(t *testing.T) {
|
||||
fakeFS := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fakeFS)
|
||||
fSys := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fSys)
|
||||
args := []string{"patch4.yaml"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
|
||||
@@ -114,7 +115,7 @@ func TestRemovePatchNotExist(t *testing.T) {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
m := readKustomizationFS(t, fakeFS)
|
||||
m := readKustomizationFS(t, fSys)
|
||||
for _, k := range []string{"patch1.yaml", "patch2.yaml"} {
|
||||
if !patch.Exist(m.PatchesStrategicMerge, k) {
|
||||
t.Errorf("%s must exist", k)
|
||||
@@ -123,8 +124,8 @@ func TestRemovePatchNotExist(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemovePatchNoArgs(t *testing.T) {
|
||||
fakeFS := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fakeFS)
|
||||
fSys := makeKustomizationPatchFS()
|
||||
cmd := newCmdRemovePatch(fSys)
|
||||
err := cmd.RunE(cmd, nil)
|
||||
|
||||
if err == nil {
|
||||
|
||||
@@ -23,7 +23,8 @@ func newCmdRemoveResource(fsys fs.FileSystem) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "resource",
|
||||
Short: "Removes one or more resource file paths from " + pgmconfig.KustomizationFileNames[0],
|
||||
Short: "Removes one or more resource file paths from " +
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
Example: `
|
||||
remove resource my-resource.yml
|
||||
remove resource resource1.yml resource2.yml resource3.yml
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -124,9 +125,12 @@ func TestRemoveResources(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomizationWith([]byte(fmt.Sprintf("resources:\n - %s", strings.Join(tc.given.resources, "\n - "))))
|
||||
cmd := newCmdRemoveResource(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys,
|
||||
[]byte(fmt.Sprintf(
|
||||
"resources:\n - %s", strings.Join(tc.given.resources, "\n - "))))
|
||||
cmd := newCmdRemoveResource(fSys)
|
||||
err := cmd.RunE(cmd, tc.given.removeArgs)
|
||||
if err != nil && tc.expected.err == nil {
|
||||
|
||||
@@ -137,7 +141,7 @@ func TestRemoveResources(t *testing.T) {
|
||||
}
|
||||
return
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -15,16 +16,16 @@ const (
|
||||
)
|
||||
|
||||
func TestSetNamePrefixHappyPath(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNamePrefix(fakeFS)
|
||||
cmd := newCmdSetNamePrefix(fSys)
|
||||
args := []string{goodPrefixValue}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -34,9 +35,9 @@ func TestSetNamePrefixHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamePrefixNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdSetNamePrefix(fakeFS)
|
||||
cmd := newCmdSetNamePrefix(fSys)
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -15,16 +16,16 @@ const (
|
||||
)
|
||||
|
||||
func TestSetNameSuffixHappyPath(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNameSuffix(fakeFS)
|
||||
cmd := newCmdSetNameSuffix(fSys)
|
||||
args := []string{goodSuffixValue}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -34,9 +35,8 @@ func TestSetNameSuffixHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNameSuffixNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
|
||||
cmd := newCmdSetNameSuffix(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
cmd := newCmdSetNameSuffix(fSys)
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
)
|
||||
|
||||
@@ -189,16 +190,16 @@ func TestSetImage(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("%s%v", tc.description, tc.given.args), func(t *testing.T) {
|
||||
// arrange
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
cmd := newCmdSetImage(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
cmd := newCmdSetImage(fSys)
|
||||
|
||||
if len(tc.given.infileImages) > 0 {
|
||||
// write file with infileImages
|
||||
fakeFS.WriteTestKustomizationWith([]byte(strings.Join(tc.given.infileImages, "\n")))
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys,
|
||||
[]byte(strings.Join(tc.given.infileImages, "\n")))
|
||||
} else {
|
||||
// writes default kustomization file
|
||||
fakeFS.WriteTestKustomization()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
}
|
||||
|
||||
// act
|
||||
@@ -210,7 +211,7 @@ func TestSetImage(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
t.FailNow()
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/validators"
|
||||
)
|
||||
@@ -17,16 +18,16 @@ const (
|
||||
)
|
||||
|
||||
func TestSetNamespaceHappyPath(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNamespace(fakeFS, validators.MakeFakeValidator())
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
args := []string{goodNamespaceValue}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -37,10 +38,10 @@ func TestSetNamespaceHappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamespaceOverride(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdSetNamespace(fakeFS, validators.MakeFakeValidator())
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
args := []string{goodNamespaceValue}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err != nil {
|
||||
@@ -51,7 +52,7 @@ func TestSetNamespaceOverride(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected cmd error: %v", err)
|
||||
}
|
||||
content, err := fakeFS.ReadTestKustomization()
|
||||
content, err := testutils.ReadTestKustomization(fSys)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected read error: %v", err)
|
||||
}
|
||||
@@ -62,9 +63,9 @@ func TestSetNamespaceOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamespaceNoArgs(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdSetNamespace(fakeFS, validators.MakeFakeValidator())
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
err := cmd.Execute()
|
||||
if err == nil {
|
||||
t.Errorf("expected error: %v", err)
|
||||
@@ -75,9 +76,9 @@ func TestSetNamespaceNoArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNamespaceInvalid(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
|
||||
cmd := newCmdSetNamespace(fakeFS, validators.MakeFakeValidator())
|
||||
cmd := newCmdSetNamespace(fSys, validators.MakeFakeValidator())
|
||||
args := []string{"/badnamespace/"}
|
||||
err := cmd.RunE(cmd, args)
|
||||
if err == nil {
|
||||
|
||||
@@ -34,7 +34,7 @@ func determineFieldOrder() []string {
|
||||
s := reflect.ValueOf(&types.Kustomization{}).Elem()
|
||||
typeOfT := s.Type()
|
||||
for i := 0; i < s.NumField(); i++ {
|
||||
m[string(typeOfT.Field(i).Name)] = false
|
||||
m[typeOfT.Field(i).Name] = false
|
||||
}
|
||||
|
||||
ordered := []string{
|
||||
@@ -119,7 +119,7 @@ func NewKustomizationFile(fSys fs.FileSystem) (*kustomizationFile, error) { // n
|
||||
func (mf *kustomizationFile) validate() error {
|
||||
match := 0
|
||||
var path []string
|
||||
for _, kfilename := range pgmconfig.KustomizationFileNames {
|
||||
for _, kfilename := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
if mf.fSys.Exists(kfilename) {
|
||||
match += 1
|
||||
path = append(path, kfilename)
|
||||
@@ -128,7 +128,9 @@ func (mf *kustomizationFile) validate() error {
|
||||
|
||||
switch match {
|
||||
case 0:
|
||||
return fmt.Errorf("Missing kustomization file '%s'.\n", pgmconfig.KustomizationFileNames[0])
|
||||
return fmt.Errorf(
|
||||
"Missing kustomization file '%s'.\n",
|
||||
pgmconfig.DefaultKustomizationFileName())
|
||||
case 1:
|
||||
mf.path = path[0]
|
||||
default:
|
||||
@@ -228,7 +230,6 @@ func (mf *kustomizationFile) marshal(kustomization *types.Kustomization) ([]byte
|
||||
return content, nil
|
||||
}
|
||||
output = append(output, content...)
|
||||
|
||||
}
|
||||
return output, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
@@ -55,8 +57,8 @@ func TestWriteAndRead(t *testing.T) {
|
||||
NamePrefix: "prefix",
|
||||
}
|
||||
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys.WriteTestKustomization()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomization(fSys)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
@@ -77,8 +79,8 @@ func TestWriteAndRead(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewNotExist(t *testing.T) {
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
_, err := NewKustomizationFile(fakeFS)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
_, err := NewKustomizationFile(fSys)
|
||||
if err == nil {
|
||||
t.Fatalf("expect an error")
|
||||
}
|
||||
@@ -86,7 +88,7 @@ func TestNewNotExist(t *testing.T) {
|
||||
if !strings.Contains(err.Error(), contained) {
|
||||
t.Fatalf("expect an error contains %q, but got %v", contained, err)
|
||||
}
|
||||
_, err = NewKustomizationFile(fakeFS)
|
||||
_, err = NewKustomizationFile(fSys)
|
||||
if err == nil {
|
||||
t.Fatalf("expect an error")
|
||||
}
|
||||
@@ -95,7 +97,7 @@ func TestNewNotExist(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecondarySuffix(t *testing.T) {
|
||||
func TestAllKustomizationFileNames(t *testing.T) {
|
||||
kcontent := `
|
||||
configMapGenerator:
|
||||
- literals:
|
||||
@@ -103,14 +105,16 @@ configMapGenerator:
|
||||
- baz=qux
|
||||
name: my-configmap
|
||||
`
|
||||
fakeFS := fs.MakeFakeFS()
|
||||
fakeFS.WriteFile(pgmconfig.KustomizationFileNames[1], []byte(kcontent))
|
||||
k, err := NewKustomizationFile(fakeFS)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
}
|
||||
if k.path != pgmconfig.KustomizationFileNames[1] {
|
||||
t.Fatalf("Load incorrect file path %s", k.path)
|
||||
for _, n := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile(n, []byte(kcontent))
|
||||
k, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
}
|
||||
if k.path != n {
|
||||
t.Fatalf("Load incorrect file path %s", k.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +143,8 @@ patchesStrategicMerge:
|
||||
- service.yaml
|
||||
- pod.yaml
|
||||
`)
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys.WriteTestKustomizationWith(kustomizationContentWithComments)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
@@ -231,8 +235,9 @@ patchesStrategicMerge:
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
`)
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys.WriteTestKustomizationWith(kustomizationContentWithComments)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
@@ -268,8 +273,9 @@ patchesStrategicMerge:
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
`)
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys.WriteTestKustomizationWith(kustomizationContentWithComments)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(
|
||||
fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
@@ -313,8 +319,8 @@ patches:
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
`)
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys.WriteTestKustomizationWith(kustomizationContentWithComments)
|
||||
fSys := fs.MakeFsInMemory()
|
||||
testutils.WriteTestKustomizationWith(fSys, kustomizationContentWithComments)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
|
||||
47
kustomize/internal/commands/testutils/testutils.go
Normal file
47
kustomize/internal/commands/testutils/testutils.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package testutils
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
// kustomizationContent is used in tests.
|
||||
kustomizationContent = `apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namePrefix: some-prefix
|
||||
nameSuffix: some-suffix
|
||||
# Labels to add to all objects and selectors.
|
||||
# These labels would also be used to form the selector for apply --prune
|
||||
# Named differently than “labels” to avoid confusion with metadata for this object
|
||||
commonLabels:
|
||||
app: helloworld
|
||||
commonAnnotations:
|
||||
note: This is an example annotation
|
||||
resources: []
|
||||
#- service.yaml
|
||||
#- ../some-dir/
|
||||
# There could also be configmaps in Base, which would make these overlays
|
||||
configMapGenerator: []
|
||||
# There could be secrets in Base, if just using a fork/rebase workflow
|
||||
secretGenerator: []
|
||||
`
|
||||
)
|
||||
|
||||
// WriteTestKustomization writes a standard test file.
|
||||
func WriteTestKustomization(fSys fs.FileSystem) {
|
||||
WriteTestKustomizationWith(fSys, []byte(kustomizationContent))
|
||||
}
|
||||
|
||||
// WriteTestKustomizationWith writes content to a well known file name.
|
||||
func WriteTestKustomizationWith(fSys fs.FileSystem, bytes []byte) {
|
||||
fSys.WriteFile(pgmconfig.DefaultKustomizationFileName(), bytes)
|
||||
}
|
||||
|
||||
// ReadTestKustomization reads content from a well known file name.
|
||||
func ReadTestKustomization(fSys fs.FileSystem) ([]byte, error) {
|
||||
return fSys.ReadFile(pgmconfig.DefaultKustomizationFileName())
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
@@ -27,7 +14,7 @@ import (
|
||||
type ConfirmedDir string
|
||||
|
||||
// NewTmpConfirmedDir returns a temporary dir, else error.
|
||||
// The directory is cleaned, no symlinks, etc. so its
|
||||
// The directory is cleaned, no symlinks, etc. so it's
|
||||
// returned as a ConfirmedDir.
|
||||
func NewTmpConfirmedDir() (ConfirmedDir, error) {
|
||||
n, err := ioutil.TempDir("", "kustomize-")
|
||||
@@ -36,13 +23,12 @@ func NewTmpConfirmedDir() (ConfirmedDir, error) {
|
||||
}
|
||||
|
||||
// In MacOs `ioutil.TempDir` creates a directory
|
||||
// with root in the `/var` folder, which is in turn a symlinked path
|
||||
// to `/private/var`.
|
||||
// with root in the `/var` folder, which is in turn
|
||||
// a symlinked path to `/private/var`.
|
||||
// Function `filepath.EvalSymlinks`is used to
|
||||
// resolve the real absolute path.
|
||||
deLinked, err := filepath.EvalSymlinks(n)
|
||||
return ConfirmedDir(deLinked), err
|
||||
|
||||
}
|
||||
|
||||
// HasPrefix returns true if the directory argument
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
@@ -22,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestJoin(t *testing.T) {
|
||||
fSys := MakeFakeFS()
|
||||
fSys := MakeFsInMemory()
|
||||
err := fSys.Mkdir("/foo")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
@@ -40,7 +27,7 @@ func TestJoin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPrefix_Slash(t *testing.T) {
|
||||
d, f, err := MakeFakeFS().CleanedAbs("/")
|
||||
d, f, err := MakeFsInMemory().CleanedAbs("/")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
@@ -56,7 +43,7 @@ func TestHasPrefix_Slash(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPrefix_SlashFoo(t *testing.T) {
|
||||
fSys := MakeFakeFS()
|
||||
fSys := MakeFsInMemory()
|
||||
err := fSys.Mkdir("/foo")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
@@ -77,7 +64,7 @@ func TestHasPrefix_SlashFoo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPrefix_SlashFooBar(t *testing.T) {
|
||||
fSys := MakeFakeFS()
|
||||
fSys := MakeFsInMemory()
|
||||
err := fSys.MkdirAll("/foo/bar")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
)
|
||||
|
||||
var _ File = &FakeFile{}
|
||||
|
||||
// FakeFile implements File in-memory for tests.
|
||||
type FakeFile struct {
|
||||
name string
|
||||
content []byte
|
||||
dir bool
|
||||
open bool
|
||||
}
|
||||
|
||||
// makeDir makes a fake directory.
|
||||
func makeDir(name string) *FakeFile {
|
||||
return &FakeFile{name: name, dir: true}
|
||||
}
|
||||
|
||||
// Close marks the fake file closed.
|
||||
func (f *FakeFile) Close() error {
|
||||
f.open = false
|
||||
return nil
|
||||
}
|
||||
|
||||
// Read never fails, and doesn't mutate p.
|
||||
func (f *FakeFile) Read(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// Write saves the contents of the argument to memory.
|
||||
func (f *FakeFile) Write(p []byte) (n int, err error) {
|
||||
f.content = p
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// ContentMatches returns true if v matches fake file's content.
|
||||
func (f *FakeFile) ContentMatches(v []byte) bool {
|
||||
return bytes.Equal(v, f.content)
|
||||
}
|
||||
|
||||
// GetContent the content of a fake file.
|
||||
func (f *FakeFile) GetContent() []byte {
|
||||
return f.content
|
||||
}
|
||||
|
||||
// Stat returns nil.
|
||||
func (f *FakeFile) Stat() (os.FileInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ os.FileInfo = &Fakefileinfo{}
|
||||
|
||||
// Fakefileinfo implements Fakefileinfo using a fake in-memory filesystem.
|
||||
type Fakefileinfo struct {
|
||||
*FakeFile
|
||||
}
|
||||
|
||||
// Name returns the name of the file
|
||||
func (fi *Fakefileinfo) Name() string { return fi.name }
|
||||
|
||||
// Size returns the size of the file
|
||||
func (fi *Fakefileinfo) Size() int64 { return int64(len(fi.content)) }
|
||||
|
||||
// Mode returns the file mode
|
||||
func (fi *Fakefileinfo) Mode() os.FileMode { return 0777 }
|
||||
|
||||
// ModTime returns the modification time
|
||||
func (fi *Fakefileinfo) ModTime() time.Time { return time.Time{} }
|
||||
|
||||
// IsDir returns if it is a directory
|
||||
func (fi *Fakefileinfo) IsDir() bool { return fi.dir }
|
||||
|
||||
// Sys should return underlying data source, but it now returns nil
|
||||
func (fi *Fakefileinfo) Sys() interface{} { return nil }
|
||||
34
pkg/fs/fileinfo.go
Normal file
34
pkg/fs/fileinfo.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ os.FileInfo = &fileInfo{}
|
||||
|
||||
// fileInfo implements os.FileInfo for a fileInMemory instance.
|
||||
type fileInfo struct {
|
||||
*fileInMemory
|
||||
}
|
||||
|
||||
// Name returns the name of the file
|
||||
func (fi *fileInfo) Name() string { return fi.name }
|
||||
|
||||
// Size returns the size of the file
|
||||
func (fi *fileInfo) Size() int64 { return int64(len(fi.content)) }
|
||||
|
||||
// Mode returns the file mode
|
||||
func (fi *fileInfo) Mode() os.FileMode { return 0777 }
|
||||
|
||||
// ModTime returns the modification time
|
||||
func (fi *fileInfo) ModTime() time.Time { return time.Time{} }
|
||||
|
||||
// IsDir returns if it is a directory
|
||||
func (fi *fileInfo) IsDir() bool { return fi.dir }
|
||||
|
||||
// Sys should return underlying data source, but it now returns nil
|
||||
func (fi *fileInfo) Sys() interface{} { return nil }
|
||||
56
pkg/fs/fileinmemory.go
Normal file
56
pkg/fs/fileinmemory.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
)
|
||||
|
||||
var _ File = &fileInMemory{}
|
||||
|
||||
// fileInMemory implements File in-memory for tests.
|
||||
type fileInMemory struct {
|
||||
name string
|
||||
content []byte
|
||||
dir bool
|
||||
open bool
|
||||
}
|
||||
|
||||
// makeDir makes a fake directory.
|
||||
func makeDir(name string) *fileInMemory {
|
||||
return &fileInMemory{name: name, dir: true}
|
||||
}
|
||||
|
||||
// Close marks the fake file closed.
|
||||
func (f *fileInMemory) Close() error {
|
||||
f.open = false
|
||||
return nil
|
||||
}
|
||||
|
||||
// Read never fails, and doesn't mutate p.
|
||||
func (f *fileInMemory) Read(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// Write saves the contents of the argument to memory.
|
||||
func (f *fileInMemory) Write(p []byte) (n int, err error) {
|
||||
f.content = p
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// ContentMatches returns true if v matches fake file's content.
|
||||
func (f *fileInMemory) ContentMatches(v []byte) bool {
|
||||
return bytes.Equal(v, f.content)
|
||||
}
|
||||
|
||||
// GetContent the content of a fake file.
|
||||
func (f *fileInMemory) GetContent() []byte {
|
||||
return f.content
|
||||
}
|
||||
|
||||
// Stat returns nil.
|
||||
func (f *fileInMemory) Stat() (os.FileInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
27
pkg/fs/fileondisk.go
Normal file
27
pkg/fs/fileondisk.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
var _ File = &fileOnDisk{}
|
||||
|
||||
// fileOnDisk implements File using the local filesystem.
|
||||
type fileOnDisk struct {
|
||||
file *os.File
|
||||
}
|
||||
|
||||
// Close closes a file.
|
||||
func (f *fileOnDisk) Close() error { return f.file.Close() }
|
||||
|
||||
// Read reads a file's content.
|
||||
func (f *fileOnDisk) Read(p []byte) (n int, err error) { return f.file.Read(p) }
|
||||
|
||||
// Write writes bytes to a file
|
||||
func (f *fileOnDisk) Write(p []byte) (n int, err error) { return f.file.Write(p) }
|
||||
|
||||
// Stat returns an interface which has all the information regarding the file.
|
||||
func (f *fileOnDisk) Stat() (os.FileInfo, error) { return f.file.Stat() }
|
||||
49
pkg/fs/fs.go
49
pkg/fs/fs.go
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package fs provides a file system abstraction layer.
|
||||
package fs
|
||||
@@ -25,17 +12,33 @@ import (
|
||||
|
||||
// FileSystem groups basic os filesystem methods.
|
||||
type FileSystem interface {
|
||||
// Create a file.
|
||||
Create(name string) (File, error)
|
||||
Mkdir(name string) error
|
||||
MkdirAll(name string) error
|
||||
RemoveAll(name string) error
|
||||
Open(name string) (File, error)
|
||||
IsDir(name string) bool
|
||||
// MkDir makes a directory.
|
||||
Mkdir(path string) error
|
||||
// MkDir makes a directory path, creating intervening directories.
|
||||
MkdirAll(path string) error
|
||||
// RemoveAll removes path and any children it contains.
|
||||
RemoveAll(path string) error
|
||||
// Open opens the named file for reading.
|
||||
Open(path string) (File, error)
|
||||
// IsDir returns true if the path is a directory.
|
||||
IsDir(path string) bool
|
||||
// CleanedAbs converts the given path into a
|
||||
// directory and a file name, where the directory
|
||||
// is represented as a ConfirmedDir and all that implies.
|
||||
// If the entire path is a directory, the file component
|
||||
// is an empty string.
|
||||
CleanedAbs(path string) (ConfirmedDir, string, error)
|
||||
Exists(name string) bool
|
||||
// Exists is true if the path exists in the file system.
|
||||
Exists(path string) bool
|
||||
// Glob returns the list of matching files
|
||||
Glob(pattern string) ([]string, error)
|
||||
ReadFile(name string) ([]byte, error)
|
||||
WriteFile(name string, data []byte) error
|
||||
// ReadFile returns the contents of the file at the given path.
|
||||
ReadFile(path string) ([]byte, error)
|
||||
// WriteFile writes the data to a file at the given path.
|
||||
WriteFile(path string, data []byte) error
|
||||
// Walk walks the file system with the given WalkFunc.
|
||||
Walk(path string, walkFn filepath.WalkFunc) error
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
@@ -22,20 +9,19 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
|
||||
var _ FileSystem = &fakeFs{}
|
||||
var _ FileSystem = &fsInMemory{}
|
||||
|
||||
// fakeFs implements FileSystem using a fake in-memory filesystem.
|
||||
type fakeFs struct {
|
||||
m map[string]*FakeFile
|
||||
// fsInMemory implements FileSystem using a in-memory filesystem
|
||||
// primarily for use in tests.
|
||||
type fsInMemory struct {
|
||||
m map[string]*fileInMemory
|
||||
}
|
||||
|
||||
// MakeFakeFS returns an instance of fakeFs with no files in it.
|
||||
func MakeFakeFS() *fakeFs {
|
||||
result := &fakeFs{m: map[string]*FakeFile{}}
|
||||
// MakeFsInMemory returns an instance of fsInMemory with no files in it.
|
||||
func MakeFsInMemory() FileSystem {
|
||||
result := &fsInMemory{m: map[string]*fileInMemory{}}
|
||||
result.Mkdir(separator)
|
||||
return result
|
||||
}
|
||||
@@ -43,55 +29,30 @@ func MakeFakeFS() *fakeFs {
|
||||
const (
|
||||
separator = string(filepath.Separator)
|
||||
doubleSep = separator + separator
|
||||
// kustomizationContent is used in tests.
|
||||
kustomizationContent = `apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namePrefix: some-prefix
|
||||
nameSuffix: some-suffix
|
||||
# Labels to add to all objects and selectors.
|
||||
# These labels would also be used to form the selector for apply --prune
|
||||
# Named differently than “labels” to avoid confusion with metadata for this object
|
||||
commonLabels:
|
||||
app: helloworld
|
||||
commonAnnotations:
|
||||
note: This is an example annotation
|
||||
resources: []
|
||||
#- service.yaml
|
||||
#- ../some-dir/
|
||||
# There could also be configmaps in Base, which would make these overlays
|
||||
configMapGenerator: []
|
||||
# There could be secrets in Base, if just using a fork/rebase workflow
|
||||
secretGenerator: []
|
||||
`
|
||||
)
|
||||
|
||||
// Create assures a fake file appears in the in-memory file system.
|
||||
func (fs *fakeFs) Create(name string) (File, error) {
|
||||
f := &FakeFile{}
|
||||
func (fs *fsInMemory) Create(name string) (File, error) {
|
||||
f := &fileInMemory{}
|
||||
f.open = true
|
||||
fs.m[name] = f
|
||||
return fs.m[name], nil
|
||||
}
|
||||
|
||||
// RPath returns a rooted path, e.g. "/hey/foo" as opposed to "hey/foo".
|
||||
func (fs *fakeFs) RPath(elem ...string) string {
|
||||
return separator + filepath.Join(elem...)
|
||||
}
|
||||
|
||||
// Mkdir assures a fake directory appears in the in-memory file system.
|
||||
func (fs *fakeFs) Mkdir(name string) error {
|
||||
func (fs *fsInMemory) Mkdir(name string) error {
|
||||
fs.m[name] = makeDir(name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MkdirAll delegates to Mkdir
|
||||
func (fs *fakeFs) MkdirAll(name string) error {
|
||||
func (fs *fsInMemory) MkdirAll(name string) error {
|
||||
return fs.Mkdir(name)
|
||||
}
|
||||
|
||||
// RemoveAll presumably does rm -r on a path.
|
||||
// There's no error.
|
||||
func (fs *fakeFs) RemoveAll(name string) error {
|
||||
func (fs *fsInMemory) RemoveAll(name string) error {
|
||||
var toRemove []string
|
||||
for k := range fs.m {
|
||||
if strings.HasPrefix(k, name) {
|
||||
@@ -105,7 +66,7 @@ func (fs *fakeFs) RemoveAll(name string) error {
|
||||
}
|
||||
|
||||
// Open returns a fake file in the open state.
|
||||
func (fs *fakeFs) Open(name string) (File, error) {
|
||||
func (fs *fsInMemory) Open(name string) (File, error) {
|
||||
if _, found := fs.m[name]; !found {
|
||||
return nil, fmt.Errorf("file %q cannot be opened", name)
|
||||
}
|
||||
@@ -113,7 +74,7 @@ func (fs *fakeFs) Open(name string) (File, error) {
|
||||
}
|
||||
|
||||
// CleanedAbs cannot fail.
|
||||
func (fs *fakeFs) CleanedAbs(path string) (ConfirmedDir, string, error) {
|
||||
func (fs *fsInMemory) CleanedAbs(path string) (ConfirmedDir, string, error) {
|
||||
if fs.IsDir(path) {
|
||||
return ConfirmedDir(path), "", nil
|
||||
}
|
||||
@@ -125,13 +86,13 @@ func (fs *fakeFs) CleanedAbs(path string) (ConfirmedDir, string, error) {
|
||||
}
|
||||
|
||||
// Exists returns true if file is known.
|
||||
func (fs *fakeFs) Exists(name string) bool {
|
||||
func (fs *fsInMemory) Exists(name string) bool {
|
||||
_, found := fs.m[name]
|
||||
return found
|
||||
}
|
||||
|
||||
// Glob returns the list of matching files
|
||||
func (fs *fakeFs) Glob(pattern string) ([]string, error) {
|
||||
func (fs *fsInMemory) Glob(pattern string) ([]string, error) {
|
||||
var result []string
|
||||
for p := range fs.m {
|
||||
if fs.pathMatch(p, pattern) {
|
||||
@@ -143,7 +104,7 @@ func (fs *fakeFs) Glob(pattern string) ([]string, error) {
|
||||
}
|
||||
|
||||
// IsDir returns true if the file exists and is a directory.
|
||||
func (fs *fakeFs) IsDir(name string) bool {
|
||||
func (fs *fsInMemory) IsDir(name string) bool {
|
||||
f, found := fs.m[name]
|
||||
if found && f.dir {
|
||||
return true
|
||||
@@ -160,37 +121,23 @@ func (fs *fakeFs) IsDir(name string) bool {
|
||||
}
|
||||
|
||||
// ReadFile always returns an empty bytes and error depending on content of m.
|
||||
func (fs *fakeFs) ReadFile(name string) ([]byte, error) {
|
||||
func (fs *fsInMemory) ReadFile(name string) ([]byte, error) {
|
||||
if ff, found := fs.m[name]; found {
|
||||
return ff.content, nil
|
||||
}
|
||||
return nil, fmt.Errorf("cannot read file %q", name)
|
||||
}
|
||||
|
||||
func (fs *fakeFs) ReadTestKustomization() ([]byte, error) {
|
||||
return fs.ReadFile(pgmconfig.KustomizationFileNames[0])
|
||||
}
|
||||
|
||||
// WriteFile always succeeds and does nothing.
|
||||
func (fs *fakeFs) WriteFile(name string, c []byte) error {
|
||||
ff := &FakeFile{}
|
||||
func (fs *fsInMemory) WriteFile(name string, c []byte) error {
|
||||
ff := &fileInMemory{}
|
||||
ff.Write(c)
|
||||
fs.m[name] = ff
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteTestKustomization writes a standard test file.
|
||||
func (fs *fakeFs) WriteTestKustomization() {
|
||||
fs.WriteTestKustomizationWith([]byte(kustomizationContent))
|
||||
}
|
||||
|
||||
// WriteTestKustomizationWith writes a standard test file.
|
||||
func (fs *fakeFs) WriteTestKustomizationWith(bytes []byte) {
|
||||
fs.WriteFile(pgmconfig.KustomizationFileNames[0], bytes)
|
||||
}
|
||||
|
||||
// Walk implements filepath.Walk using the fake filesystem.
|
||||
func (fs *fakeFs) Walk(path string, walkFn filepath.WalkFunc) error {
|
||||
func (fs *fsInMemory) Walk(path string, walkFn filepath.WalkFunc) error {
|
||||
info, err := fs.lstat(path)
|
||||
if err != nil {
|
||||
err = walkFn(path, info, err)
|
||||
@@ -203,20 +150,20 @@ func (fs *fakeFs) Walk(path string, walkFn filepath.WalkFunc) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (fs *fakeFs) pathMatch(path, pattern string) bool {
|
||||
func (fs *fsInMemory) pathMatch(path, pattern string) bool {
|
||||
match, _ := filepath.Match(pattern, path)
|
||||
return match
|
||||
}
|
||||
|
||||
func (fs *fakeFs) lstat(path string) (*Fakefileinfo, error) {
|
||||
func (fs *fsInMemory) lstat(path string) (*fileInfo, error) {
|
||||
f, found := fs.m[path]
|
||||
if !found {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
return &Fakefileinfo{f}, nil
|
||||
return &fileInfo{f}, nil
|
||||
}
|
||||
|
||||
func (fs *fakeFs) join(elem ...string) string {
|
||||
func (fs *fsInMemory) join(elem ...string) string {
|
||||
for i, e := range elem {
|
||||
if e != "" {
|
||||
return strings.Replace(
|
||||
@@ -226,7 +173,7 @@ func (fs *fakeFs) join(elem ...string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (fs *fakeFs) readDirNames(path string) []string {
|
||||
func (fs *fsInMemory) readDirNames(path string) []string {
|
||||
var names []string
|
||||
if !strings.HasSuffix(path, separator) {
|
||||
path += separator
|
||||
@@ -247,7 +194,7 @@ func (fs *fakeFs) readDirNames(path string) []string {
|
||||
return names
|
||||
}
|
||||
|
||||
func (fs *fakeFs) walk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
|
||||
func (fs *fsInMemory) walk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
|
||||
if !info.IsDir() {
|
||||
return walkFn(path, info, nil)
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
@@ -23,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestExists(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
if x.Exists("foo") {
|
||||
t.Fatalf("expected no foo")
|
||||
}
|
||||
@@ -34,7 +21,7 @@ func TestExists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsDir(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
expectedName := "my-dir"
|
||||
err := x.Mkdir(expectedName)
|
||||
if err != nil {
|
||||
@@ -59,7 +46,7 @@ func shouldNotExist(t *testing.T, fs FileSystem, name string) {
|
||||
}
|
||||
|
||||
func TestRemoveAll(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
x.WriteFile("/foo/project/file.yaml", []byte("Unused"))
|
||||
x.WriteFile("/foo/project/subdir/file.yaml", []byte("Unused"))
|
||||
x.WriteFile("/foo/apple/subdir/file.yaml", []byte("Unused"))
|
||||
@@ -76,7 +63,7 @@ func TestRemoveAll(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsDirDeeper(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
x.WriteFile("/foo/project/file.yaml", []byte("Unused"))
|
||||
x.WriteFile("/foo/project/subdir/file.yaml", []byte("Unused"))
|
||||
if !x.IsDir("/") {
|
||||
@@ -97,7 +84,7 @@ func TestIsDirDeeper(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
f, err := x.Create("foo")
|
||||
if f == nil {
|
||||
t.Fatalf("expected file")
|
||||
@@ -109,7 +96,7 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadFile(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
f, err := x.Create("foo")
|
||||
if f == nil {
|
||||
t.Fatalf("expected file")
|
||||
@@ -127,7 +114,7 @@ func TestReadFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWriteFile(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
c := []byte("heybuddy")
|
||||
err := x.WriteFile("foo", c)
|
||||
if err != nil {
|
||||
@@ -143,7 +130,7 @@ func TestWriteFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGlob(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
x := MakeFsInMemory()
|
||||
x.Create("dir/foo")
|
||||
x.Create("dir/bar")
|
||||
files, err := x.Glob("dir/*")
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
@@ -24,43 +11,43 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var _ FileSystem = realFS{}
|
||||
var _ FileSystem = fsOnDisk{}
|
||||
|
||||
// realFS implements FileSystem using the local filesystem.
|
||||
type realFS struct{}
|
||||
// fsOnDisk implements FileSystem using the local filesystem.
|
||||
type fsOnDisk struct{}
|
||||
|
||||
// MakeRealFS makes an instance of realFS.
|
||||
func MakeRealFS() FileSystem {
|
||||
return realFS{}
|
||||
// MakeFsOnDisk makes an instance of fsOnDisk.
|
||||
func MakeFsOnDisk() FileSystem {
|
||||
return fsOnDisk{}
|
||||
}
|
||||
|
||||
// Create delegates to os.Create.
|
||||
func (realFS) Create(name string) (File, error) { return os.Create(name) }
|
||||
func (fsOnDisk) Create(name string) (File, error) { return os.Create(name) }
|
||||
|
||||
// Mkdir delegates to os.Mkdir.
|
||||
func (realFS) Mkdir(name string) error {
|
||||
func (fsOnDisk) Mkdir(name string) error {
|
||||
return os.Mkdir(name, 0777|os.ModeDir)
|
||||
}
|
||||
|
||||
// MkdirAll delegates to os.MkdirAll.
|
||||
func (realFS) MkdirAll(name string) error {
|
||||
func (fsOnDisk) MkdirAll(name string) error {
|
||||
return os.MkdirAll(name, 0777|os.ModeDir)
|
||||
}
|
||||
|
||||
// RemoveAll delegates to os.RemoveAll.
|
||||
func (realFS) RemoveAll(name string) error {
|
||||
func (fsOnDisk) RemoveAll(name string) error {
|
||||
return os.RemoveAll(name)
|
||||
}
|
||||
|
||||
// Open delegates to os.Open.
|
||||
func (realFS) Open(name string) (File, error) { return os.Open(name) }
|
||||
func (fsOnDisk) Open(name string) (File, error) { return os.Open(name) }
|
||||
|
||||
// CleanedAbs returns a cleaned, absolute path
|
||||
// with no symbolic links split into directory
|
||||
// and file components. If the entire path is
|
||||
// a directory, the file component is an empty
|
||||
// string.
|
||||
func (x realFS) CleanedAbs(
|
||||
// CleanedAbs converts the given path into a
|
||||
// directory and a file name, where the directory
|
||||
// is represented as a ConfirmedDir and all that implies.
|
||||
// If the entire path is a directory, the file component
|
||||
// is an empty string.
|
||||
func (x fsOnDisk) CleanedAbs(
|
||||
path string) (ConfirmedDir, string, error) {
|
||||
absRoot, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
@@ -94,18 +81,18 @@ func (x realFS) CleanedAbs(
|
||||
}
|
||||
|
||||
// Exists returns true if os.Stat succeeds.
|
||||
func (realFS) Exists(name string) bool {
|
||||
func (fsOnDisk) Exists(name string) bool {
|
||||
_, err := os.Stat(name)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// Glob returns the list of matching files
|
||||
func (realFS) Glob(pattern string) ([]string, error) {
|
||||
func (fsOnDisk) Glob(pattern string) ([]string, error) {
|
||||
return filepath.Glob(pattern)
|
||||
}
|
||||
|
||||
// IsDir delegates to os.Stat and FileInfo.IsDir
|
||||
func (realFS) IsDir(name string) bool {
|
||||
func (fsOnDisk) IsDir(name string) bool {
|
||||
info, err := os.Stat(name)
|
||||
if err != nil {
|
||||
return false
|
||||
@@ -114,14 +101,14 @@ func (realFS) IsDir(name string) bool {
|
||||
}
|
||||
|
||||
// ReadFile delegates to ioutil.ReadFile.
|
||||
func (realFS) ReadFile(name string) ([]byte, error) { return ioutil.ReadFile(name) }
|
||||
func (fsOnDisk) ReadFile(name string) ([]byte, error) { return ioutil.ReadFile(name) }
|
||||
|
||||
// WriteFile delegates to ioutil.WriteFile with read/write permissions.
|
||||
func (realFS) WriteFile(name string, c []byte) error {
|
||||
func (fsOnDisk) WriteFile(name string, c []byte) error {
|
||||
return ioutil.WriteFile(name, c, 0666)
|
||||
}
|
||||
|
||||
// Walk delegates to filepath.Walk.
|
||||
func (realFS) Walk(path string, walkFn filepath.WalkFunc) error {
|
||||
func (fsOnDisk) Walk(path string, walkFn filepath.WalkFunc) error {
|
||||
return filepath.Walk(path, walkFn)
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
@@ -26,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func makeTestDir(t *testing.T) (FileSystem, string) {
|
||||
x := MakeRealFS()
|
||||
x := MakeFsOnDisk()
|
||||
td, err := ioutil.TempDir("", "kustomize_testing_dir")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %s", err)
|
||||
@@ -100,7 +87,6 @@ func TestCleanedAbs_3(t *testing.T) {
|
||||
if f != "foo" {
|
||||
t.Fatalf("unexpected f=%s", f)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCleanedAbs_4(t *testing.T) {
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
var _ File = &realFile{}
|
||||
|
||||
// realFile implements File using the local filesystem.
|
||||
type realFile struct {
|
||||
file *os.File
|
||||
}
|
||||
|
||||
// Close closes a file.
|
||||
func (f *realFile) Close() error { return f.file.Close() }
|
||||
|
||||
// Read reads a file's content.
|
||||
func (f *realFile) Read(p []byte) (n int, err error) { return f.file.Read(p) }
|
||||
|
||||
// Write writes bytes to a file
|
||||
func (f *realFile) Write(p []byte) (n int, err error) { return f.file.Write(p) }
|
||||
|
||||
// Stat returns an interface which has all the information regarding the file.
|
||||
func (f *realFile) Stat() (os.FileInfo, error) { return f.file.Stat() }
|
||||
12
pkg/fs/rpath.go
Normal file
12
pkg/fs/rpath.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package fs
|
||||
|
||||
import "path/filepath"
|
||||
|
||||
// RPath returns a rooted path, e.g. "/hey/foo" as
|
||||
// opposed to "hey/foo".
|
||||
func RPath(elem ...string) string {
|
||||
return separator + filepath.Join(elem...)
|
||||
}
|
||||
@@ -74,7 +74,10 @@ func (th *KustTestHarness) WriteF(dir string, content string) {
|
||||
}
|
||||
|
||||
func (th *KustTestHarness) WriteK(dir string, content string) {
|
||||
th.WriteF(filepath.Join(dir, pgmconfig.KustomizationFileNames[0]), `
|
||||
th.WriteF(
|
||||
filepath.Join(
|
||||
dir,
|
||||
pgmconfig.DefaultKustomizationFileName()), `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
`+content)
|
||||
|
||||
@@ -57,7 +57,7 @@ var testCases = []testData{
|
||||
}
|
||||
|
||||
func MakeFakeFs(td []testData) fs.FileSystem {
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
for _, x := range td {
|
||||
fSys.WriteFile("/"+x.path, []byte(x.expectedContent))
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func commonSetupForLoaderRestrictionTest() (string, fs.FileSystem, error) {
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
fSys := fs.MakeRealFS()
|
||||
fSys := fs.MakeFsOnDisk()
|
||||
fSys.Mkdir(filepath.Join(dir, "base"))
|
||||
|
||||
fSys.WriteFile(
|
||||
@@ -385,11 +385,12 @@ func TestNewLoaderAtGitClone(t *testing.T) {
|
||||
pathInRepo := "foo/base"
|
||||
url := rootUrl + "/" + pathInRepo
|
||||
coRoot := "/tmp"
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.MkdirAll(coRoot)
|
||||
fSys.MkdirAll(coRoot + "/" + pathInRepo)
|
||||
fSys.WriteFile(
|
||||
coRoot+"/"+pathInRepo+"/"+pgmconfig.KustomizationFileNames[0],
|
||||
coRoot+"/"+pathInRepo+"/"+
|
||||
pgmconfig.DefaultKustomizationFileName(),
|
||||
[]byte(`
|
||||
whatever
|
||||
`))
|
||||
@@ -432,7 +433,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
|
||||
// Define an overlay-base structure in the file system.
|
||||
topDir := "/whatever"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir + "/highBase")
|
||||
fSys.MkdirAll(cloneRoot + "/foo/base")
|
||||
fSys.MkdirAll(cloneRoot + "/foo/overlay")
|
||||
@@ -508,7 +509,7 @@ func TestLoaderDisallowsLocalBaseFromRemoteOverlay(t *testing.T) {
|
||||
func TestLocalLoaderReferencingGitBase(t *testing.T) {
|
||||
topDir := "/whatever"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir)
|
||||
fSys.MkdirAll(cloneRoot + "/foo/base")
|
||||
|
||||
@@ -534,7 +535,7 @@ func TestLocalLoaderReferencingGitBase(t *testing.T) {
|
||||
func TestRepoDirectCycleDetection(t *testing.T) {
|
||||
topDir := "/cycles"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir)
|
||||
fSys.MkdirAll(cloneRoot)
|
||||
|
||||
@@ -563,7 +564,7 @@ func TestRepoDirectCycleDetection(t *testing.T) {
|
||||
func TestRepoIndirectCycleDetection(t *testing.T) {
|
||||
topDir := "/cycles"
|
||||
cloneRoot := topDir + "/someClone"
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.MkdirAll(topDir)
|
||||
fSys.MkdirAll(cloneRoot)
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestKeyValuesFromLines(t *testing.T) {
|
||||
}
|
||||
|
||||
l := NewFileLoaderAtRoot(
|
||||
validators.MakeFakeValidator(), fs.MakeFakeFS())
|
||||
validators.MakeFakeValidator(), fs.MakeFsInMemory())
|
||||
for _, test := range tests {
|
||||
pairs, err := l.keyValuesFromLines([]byte(test.content))
|
||||
if test.expectedErr && err == nil {
|
||||
@@ -76,7 +76,7 @@ func TestKeyValuesFromFileSources(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.WriteFile("/files/app-init.ini", []byte("FOO=bar"))
|
||||
l := NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys)
|
||||
for _, tc := range tests {
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRestrictionNone(t *testing.T) {
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
root := fs.ConfirmedDir("irrelevant")
|
||||
path := "whatever"
|
||||
p, err := RestrictionNone(fSys, root, path)
|
||||
@@ -37,7 +37,7 @@ func TestRestrictionNone(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestrictionRootOnly(t *testing.T) {
|
||||
fSys := fs.MakeFakeFS()
|
||||
fSys := fs.MakeFsInMemory()
|
||||
root := fs.ConfirmedDir("/tmp/foo")
|
||||
|
||||
path := "/tmp/foo/whatever/beans"
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package commands holds the CLI glue mapping textual commands/args to method calls.
|
||||
package pgmconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
//noinspection GoSnakeCaseUsage
|
||||
const (
|
||||
XDG_CONFIG_HOME = "XDG_CONFIG_HOME"
|
||||
defaultConfigSubdir = ".config"
|
||||
PluginRoot = "plugin"
|
||||
)
|
||||
|
||||
// Use https://github.com/kirsle/configdir instead?
|
||||
func ConfigRoot() string {
|
||||
dir := os.Getenv(XDG_CONFIG_HOME)
|
||||
if len(dir) == 0 {
|
||||
dir = filepath.Join(
|
||||
HomeDir(), defaultConfigSubdir)
|
||||
}
|
||||
return filepath.Join(dir, ProgramName)
|
||||
}
|
||||
|
||||
func HomeDir() string {
|
||||
home := os.Getenv(homeEnv())
|
||||
if len(home) > 0 {
|
||||
return home
|
||||
}
|
||||
return "~"
|
||||
}
|
||||
|
||||
func homeEnv() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "USERPROFILE"
|
||||
}
|
||||
return "HOME"
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package pgmconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigDirNoXdg(t *testing.T) {
|
||||
xdg, isSet := os.LookupEnv(XDG_CONFIG_HOME)
|
||||
if isSet {
|
||||
os.Unsetenv(XDG_CONFIG_HOME)
|
||||
}
|
||||
s := ConfigRoot()
|
||||
if isSet {
|
||||
os.Setenv(XDG_CONFIG_HOME, xdg)
|
||||
}
|
||||
if !strings.HasSuffix(
|
||||
s,
|
||||
rootedPath(defaultConfigSubdir, ProgramName)) {
|
||||
t.Fatalf("unexpected config dir: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func rootedPath(elem ...string) string {
|
||||
return string(filepath.Separator) + filepath.Join(elem...)
|
||||
}
|
||||
|
||||
func TestConfigDirWithXdg(t *testing.T) {
|
||||
xdg, isSet := os.LookupEnv(XDG_CONFIG_HOME)
|
||||
os.Setenv(XDG_CONFIG_HOME, rootedPath("blah"))
|
||||
s := ConfigRoot()
|
||||
if isSet {
|
||||
os.Setenv(XDG_CONFIG_HOME, xdg)
|
||||
}
|
||||
if s != rootedPath("blah", ProgramName) {
|
||||
t.Fatalf("unexpected config dir: %s", s)
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package constants holds global constants for the kustomize tool.
|
||||
package pgmconfig
|
||||
|
||||
// KustomizationFileNames is a list of filenames
|
||||
// that kustomize recognizes.
|
||||
// To avoid ambiguity, a directory cannot contain
|
||||
// more than one match to this list.
|
||||
var KustomizationFileNames = []string{
|
||||
"kustomization.yaml",
|
||||
"kustomization.yml",
|
||||
"Kustomization",
|
||||
}
|
||||
|
||||
const (
|
||||
// Program name, for help, finding the XDG_CONFIG_DIR, etc.
|
||||
ProgramName = "kustomize"
|
||||
// Domain from which kustomize code is imported, for locating
|
||||
// plugin source code under $GOPATH.
|
||||
DomainName = "sigs.k8s.io"
|
||||
)
|
||||
45
pkg/pgmconfig/pgmconfig.go
Normal file
45
pkg/pgmconfig/pgmconfig.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package pgmconfig holds global constants for the kustomize tool.
|
||||
package pgmconfig
|
||||
|
||||
// RecognizedKustomizationFileNames is a list of file names
|
||||
// that kustomize recognizes.
|
||||
// To avoid ambiguity, a kustomization directory may not
|
||||
// contain more than one match to this list.
|
||||
func RecognizedKustomizationFileNames() []string {
|
||||
return []string{
|
||||
"kustomization.yaml",
|
||||
"kustomization.yml",
|
||||
"Kustomization",
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultKustomizationFileName() string {
|
||||
return RecognizedKustomizationFileNames()[0]
|
||||
}
|
||||
|
||||
const (
|
||||
// An environment variable to consult for kustomization
|
||||
// configuration data. See:
|
||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
XdgConfigHome = "XDG_CONFIG_HOME"
|
||||
|
||||
// Use this when XdgConfigHome not defined.
|
||||
DefaultConfigSubdir = ".config"
|
||||
|
||||
// Program name, for help, finding the XDG_CONFIG_DIR, etc.
|
||||
ProgramName = "kustomize"
|
||||
|
||||
// Domain from which kustomize code is imported, for locating
|
||||
// plugin source code under $GOPATH.
|
||||
// TODO: move to pgk/plugin/config.go or equivalent
|
||||
// as part of v4 release. Cannot move till then
|
||||
// because of pluginator dependence at v3.
|
||||
DomainName = "sigs.k8s.io"
|
||||
|
||||
// Name of directory housing all plugins.
|
||||
// TODO: move to pgk/plugin/config.go or equivalent
|
||||
PluginRoot = "plugin"
|
||||
)
|
||||
@@ -63,7 +63,7 @@ func DefaultSrcRoot() (string, error) {
|
||||
nope = append(nope, root)
|
||||
|
||||
root = filepath.Join(
|
||||
pgmconfig.HomeDir(),
|
||||
homeDir(),
|
||||
pgmconfig.ProgramName, pgmconfig.PluginRoot)
|
||||
if FileExists(root) {
|
||||
return root, nil
|
||||
|
||||
@@ -5,19 +5,28 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/pflag"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
)
|
||||
|
||||
const (
|
||||
PluginSymbol = "KustomizePlugin"
|
||||
BuiltinPluginPackage = "builtin"
|
||||
// Used with Go plugins.
|
||||
PluginSymbol = "KustomizePlugin"
|
||||
|
||||
// Location of builtins.
|
||||
BuiltinPluginPackage = "builtin"
|
||||
|
||||
// ApiVersion of builtins.
|
||||
BuiltinPluginApiVersion = BuiltinPluginPackage
|
||||
flagEnablePluginsName = "enable_alpha_plugins"
|
||||
flagEnablePluginsHelp = `enable plugins, an alpha feature.
|
||||
See https://github.com/kubernetes-sigs/kustomize/blob/master/docs/plugins.md
|
||||
|
||||
flagEnablePluginsName = "enable_alpha_plugins"
|
||||
flagEnablePluginsHelp = `enable plugins, an alpha feature.
|
||||
See https://github.com/kubernetes-sigs/kustomize/blob/master/docs/plugins/README.md
|
||||
`
|
||||
flagErrorFmt = `
|
||||
unable to load external plugin %s because plugins disabled
|
||||
@@ -36,11 +45,11 @@ func DefaultPluginConfig() *types.PluginConfig {
|
||||
return &types.PluginConfig{
|
||||
Enabled: false,
|
||||
DirectoryPath: filepath.Join(
|
||||
pgmconfig.ConfigRoot(), pgmconfig.PluginRoot),
|
||||
configRoot(), pgmconfig.PluginRoot),
|
||||
}
|
||||
}
|
||||
|
||||
func NotEnabledErr(name string) error {
|
||||
func notEnabledErr(name string) error {
|
||||
return fmt.Errorf(
|
||||
flagErrorFmt,
|
||||
name,
|
||||
@@ -53,3 +62,28 @@ func AddFlagEnablePlugins(set *pflag.FlagSet, v *bool) {
|
||||
v, flagEnablePluginsName,
|
||||
false, flagEnablePluginsHelp)
|
||||
}
|
||||
|
||||
// Use https://github.com/kirsle/configdir instead?
|
||||
func configRoot() string {
|
||||
dir := os.Getenv(pgmconfig.XdgConfigHome)
|
||||
if len(dir) == 0 {
|
||||
dir = filepath.Join(
|
||||
homeDir(), pgmconfig.DefaultConfigSubdir)
|
||||
}
|
||||
return filepath.Join(dir, pgmconfig.ProgramName)
|
||||
}
|
||||
|
||||
func homeDir() string {
|
||||
home := os.Getenv(homeEnv())
|
||||
if len(home) > 0 {
|
||||
return home
|
||||
}
|
||||
return "~"
|
||||
}
|
||||
|
||||
func homeEnv() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "USERPROFILE"
|
||||
}
|
||||
return "HOME"
|
||||
}
|
||||
|
||||
45
pkg/plugins/config_test.go
Normal file
45
pkg/plugins/config_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
|
||||
)
|
||||
|
||||
func TestConfigDirNoXdg(t *testing.T) {
|
||||
xdg, isSet := os.LookupEnv(pgmconfig.XdgConfigHome)
|
||||
if isSet {
|
||||
os.Unsetenv(pgmconfig.XdgConfigHome)
|
||||
}
|
||||
s := configRoot()
|
||||
if isSet {
|
||||
os.Setenv(pgmconfig.XdgConfigHome, xdg)
|
||||
}
|
||||
if !strings.HasSuffix(
|
||||
s,
|
||||
rootedPath(pgmconfig.DefaultConfigSubdir, pgmconfig.ProgramName)) {
|
||||
t.Fatalf("unexpected config dir: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func rootedPath(elem ...string) string {
|
||||
return string(filepath.Separator) + filepath.Join(elem...)
|
||||
}
|
||||
|
||||
func TestConfigDirWithXdg(t *testing.T) {
|
||||
xdg, isSet := os.LookupEnv(pgmconfig.XdgConfigHome)
|
||||
os.Setenv(pgmconfig.XdgConfigHome, rootedPath("blah"))
|
||||
s := configRoot()
|
||||
if isSet {
|
||||
os.Setenv(pgmconfig.XdgConfigHome, xdg)
|
||||
}
|
||||
if s != rootedPath("blah", pgmconfig.ProgramName) {
|
||||
t.Fatalf("unexpected config dir: %s", s)
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func (l *Loader) loadAndConfigurePlugin(
|
||||
} else if l.pc.Enabled {
|
||||
c, err = l.loadPlugin(res.OrgId())
|
||||
} else {
|
||||
err = NotEnabledErr(res.OrgId().Kind)
|
||||
err = notEnabledErr(res.OrgId().Kind)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"sigs.k8s.io/kustomize/v3/internal/loadertest"
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
|
||||
. "sigs.k8s.io/kustomize/v3/pkg/plugins"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
)
|
||||
@@ -42,7 +42,7 @@ port: "12345"
|
||||
)
|
||||
|
||||
func TestLoader(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package test
|
||||
package testenv
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
@@ -98,14 +98,14 @@ func (x *EnvForTest) removeWorkDir() {
|
||||
}
|
||||
|
||||
func (x *EnvForTest) setEnv() {
|
||||
x.oldXdg, x.wasSet = os.LookupEnv(pgmconfig.XDG_CONFIG_HOME)
|
||||
os.Setenv(pgmconfig.XDG_CONFIG_HOME, x.workDir)
|
||||
x.oldXdg, x.wasSet = os.LookupEnv(pgmconfig.XdgConfigHome)
|
||||
os.Setenv(pgmconfig.XdgConfigHome, x.workDir)
|
||||
}
|
||||
|
||||
func (x *EnvForTest) resetEnv() {
|
||||
if x.wasSet {
|
||||
os.Setenv(pgmconfig.XDG_CONFIG_HOME, x.oldXdg)
|
||||
os.Setenv(pgmconfig.XdgConfigHome, x.oldXdg)
|
||||
} else {
|
||||
os.Unsetenv(pgmconfig.XDG_CONFIG_HOME)
|
||||
os.Unsetenv(pgmconfig.XdgConfigHome)
|
||||
}
|
||||
}
|
||||
@@ -234,10 +234,10 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
|
||||
Type: ifc.SecretTypeOpaque,
|
||||
},
|
||||
}
|
||||
fakeFs := fs.MakeFakeFS()
|
||||
fakeFs.Mkdir(".")
|
||||
fSys := fs.MakeFsInMemory()
|
||||
fSys.Mkdir(".")
|
||||
actual, err := rmF.NewResMapFromSecretArgs(
|
||||
loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fakeFs), nil, secrets)
|
||||
loader.NewFileLoaderAtRoot(validators.MakeFakeValidator(), fSys), nil, secrets)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
// This is an example of using a helm chart as a base,
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
// TODO: Download and inflate the chart, and check that
|
||||
// in for the test.
|
||||
func TestChartInflatorPlugin(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildExecPlugin(
|
||||
|
||||
@@ -6,15 +6,15 @@ package target_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
// Demo custom configuration of a builtin transformation.
|
||||
// This is a NamePrefixer that only touches Deployments
|
||||
// and Services.
|
||||
func TestCustomNamePrefixer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -103,7 +103,7 @@ metadata:
|
||||
|
||||
// Demo custom configuration as a base.
|
||||
func TestReusableCustomNamePrefixer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
const patchAddProbe = `
|
||||
@@ -340,7 +340,7 @@ patchesStrategicMerge:
|
||||
}
|
||||
|
||||
func TestIssue1251_Plugins_ProdVsDev(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -380,7 +380,7 @@ transformers:
|
||||
}
|
||||
|
||||
func TestIssue1251_Plugins_Local(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -430,7 +430,7 @@ jsonOp: '%s'
|
||||
|
||||
// Remote in the sense that they are bundled in a different kustomization.
|
||||
func TestIssue1251_Plugins_Bundled(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
package target_test
|
||||
|
||||
import (
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
)
|
||||
|
||||
// Here's a structure of two kustomizations,
|
||||
|
||||
@@ -81,7 +81,7 @@ func commaOr(q []string) string {
|
||||
func loadKustFile(ldr ifc.Loader) ([]byte, error) {
|
||||
var content []byte
|
||||
match := 0
|
||||
for _, kf := range pgmconfig.KustomizationFileNames {
|
||||
for _, kf := range pgmconfig.RecognizedKustomizationFileNames() {
|
||||
c, err := ldr.Load(kf)
|
||||
if err == nil {
|
||||
match += 1
|
||||
@@ -92,7 +92,8 @@ func loadKustFile(ldr ifc.Loader) ([]byte, error) {
|
||||
case 0:
|
||||
return nil, fmt.Errorf(
|
||||
"unable to find one of %v in directory '%s'",
|
||||
commaOr(quoted(pgmconfig.KustomizationFileNames)), ldr.Root())
|
||||
commaOr(quoted(pgmconfig.RecognizedKustomizationFileNames())),
|
||||
ldr.Root())
|
||||
case 1:
|
||||
return content, nil
|
||||
default:
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
)
|
||||
|
||||
func makeCommonFileForMultiplePatchTest(th *kusttest_test.KustTestHarness) {
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/v3/k8sdeps/transformer"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/target"
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginDir(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildExecPlugin(
|
||||
@@ -39,7 +39,7 @@ func TestPluginDir(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
fSys := fs.MakeRealFS()
|
||||
fSys := fs.MakeFsOnDisk()
|
||||
err = fSys.WriteFile(filepath.Join(dir, "kustomization.yaml"), []byte(`
|
||||
generators:
|
||||
- config.yaml
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func writeDeployment(th *kusttest_test.KustTestHarness, path string) {
|
||||
@@ -50,7 +50,7 @@ metadata:
|
||||
}
|
||||
|
||||
func TestOrderedTransformers(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -96,7 +96,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestPluginsNotEnabled(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -119,7 +119,7 @@ transformers:
|
||||
}
|
||||
|
||||
func TestSedTransformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildExecPlugin(
|
||||
@@ -187,7 +187,7 @@ metadata:
|
||||
}
|
||||
|
||||
func TestTransformedTransformers(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -39,15 +39,6 @@ func NewMultiTransformer(t []resmap.Transformer) resmap.Transformer {
|
||||
return r
|
||||
}
|
||||
|
||||
// NewMultiTransformerWithConflictCheck constructs a multiTransformer with checking of conflicts.
|
||||
func NewMultiTransformerWithConflictCheck(t []resmap.Transformer) resmap.Transformer {
|
||||
r := &multiTransformer{
|
||||
transformers: make([]resmap.Transformer, len(t)),
|
||||
checkConflictEnabled: true}
|
||||
copy(r.transformers, t)
|
||||
return r
|
||||
}
|
||||
|
||||
// Transform prepends the name prefix.
|
||||
func (o *multiTransformer) Transform(m resmap.ResMap) error {
|
||||
if o.checkConflictEnabled {
|
||||
|
||||
@@ -265,16 +265,6 @@ func (o *nameReferenceTransformer) getNewNameFunc(
|
||||
}
|
||||
}
|
||||
|
||||
func indexOf(s string, slice []string) []int {
|
||||
var index []int
|
||||
for i, item := range slice {
|
||||
if item == s {
|
||||
index = append(index, i)
|
||||
}
|
||||
}
|
||||
return index
|
||||
}
|
||||
|
||||
func getIds(rs []*resource.Resource) []string {
|
||||
var result []string
|
||||
for _, r := range rs {
|
||||
|
||||
@@ -38,7 +38,11 @@ func TestVarRef(t *testing.T) {
|
||||
"BOO": true,
|
||||
},
|
||||
fs: []config.FieldSpec{
|
||||
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data"},
|
||||
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/map"},
|
||||
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/slice"},
|
||||
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/interface"},
|
||||
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/nil"},
|
||||
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/num"},
|
||||
},
|
||||
res: resmaptest_test.NewRmBuilder(t, rf).
|
||||
Add(map[string]interface{}{
|
||||
@@ -48,14 +52,27 @@ func TestVarRef(t *testing.T) {
|
||||
"name": "cm1",
|
||||
},
|
||||
"data": map[string]interface{}{
|
||||
"item1": "$(FOO)",
|
||||
"item2": "bla",
|
||||
"item3": "$(BAZ)",
|
||||
"item4": "$(BAZ)+$(BAZ)",
|
||||
"item5": "$(BOO)",
|
||||
"item6": "if $(BOO)",
|
||||
},
|
||||
}).ResMap(),
|
||||
"map": map[string]interface{}{
|
||||
"item1": "$(FOO)",
|
||||
"item2": "bla",
|
||||
"item3": "$(BAZ)",
|
||||
"item4": "$(BAZ)+$(BAZ)",
|
||||
"item5": "$(BOO)",
|
||||
"item6": "if $(BOO)",
|
||||
"item7": 2019,
|
||||
},
|
||||
"slice": []interface{}{
|
||||
"$(FOO)",
|
||||
"bla",
|
||||
"$(BAZ)",
|
||||
"$(BAZ)+$(BAZ)",
|
||||
"$(BOO)",
|
||||
"if $(BOO)",
|
||||
},
|
||||
"interface": "$(FOO)",
|
||||
"nil": nil,
|
||||
"num": 2019,
|
||||
}}).ResMap(),
|
||||
},
|
||||
expected: expected{
|
||||
res: resmaptest_test.NewRmBuilder(t, rf).
|
||||
@@ -66,12 +83,26 @@ func TestVarRef(t *testing.T) {
|
||||
"name": "cm1",
|
||||
},
|
||||
"data": map[string]interface{}{
|
||||
"item1": "replacementForFoo",
|
||||
"item2": "bla",
|
||||
"item3": int64(5),
|
||||
"item4": "5+5",
|
||||
"item5": true,
|
||||
"item6": "if true",
|
||||
"map": map[string]interface{}{
|
||||
"item1": "replacementForFoo",
|
||||
"item2": "bla",
|
||||
"item3": int64(5),
|
||||
"item4": "5+5",
|
||||
"item5": true,
|
||||
"item6": "if true",
|
||||
"item7": 2019,
|
||||
},
|
||||
"slice": []interface{}{
|
||||
"replacementForFoo",
|
||||
"bla",
|
||||
int64(5),
|
||||
"5+5",
|
||||
true,
|
||||
"if true",
|
||||
},
|
||||
"interface": "replacementForFoo",
|
||||
"nil": nil,
|
||||
"num": 2019,
|
||||
}}).ResMap(),
|
||||
unused: []string{"BAR"},
|
||||
},
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
package builtin
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Sort the resources using an ordering defined in the Gvk class.
|
||||
|
||||
@@ -64,7 +64,7 @@ const metaNamespace = "metadata/namespace"
|
||||
// that don't exist in a namespace (the Namespace
|
||||
// object itself doesn't live in a namespace).
|
||||
func (p *NamespaceTransformerPlugin) applicableFieldSpecs(id resid.ResId) []config.FieldSpec {
|
||||
res := []config.FieldSpec{}
|
||||
var res []config.FieldSpec
|
||||
for _, fs := range p.FieldSpecs {
|
||||
if id.IsSelected(&fs.Gvk) && (fs.Path != metaNamespace || (fs.Path == metaNamespace && id.IsNamespaceableKind())) {
|
||||
res = append(res, fs)
|
||||
@@ -73,14 +73,14 @@ func (p *NamespaceTransformerPlugin) applicableFieldSpecs(id resid.ResId) []conf
|
||||
return res
|
||||
}
|
||||
|
||||
func (o *NamespaceTransformerPlugin) changeNamespace(
|
||||
func (p *NamespaceTransformerPlugin) changeNamespace(
|
||||
referrer *resource.Resource) func(in interface{}) (interface{}, error) {
|
||||
return func(in interface{}) (interface{}, error) {
|
||||
switch in.(type) {
|
||||
case string:
|
||||
// will happen when the metadata/namespace
|
||||
// value is replaced
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
case []interface{}:
|
||||
l, _ := in.([]interface{})
|
||||
for idx, item := range l {
|
||||
@@ -102,7 +102,7 @@ func (o *NamespaceTransformerPlugin) changeNamespace(
|
||||
if name != "default" {
|
||||
continue
|
||||
}
|
||||
inMap["namespace"] = o.Namespace
|
||||
inMap["namespace"] = p.Namespace
|
||||
l[idx] = inMap
|
||||
default:
|
||||
// nothing to do for right now
|
||||
@@ -115,7 +115,7 @@ func (o *NamespaceTransformerPlugin) changeNamespace(
|
||||
// object
|
||||
inMap := in.(map[string]interface{})
|
||||
if len(inMap) == 0 {
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
} else {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package builtin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
jsonpatch "github.com/evanphx/json-patch"
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/gvk"
|
||||
|
||||
@@ -3,6 +3,7 @@ package builtin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
|
||||
@@ -3,6 +3,7 @@ package builtin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/evanphx/json-patch"
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
@@ -19,7 +20,7 @@ type PatchTransformerPlugin struct {
|
||||
decodedPatch jsonpatch.Patch
|
||||
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"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PatchTransformerPlugin) Config(
|
||||
@@ -93,9 +94,9 @@ func (p *PatchTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, resource := range resources {
|
||||
for _, res := range resources {
|
||||
if p.decodedPatch != nil {
|
||||
rawObj, err := resource.MarshalJSON()
|
||||
rawObj, err := res.MarshalJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -104,17 +105,17 @@ func (p *PatchTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
return errors.Wrapf(
|
||||
err, "failed to apply json patch '%s'", p.Patch)
|
||||
}
|
||||
err = resource.UnmarshalJSON(modifiedObj)
|
||||
err = res.UnmarshalJSON(modifiedObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if p.loadedPatch != nil {
|
||||
patchCopy := p.loadedPatch.DeepCopy()
|
||||
patchCopy.SetName(resource.GetName())
|
||||
patchCopy.SetNamespace(resource.GetNamespace())
|
||||
patchCopy.SetGvk(resource.GetGvk())
|
||||
err = resource.Patch(patchCopy.Kunstructured)
|
||||
patchCopy.SetName(res.GetName())
|
||||
patchCopy.SetNamespace(res.GetNamespace())
|
||||
patchCopy.SetGvk(res.GetGvk())
|
||||
err = res.Patch(patchCopy.Kunstructured)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (p *ReplicaCountTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
for i, replicaSpec := range p.FieldSpecs {
|
||||
gvks[i] = replicaSpec.Gvk.String()
|
||||
}
|
||||
return fmt.Errorf("Resource with name %s does not match a config with the following GVK %v",
|
||||
return fmt.Errorf("resource with name %s does not match a config with the following GVK %v",
|
||||
p.Replica.Name, gvks)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestAnnotationsTransformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestConfigMapGenerator(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestHashTransformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestImageTagTransformerNewTag(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -82,7 +82,7 @@ spec:
|
||||
`)
|
||||
}
|
||||
func TestImageTagTransformerNewImage(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -154,7 +154,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestImageTagTransformerNewImageAndTag(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -227,7 +227,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestImageTagTransformerNewDigest(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -299,7 +299,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestImageTagTransformerNewImageAndDigest(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -6,8 +6,8 @@ package main_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -59,7 +59,7 @@ metadata:
|
||||
)
|
||||
|
||||
func TestInventoryTransformerCollect(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -80,7 +80,7 @@ policy: GarbageCollect
|
||||
}
|
||||
|
||||
func TestInventoryTransformerIgnore(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -101,7 +101,7 @@ policy: GarbageIgnore
|
||||
}
|
||||
|
||||
func TestInventoryTransformerDefaultPolicy(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestLabelTransformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Sort the resources using an ordering defined in the Gvk class.
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestLegacyOrderTransformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -70,7 +70,7 @@ const metaNamespace = "metadata/namespace"
|
||||
// that don't exist in a namespace (the Namespace
|
||||
// object itself doesn't live in a namespace).
|
||||
func (p *plugin) applicableFieldSpecs(id resid.ResId) []config.FieldSpec {
|
||||
res := []config.FieldSpec{}
|
||||
var res []config.FieldSpec
|
||||
for _, fs := range p.FieldSpecs {
|
||||
if id.IsSelected(&fs.Gvk) && (fs.Path != metaNamespace || (fs.Path == metaNamespace && id.IsNamespaceableKind())) {
|
||||
res = append(res, fs)
|
||||
@@ -79,14 +79,14 @@ func (p *plugin) applicableFieldSpecs(id resid.ResId) []config.FieldSpec {
|
||||
return res
|
||||
}
|
||||
|
||||
func (o *plugin) changeNamespace(
|
||||
func (p *plugin) changeNamespace(
|
||||
referrer *resource.Resource) func(in interface{}) (interface{}, error) {
|
||||
return func(in interface{}) (interface{}, error) {
|
||||
switch in.(type) {
|
||||
case string:
|
||||
// will happen when the metadata/namespace
|
||||
// value is replaced
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
case []interface{}:
|
||||
l, _ := in.([]interface{})
|
||||
for idx, item := range l {
|
||||
@@ -108,7 +108,7 @@ func (o *plugin) changeNamespace(
|
||||
if name != "default" {
|
||||
continue
|
||||
}
|
||||
inMap["namespace"] = o.Namespace
|
||||
inMap["namespace"] = p.Namespace
|
||||
l[idx] = inMap
|
||||
default:
|
||||
// nothing to do for right now
|
||||
@@ -121,7 +121,7 @@ func (o *plugin) changeNamespace(
|
||||
// object
|
||||
inMap := in.(map[string]interface{})
|
||||
if len(inMap) == 0 {
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
} else {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
func TestNamespaceTransformer1(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -190,7 +190,7 @@ metadata:
|
||||
}
|
||||
|
||||
func TestNamespaceTransformerClusterLevelKinds(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -241,7 +241,7 @@ fieldSpecs:
|
||||
}
|
||||
|
||||
func TestNamespaceTransformerObjectConflict(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
@@ -6,6 +6,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
jsonpatch "github.com/evanphx/json-patch"
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/gvk"
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
|
||||
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/plugins/testenv"
|
||||
)
|
||||
|
||||
const target = `
|
||||
@@ -29,7 +29,7 @@ spec:
|
||||
`
|
||||
|
||||
func TestPatchJson6902TransformerMissingFile(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -58,7 +58,7 @@ path: jsonpatch.json
|
||||
}
|
||||
|
||||
func TestBadPatchJson6902Transformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -87,7 +87,7 @@ jsonOp: 'thisIsNotAPatch'
|
||||
}
|
||||
|
||||
func TestBothEmptyJson6902Transformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -115,7 +115,7 @@ target:
|
||||
}
|
||||
|
||||
func TestBothSpecifiedJson6902Transformer(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -151,7 +151,7 @@ jsonOp: '[{"op": "add", "path": "/spec/template/spec/dnsPolicy", "value": "Clust
|
||||
}
|
||||
|
||||
func TestPatchJson6902TransformerFromJsonFile(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -201,7 +201,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestPatchJson6902TransformerFromYamlFile(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -251,7 +251,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestPatchJson6902TransformerWithInlineJSON(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
@@ -292,7 +292,7 @@ spec:
|
||||
}
|
||||
|
||||
func TestPatchJson6902TransformerWithInlineYAML(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
tc := testenv.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user