mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 01:46:23 +00:00
Merge remote-tracking branch 'upstream/master' into release-cmd/config-v0.0
This commit is contained in:
@@ -29,7 +29,7 @@ metadata:
|
||||
### `config.kubernetes.io/index`
|
||||
|
||||
Records the index of a Resource in file. In a multi-object YAML file, Resources are separated
|
||||
by three dashes (`---`), and the index represents the positon of the Resource starting from zero.
|
||||
by three dashes (`---`), and the index represents the position of the Resource starting from zero.
|
||||
|
||||
This annotation **SHOULD** be set when reading Resources from files.
|
||||
It **SHOULD** be unset when writing Resources to files.
|
||||
|
||||
@@ -129,7 +129,7 @@ spec:
|
||||
|
||||
### Output
|
||||
|
||||
The function is invoked using by runing `kustomize config run dir/`.
|
||||
The function is invoked using byrunning `kustomize config run dir/`.
|
||||
|
||||
`dir/my-instance_deployment.yaml` contains the Deployment:
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
[Alpha] Implement a Sink by writing input to a local directory.
|
||||
|
||||
kustomize config sink DIR
|
||||
kustomize config sink [DIR]
|
||||
|
||||
DIR:
|
||||
Path to local directory.
|
||||
Path to local directory. If unspecified, sink will write to stdout as if it were a single file.
|
||||
|
||||
`sink` writes its input to a directory
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
|
||||
[Alpha] Implement a Source by reading a local directory.
|
||||
|
||||
kustomize config source DIR
|
||||
kustomize config source DIR...
|
||||
|
||||
DIR:
|
||||
Path to local directory.
|
||||
One or more paths to local directories. Contents from directories will be concatenated.
|
||||
If no directories are provided, source will read from stdin as if it were a single file.
|
||||
|
||||
`source` emits configuration to act as input to a function
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ func NewCreateSetterRunner(parent string) *CreateSetterRunner {
|
||||
"create a partial setter for only part of the field value.")
|
||||
fixDocs(parent, set)
|
||||
set.MarkFlagRequired("type")
|
||||
set.MarkFlagRequired("field")
|
||||
r.Command = set
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ formatting substitution verbs {'%n': 'metadata.name', '%s': 'metadata.namespace'
|
||||
`if true, keep index and filename annotations set on Resources.`)
|
||||
c.Flags().BoolVar(&r.Override, "override", false,
|
||||
`if true, override existing filepath annotations.`)
|
||||
c.Flags().BoolVar(&r.UseSchema, "use-schema", false,
|
||||
`if true, uses openapi resource schema to format resources.`)
|
||||
r.Command = c
|
||||
return r
|
||||
}
|
||||
@@ -46,6 +48,7 @@ type FmtRunner struct {
|
||||
SetFilenames bool
|
||||
KeepAnnotations bool
|
||||
Override bool
|
||||
UseSchema bool
|
||||
}
|
||||
|
||||
func (r *FmtRunner) preRunE(c *cobra.Command, args []string) error {
|
||||
@@ -56,7 +59,9 @@ func (r *FmtRunner) preRunE(c *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
func (r *FmtRunner) runE(c *cobra.Command, args []string) error {
|
||||
f := []kio.Filter{filters.FormatFilter{}}
|
||||
f := []kio.Filter{filters.FormatFilter{
|
||||
UseSchema: r.UseSchema,
|
||||
}}
|
||||
|
||||
// format with file names
|
||||
if r.SetFilenames {
|
||||
|
||||
@@ -25,6 +25,8 @@ func GetMerge3Runner(name string) *Merge3Runner {
|
||||
"Path to updated package")
|
||||
c.Flags().StringVar(&r.toDir, "to", "",
|
||||
"Path to destination package")
|
||||
c.Flags().BoolVar(&r.path, "path-merge-key", false,
|
||||
"Use the path as part of the merge key when merging resources")
|
||||
|
||||
r.Command = c
|
||||
return r
|
||||
@@ -40,6 +42,7 @@ type Merge3Runner struct {
|
||||
ancestor string
|
||||
fromDir string
|
||||
toDir string
|
||||
path bool
|
||||
}
|
||||
|
||||
func (r *Merge3Runner) runE(c *cobra.Command, args []string) error {
|
||||
@@ -47,6 +50,7 @@ func (r *Merge3Runner) runE(c *cobra.Command, args []string) error {
|
||||
OriginalPath: r.ancestor,
|
||||
UpdatedPath: r.fromDir,
|
||||
DestPath: r.toDir,
|
||||
MergeOnPath: r.path,
|
||||
}.Merge()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio/kioutil"
|
||||
)
|
||||
|
||||
// GetSinkRunner returns a command for Sink.
|
||||
@@ -18,7 +19,7 @@ func GetSinkRunner(name string) *SinkRunner {
|
||||
Long: commands.SinkLong,
|
||||
Example: commands.SinkExamples,
|
||||
RunE: r.runE,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
}
|
||||
fixDocs(name, c)
|
||||
r.Command = c
|
||||
@@ -35,14 +36,18 @@ type SinkRunner struct {
|
||||
}
|
||||
|
||||
func (r *SinkRunner) runE(c *cobra.Command, args []string) error {
|
||||
var outputs []kio.Writer
|
||||
if len(args) == 1 {
|
||||
outputs = []kio.Writer{&kio.LocalPackageWriter{PackagePath: args[0]}}
|
||||
} else {
|
||||
outputs = []kio.Writer{&kio.ByteWriter{
|
||||
Writer: c.OutOrStdout(),
|
||||
ClearAnnotations: []string{kioutil.PathAnnotation}},
|
||||
}
|
||||
}
|
||||
|
||||
err := kio.Pipeline{
|
||||
Inputs: []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}},
|
||||
Outputs: []kio.Writer{
|
||||
&kio.LocalPackageWriter{
|
||||
PackagePath: args[0],
|
||||
ClearAnnotations: []string{"config.kubernetes.io/path"},
|
||||
},
|
||||
},
|
||||
}.Execute()
|
||||
Inputs: []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}},
|
||||
Outputs: outputs}.Execute()
|
||||
return handleError(c, err)
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ func TestSinkCommand(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll(d)
|
||||
|
||||
// fmt the files
|
||||
b := &bytes.Buffer{}
|
||||
r := commands.GetSinkRunner("")
|
||||
r.Command.SetIn(bytes.NewBufferString(`apiVersion: config.kubernetes.io/v1alpha1
|
||||
kind: ResourceList
|
||||
@@ -75,7 +73,6 @@ items:
|
||||
replicas: 3
|
||||
`))
|
||||
r.Command.SetArgs([]string{d})
|
||||
r.Command.SetOut(b)
|
||||
if !assert.NoError(t, r.Command.Execute()) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -138,3 +135,117 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func TestSinkCommand_Stdout(t *testing.T) {
|
||||
d, err := ioutil.TempDir("", "kustomize-source-test")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
defer os.RemoveAll(d)
|
||||
|
||||
// fmt the files
|
||||
out := &bytes.Buffer{}
|
||||
r := commands.GetSinkRunner("")
|
||||
r.Command.SetIn(bytes.NewBufferString(`apiVersion: config.kubernetes.io/v1alpha1
|
||||
kind: ResourceList
|
||||
items:
|
||||
- kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx2
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx2
|
||||
config.kubernetes.io/index: '0'
|
||||
config.kubernetes.io/path: 'f1.yaml'
|
||||
spec:
|
||||
replicas: 1
|
||||
- kind: Service
|
||||
metadata:
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx
|
||||
config.kubernetes.io/index: '1'
|
||||
config.kubernetes.io/path: 'f1.yaml'
|
||||
spec:
|
||||
selector:
|
||||
app: nginx
|
||||
- apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
name: foo
|
||||
annotations:
|
||||
config.kubernetes.io/function: |
|
||||
container:
|
||||
image: gcr.io/example/reconciler:v1
|
||||
config.kubernetes.io/local-config: "true"
|
||||
config.kubernetes.io/index: '0'
|
||||
config.kubernetes.io/path: 'f2.yaml'
|
||||
spec:
|
||||
replicas: 3
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
name: bar
|
||||
annotations:
|
||||
app: nginx
|
||||
config.kubernetes.io/index: '1'
|
||||
config.kubernetes.io/path: 'f2.yaml'
|
||||
spec:
|
||||
replicas: 3
|
||||
`))
|
||||
|
||||
r.Command.SetOut(out)
|
||||
r.Command.SetArgs([]string{})
|
||||
if !assert.NoError(t, r.Command.Execute()) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
expected := `kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx2
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx2
|
||||
spec:
|
||||
replicas: 1
|
||||
---
|
||||
kind: Service
|
||||
metadata:
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx
|
||||
spec:
|
||||
selector:
|
||||
app: nginx
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
name: foo
|
||||
annotations:
|
||||
config.kubernetes.io/function: |
|
||||
container:
|
||||
image: gcr.io/example/reconciler:v1
|
||||
config.kubernetes.io/local-config: "true"
|
||||
spec:
|
||||
replicas: 3
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
name: bar
|
||||
annotations:
|
||||
app: nginx
|
||||
spec:
|
||||
replicas: 3
|
||||
`
|
||||
if !assert.Equal(t, expected, out.String()) {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ func GetSourceRunner(name string) *SourceRunner {
|
||||
Long: commands.SourceLong,
|
||||
Example: commands.SourceExamples,
|
||||
RunE: r.runE,
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
fixDocs(name, c)
|
||||
c.Flags().StringVar(&r.WrapKind, "wrap-kind", kio.ResourceListKind,
|
||||
@@ -70,8 +69,14 @@ func (r *SourceRunner) runE(c *cobra.Command, args []string) error {
|
||||
FunctionConfig: functionConfig,
|
||||
})
|
||||
|
||||
err := kio.Pipeline{
|
||||
Inputs: []kio.Reader{kio.LocalPackageReader{PackagePath: args[0]}},
|
||||
Outputs: outputs}.Execute()
|
||||
var inputs []kio.Reader
|
||||
for _, a := range args {
|
||||
inputs = append(inputs, kio.LocalPackageReader{PackagePath: a})
|
||||
}
|
||||
if len(inputs) == 0 {
|
||||
inputs = []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}}
|
||||
}
|
||||
|
||||
err := kio.Pipeline{Inputs: inputs, Outputs: outputs}.Execute()
|
||||
return handleError(c, err)
|
||||
}
|
||||
|
||||
@@ -134,3 +134,67 @@ items:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceCommand_Stdin(t *testing.T) {
|
||||
d, err := ioutil.TempDir("", "kustomize-source-test")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(d)
|
||||
|
||||
in := bytes.NewBufferString(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx2
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx2
|
||||
spec:
|
||||
replicas: 1
|
||||
---
|
||||
kind: Service
|
||||
metadata:
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx
|
||||
spec:
|
||||
selector:
|
||||
app: nginx
|
||||
`)
|
||||
|
||||
out := &bytes.Buffer{}
|
||||
r := commands.GetSourceRunner("")
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(in)
|
||||
r.Command.SetOut(out)
|
||||
if !assert.NoError(t, r.Command.Execute()) {
|
||||
return
|
||||
}
|
||||
|
||||
if !assert.Equal(t, `apiVersion: config.kubernetes.io/v1alpha1
|
||||
kind: ResourceList
|
||||
items:
|
||||
- kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx2
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx2
|
||||
config.kubernetes.io/index: '0'
|
||||
spec:
|
||||
replicas: 1
|
||||
- kind: Service
|
||||
metadata:
|
||||
name: foo
|
||||
annotations:
|
||||
app: nginx
|
||||
config.kubernetes.io/index: '1'
|
||||
spec:
|
||||
selector:
|
||||
app: nginx
|
||||
`, out.String()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ Example:
|
||||
### ` + "`" + `config.kubernetes.io/index` + "`" + `
|
||||
|
||||
Records the index of a Resource in file. In a multi-object YAML file, Resources are separated
|
||||
by three dashes (` + "`" + `---` + "`" + `), and the index represents the positon of the Resource starting from zero.
|
||||
by three dashes (` + "`" + `---` + "`" + `), and the index represents the position of the Resource starting from zero.
|
||||
|
||||
This annotation **SHOULD** be set when reading Resources from files.
|
||||
It **SHOULD** be unset when writing Resources to files.
|
||||
@@ -187,7 +187,7 @@ are passed to the Function through the ` + "`" + `ResourceList.functionConfig` +
|
||||
|
||||
### Output
|
||||
|
||||
The function is invoked using by runing ` + "`" + `kustomize config run dir/` + "`" + `.
|
||||
The function is invoked using byrunning ` + "`" + `kustomize config run dir/` + "`" + `.
|
||||
|
||||
` + "`" + `dir/my-instance_deployment.yaml` + "`" + ` contains the Deployment:
|
||||
|
||||
|
||||
@@ -350,10 +350,10 @@ var SinkShort = `[Alpha] Implement a Sink by writing input to a local directory.
|
||||
var SinkLong = `
|
||||
[Alpha] Implement a Sink by writing input to a local directory.
|
||||
|
||||
kustomize config sink DIR
|
||||
kustomize config sink [DIR]
|
||||
|
||||
DIR:
|
||||
Path to local directory.
|
||||
Path to local directory. If unspecified, sink will write to stdout as if it were a single file.
|
||||
|
||||
` + "`" + `sink` + "`" + ` writes its input to a directory
|
||||
`
|
||||
@@ -364,10 +364,11 @@ var SourceShort = `[Alpha] Implement a Source by reading a local directory.`
|
||||
var SourceLong = `
|
||||
[Alpha] Implement a Source by reading a local directory.
|
||||
|
||||
kustomize config source DIR
|
||||
kustomize config source DIR...
|
||||
|
||||
DIR:
|
||||
Path to local directory.
|
||||
One or more paths to local directories. Contents from directories will be concatenated.
|
||||
If no directories are provided, source will read from stdin as if it were a single file.
|
||||
|
||||
` + "`" + `source` + "`" + ` emits configuration to act as input to a function
|
||||
`
|
||||
|
||||
@@ -3,7 +3,9 @@ module sigs.k8s.io/kustomize/cmd/kubectl
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/go-errors/errors v1.0.1
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/stretchr/testify v1.4.0
|
||||
k8s.io/api v0.17.0
|
||||
k8s.io/apimachinery v0.17.0
|
||||
k8s.io/cli-runtime v0.17.0
|
||||
|
||||
@@ -83,6 +83,7 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
@@ -364,7 +365,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@@ -504,7 +504,6 @@ k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd h1:nZX5+wEqTu/EBIYjrZlFOA63z4+
|
||||
k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd/go.mod h1:9ehGcuUGjXVZh0qbYSB0vvofQw2JQe6c6cO0k4wu/Oo=
|
||||
k8s.io/metrics v0.0.0-20191214191643-6b1944c9f765/go.mod h1:5V7rewilItwK0cz4nomU0b3XCcees2Ka5EBYWS1HBeM=
|
||||
k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||
k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo=
|
||||
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
||||
|
||||
205
cmd/kubectl/kubectlcobra/applier.go
Normal file
205
cmd/kubectl/kubectlcobra/applier.go
Normal file
@@ -0,0 +1,205 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
"k8s.io/kubectl/pkg/cmd/apply"
|
||||
"k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
)
|
||||
|
||||
// newApplier returns a new Applier. It will set up the applyOptions and
|
||||
// statusOptions which are responsible for capturing any command line flags.
|
||||
// It currently requires IOStreams, but this is a legacy from when
|
||||
// the ApplyOptions were responsible for printing progress. This is now
|
||||
// handled by a separate printer with the KubectlPrinterAdapter bridging
|
||||
// between the two.
|
||||
func newApplier(factory util.Factory, ioStreams genericclioptions.IOStreams) *Applier {
|
||||
return &Applier{
|
||||
applyOptions: apply.NewApplyOptions(ioStreams),
|
||||
statusOptions: NewStatusOptions(),
|
||||
factory: factory,
|
||||
ioStreams: ioStreams,
|
||||
}
|
||||
}
|
||||
|
||||
// resolver defines the interface the applier needs to observe status for resources.
|
||||
type resolver interface {
|
||||
WaitForStatusOfObjects(ctx context.Context, objects []wait.KubernetesObject) <-chan wait.Event
|
||||
}
|
||||
|
||||
// Applier performs the step of applying a set of resources into a cluster,
|
||||
// conditionally waits for all of them to be fully reconciled and finally
|
||||
// performs prune to clean up any resources that has been deleted.
|
||||
type Applier struct {
|
||||
factory util.Factory
|
||||
ioStreams genericclioptions.IOStreams
|
||||
|
||||
applyOptions *apply.ApplyOptions
|
||||
statusOptions *StatusOptions
|
||||
resolver resolver
|
||||
}
|
||||
|
||||
// Initialize sets up the Applier for actually doing an apply against
|
||||
// a cluster. This involves validating command line inputs and configuring
|
||||
// clients for communicating with the cluster.
|
||||
func (a *Applier) Initialize(cmd *cobra.Command) error {
|
||||
a.applyOptions.PreProcessorFn = PrependGroupingObject(a.applyOptions)
|
||||
err := a.applyOptions.Complete(a.factory, cmd)
|
||||
if err != nil {
|
||||
return errors.WrapPrefix(err, "error setting up ApplyOptions", 1)
|
||||
}
|
||||
// Default PostProcessor is configured in "Complete" function,
|
||||
// so the prune must happen after "Complete".
|
||||
a.applyOptions.PostProcessorFn = prune(a.factory, a.applyOptions)
|
||||
|
||||
resolver, err := a.newResolver(a.statusOptions.period)
|
||||
if err != nil {
|
||||
return errors.WrapPrefix(err, "error creating resolver", 1)
|
||||
}
|
||||
a.resolver = resolver
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetFlags configures the command line flags needed for apply and
|
||||
// status. This is a temporary solution as we should separate the configuration
|
||||
// of cobra flags from the Applier.
|
||||
func (a *Applier) SetFlags(cmd *cobra.Command) {
|
||||
a.applyOptions.DeleteFlags.AddFlags(cmd)
|
||||
a.applyOptions.RecordFlags.AddFlags(cmd)
|
||||
a.applyOptions.PrintFlags.AddFlags(cmd)
|
||||
a.statusOptions.AddFlags(cmd)
|
||||
a.applyOptions.Overwrite = true
|
||||
}
|
||||
|
||||
// newResolver sets up a new Resolver for computing status. The configuration
|
||||
// needed for the resolver is taken from the Factory.
|
||||
func (a *Applier) newResolver(pollInterval time.Duration) (*wait.Resolver, error) {
|
||||
config, err := a.factory.ToRESTConfig()
|
||||
if err != nil {
|
||||
return nil, errors.WrapPrefix(err, "error getting RESTConfig", 1)
|
||||
}
|
||||
|
||||
mapper, err := a.factory.ToRESTMapper()
|
||||
if err != nil {
|
||||
return nil, errors.WrapPrefix(err, "error getting RESTMapper", 1)
|
||||
}
|
||||
|
||||
c, err := client.New(config, client.Options{Scheme: scheme.Scheme, Mapper: mapper})
|
||||
if err != nil {
|
||||
return nil, errors.WrapPrefix(err, "error creating client", 1)
|
||||
}
|
||||
|
||||
return wait.NewResolver(c, mapper, pollInterval), nil
|
||||
}
|
||||
|
||||
// Run performs the Apply step. This happens asynchronously with updates
|
||||
// on progress and any errors are reported back on the event channel.
|
||||
// Cancelling the operation or setting timeout on how long to wait
|
||||
// for it complete can be done with the passed in context.
|
||||
// Note: There sn't currently any way to interrupt the operation
|
||||
// before all the given resources have been applied to the cluster. Any
|
||||
// cancellation or timeout will only affect how long we wait for the
|
||||
// resources to become current.
|
||||
func (a *Applier) Run(ctx context.Context) <-chan Event {
|
||||
ch := make(chan Event)
|
||||
|
||||
go func() {
|
||||
defer close(ch)
|
||||
adapter := &KubectlPrinterAdapter{
|
||||
ch: ch,
|
||||
}
|
||||
// The adapter is used to intercept what is meant to be printing
|
||||
// in the ApplyOptions, and instead turn those into events.
|
||||
a.applyOptions.ToPrinter = adapter.toPrinterFunc()
|
||||
// This provides us with a slice of all the objects that will be
|
||||
// applied to the cluster.
|
||||
infos, _ := a.applyOptions.GetObjects()
|
||||
err := a.applyOptions.Run()
|
||||
if err != nil {
|
||||
// If we see an error here we just report it on the channel and then
|
||||
// give up. Eventually we might be able to determine which errors
|
||||
// are fatal and which might allow us to continue.
|
||||
ch <- Event{
|
||||
EventType: ErrorEventType,
|
||||
ErrorEvent: ErrorEvent{
|
||||
Err: errors.WrapPrefix(err, "error applying resources", 1),
|
||||
},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if a.statusOptions.wait {
|
||||
statusChannel := a.resolver.WaitForStatusOfObjects(ctx, infosToObjects(infos))
|
||||
// As long as the statusChannel remains open, we take every statusEvent,
|
||||
// wrap it in an Event and send it on the channel.
|
||||
for statusEvent := range statusChannel {
|
||||
ch <- Event{
|
||||
EventType: StatusEventType,
|
||||
StatusEvent: statusEvent,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
return ch
|
||||
}
|
||||
|
||||
func infosToObjects(infos []*resource.Info) []wait.KubernetesObject {
|
||||
var objects []wait.KubernetesObject
|
||||
for _, info := range infos {
|
||||
u := info.Object.(*unstructured.Unstructured)
|
||||
objects = append(objects, u)
|
||||
}
|
||||
return objects
|
||||
}
|
||||
|
||||
// EventType determines the type of events that are available.
|
||||
type EventType string
|
||||
|
||||
const (
|
||||
ErrorEventType EventType = "error"
|
||||
ApplyEventType EventType = "apply"
|
||||
StatusEventType EventType = "status"
|
||||
)
|
||||
|
||||
// Event is the type of the objects that will be returned through
|
||||
// the channel that is returned from a call to Run. It contains
|
||||
// information about progress and errors encountered during
|
||||
// the process of doing apply, waiting for status and doing a prune.
|
||||
type Event struct {
|
||||
// EventType is the type of event.
|
||||
EventType EventType
|
||||
|
||||
// ErrorEvent contains information about any errors encountered.
|
||||
ErrorEvent ErrorEvent
|
||||
|
||||
// ApplyEvent contains information about progress pertaining to
|
||||
// applying a resource to the cluster.
|
||||
ApplyEvent ApplyEvent
|
||||
|
||||
// StatusEvents contains information about the status of one of
|
||||
// the applied resources.
|
||||
StatusEvent wait.Event
|
||||
}
|
||||
|
||||
type ErrorEvent struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
type ApplyEvent struct {
|
||||
Operation string
|
||||
Object runtime.Object
|
||||
}
|
||||
48
cmd/kubectl/kubectlcobra/applier_test.go
Normal file
48
cmd/kubectl/kubectlcobra/applier_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The applier is currently hard to test, as the dependencies on the ApplyOptions and
|
||||
// the resolver are hard to stub out. As we work to better separate the different
|
||||
// responsibilities of the apply functionality, we should also make it easier to test.
|
||||
// This provides some basic tests for now.
|
||||
|
||||
func TestApplierWithUnknownFile(t *testing.T) {
|
||||
tf := cmdtesting.NewTestFactory()
|
||||
defer tf.Cleanup()
|
||||
iostreams, _, _, _ := genericclioptions.NewTestIOStreams()
|
||||
cmd := NewCmdApply("base", tf, iostreams)
|
||||
|
||||
applier := newApplier(tf, iostreams)
|
||||
filenames := []string{"file.yaml"}
|
||||
applier.applyOptions.DeleteFlags.FileNameFlags.Filenames = &filenames
|
||||
|
||||
err := applier.Initialize(cmd)
|
||||
assert.NoError(t, err)
|
||||
|
||||
ch := applier.Run(context.TODO())
|
||||
|
||||
var events []Event
|
||||
for msg := range ch {
|
||||
events = append(events, msg)
|
||||
}
|
||||
|
||||
if !assert.Equal(t, 1, len(events)) {
|
||||
return
|
||||
}
|
||||
|
||||
event := events[0]
|
||||
if !assert.Equal(t, ErrorEventType, event.EventType) {
|
||||
return
|
||||
}
|
||||
assert.Contains(t, event.ErrorEvent.Err.Error(), "does not exist")
|
||||
}
|
||||
62
cmd/kubectl/kubectlcobra/basic_printer.go
Normal file
62
cmd/kubectl/kubectlcobra/basic_printer.go
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
)
|
||||
|
||||
// BasicPrinter is a simple implementation that just prints the events
|
||||
// from the channel in the default format for kubectl.
|
||||
// We need to support different printers for different output formats.
|
||||
type BasicPrinter struct {
|
||||
ioStreams genericclioptions.IOStreams
|
||||
}
|
||||
|
||||
// Print outputs the events from the provided channel in a simple
|
||||
// format on StdOut. As we support other printer implementations
|
||||
// this should probably be an interface.
|
||||
// This function will block until the channel is closed.
|
||||
func (b *BasicPrinter) Print(ch <-chan Event) {
|
||||
for event := range ch {
|
||||
switch event.EventType {
|
||||
case ErrorEventType:
|
||||
cmdutil.CheckErr(event.ErrorEvent.Err)
|
||||
case ApplyEventType:
|
||||
obj := event.ApplyEvent.Object
|
||||
gvk := obj.GetObjectKind().GroupVersionKind()
|
||||
name := "<unknown>"
|
||||
if acc, err := meta.Accessor(obj); err == nil {
|
||||
if n := acc.GetName(); len(n) > 0 {
|
||||
name = n
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(b.ioStreams.Out, "%s %s\n", resourceIdToString(gvk.GroupKind(), name), event.ApplyEvent.Operation)
|
||||
case StatusEventType:
|
||||
statusEvent := event.StatusEvent
|
||||
switch statusEvent.Type {
|
||||
case wait.ResourceUpdate:
|
||||
id := statusEvent.EventResource.ResourceIdentifier
|
||||
gk := id.GroupKind
|
||||
fmt.Fprintf(b.ioStreams.Out, "%s is %s: %s\n", resourceIdToString(gk, id.Name), statusEvent.EventResource.Status.String(), statusEvent.EventResource.Message)
|
||||
case wait.Completed:
|
||||
fmt.Fprint(b.ioStreams.Out, "all resources has reached the Current status\n")
|
||||
case wait.Aborted:
|
||||
fmt.Fprintf(b.ioStreams.Out, "resources failed to the reached Current status\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// resourceIdToString returns the string representation of a GroupKind and a resource name.
|
||||
func resourceIdToString(gk schema.GroupKind, name string) string {
|
||||
return fmt.Sprintf("%s/%s", strings.ToLower(gk.String()), name)
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -79,9 +80,10 @@ func updateHelp(names []string, c *cobra.Command) {
|
||||
|
||||
// NewCmdApply creates the `apply` command
|
||||
func NewCmdApply(baseName string, f util.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
o := apply.NewApplyOptions(ioStreams)
|
||||
so := newStatusOptions(f, ioStreams)
|
||||
o.PreProcessorFn = PrependGroupingObject(o)
|
||||
applier := newApplier(f, ioStreams)
|
||||
printer := &BasicPrinter{
|
||||
ioStreams: ioStreams,
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "apply (-f FILENAME | -k DIRECTORY)",
|
||||
@@ -93,28 +95,28 @@ func NewCmdApply(baseName string, f util.Factory, ioStreams genericclioptions.IO
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) > 0 {
|
||||
// check is kustomize, if so update
|
||||
o.DeleteFlags.FileNameFlags.Kustomize = &args[0]
|
||||
applier.applyOptions.DeleteFlags.FileNameFlags.Kustomize = &args[0]
|
||||
}
|
||||
|
||||
cmdutil.CheckErr(o.Complete(f, cmd))
|
||||
cmdutil.CheckErr(o.Run())
|
||||
infos, _ := o.GetObjects()
|
||||
if so.wait {
|
||||
cmdutil.CheckErr(so.waitForStatus(infos))
|
||||
}
|
||||
cmdutil.CheckErr(applier.Initialize(cmd))
|
||||
|
||||
// Create a context with the provided timout from the cobra parameter.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), applier.statusOptions.timeout)
|
||||
defer cancel()
|
||||
// Run the applier. It will return a channel where we can receive updates
|
||||
// to keep track of progress and any issues.
|
||||
ch := applier.Run(ctx)
|
||||
|
||||
// The printer will print updates from the channel. It will block
|
||||
// until the channel is closed.
|
||||
printer.Print(ch)
|
||||
},
|
||||
}
|
||||
|
||||
// bind flag structs
|
||||
o.DeleteFlags.AddFlags(cmd)
|
||||
o.RecordFlags.AddFlags(cmd)
|
||||
o.PrintFlags.AddFlags(cmd)
|
||||
so.AddFlags(cmd)
|
||||
|
||||
o.Overwrite = true
|
||||
applier.SetFlags(cmd)
|
||||
|
||||
cmdutil.AddValidateFlags(cmd)
|
||||
cmd.Flags().BoolVar(&o.ServerDryRun, "server-dry-run", o.ServerDryRun, "If true, request will be sent to server with dry-run flag, which means the modifications won't be persisted. This is an alpha feature and flag.")
|
||||
cmd.Flags().BoolVar(&applier.applyOptions.ServerDryRun, "server-dry-run", applier.applyOptions.ServerDryRun, "If true, request will be sent to server with dry-run flag, which means the modifications won't be persisted. This is an alpha feature and flag.")
|
||||
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without sending it. Warning: --dry-run cannot accurately output the result of merging the local manifest and the server-side data. Use --server-dry-run to get the merged result instead.")
|
||||
cmdutil.AddServerSideApplyFlags(cmd)
|
||||
|
||||
@@ -144,3 +146,16 @@ func PrependGroupingObject(o *apply.ApplyOptions) func() error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Prune deletes previously applied objects that have been
|
||||
// omitted in the current apply. The previously applied objects
|
||||
// are reached through ConfigMap grouping objects.
|
||||
func prune(f util.Factory, o *apply.ApplyOptions) func() error {
|
||||
return func() error {
|
||||
po, err := NewPruneOptions(f, o)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return po.Prune()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,26 @@ const (
|
||||
GroupingHash = "kustomize.config.k8s.io/inventory-hash"
|
||||
)
|
||||
|
||||
// retrieveGroupingLabel returns the string value of the GroupingLabel
|
||||
// for the passed object. Returns error if the passed object is nil or
|
||||
// is not a grouping object.
|
||||
func retrieveGroupingLabel(obj runtime.Object) (string, error) {
|
||||
var groupingLabel string
|
||||
if obj == nil {
|
||||
return "", fmt.Errorf("Grouping object is nil.\n")
|
||||
}
|
||||
accessor, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
labels := accessor.GetLabels()
|
||||
groupingLabel, exists := labels[GroupingLabel]
|
||||
if !exists {
|
||||
return "", fmt.Errorf("Grouping label does not exist for grouping object: %s\n", GroupingLabel)
|
||||
}
|
||||
return strings.TrimSpace(groupingLabel), nil
|
||||
}
|
||||
|
||||
// isGroupingObject returns true if the passed object has the
|
||||
// grouping label.
|
||||
// TODO(seans3): Check type is ConfigMap.
|
||||
@@ -29,13 +49,9 @@ func isGroupingObject(obj runtime.Object) bool {
|
||||
if obj == nil {
|
||||
return false
|
||||
}
|
||||
accessor, err := meta.Accessor(obj)
|
||||
if err == nil {
|
||||
labels := accessor.GetLabels()
|
||||
_, exists := labels[GroupingLabel]
|
||||
if exists {
|
||||
return true
|
||||
}
|
||||
groupingLabel, err := retrieveGroupingLabel(obj)
|
||||
if err == nil && len(groupingLabel) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ var pod1Name = "pod-1"
|
||||
var pod2Name = "pod-2"
|
||||
var pod3Name = "pod-3"
|
||||
|
||||
var testGroupingLabel = "test-app-label"
|
||||
|
||||
var groupingObj = unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
@@ -30,7 +32,7 @@ var groupingObj = unstructured.Unstructured{
|
||||
"name": groupingObjName,
|
||||
"namespace": testNamespace,
|
||||
"labels": map[string]interface{}{
|
||||
GroupingLabel: "true",
|
||||
GroupingLabel: testGroupingLabel,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -109,6 +111,67 @@ var nilInfo = &resource.Info{
|
||||
Object: nil,
|
||||
}
|
||||
|
||||
var groupingObjLabelWithSpace = unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": groupingObjName,
|
||||
"namespace": testNamespace,
|
||||
"labels": map[string]interface{}{
|
||||
GroupingLabel: "\tgrouping-label ",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestRetrieveGroupingLabel(t *testing.T) {
|
||||
tests := []struct {
|
||||
obj runtime.Object
|
||||
groupingLabel string
|
||||
isError bool
|
||||
}{
|
||||
// Nil grouping object throws error.
|
||||
{
|
||||
obj: nil,
|
||||
groupingLabel: "",
|
||||
isError: true,
|
||||
},
|
||||
// Pod is not a grouping object.
|
||||
{
|
||||
obj: &pod2,
|
||||
groupingLabel: "",
|
||||
isError: true,
|
||||
},
|
||||
// Retrieves label without preceding/trailing whitespace.
|
||||
{
|
||||
obj: &groupingObjLabelWithSpace,
|
||||
groupingLabel: "grouping-label",
|
||||
isError: false,
|
||||
},
|
||||
{
|
||||
obj: &groupingObj,
|
||||
groupingLabel: testGroupingLabel,
|
||||
isError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
actual, err := retrieveGroupingLabel(test.obj)
|
||||
if test.isError && err == nil {
|
||||
t.Errorf("Did not receive expected error.\n")
|
||||
}
|
||||
if !test.isError {
|
||||
if err != nil {
|
||||
t.Fatalf("Received unexpected error: %s\n", err)
|
||||
}
|
||||
if test.groupingLabel != actual {
|
||||
t.Errorf("Expected grouping label (%s), got (%s)\n", test.groupingLabel, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGroupingObject(t *testing.T) {
|
||||
tests := []struct {
|
||||
obj runtime.Object
|
||||
|
||||
@@ -71,6 +71,9 @@ func parseInventory(inv string) (*Inventory, error) {
|
||||
// Equals returns true if the Inventory structs are identical;
|
||||
// false otherwise.
|
||||
func (i *Inventory) Equals(other *Inventory) bool {
|
||||
if other == nil {
|
||||
return false
|
||||
}
|
||||
return i.String() == other.String()
|
||||
}
|
||||
|
||||
@@ -164,6 +167,16 @@ func (is *InventorySet) Subtract(other *InventorySet) (*InventorySet, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Equals returns true if the "other" inventory set is the same
|
||||
// as this current inventory set. Relies on the fact that the
|
||||
// inventory items are sorted for the String() function.
|
||||
func (is *InventorySet) Equals(other *InventorySet) bool {
|
||||
if other == nil {
|
||||
return false
|
||||
}
|
||||
return is.String() == other.String()
|
||||
}
|
||||
|
||||
// String returns a string describing set of Inventory structs.
|
||||
func (is *InventorySet) String() string {
|
||||
strs := []string{}
|
||||
|
||||
@@ -80,6 +80,18 @@ func TestInventoryEqual(t *testing.T) {
|
||||
inventory2 *Inventory
|
||||
isEqual bool
|
||||
}{
|
||||
// "Other" inventory is nil, then not equal.
|
||||
{
|
||||
inventory1: &Inventory{
|
||||
Name: "test-inv",
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: "apps",
|
||||
Kind: "Deployment",
|
||||
},
|
||||
},
|
||||
inventory2: nil,
|
||||
isEqual: false,
|
||||
},
|
||||
// Two equal inventories without a namespace
|
||||
{
|
||||
inventory1: &Inventory{
|
||||
@@ -487,3 +499,60 @@ func TestInventorySetSubtract(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInventorySetEquals(t *testing.T) {
|
||||
tests := []struct {
|
||||
set1 []*Inventory
|
||||
set2 []*Inventory
|
||||
isEqual bool
|
||||
}{
|
||||
{
|
||||
set1: []*Inventory{},
|
||||
set2: []*Inventory{&inventory1},
|
||||
isEqual: false,
|
||||
},
|
||||
{
|
||||
set1: []*Inventory{&inventory1},
|
||||
set2: []*Inventory{},
|
||||
isEqual: false,
|
||||
},
|
||||
{
|
||||
set1: []*Inventory{&inventory1, &inventory2},
|
||||
set2: []*Inventory{&inventory1},
|
||||
isEqual: false,
|
||||
},
|
||||
{
|
||||
set1: []*Inventory{&inventory1, &inventory2},
|
||||
set2: []*Inventory{&inventory3, &inventory4},
|
||||
isEqual: false,
|
||||
},
|
||||
// Empty sets are equal.
|
||||
{
|
||||
set1: []*Inventory{},
|
||||
set2: []*Inventory{},
|
||||
isEqual: true,
|
||||
},
|
||||
{
|
||||
set1: []*Inventory{&inventory1},
|
||||
set2: []*Inventory{&inventory1},
|
||||
isEqual: true,
|
||||
},
|
||||
// Ordering of the inventory items does not matter for equality.
|
||||
{
|
||||
set1: []*Inventory{&inventory1, &inventory2},
|
||||
set2: []*Inventory{&inventory2, &inventory1},
|
||||
isEqual: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
invSet1 := NewInventorySet(test.set1)
|
||||
invSet2 := NewInventorySet(test.set2)
|
||||
if !invSet1.Equals(invSet2) && test.isEqual {
|
||||
t.Errorf("Expected equal inventory sets; got unequal (%s)/(%s)\n", invSet1, invSet2)
|
||||
}
|
||||
if invSet1.Equals(invSet2) && !test.isEqual {
|
||||
t.Errorf("Expected inequal inventory sets; got equal (%s)/(%s)\n", invSet1, invSet2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
cmd/kubectl/kubectlcobra/printer_adapter.go
Normal file
53
cmd/kubectl/kubectlcobra/printer_adapter.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/cli-runtime/pkg/printers"
|
||||
)
|
||||
|
||||
// KubectlPrinterAdapter is a workaround for capturing progress from
|
||||
// ApplyOptions. ApplyOptions were originally meant to print progress
|
||||
// directly using a configurable printer. The KubectlPrinterAdapter
|
||||
// plugs into ApplyOptions as a ToPrinter function, but instead of
|
||||
// printing the info, it emits it as an event on the provided channel.
|
||||
type KubectlPrinterAdapter struct {
|
||||
ch chan<- Event
|
||||
}
|
||||
|
||||
// resourcePrinterImpl implements the ResourcePrinter interface. But
|
||||
// instead of printing, it emits information on the provided channel.
|
||||
type resourcePrinterImpl struct {
|
||||
operation string
|
||||
ch chan<- Event
|
||||
}
|
||||
|
||||
// PrintObj takes the provided object and operation and emits
|
||||
// it on the channel.
|
||||
func (r *resourcePrinterImpl) PrintObj(obj runtime.Object, _ io.Writer) error {
|
||||
r.ch <- Event{
|
||||
EventType: ApplyEventType,
|
||||
ApplyEvent: ApplyEvent{
|
||||
Operation: r.operation,
|
||||
Object: obj,
|
||||
},
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type toPrinterFunc func(string) (printers.ResourcePrinter, error)
|
||||
|
||||
// toPrinterFunc returns a function of type toPrinterFunc. This
|
||||
// is the type required by the ApplyOptions.
|
||||
func (p *KubectlPrinterAdapter) toPrinterFunc() toPrinterFunc {
|
||||
return func(operation string) (printers.ResourcePrinter, error) {
|
||||
return &resourcePrinterImpl{
|
||||
ch: p.ch,
|
||||
operation: operation,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
49
cmd/kubectl/kubectlcobra/printer_adapter_test.go
Normal file
49
cmd/kubectl/kubectlcobra/printer_adapter_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func TestKubectlPrinterAdapter(t *testing.T) {
|
||||
ch := make(chan Event)
|
||||
buffer := bytes.Buffer{}
|
||||
operation := "operation"
|
||||
|
||||
adapter := KubectlPrinterAdapter{
|
||||
ch: ch,
|
||||
}
|
||||
|
||||
toPrinterFunc := adapter.toPrinterFunc()
|
||||
resourcePrinter, err := toPrinterFunc(operation)
|
||||
assert.NoError(t, err)
|
||||
|
||||
deployment := appsv1.Deployment{
|
||||
TypeMeta: v1.TypeMeta{
|
||||
APIVersion: "apps/v1",
|
||||
Kind: "Deployment",
|
||||
},
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: "name",
|
||||
Namespace: "namespace",
|
||||
},
|
||||
}
|
||||
|
||||
// Need to run this in a separate gorutine since go channels
|
||||
// are blocking.
|
||||
go func() {
|
||||
err = resourcePrinter.PrintObj(&deployment, &buffer)
|
||||
}()
|
||||
msg := <-ch
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, operation, msg.ApplyEvent.Operation)
|
||||
assert.Equal(t, &deployment, msg.ApplyEvent.Object)
|
||||
}
|
||||
258
cmd/kubectl/kubectlcobra/prune.go
Normal file
258
cmd/kubectl/kubectlcobra/prune.go
Normal file
@@ -0,0 +1,258 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// package kubectlcobra contains cobra commands from kubectl
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/cli-runtime/pkg/printers"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/kubectl/pkg/cmd/apply"
|
||||
"k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/validation"
|
||||
)
|
||||
|
||||
// PruneOptions encapsulates the necessary information to
|
||||
// implement the prune functionality.
|
||||
type PruneOptions struct {
|
||||
client dynamic.Interface
|
||||
builder *resource.Builder
|
||||
mapper meta.RESTMapper
|
||||
namespace string
|
||||
// The currently applied objects (as Infos), including the
|
||||
// current grouping object. These objects are used to
|
||||
// calculate the prune set after retreiving the previous
|
||||
// grouping objects.
|
||||
currentGroupingObject *resource.Info
|
||||
// The set of retrieved grouping objects (as Infos) selected
|
||||
// by the grouping label. This set should also include the
|
||||
// current grouping object. Stored here to make testing
|
||||
// easier by manually setting the retrieved grouping infos.
|
||||
pastGroupingObjects []*resource.Info
|
||||
retrievedGroupingObjects bool
|
||||
|
||||
toPrinter func(string) (printers.ResourcePrinter, error)
|
||||
out io.Writer
|
||||
|
||||
validator validation.Schema
|
||||
|
||||
// TODO: DeleteOptions--cascade?
|
||||
}
|
||||
|
||||
// NewPruneOptions returns a struct (PruneOptions) encapsulating the necessary
|
||||
// information to run the prune. Returns an error if an error occurs
|
||||
// gathering this information.
|
||||
// TODO: Add dry-run options.
|
||||
func NewPruneOptions(f util.Factory, ao *apply.ApplyOptions) (*PruneOptions, error) {
|
||||
|
||||
po := &PruneOptions{}
|
||||
var err error
|
||||
// Fields copied from ApplyOptions.
|
||||
po.namespace = ao.Namespace
|
||||
po.toPrinter = ao.ToPrinter
|
||||
po.out = ao.Out
|
||||
// Client/Builder fields from the Factory.
|
||||
po.client, err = f.DynamicClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
po.builder = f.NewBuilder()
|
||||
po.mapper, err = f.ToRESTMapper()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
po.validator, err = f.Validator(false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Retrieve/store the grouping object for current apply.
|
||||
currentObjects, err := ao.GetObjects()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
currentGroupingObject, found := findGroupingObject(currentObjects)
|
||||
if !found {
|
||||
return nil, fmt.Errorf("Current grouping object not found during prune.")
|
||||
}
|
||||
po.currentGroupingObject = currentGroupingObject
|
||||
// Initialize past grouping objects as empty.
|
||||
po.pastGroupingObjects = []*resource.Info{}
|
||||
po.retrievedGroupingObjects = false
|
||||
|
||||
return po, nil
|
||||
}
|
||||
|
||||
// getPreviousGroupingObjects returns the set of grouping objects
|
||||
// that have the same label as the current grouping object. Removes
|
||||
// the current grouping object from this set. Returns an error
|
||||
// if there is a problem retrieving the grouping objects.
|
||||
func (po *PruneOptions) getPreviousGroupingObjects() ([]*resource.Info, error) {
|
||||
|
||||
// Ensures the "pastGroupingObjects" is set.
|
||||
if !po.retrievedGroupingObjects {
|
||||
if err := po.retrievePreviousGroupingObjects(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the current grouping info from the previous grouping infos.
|
||||
currentInventory, err := infoToInventory(po.currentGroupingObject)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pastGroupInfos := []*resource.Info{}
|
||||
for _, pastInfo := range po.pastGroupingObjects {
|
||||
pastInventory, err := infoToInventory(pastInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !currentInventory.Equals(pastInventory) {
|
||||
pastGroupInfos = append(pastGroupInfos, pastInfo)
|
||||
}
|
||||
}
|
||||
return pastGroupInfos, nil
|
||||
}
|
||||
|
||||
// retrievePreviousGroupingObjects requests the previous grouping objects
|
||||
// using the grouping label from the current grouping object. Sets
|
||||
// the field "pastGroupingObjects". Returns an error if the grouping
|
||||
// label doesn't exist for the current currentGroupingObject does not
|
||||
// exist or if the call to retrieve the past grouping objects fails.
|
||||
func (po *PruneOptions) retrievePreviousGroupingObjects() error {
|
||||
// Get the grouping label for this grouping object, and create
|
||||
// a label selector from it.
|
||||
if po.currentGroupingObject == nil || po.currentGroupingObject.Object == nil {
|
||||
return fmt.Errorf("Missing current grouping object.\n")
|
||||
}
|
||||
groupingLabel, err := retrieveGroupingLabel(po.currentGroupingObject.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
labelSelector := fmt.Sprintf("%s=%s", GroupingLabel, groupingLabel)
|
||||
retrievedGroupingInfos, err := po.builder.
|
||||
Unstructured().
|
||||
// TODO: Check if this validator is necessary.
|
||||
Schema(po.validator).
|
||||
ContinueOnError().
|
||||
NamespaceParam(po.namespace).DefaultNamespace().
|
||||
ResourceTypes("configmap").
|
||||
LabelSelectorParam(labelSelector).
|
||||
Flatten().
|
||||
Do().
|
||||
Infos()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
po.pastGroupingObjects = retrievedGroupingInfos
|
||||
po.retrievedGroupingObjects = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// infoToInventory transforms the object represented by the passed "info"
|
||||
// into its Inventory representation. Returns error if the passed Info
|
||||
// is nil, or the Object in the Info is empty.
|
||||
func infoToInventory(info *resource.Info) (*Inventory, error) {
|
||||
if info == nil || info.Object == nil {
|
||||
return nil, fmt.Errorf("Empty resource.Info can not calculate as inventory.\n")
|
||||
}
|
||||
obj := info.Object
|
||||
gk := obj.GetObjectKind().GroupVersionKind().GroupKind()
|
||||
return createInventory(info.Namespace, info.Name, gk)
|
||||
}
|
||||
|
||||
// unionPastInventory takes a set of grouping objects (infos), returning the
|
||||
// union of the objects referenced by these grouping objects as an
|
||||
// InventorySet. Returns an error if any of the passed objects are not
|
||||
// grouping objects, or if unable to retrieve the inventory from any
|
||||
// grouping object.
|
||||
func unionPastInventory(infos []*resource.Info) (*InventorySet, error) {
|
||||
inventorySet := NewInventorySet([]*Inventory{})
|
||||
for _, info := range infos {
|
||||
inv, err := retrieveInventoryFromGroupingObj([]*resource.Info{info})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inventorySet.AddItems(inv)
|
||||
}
|
||||
return inventorySet, nil
|
||||
}
|
||||
|
||||
// calcPruneSet returns the InventorySet representing the objects to
|
||||
// delete (prune). pastGroupInfos are the set of past applied grouping
|
||||
// objects, storing the inventory of the objects applied at the same time.
|
||||
// Calculates the prune set as:
|
||||
//
|
||||
// prune set = (prev1 U prev2 U ... U prevN) - (curr1, curr2, ..., currN)
|
||||
//
|
||||
// Returns an error if we are unable to retrieve the set of previously
|
||||
// applied objects, or if we are unable to get the currently applied objects
|
||||
// from the current grouping object.
|
||||
func (po *PruneOptions) calcPruneSet(pastGroupingInfos []*resource.Info) (*InventorySet, error) {
|
||||
pastInventory, err := unionPastInventory(pastGroupingInfos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Current grouping object as inventory set.
|
||||
c := []*resource.Info{po.currentGroupingObject}
|
||||
currentInv, err := retrieveInventoryFromGroupingObj(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pastInventory.Subtract(NewInventorySet(currentInv))
|
||||
}
|
||||
|
||||
// Prune deletes the set of resources which were previously applied
|
||||
// (retrieved from previous grouping objects) but omitted in
|
||||
// the current apply. Prune also delete all previous grouping
|
||||
// objects. Returns an error if there was a problem.
|
||||
func (po *PruneOptions) Prune() error {
|
||||
|
||||
// Retrieve previous grouping objects, and calculate the
|
||||
// union of the previous applies as an inventory set.
|
||||
pastGroupingInfos, err := po.getPreviousGroupingObjects()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pruneSet, err := po.calcPruneSet(pastGroupingInfos)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete the prune objects.
|
||||
for _, inv := range pruneSet.GetItems() {
|
||||
mapping, err := po.mapper.RESTMapping(inv.GroupKind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = po.client.Resource(mapping.Resource).Namespace(inv.Namespace).Delete(inv.Name, &metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(po.out, "%s/%s deleted\n", strings.ToLower(inv.GroupKind.Kind), inv.Name)
|
||||
}
|
||||
// Delete previous grouping objects.
|
||||
for _, pastGroupInfo := range pastGroupingInfos {
|
||||
err = po.client.Resource(pastGroupInfo.Mapping.Resource).
|
||||
Namespace(pastGroupInfo.Namespace).
|
||||
Delete(pastGroupInfo.Name, &metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printer, err := po.toPrinter("deleted")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = printer.PrintObj(pastGroupInfo.Object, po.out); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
244
cmd/kubectl/kubectlcobra/prune_test.go
Normal file
244
cmd/kubectl/kubectlcobra/prune_test.go
Normal file
@@ -0,0 +1,244 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// package kubectlcobra contains cobra commands from kubectl
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
)
|
||||
|
||||
var pod1Inv = &Inventory{
|
||||
Namespace: testNamespace,
|
||||
Name: pod1Name,
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: "",
|
||||
Kind: "Pod",
|
||||
},
|
||||
}
|
||||
|
||||
var pod2Inv = &Inventory{
|
||||
Namespace: testNamespace,
|
||||
Name: pod2Name,
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: "",
|
||||
Kind: "Pod",
|
||||
},
|
||||
}
|
||||
|
||||
var pod3Inv = &Inventory{
|
||||
Namespace: testNamespace,
|
||||
Name: pod3Name,
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: "",
|
||||
Kind: "Pod",
|
||||
},
|
||||
}
|
||||
|
||||
var groupingInv = &Inventory{
|
||||
Namespace: testNamespace,
|
||||
Name: groupingObjName,
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: "",
|
||||
Kind: "ConfigMap",
|
||||
},
|
||||
}
|
||||
|
||||
func TestInfoToInventory(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
info *resource.Info
|
||||
expected *Inventory
|
||||
isError bool
|
||||
}{
|
||||
"Nil info is an error": {
|
||||
info: nil,
|
||||
expected: nil,
|
||||
isError: true,
|
||||
},
|
||||
"Nil info object is an error": {
|
||||
info: nilInfo,
|
||||
expected: nil,
|
||||
isError: true,
|
||||
},
|
||||
"Pod 1 object becomes Pod 1 inventory": {
|
||||
info: pod1Info,
|
||||
expected: pod1Inv,
|
||||
isError: false,
|
||||
},
|
||||
"Grouping object becomes grouping inventory": {
|
||||
info: copyGroupingInfo(),
|
||||
expected: groupingInv,
|
||||
isError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
actual, err := infoToInventory(test.info)
|
||||
if test.isError && err == nil {
|
||||
t.Errorf("Did not receive expected error.\n")
|
||||
}
|
||||
if !test.isError {
|
||||
if err != nil {
|
||||
t.Errorf("Receieved unexpected error: %s\n", err)
|
||||
}
|
||||
if !test.expected.Equals(actual) {
|
||||
t.Errorf("Expected inventory (%s), got (%s)\n", test.expected, actual)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a grouping object with the inventory set from
|
||||
// the passed "children".
|
||||
func createGroupingInfo(name string, children ...(*resource.Info)) *resource.Info {
|
||||
groupingObjCopy := groupingObj.DeepCopy()
|
||||
var groupingInfo = &resource.Info{
|
||||
Namespace: testNamespace,
|
||||
Name: groupingObjName,
|
||||
Object: groupingObjCopy,
|
||||
}
|
||||
infos := []*resource.Info{groupingInfo}
|
||||
infos = append(infos, children...)
|
||||
_ = addInventoryToGroupingObj(infos)
|
||||
return groupingInfo
|
||||
}
|
||||
|
||||
func TestUnionPastInventory(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
groupingInfos []*resource.Info
|
||||
expected []*Inventory
|
||||
}{
|
||||
"Empty grouping objects = empty inventory set": {
|
||||
groupingInfos: []*resource.Info{},
|
||||
expected: []*Inventory{},
|
||||
},
|
||||
"No children in grouping object, equals no inventory": {
|
||||
groupingInfos: []*resource.Info{createGroupingInfo("test-1")},
|
||||
expected: []*Inventory{},
|
||||
},
|
||||
"Grouping object with Pod1 returns inventory with Pod1": {
|
||||
groupingInfos: []*resource.Info{createGroupingInfo("test-1", pod1Info)},
|
||||
expected: []*Inventory{pod1Inv},
|
||||
},
|
||||
"Grouping object with three pods returns inventory with three pods": {
|
||||
groupingInfos: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info, pod2Info, pod3Info),
|
||||
},
|
||||
expected: []*Inventory{pod1Inv, pod2Inv, pod3Inv},
|
||||
},
|
||||
"Two grouping objects with different pods returns inventory with both pods": {
|
||||
groupingInfos: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info),
|
||||
createGroupingInfo("test-2", pod2Info),
|
||||
},
|
||||
expected: []*Inventory{pod1Inv, pod2Inv},
|
||||
},
|
||||
"Two grouping objects with overlapping pods returns set of pods": {
|
||||
groupingInfos: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info, pod2Info),
|
||||
createGroupingInfo("test-2", pod2Info, pod3Info),
|
||||
},
|
||||
expected: []*Inventory{pod1Inv, pod2Inv, pod3Inv},
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
actual, err := unionPastInventory(test.groupingInfos)
|
||||
expected := NewInventorySet(test.expected)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error received: %s\n", err)
|
||||
}
|
||||
if !expected.Equals(actual) {
|
||||
t.Errorf("Expected inventory (%s), got (%s)\n", expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalcPruneSet(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
past []*resource.Info
|
||||
current *resource.Info
|
||||
expected []*Inventory
|
||||
isError bool
|
||||
}{
|
||||
"Object not unstructured--error": {
|
||||
past: []*resource.Info{nonUnstructuredGroupingInfo},
|
||||
current: &resource.Info{},
|
||||
expected: []*Inventory{},
|
||||
isError: true,
|
||||
},
|
||||
"No past group objects--no prune set": {
|
||||
|
||||
past: []*resource.Info{},
|
||||
current: createGroupingInfo("test-1"),
|
||||
expected: []*Inventory{},
|
||||
isError: false,
|
||||
},
|
||||
"Empty past grouping object--no prune set": {
|
||||
past: []*resource.Info{createGroupingInfo("test-1")},
|
||||
current: createGroupingInfo("test-1"),
|
||||
expected: []*Inventory{},
|
||||
isError: false,
|
||||
},
|
||||
"Pod1 - Pod1 = empty set": {
|
||||
past: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info),
|
||||
},
|
||||
current: createGroupingInfo("test-1", pod1Info),
|
||||
expected: []*Inventory{},
|
||||
isError: false,
|
||||
},
|
||||
"(Pod1, Pod2) - Pod1 = Pod2": {
|
||||
past: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info, pod2Info),
|
||||
},
|
||||
current: createGroupingInfo("test-1", pod1Info),
|
||||
expected: []*Inventory{pod2Inv},
|
||||
isError: false,
|
||||
},
|
||||
"(Pod1, Pod2) - Pod2 = Pod1": {
|
||||
past: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info, pod2Info),
|
||||
},
|
||||
current: createGroupingInfo("test-1", pod2Info),
|
||||
expected: []*Inventory{pod1Inv},
|
||||
isError: false,
|
||||
},
|
||||
"(Pod1, Pod2, Pod3) - Pod2 = Pod1, Pod3": {
|
||||
past: []*resource.Info{
|
||||
createGroupingInfo("test-1", pod1Info, pod2Info),
|
||||
createGroupingInfo("test-1", pod2Info, pod3Info),
|
||||
},
|
||||
current: createGroupingInfo("test-1", pod2Info),
|
||||
expected: []*Inventory{pod1Inv, pod3Inv},
|
||||
isError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
po := &PruneOptions{}
|
||||
po.currentGroupingObject = test.current
|
||||
actual, err := po.calcPruneSet(test.past)
|
||||
expected := NewInventorySet(test.expected)
|
||||
if test.isError && err == nil {
|
||||
t.Errorf("Did not receive expected error.\n")
|
||||
}
|
||||
if !test.isError {
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error received: %s\n", err)
|
||||
}
|
||||
if !expected.Equals(actual) {
|
||||
t.Errorf("Expected prune set (%s), got (%s)\n", expected, actual)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,102 +4,27 @@
|
||||
package kubectlcobra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
"k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
)
|
||||
|
||||
type StatusOptions struct {
|
||||
factory util.Factory
|
||||
ioStreams genericclioptions.IOStreams
|
||||
func NewStatusOptions() *StatusOptions {
|
||||
return &StatusOptions{
|
||||
wait: false,
|
||||
period: 2 * time.Second,
|
||||
timeout: time.Minute,
|
||||
}
|
||||
}
|
||||
|
||||
type StatusOptions struct {
|
||||
wait bool
|
||||
period time.Duration
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func newStatusOptions(factory util.Factory, ioStreams genericclioptions.IOStreams) *StatusOptions {
|
||||
return &StatusOptions{
|
||||
factory: factory,
|
||||
ioStreams: ioStreams,
|
||||
|
||||
wait: false,
|
||||
period: 2 * time.Second,
|
||||
timeout: 1 * time.Minute,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StatusOptions) AddFlags(c *cobra.Command) {
|
||||
c.Flags().BoolVar(&s.wait, "status", s.wait, "Wait for all applied resources to reach the Current status.")
|
||||
c.Flags().DurationVar(&s.period, "status-period", s.period, "Polling period for resource statuses.")
|
||||
c.Flags().DurationVar(&s.timeout, "status-timeout", s.timeout, "Timeout threshold for waiting for all resources to reach the Current status.")
|
||||
}
|
||||
|
||||
func (s *StatusOptions) waitForStatus(infos []*resource.Info) error {
|
||||
mapper, err := getRESTMapper(s.factory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := getClient(s.factory, mapper)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
|
||||
defer cancel()
|
||||
|
||||
resolver := wait.NewResolver(c, mapper, s.period)
|
||||
ch := resolver.WaitForStatus(ctx, infosToResourceIdentifiers(infos))
|
||||
|
||||
for msg := range ch {
|
||||
switch msg.Type {
|
||||
case wait.ResourceUpdate:
|
||||
id := msg.EventResource.ResourceIdentifier
|
||||
gk := id.GroupKind
|
||||
fmt.Fprintf(s.ioStreams.Out, "%s/%s is %s: %s\n", strings.ToLower(gk.String()), id.Name, msg.EventResource.Status.String(), msg.EventResource.Message)
|
||||
case wait.Completed:
|
||||
fmt.Fprint(s.ioStreams.Out, "all resources has reached the Current status\n")
|
||||
case wait.Aborted:
|
||||
fmt.Fprintf(s.ioStreams.Out, "resources failed to the reached Current status after %s\n", s.timeout.String())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func infosToResourceIdentifiers(infos []*resource.Info) []wait.ResourceIdentifier {
|
||||
var resources []wait.ResourceIdentifier
|
||||
for _, info := range infos {
|
||||
u := info.Object.(*unstructured.Unstructured)
|
||||
resources = append(resources, wait.ResourceIdentifier{
|
||||
GroupKind: u.GroupVersionKind().GroupKind(),
|
||||
Namespace: u.GetNamespace(),
|
||||
Name: u.GetName(),
|
||||
})
|
||||
}
|
||||
return resources
|
||||
}
|
||||
|
||||
func getRESTMapper(f util.Factory) (meta.RESTMapper, error) {
|
||||
return f.ToRESTMapper()
|
||||
}
|
||||
|
||||
func getClient(f util.Factory, mapper meta.RESTMapper) (client.Reader, error) {
|
||||
config, err := f.ToRESTConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client.New(config, client.Options{Scheme: scheme.Scheme, Mapper: mapper})
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Copyright {{.Year}} {{.Holder}}
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
@@ -1,39 +0,0 @@
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
.PHONY: generate license fix vet fmt test build tidy
|
||||
|
||||
GOBIN := $(shell go env GOPATH)/bin
|
||||
|
||||
build:
|
||||
go build -v -o $(GOBIN)/resource .
|
||||
|
||||
all: generate build license fix vet fmt test lint tidy
|
||||
|
||||
fix:
|
||||
go fix ./...
|
||||
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
generate:
|
||||
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
|
||||
GOBIN=$(GOBIN) go generate ./...
|
||||
|
||||
license:
|
||||
(which $(GOBIN)/addlicense || go get github.com/google/addlicense)
|
||||
$(GOBIN)/addlicense -y 2019 -c "The Kubernetes Authors." -f LICENSE_TEMPLATE .
|
||||
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
||||
lint:
|
||||
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
|
||||
$(GOBIN)/golangci-lint run ./...
|
||||
|
||||
test:
|
||||
go test -cover ./...
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -e
|
||||
|
||||
: "${kyaml_major?Need to source VERSIONS}"
|
||||
: "${kyaml_minor?Need to source VERSIONS}"
|
||||
: "${kyaml_patch?Need to source VERSIONS}"
|
||||
|
||||
: "${kstatus_major?Need to source VERSIONS}"
|
||||
: "${kstatus_minor?Need to source VERSIONS}"
|
||||
: "${kstatus_patch?Need to source VERSIONS}"
|
||||
|
||||
|
||||
go mod edit -dropreplace=sigs.k8s.io/kustomize/kyaml@v0.0.0
|
||||
go mod edit -require=sigs.k8s.io/kustomize/kyaml@v$kyaml_major.$kyaml_minor.$kyaml_patch
|
||||
|
||||
go mod edit -dropreplace=sigs.k8s.io/kustomize/kstatus@v0.0.0
|
||||
go mod edit -require=sigs.k8s.io/kustomize/kstatus@v$kstatus_major.$kstatus_minor.$kstatus_patch
|
||||
@@ -1,21 +0,0 @@
|
||||
module sigs.k8s.io/kustomize/cmd/resource
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/stretchr/testify v1.4.0
|
||||
k8s.io/api v0.17.0
|
||||
k8s.io/apimachinery v0.17.0
|
||||
k8s.io/client-go v0.17.0
|
||||
sigs.k8s.io/controller-runtime v0.4.0
|
||||
sigs.k8s.io/kustomize/kstatus v0.0.0
|
||||
sigs.k8s.io/kustomize/kyaml v0.0.0
|
||||
)
|
||||
|
||||
replace (
|
||||
sigs.k8s.io/kustomize/kstatus v0.0.0 => ../../kstatus
|
||||
sigs.k8s.io/kustomize/kyaml v0.0.0 => ../../kyaml
|
||||
)
|
||||
@@ -1,444 +0,0 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
|
||||
github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs=
|
||||
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
|
||||
github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU=
|
||||
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
|
||||
github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM=
|
||||
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
|
||||
github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY=
|
||||
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
|
||||
github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k=
|
||||
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-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/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.1-coreos.6/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/etcd v3.3.15+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
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 h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
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 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||
github.com/go-logr/zapr v0.1.0 h1:h+WVe9j6HAA01niTJPA/kKH0i7e0rLZBCwauQFcRE54=
|
||||
github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk=
|
||||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
|
||||
github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk=
|
||||
github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0=
|
||||
github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0=
|
||||
github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94=
|
||||
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
|
||||
github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||
github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||
github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
|
||||
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||
github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
|
||||
github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
|
||||
github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
|
||||
github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs=
|
||||
github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA=
|
||||
github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64=
|
||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||
github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||
github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||
github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
|
||||
github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw=
|
||||
github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
|
||||
github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU=
|
||||
github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU=
|
||||
github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY=
|
||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
|
||||
github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
|
||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4=
|
||||
github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
|
||||
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
|
||||
github.com/gogo/protobuf v1.3.1/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-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 h1:u4bArs140e9+AfE52mFHOXVFnOSBJBRlzTHrOPLOIhE=
|
||||
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
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/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||
github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk=
|
||||
github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU=
|
||||
github.com/gophercloud/gophercloud v0.1.0 h1:P/nh25+rzXouhytV2pUHBb65fnds26Ghl8/391+sT5o=
|
||||
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/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.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
|
||||
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
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/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
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/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
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/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
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-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
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/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-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/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.4.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
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/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.3.0/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
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/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||
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/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
|
||||
github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740=
|
||||
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8=
|
||||
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE=
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
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=
|
||||
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/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/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/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=
|
||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v0.0.0-20180122172545-ddea229ff1df/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v0.0.0-20180814183419-67bc79d13d15/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180112015858-5ccada7d0a7b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/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-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/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/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
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-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/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-20180117170059-2c42eef0765b/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-20180909124046-d0be0721c37e/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-20190209173611-3b5209105503/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-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/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.1-0.20171227012246-e19ae1496984/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.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-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/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/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0=
|
||||
gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
|
||||
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
|
||||
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
|
||||
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 h1:nfPFGzJkUDX6uBmpN/pSw7MbOAWegH5QDQuoXFHedLg=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
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/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.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
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/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d h1:LCPbGQ34PMrwad11aMZ+dbz5SAsq/0ySjRwQ8I9Qwd8=
|
||||
gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
k8s.io/api v0.0.0-20190918155943-95b840bb6a1f h1:8FRUST8oUkEI45WYKyD8ed7Ad0Kg5v11zHyPkEVb2xo=
|
||||
k8s.io/api v0.0.0-20190918155943-95b840bb6a1f/go.mod h1:uWuOHnjmNrtQomJrvEBg0c0HRNyQ+8KTEERVsK0PW48=
|
||||
k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM=
|
||||
k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI=
|
||||
k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783 h1:V6ndwCPoao1yZ52agqOKaUAl7DYWVGiXjV7ePA2i610=
|
||||
k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783/go.mod h1:xvae1SZB3E17UpV59AWc271W/Ph25N+bjPyR63X6tPY=
|
||||
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655 h1:CS1tBQz3HOXiseWZu6ZicKX361CZLT97UFnnPx0aqBw=
|
||||
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655/go.mod h1:nL6pwRT8NgfF8TT68DBI8uEePRt89cSvoXUVqbkWHq4=
|
||||
k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo=
|
||||
k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
|
||||
k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad/go.mod h1:XPCXEwhjaFN29a8NldXA901ElnKeKLrLtREO9ZhFyhg=
|
||||
k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90 h1:mLmhKUm1X+pXu0zXMEzNsOF5E2kKFGe5o6BZBIIqA6A=
|
||||
k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90/go.mod h1:J69/JveO6XESwVgG53q3Uz5OSfgsv4uxpScmmyYOOlk=
|
||||
k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg=
|
||||
k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k=
|
||||
k8s.io/code-generator v0.0.0-20190912054826-cd179ad6a269/go.mod h1:V5BD6M4CyaN5m+VthcclXWsVcT1Hu+glwa1bi3MIsyE=
|
||||
k8s.io/component-base v0.0.0-20190918160511-547f6c5d7090/go.mod h1:933PBGtQFJky3TEwYx4aEPZ4IxqhWh3R6DCmzqIn1hA=
|
||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
||||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
|
||||
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU=
|
||||
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
|
||||
k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo=
|
||||
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
||||
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
|
||||
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
|
||||
modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
|
||||
modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I=
|
||||
sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg=
|
||||
sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA=
|
||||
sigs.k8s.io/testing_frameworks v0.1.2 h1:vK0+tvjF0BZ/RYFeZ1E6BYBwHJJXhjuZ3TdsEKH+UQM=
|
||||
sigs.k8s.io/testing_frameworks v0.1.2/go.mod h1:ToQrwSC3s8Xf/lADdZp3Mktcql9CG0UAmdJG9th5i0w=
|
||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"sigs.k8s.io/kustomize/cmd/resource/status"
|
||||
|
||||
// This is here rather than in the libraries because of
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/2060
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
)
|
||||
|
||||
var root = &cobra.Command{
|
||||
Use: "resource",
|
||||
Short: "resource reference command",
|
||||
}
|
||||
|
||||
func main() {
|
||||
root.AddCommand(status.StatusCommand())
|
||||
|
||||
if err := root.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/resource/status/generateddocs/commands"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
)
|
||||
|
||||
// GetEventsRunner returns a command EventsRunner.
|
||||
func GetEventsRunner() *EventsRunner {
|
||||
r := &EventsRunner{
|
||||
newResolverFunc: newResolver,
|
||||
}
|
||||
c := &cobra.Command{
|
||||
Use: "events DIR...",
|
||||
Short: commands.EventsShort,
|
||||
Long: commands.EventsLong,
|
||||
Example: commands.EventsExamples,
|
||||
RunE: r.runE,
|
||||
}
|
||||
c.Flags().BoolVar(&r.IncludeSubpackages, "include-subpackages", true,
|
||||
"also print resources from subpackages.")
|
||||
c.Flags().DurationVar(&r.Interval, "interval", 2*time.Second,
|
||||
"check every n seconds.")
|
||||
c.Flags().DurationVar(&r.Timeout, "timeout", 60*time.Second,
|
||||
"give up after n seconds.")
|
||||
|
||||
r.Command = c
|
||||
return r
|
||||
}
|
||||
|
||||
func EventsCommand() *cobra.Command {
|
||||
return GetEventsRunner().Command
|
||||
}
|
||||
|
||||
// EventsRunner captures the parameters for the command
|
||||
// and contains the run function.
|
||||
type EventsRunner struct {
|
||||
IncludeSubpackages bool
|
||||
Interval time.Duration
|
||||
Timeout time.Duration
|
||||
Command *cobra.Command
|
||||
|
||||
newResolverFunc newResolverFunc
|
||||
}
|
||||
|
||||
func (r *EventsRunner) runE(c *cobra.Command, args []string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
resolver, err := r.newResolverFunc(r.Interval)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating resolver")
|
||||
}
|
||||
|
||||
// Set up a CaptureIdentifierFilter and run all inputs through the
|
||||
// filter with the pipeline to capture the inventory of resources
|
||||
// which we are interested in.
|
||||
captureFilter := &CaptureIdentifiersFilter{}
|
||||
filters := []kio.Filter{captureFilter}
|
||||
|
||||
var inputs []kio.Reader
|
||||
for _, a := range args {
|
||||
inputs = append(inputs, kio.LocalPackageReader{
|
||||
PackagePath: a,
|
||||
IncludeSubpackages: r.IncludeSubpackages,
|
||||
})
|
||||
}
|
||||
if len(inputs) == 0 {
|
||||
inputs = append(inputs, &kio.ByteReader{Reader: c.InOrStdin()})
|
||||
}
|
||||
|
||||
err = kio.Pipeline{
|
||||
Inputs: inputs,
|
||||
Filters: filters,
|
||||
}.Execute()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading manifests")
|
||||
}
|
||||
|
||||
// Create a new printer that knows how to print updates about
|
||||
// resourdes and their aggregate status in the events format.
|
||||
printer := newEventPrinter(c.OutOrStdout(), c.OutOrStderr())
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, r.Timeout)
|
||||
defer cancel()
|
||||
resChannel := resolver.WaitForStatus(ctx, captureFilter.Identifiers)
|
||||
|
||||
// Print events until the channel is closed. This will happen
|
||||
// either because all resources has reached the Current status
|
||||
// or it has timed out.
|
||||
for msg := range resChannel {
|
||||
printer.printEvent(msg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,301 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
)
|
||||
|
||||
func TestEventsNoResources(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
fakeClient := &FakeClient{}
|
||||
|
||||
r := GetEventsRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient)
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err := r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
eventOutput := parseEventOutput(t, outBuffer.String())
|
||||
|
||||
if want, got := 1, len(eventOutput.events); want != got {
|
||||
t.Errorf("expected %d events, but got %d", want, got)
|
||||
}
|
||||
|
||||
event := eventOutput.events[0]
|
||||
if want, got := status.CurrentStatus, event.aggStatus; want != got {
|
||||
t.Errorf("expected agg status %s, but got %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventsMultipleUpdates(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
_, err := fmt.Fprint(inBuffer, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: bar
|
||||
namespace: default
|
||||
`)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
fakeClient := &FakeClient{
|
||||
resourceCallbackMap: map[string]ResourceGetCallback{
|
||||
"Deployment": createDeploymentStatusFunc(),
|
||||
},
|
||||
}
|
||||
|
||||
r := GetEventsRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient, appsv1.SchemeGroupVersion.WithKind("Deployment"))
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err = r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
eventOutput := parseEventOutput(t, outBuffer.String())
|
||||
|
||||
aggStatuses := eventOutput.allAggStatuses()
|
||||
expectedAggStatuses := []status.Status{
|
||||
status.InProgressStatus,
|
||||
status.InProgressStatus,
|
||||
status.InProgressStatus,
|
||||
status.InProgressStatus,
|
||||
status.CurrentStatus,
|
||||
status.CurrentStatus,
|
||||
}
|
||||
if !reflect.DeepEqual(aggStatuses, expectedAggStatuses) {
|
||||
t.Errorf("expected agg statuses to be %s, but got %s", joinStatuses(expectedAggStatuses),
|
||||
joinStatuses(aggStatuses))
|
||||
}
|
||||
|
||||
resources := eventOutput.allResources()
|
||||
if want, got := 1, len(resources); want != got {
|
||||
t.Errorf("expected %d resource, but got %d", want, got)
|
||||
}
|
||||
|
||||
resource := resources[0]
|
||||
resourceStatuses := eventOutput.statusesForResource(resource)
|
||||
expectedResourceStatuses := []status.Status{
|
||||
status.InProgressStatus,
|
||||
status.InProgressStatus,
|
||||
status.InProgressStatus,
|
||||
status.InProgressStatus,
|
||||
status.CurrentStatus,
|
||||
}
|
||||
if !reflect.DeepEqual(resourceStatuses, expectedResourceStatuses) {
|
||||
t.Errorf("expected statuses to be %s, but got %s", joinStatuses(expectedResourceStatuses),
|
||||
joinStatuses(resourceStatuses))
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventsMultipleResources(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
_, err := fmt.Fprint(inBuffer, `
|
||||
apiVersion: v1
|
||||
kind: List
|
||||
items:
|
||||
- apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: default
|
||||
- apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: bar
|
||||
namespace: default
|
||||
`)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
fakeClient := &FakeClient{
|
||||
resourceCallbackMap: map[string]ResourceGetCallback{
|
||||
"Pod": createPodStatusFunc(),
|
||||
"Service": createServiceStatusFunc(),
|
||||
},
|
||||
}
|
||||
|
||||
r := GetEventsRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient, corev1.SchemeGroupVersion.WithKind("Pod"),
|
||||
corev1.SchemeGroupVersion.WithKind("Service"))
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err = r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
eventOutput := parseEventOutput(t, outBuffer.String())
|
||||
|
||||
aggStatuses := eventOutput.allAggStatuses()
|
||||
expectedAggStatuses := []status.Status{
|
||||
status.UnknownStatus,
|
||||
status.CurrentStatus,
|
||||
status.CurrentStatus,
|
||||
}
|
||||
if !reflect.DeepEqual(aggStatuses, expectedAggStatuses) {
|
||||
t.Errorf("expected agg statuses to be %s, but got %s", joinStatuses(expectedAggStatuses),
|
||||
joinStatuses(aggStatuses))
|
||||
}
|
||||
|
||||
resources := eventOutput.allResources()
|
||||
if want, got := 2, len(resources); got != want {
|
||||
t.Errorf("expected %d resource, but got %d", want, got)
|
||||
}
|
||||
|
||||
for _, resource := range resources {
|
||||
resourceStatuses := eventOutput.statusesForResource(resource)
|
||||
if want, got := status.CurrentStatus, resourceStatuses[len(resourceStatuses)-1]; want != got {
|
||||
t.Errorf("expected resource %q to have final status %s, but got %s", resource.name, want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type EventOutput struct {
|
||||
events []EventOutputLine
|
||||
unknownLines []string
|
||||
}
|
||||
|
||||
func (e *EventOutput) allAggStatuses() []status.Status {
|
||||
var aggStatuses []status.Status
|
||||
for _, event := range e.events {
|
||||
aggStatuses = append(aggStatuses, event.aggStatus)
|
||||
}
|
||||
return aggStatuses
|
||||
}
|
||||
|
||||
func (e *EventOutput) allResources() []ResourceIdentifier {
|
||||
var resources []ResourceIdentifier
|
||||
seenResources := make(map[ResourceIdentifier]bool)
|
||||
for _, event := range e.events {
|
||||
if !event.isResourceUpdateEvent() {
|
||||
continue
|
||||
}
|
||||
r := event.identifier
|
||||
if _, found := seenResources[r]; !found {
|
||||
resources = append(resources, r)
|
||||
seenResources[r] = true
|
||||
}
|
||||
}
|
||||
return resources
|
||||
}
|
||||
|
||||
func (e *EventOutput) statusesForResource(resource ResourceIdentifier) []status.Status {
|
||||
var statuses []status.Status
|
||||
for _, event := range e.events {
|
||||
if !event.isResourceUpdateEvent() {
|
||||
continue
|
||||
}
|
||||
if event.identifier.Equals(resource) {
|
||||
statuses = append(statuses, event.status)
|
||||
}
|
||||
}
|
||||
return statuses
|
||||
}
|
||||
|
||||
type EventOutputLine struct {
|
||||
eventType string
|
||||
aggStatus status.Status
|
||||
identifier ResourceIdentifier
|
||||
status status.Status
|
||||
message string
|
||||
}
|
||||
|
||||
func (e *EventOutputLine) isResourceUpdateEvent() bool {
|
||||
return e.eventType == string(wait.ResourceUpdate)
|
||||
}
|
||||
|
||||
var (
|
||||
eventRegex = regexp.MustCompile(`^\s*` +
|
||||
`(?P<eventType>\S+)\s+` +
|
||||
`(?P<aggStatus>\S+)\s+` +
|
||||
`((?P<resourceType>\S+)\s+` +
|
||||
`(?P<namespace>\S+)\s+` +
|
||||
`(?P<name>\S+)\s+` +
|
||||
`(?P<status>\S+)\s+` +
|
||||
`(?P<message>.*\S)){0,1}` +
|
||||
`\s*$`)
|
||||
eventHeaderRegex = regexp.MustCompile(`^\s*` +
|
||||
`EVENT TYPE\s+` +
|
||||
`AGG STATUS\s+` +
|
||||
`TYPE\s+` +
|
||||
`NAMESPACE\s+` +
|
||||
`NAME\s+` +
|
||||
`STATUS\s+` +
|
||||
`MESSAGE` +
|
||||
`\s*$`)
|
||||
)
|
||||
|
||||
func parseEventOutput(_ *testing.T, output string) EventOutput {
|
||||
var eventOutput EventOutput
|
||||
lines := strings.Split(output, "\n")
|
||||
for _, line := range lines {
|
||||
if len(line) == 0 {
|
||||
continue // Ignore empty lines
|
||||
}
|
||||
match := eventHeaderRegex.FindStringSubmatch(line)
|
||||
if match != nil {
|
||||
continue // Ignore headers
|
||||
}
|
||||
match = eventRegex.FindStringSubmatch(line)
|
||||
if match == nil {
|
||||
eventOutput.unknownLines = append(eventOutput.unknownLines, line)
|
||||
continue
|
||||
}
|
||||
|
||||
eventOutputLine := EventOutputLine{
|
||||
eventType: match[1],
|
||||
aggStatus: status.FromStringOrDie(match[2]),
|
||||
}
|
||||
|
||||
if eventOutputLine.eventType == string(wait.ResourceUpdate) {
|
||||
resourceType := match[4]
|
||||
parts := strings.Split(resourceType, "/")
|
||||
var identifier ResourceIdentifier
|
||||
if len(parts) == 2 {
|
||||
identifier.apiVersion = parts[0]
|
||||
identifier.kind = parts[1]
|
||||
} else {
|
||||
identifier.apiVersion = strings.Join(parts[:2], "/")
|
||||
identifier.kind = parts[2]
|
||||
}
|
||||
identifier.namespace = match[5]
|
||||
identifier.name = match[6]
|
||||
eventOutputLine.identifier = identifier
|
||||
eventOutputLine.status = status.FromStringOrDie(match[7])
|
||||
eventOutputLine.message = match[8]
|
||||
}
|
||||
|
||||
eventOutput.events = append(eventOutput.events, eventOutputLine)
|
||||
}
|
||||
return eventOutput
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/resource/status/generateddocs/commands"
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
)
|
||||
|
||||
// GetFetchRunner returns a command FetchRunner.
|
||||
func GetFetchRunner() *FetchRunner {
|
||||
r := &FetchRunner{
|
||||
newResolverFunc: newResolver,
|
||||
}
|
||||
c := &cobra.Command{
|
||||
Use: "fetch DIR...",
|
||||
Short: commands.FetchShort,
|
||||
Long: commands.FetchLong,
|
||||
Example: commands.FetchExamples,
|
||||
RunE: r.runE,
|
||||
}
|
||||
c.Flags().BoolVar(&r.IncludeSubpackages, "include-subpackages", true,
|
||||
"also print resources from subpackages.")
|
||||
|
||||
r.Command = c
|
||||
return r
|
||||
}
|
||||
|
||||
func FetchCommand() *cobra.Command {
|
||||
return GetFetchRunner().Command
|
||||
}
|
||||
|
||||
// FetchRunner captures the parameters for the command and contains
|
||||
// the run function.
|
||||
type FetchRunner struct {
|
||||
IncludeSubpackages bool
|
||||
Command *cobra.Command
|
||||
|
||||
newResolverFunc newResolverFunc
|
||||
}
|
||||
|
||||
func (r *FetchRunner) runE(c *cobra.Command, args []string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
resolver, err := r.newResolverFunc(time.Minute)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating resolver")
|
||||
}
|
||||
|
||||
// Set up a CaptureIdentifierFilter and run all inputs through the
|
||||
// filter with the pipeline to capture the inventory of resources
|
||||
// which we are interested in.
|
||||
captureFilter := &CaptureIdentifiersFilter{}
|
||||
filters := []kio.Filter{captureFilter}
|
||||
|
||||
var inputs []kio.Reader
|
||||
for _, a := range args {
|
||||
inputs = append(inputs, kio.LocalPackageReader{
|
||||
PackagePath: a,
|
||||
IncludeSubpackages: r.IncludeSubpackages,
|
||||
})
|
||||
}
|
||||
if len(inputs) == 0 {
|
||||
inputs = append(inputs, &kio.ByteReader{Reader: c.InOrStdin()})
|
||||
}
|
||||
|
||||
err = kio.Pipeline{
|
||||
Inputs: inputs,
|
||||
Filters: filters,
|
||||
}.Execute()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading manifests")
|
||||
}
|
||||
|
||||
// Pass in the inventory of resources to the FetchAndResolve function
|
||||
// on the resolver. It will return the status (or an error) for each
|
||||
// resource in the inventory.
|
||||
results := resolver.FetchAndResolve(ctx, captureFilter.Identifiers)
|
||||
|
||||
// Create new printer that knows how to print resource statuses
|
||||
// in a table format and ask it to print the results.
|
||||
newTablePrinter(FetchStatusInfo{results}, c.OutOrStdout(), c.OutOrStderr(), false).Print()
|
||||
return nil
|
||||
}
|
||||
|
||||
// FetchStatusInfo wraps the results from the FetchAndResolve function
|
||||
// to the format expected in the TablePrinter.
|
||||
type FetchStatusInfo struct {
|
||||
Results []wait.ResourceResult
|
||||
}
|
||||
|
||||
// CurrentStatus returns the latest information known about the
|
||||
// status of each of the resources. For FetchStatusInfo, the result
|
||||
// is never updated, so it just returns the information provided
|
||||
// by the slice of wait.ResourceResult at creation.
|
||||
func (f FetchStatusInfo) CurrentStatus() StatusData {
|
||||
var resourceData []ResourceStatusData
|
||||
for _, res := range f.Results {
|
||||
rsd := ResourceStatusData{
|
||||
Identifier: res.ResourceIdentifier,
|
||||
}
|
||||
if res.Error != nil {
|
||||
rsd.Status = status.UnknownStatus
|
||||
rsd.Message = res.Error.Error()
|
||||
} else {
|
||||
rsd.Status = res.Result.Status
|
||||
rsd.Message = res.Result.Message
|
||||
}
|
||||
|
||||
resourceData = append(resourceData, rsd)
|
||||
}
|
||||
|
||||
return StatusData{
|
||||
AggregateStatus: status.UnknownStatus,
|
||||
ResourceStatuses: resourceData,
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/acarl005/stripansi"
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
)
|
||||
|
||||
func TestEmptyManifest(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
fakeClient := fake.NewFakeClientWithScheme(scheme)
|
||||
|
||||
r := GetFetchRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient)
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err := r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
output := outBuffer.String()
|
||||
lines := strings.Split(output, "\n")
|
||||
|
||||
if want, got := 2, len(lines); want != got {
|
||||
t.Errorf("Expected %d lines, but got %d", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetchStatusFromManifestStdIn(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
_, err := fmt.Fprint(inBuffer, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: bar
|
||||
namespace: default
|
||||
`)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
deployment := createDeployment("bar", "default", 42, appsv1.DeploymentStatus{
|
||||
ObservedGeneration: 1,
|
||||
})
|
||||
|
||||
fakeClient := fake.NewFakeClientWithScheme(scheme, deployment)
|
||||
|
||||
r := GetFetchRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient, appsv1.SchemeGroupVersion.WithKind("Deployment"))
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err = r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
cleanOutput := stripansi.Strip(outBuffer.String())
|
||||
tableOutput := parseTableOutput(t, cleanOutput)
|
||||
|
||||
expectedResource := ResourceIdentifier{
|
||||
apiVersion: "apps",
|
||||
kind: "Deployment",
|
||||
namespace: "default",
|
||||
name: "bar",
|
||||
}
|
||||
expectedStatus := status.InProgressStatus
|
||||
expectedMessage := "Deployment generation is 2, but latest observed generation is 1"
|
||||
|
||||
verifyOutputContains(t, tableOutput, expectedResource, expectedStatus, expectedMessage)
|
||||
}
|
||||
|
||||
//nolint:funlen
|
||||
func TestFetchStatusFromManifestsFiles(t *testing.T) {
|
||||
d, err := ioutil.TempDir("", "status-fetch-test")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(d)
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(d, "dep.yaml"), []byte(`
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: default
|
||||
`), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "svc.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: default
|
||||
`), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
replicas := int32(42)
|
||||
deployment := createDeployment("foo", "default", replicas, appsv1.DeploymentStatus{
|
||||
ObservedGeneration: 2,
|
||||
Replicas: replicas,
|
||||
ReadyReplicas: replicas,
|
||||
AvailableReplicas: replicas,
|
||||
UpdatedReplicas: replicas,
|
||||
Conditions: []appsv1.DeploymentCondition{
|
||||
{
|
||||
Type: appsv1.DeploymentAvailable,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
},
|
||||
})
|
||||
service := createService("foo", "default")
|
||||
|
||||
fakeClient := fake.NewFakeClientWithScheme(scheme, deployment, service)
|
||||
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
r := GetFetchRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient, appsv1.SchemeGroupVersion.WithKind("Deployment"),
|
||||
v1.SchemeGroupVersion.WithKind("Service"))
|
||||
r.Command.SetArgs([]string{d})
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err = r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
cleanOutput := stripansi.Strip(outBuffer.String())
|
||||
tableOutput := parseTableOutput(t, cleanOutput)
|
||||
|
||||
expectedDeploymentResource := ResourceIdentifier{
|
||||
apiVersion: "apps",
|
||||
kind: "Deployment",
|
||||
namespace: "default",
|
||||
name: "foo",
|
||||
}
|
||||
expectedDeploymentStatus := status.CurrentStatus
|
||||
expectedDeploymentMessage := "Deployment is available. Replicas: 42"
|
||||
verifyOutputContains(t, tableOutput, expectedDeploymentResource, expectedDeploymentStatus, expectedDeploymentMessage)
|
||||
|
||||
expectedServiceResource := ResourceIdentifier{
|
||||
apiVersion: "",
|
||||
kind: "Service",
|
||||
namespace: "default",
|
||||
name: "foo",
|
||||
}
|
||||
expectedServiceStatus := status.CurrentStatus
|
||||
expectedServiceMessage := "Service is ready"
|
||||
|
||||
verifyOutputContains(t, tableOutput, expectedServiceResource, expectedServiceStatus, expectedServiceMessage)
|
||||
}
|
||||
|
||||
func createDeployment(name, namespace string, replicas int32, status appsv1.DeploymentStatus) *appsv1.Deployment {
|
||||
return &appsv1.Deployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "apps/v1",
|
||||
Kind: "Deployment",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Generation: 2,
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: &replicas,
|
||||
},
|
||||
Status: status,
|
||||
}
|
||||
}
|
||||
|
||||
func createService(name, namespace string) *v1.Service {
|
||||
return &v1.Service{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "v1",
|
||||
Kind: "Service",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func verifyOutputContains(t *testing.T, tableOutput TableOutput, resource ResourceIdentifier, status status.Status, message string) {
|
||||
if len(tableOutput.Frames) == 0 {
|
||||
t.Fatalf("expected match for resource %s, but output had no frames", resource.name)
|
||||
}
|
||||
firstFrame := tableOutput.Frames[0]
|
||||
var foundResource ResourceOutput
|
||||
match := false
|
||||
for _, resourceOutput := range firstFrame.Resources {
|
||||
if resourceOutput.identifier.Equals(resource) {
|
||||
foundResource = resourceOutput
|
||||
match = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !match {
|
||||
t.Errorf("expected match for resource %s, but didn't find it", resource.name)
|
||||
}
|
||||
if want, got := status, foundResource.status; want != got {
|
||||
t.Errorf("expected status %s for resource %s, but got %s", want, resource.name, got)
|
||||
}
|
||||
if want, got := message, foundResource.message; !strings.HasPrefix(want, got) {
|
||||
t.Errorf("expected message %s for resource %s, but got %s", want, resource.name, got)
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
)
|
||||
|
||||
type TableOutput struct {
|
||||
Frames []TableOutputFrame
|
||||
UnknownRows []string
|
||||
}
|
||||
|
||||
func (t *TableOutput) allAggStatuses() []status.Status {
|
||||
var statuses []status.Status
|
||||
for _, frame := range t.Frames {
|
||||
if frame.AggregateStatus != "" {
|
||||
statuses = append(statuses, frame.AggregateStatus)
|
||||
}
|
||||
}
|
||||
return statuses
|
||||
}
|
||||
|
||||
func (t *TableOutput) dedupedAggStatuses() []status.Status {
|
||||
var dedupedStatuses []status.Status
|
||||
statuses := t.allAggStatuses()
|
||||
var previousStatus status.Status
|
||||
for _, s := range statuses {
|
||||
if s != previousStatus {
|
||||
dedupedStatuses = append(dedupedStatuses, s)
|
||||
previousStatus = s
|
||||
}
|
||||
}
|
||||
return dedupedStatuses
|
||||
}
|
||||
|
||||
func (t *TableOutput) resources() []ResourceIdentifier {
|
||||
seenResources := make(map[ResourceIdentifier]bool)
|
||||
var resources []ResourceIdentifier
|
||||
for _, frame := range t.Frames {
|
||||
for _, resource := range frame.Resources {
|
||||
r := resource.identifier
|
||||
_, found := seenResources[r]
|
||||
if !found {
|
||||
seenResources[r] = true
|
||||
resources = append(resources, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
return resources
|
||||
}
|
||||
|
||||
func (t *TableOutput) dedupedStatusesForResource(resource ResourceIdentifier) []status.Status {
|
||||
var dedupedStatuses []status.Status
|
||||
var previousStatus status.Status
|
||||
for _, frame := range t.Frames {
|
||||
for _, r := range frame.Resources {
|
||||
if r.identifier.Equals(resource) {
|
||||
if r.status != previousStatus {
|
||||
previousStatus = r.status
|
||||
dedupedStatuses = append(dedupedStatuses, r.status)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dedupedStatuses
|
||||
}
|
||||
|
||||
type TableOutputFrame struct {
|
||||
AggregateStatus status.Status
|
||||
Resources []ResourceOutput
|
||||
}
|
||||
|
||||
type ResourceIdentifier struct {
|
||||
apiVersion string
|
||||
kind string
|
||||
name string
|
||||
namespace string
|
||||
}
|
||||
|
||||
func (r ResourceIdentifier) Equals(identifier ResourceIdentifier) bool {
|
||||
return r.apiVersion == identifier.apiVersion &&
|
||||
r.kind == identifier.kind &&
|
||||
r.namespace == identifier.namespace &&
|
||||
r.name == identifier.name
|
||||
}
|
||||
|
||||
type ResourceOutput struct {
|
||||
identifier ResourceIdentifier
|
||||
status status.Status
|
||||
message string
|
||||
}
|
||||
|
||||
var (
|
||||
headerRegex = regexp.MustCompile(`^\s*TYPE\s+NAMESPACE\s+NAME\s+STATUS\s+MESSAGE\s*$`)
|
||||
resourceRegex = regexp.MustCompile(`^(?P<resourceType>\S+)\s+(?P<namespace>\S+)\s+(?P<name>\S+)\s+(?P<status>\S+)\s+(?P<message>.*\S)\s*$`)
|
||||
aggStatusRegex = regexp.MustCompile(`^\s*AggregateStatus: (?P<aggregateStatus>\S+)\s*$`)
|
||||
)
|
||||
|
||||
func parseTableOutput(_ *testing.T, output string) TableOutput {
|
||||
tableOutput := TableOutput{}
|
||||
|
||||
lines := strings.Split(output, "\n")
|
||||
|
||||
hasAggStatus := false
|
||||
var currentFrame TableOutputFrame
|
||||
for i, line := range lines {
|
||||
if len(line) == 0 {
|
||||
continue // We don't care about empty lines.
|
||||
}
|
||||
|
||||
// Check for lines with aggregate status. They are not always present, but if they are,
|
||||
// they always start a new frame of output.
|
||||
match := aggStatusRegex.FindStringSubmatch(line)
|
||||
if match != nil {
|
||||
hasAggStatus = true
|
||||
if i != 0 {
|
||||
tableOutput.Frames = append(tableOutput.Frames, currentFrame)
|
||||
}
|
||||
currentFrame = TableOutputFrame{
|
||||
AggregateStatus: status.FromStringOrDie(match[1]),
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
match = headerRegex.FindStringSubmatch(line)
|
||||
if match != nil {
|
||||
if !hasAggStatus {
|
||||
if i != 0 {
|
||||
tableOutput.Frames = append(tableOutput.Frames, currentFrame)
|
||||
}
|
||||
currentFrame = TableOutputFrame{}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
match = resourceRegex.FindStringSubmatch(line)
|
||||
if match != nil {
|
||||
var identifier ResourceIdentifier
|
||||
resourceType := match[1]
|
||||
parts := strings.Split(resourceType, "/")
|
||||
if len(parts) == 2 {
|
||||
identifier.apiVersion = parts[0]
|
||||
identifier.kind = parts[1]
|
||||
} else {
|
||||
identifier.apiVersion = strings.Join(parts[:2], "/")
|
||||
identifier.kind = parts[2]
|
||||
}
|
||||
identifier.namespace = match[2]
|
||||
identifier.name = match[3]
|
||||
|
||||
res := ResourceOutput{
|
||||
identifier: identifier,
|
||||
}
|
||||
res.status = status.FromStringOrDie(match[4])
|
||||
res.message = match[5]
|
||||
currentFrame.Resources = append(currentFrame.Resources, res)
|
||||
continue
|
||||
}
|
||||
tableOutput.UnknownRows = append(tableOutput.UnknownRows, line)
|
||||
}
|
||||
tableOutput.Frames = append(tableOutput.Frames, currentFrame)
|
||||
return tableOutput
|
||||
}
|
||||
|
||||
func createDeploymentStatusFunc() func(*unstructured.Unstructured) error {
|
||||
metadataMap := map[string]interface{}{
|
||||
"generation": int64(2),
|
||||
}
|
||||
specMap := map[string]interface{}{
|
||||
"replicas": int64(2),
|
||||
}
|
||||
statusMap := map[string]interface{}{
|
||||
"observedGeneration": int64(2),
|
||||
"replicas": int64(4),
|
||||
"updatedReplicas": int64(4),
|
||||
"readyReplicas": int64(4),
|
||||
}
|
||||
var conditions = make([]interface{}, 0)
|
||||
conditions = append(conditions, map[string]interface{}{
|
||||
"type": "Available",
|
||||
"status": "True",
|
||||
})
|
||||
callbackCount := int64(0)
|
||||
return func(deployment *unstructured.Unstructured) error {
|
||||
_ = unstructured.SetNestedMap(deployment.Object, metadataMap, "metadata")
|
||||
_ = unstructured.SetNestedMap(deployment.Object, specMap, "spec")
|
||||
statusMap["availableReplicas"] = callbackCount
|
||||
_ = unstructured.SetNestedMap(deployment.Object, statusMap, "status")
|
||||
_ = unstructured.SetNestedSlice(deployment.Object, conditions, "status", "conditions")
|
||||
callbackCount++
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func createServiceStatusFunc() func(*unstructured.Unstructured) error {
|
||||
return func(*unstructured.Unstructured) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func createPodStatusFunc() func(*unstructured.Unstructured) error {
|
||||
statusMap := map[string]interface{}{
|
||||
"phase": "Succeeded",
|
||||
}
|
||||
return func(pod *unstructured.Unstructured) error {
|
||||
_ = unstructured.SetNestedMap(pod.Object, statusMap, "status")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
type ResourceGetCallback func(resource *unstructured.Unstructured) error
|
||||
|
||||
type FakeClient struct {
|
||||
resourceCallbackMap map[string]ResourceGetCallback
|
||||
}
|
||||
|
||||
func (f *FakeClient) Get(_ context.Context, _ client.ObjectKey, obj runtime.Object) error {
|
||||
kind := obj.GetObjectKind().GroupVersionKind().Kind
|
||||
callbackFunc, found := f.resourceCallbackMap[kind]
|
||||
if !found {
|
||||
return fmt.Errorf("no callback func found for kind %s", kind)
|
||||
}
|
||||
u := obj.(*unstructured.Unstructured)
|
||||
return callbackFunc(u)
|
||||
}
|
||||
|
||||
func (f *FakeClient) List(context.Context, runtime.Object, ...client.ListOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func fakeResolver(fakeClient client.Reader, mapperTypes ...schema.GroupVersionKind) newResolverFunc {
|
||||
return func(pollInterval time.Duration) (*wait.Resolver, error) {
|
||||
var groupVersions []schema.GroupVersion
|
||||
for _, gvk := range mapperTypes {
|
||||
groupVersions = append(groupVersions, gvk.GroupVersion())
|
||||
}
|
||||
mapper := meta.NewDefaultRESTMapper(groupVersions)
|
||||
for _, gvk := range mapperTypes {
|
||||
mapper.Add(gvk, meta.RESTScopeNamespace)
|
||||
}
|
||||
|
||||
return wait.NewResolver(fakeClient, mapper, pollInterval), nil
|
||||
}
|
||||
}
|
||||
|
||||
func joinStatuses(statuses []status.Status) string {
|
||||
var stringStatuses []string
|
||||
for _, s := range statuses {
|
||||
stringStatuses = append(stringStatuses, s.String())
|
||||
}
|
||||
return strings.Join(stringStatuses, ",")
|
||||
}
|
||||
@@ -1,353 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
)
|
||||
|
||||
const (
|
||||
typeColumn = "type"
|
||||
namespaceColumn = "namespace"
|
||||
nameColumn = "name"
|
||||
statusColumn = "status"
|
||||
messageColumn = "message"
|
||||
|
||||
ESC = 27
|
||||
RED color = 31
|
||||
GREEN color = 32
|
||||
YELLOW color = 33
|
||||
WHITE color = 37
|
||||
)
|
||||
|
||||
type color int
|
||||
|
||||
func moveUp(w io.Writer, lineCount int) {
|
||||
printOrDie(w, "%c[%dA", ESC, lineCount)
|
||||
}
|
||||
|
||||
func eraseCurrentLine(w io.Writer) {
|
||||
printOrDie(w, "%c[2K\r", ESC)
|
||||
}
|
||||
|
||||
func setColor(w io.Writer, color color) {
|
||||
printOrDie(w, "%c[%dm", ESC, color)
|
||||
}
|
||||
|
||||
type colorFunc func(s status.Status) color
|
||||
type contentFunc func(resource ResourceStatusData) string
|
||||
|
||||
type tableColumnInfo struct {
|
||||
header string
|
||||
width int
|
||||
colorFunc colorFunc
|
||||
contentFunc contentFunc
|
||||
}
|
||||
|
||||
func defaultColorFunc(_ status.Status) color {
|
||||
return WHITE
|
||||
}
|
||||
|
||||
var (
|
||||
tableColumns = map[string]tableColumnInfo{
|
||||
typeColumn: {
|
||||
header: "TYPE",
|
||||
width: 25,
|
||||
colorFunc: defaultColorFunc,
|
||||
contentFunc: func(data ResourceStatusData) string {
|
||||
return fmt.Sprintf("%s/%s", data.Identifier.GroupKind.Group, data.Identifier.GroupKind.Kind)
|
||||
},
|
||||
},
|
||||
namespaceColumn: {
|
||||
header: "NAMESPACE",
|
||||
width: 15,
|
||||
colorFunc: defaultColorFunc,
|
||||
contentFunc: func(data ResourceStatusData) string {
|
||||
return data.Identifier.Namespace
|
||||
},
|
||||
},
|
||||
nameColumn: {
|
||||
header: "NAME",
|
||||
width: 20,
|
||||
colorFunc: defaultColorFunc,
|
||||
contentFunc: func(data ResourceStatusData) string {
|
||||
return data.Identifier.Name
|
||||
},
|
||||
},
|
||||
statusColumn: {
|
||||
header: "STATUS",
|
||||
width: 10,
|
||||
colorFunc: colorForStatus,
|
||||
contentFunc: func(data ResourceStatusData) string {
|
||||
return data.Status.String()
|
||||
},
|
||||
},
|
||||
messageColumn: {
|
||||
header: "MESSAGE",
|
||||
width: 40,
|
||||
colorFunc: defaultColorFunc,
|
||||
contentFunc: func(data ResourceStatusData) string {
|
||||
return data.Message
|
||||
},
|
||||
},
|
||||
}
|
||||
tableColumnOrder = []string{typeColumn, namespaceColumn, nameColumn, statusColumn, messageColumn}
|
||||
)
|
||||
|
||||
type StatusInfo interface {
|
||||
CurrentStatus() StatusData
|
||||
}
|
||||
|
||||
type StatusData struct {
|
||||
AggregateStatus status.Status
|
||||
ResourceStatuses []ResourceStatusData
|
||||
}
|
||||
|
||||
type ResourceStatusData struct {
|
||||
Identifier wait.ResourceIdentifier
|
||||
Status status.Status
|
||||
Message string
|
||||
}
|
||||
|
||||
type TablePrinter struct {
|
||||
statusInfo StatusInfo
|
||||
out io.Writer
|
||||
err io.Writer
|
||||
showAggStatus bool
|
||||
}
|
||||
|
||||
func newTablePrinter(statusInfo StatusInfo, out io.Writer, err io.Writer, showAggStatus bool) *TablePrinter {
|
||||
return &TablePrinter{
|
||||
statusInfo: statusInfo,
|
||||
out: out,
|
||||
err: err,
|
||||
showAggStatus: showAggStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TablePrinter) Print() {
|
||||
s.printTable(s.statusInfo.CurrentStatus(), false)
|
||||
}
|
||||
|
||||
func (s *TablePrinter) PrintUntil(stop <-chan struct{}, interval time.Duration) <-chan struct{} {
|
||||
completed := make(chan struct{})
|
||||
setColor(s.out, WHITE)
|
||||
s.printTable(s.statusInfo.CurrentStatus(), false)
|
||||
go func() {
|
||||
defer close(completed)
|
||||
ticker := time.NewTicker(interval)
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
ticker.Stop()
|
||||
s.printTable(s.statusInfo.CurrentStatus(), true)
|
||||
return
|
||||
case <-ticker.C:
|
||||
s.printTable(s.statusInfo.CurrentStatus(), true)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return completed
|
||||
}
|
||||
|
||||
func (s *TablePrinter) printTable(data StatusData, deleteUp bool) {
|
||||
if deleteUp {
|
||||
if s.showAggStatus {
|
||||
moveUp(s.out, 1)
|
||||
}
|
||||
moveUp(s.out, 1)
|
||||
moveUp(s.out, len(data.ResourceStatuses))
|
||||
}
|
||||
eraseCurrentLine(s.out)
|
||||
if s.showAggStatus {
|
||||
printOrDie(s.out, "AggregateStatus: ")
|
||||
setColor(s.out, colorForStatus(data.AggregateStatus))
|
||||
printOrDie(s.out, "%s\n", data.AggregateStatus)
|
||||
setColor(s.out, WHITE)
|
||||
}
|
||||
s.printTableRow(headers())
|
||||
for _, resource := range data.ResourceStatuses {
|
||||
s.printTableRow(row(resource))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TablePrinter) printTableRow(rowData []RowData) {
|
||||
for i, row := range rowData {
|
||||
setColor(s.out, row.color)
|
||||
format := fmt.Sprintf("%%-%ds", row.width)
|
||||
printOrDie(s.out, format, trimString(row.content, row.width))
|
||||
if i != len(rowData)-1 {
|
||||
printOrDie(s.out, " ")
|
||||
}
|
||||
setColor(s.out, WHITE)
|
||||
}
|
||||
printOrDie(s.out, "\n")
|
||||
}
|
||||
|
||||
type RowData struct {
|
||||
content string
|
||||
color color
|
||||
width int
|
||||
}
|
||||
|
||||
func headers() []RowData {
|
||||
var headers []RowData
|
||||
for _, columnName := range tableColumnOrder {
|
||||
column := tableColumns[columnName]
|
||||
headers = append(headers, RowData{
|
||||
content: column.header,
|
||||
color: WHITE,
|
||||
width: column.width,
|
||||
})
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
func row(resource ResourceStatusData) []RowData {
|
||||
var row []RowData
|
||||
for _, columnName := range tableColumnOrder {
|
||||
column := tableColumns[columnName]
|
||||
row = append(row, RowData{
|
||||
content: column.contentFunc(resource),
|
||||
color: column.colorFunc(resource.Status),
|
||||
width: column.width,
|
||||
})
|
||||
}
|
||||
return row
|
||||
}
|
||||
|
||||
type eventContentFunc func(wait.Event) string
|
||||
|
||||
type eventColumnInfo struct {
|
||||
header string
|
||||
width int
|
||||
requireResourceUpdateEvent bool
|
||||
contentFunc eventContentFunc
|
||||
}
|
||||
|
||||
var (
|
||||
eventColumns = []eventColumnInfo{
|
||||
{
|
||||
header: "EVENT TYPE",
|
||||
width: 15,
|
||||
requireResourceUpdateEvent: false,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
return string(event.Type)
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "AGG STATUS",
|
||||
width: 10,
|
||||
requireResourceUpdateEvent: false,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
return event.AggregateStatus.String()
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "TYPE",
|
||||
width: 20,
|
||||
requireResourceUpdateEvent: true,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
return fmt.Sprintf("%s/%s", event.EventResource.ResourceIdentifier.GroupKind.Group,
|
||||
event.EventResource.ResourceIdentifier.GroupKind.Kind)
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "NAMESPACE",
|
||||
width: 15,
|
||||
requireResourceUpdateEvent: true,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
return event.EventResource.ResourceIdentifier.Namespace
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "NAME",
|
||||
width: 20,
|
||||
requireResourceUpdateEvent: true,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
return event.EventResource.ResourceIdentifier.Name
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "STATUS",
|
||||
width: 10,
|
||||
requireResourceUpdateEvent: true,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
return event.EventResource.Status.String()
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "MESSAGE",
|
||||
width: 50,
|
||||
requireResourceUpdateEvent: true,
|
||||
contentFunc: func(event wait.Event) string {
|
||||
if event.EventResource.Error != nil {
|
||||
return event.EventResource.Error.Error()
|
||||
}
|
||||
return event.EventResource.Message
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type EventPrinter struct {
|
||||
out io.Writer
|
||||
err io.Writer
|
||||
}
|
||||
|
||||
func newEventPrinter(out io.Writer, err io.Writer) *EventPrinter {
|
||||
for _, column := range eventColumns {
|
||||
format := fmt.Sprintf("%%-%ds ", column.width)
|
||||
printOrDie(out, format, column.header)
|
||||
}
|
||||
printOrDie(out, "\n")
|
||||
return &EventPrinter{
|
||||
out: out,
|
||||
err: err,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *EventPrinter) printEvent(event wait.Event) {
|
||||
for _, column := range eventColumns {
|
||||
if event.Type != wait.ResourceUpdate && column.requireResourceUpdateEvent {
|
||||
continue
|
||||
}
|
||||
format := fmt.Sprintf("%%-%ds ", column.width)
|
||||
printOrDie(e.out, format, trimString(column.contentFunc(event), column.width))
|
||||
}
|
||||
printOrDie(e.out, "\n")
|
||||
}
|
||||
|
||||
func printOrDie(w io.Writer, format string, a ...interface{}) {
|
||||
_, err := fmt.Fprintf(w, format, a...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func colorForStatus(s status.Status) color {
|
||||
switch s {
|
||||
case status.CurrentStatus:
|
||||
return GREEN
|
||||
case status.UnknownStatus:
|
||||
return WHITE
|
||||
case status.InProgressStatus:
|
||||
return YELLOW
|
||||
case status.FailedStatus:
|
||||
return RED
|
||||
}
|
||||
return WHITE
|
||||
}
|
||||
|
||||
func trimString(str string, maxLength int) string {
|
||||
if len(str) <= maxLength {
|
||||
return str
|
||||
}
|
||||
return str[:maxLength]
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
)
|
||||
|
||||
var (
|
||||
scheme = runtime.NewScheme()
|
||||
)
|
||||
|
||||
func init() {
|
||||
_ = clientgoscheme.AddToScheme(scheme)
|
||||
}
|
||||
|
||||
type newResolverFunc func(pollInterval time.Duration) (*wait.Resolver, error)
|
||||
|
||||
// newResolver returns a new resolver that can resolve status for resources based
|
||||
// on polling the cluster.
|
||||
func newResolver(pollInterval time.Duration) (*wait.Resolver, error) {
|
||||
config := ctrl.GetConfigOrDie()
|
||||
mapper, err := apiutil.NewDiscoveryRESTMapper(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c, err := client.New(config, client.Options{Scheme: scheme, Mapper: mapper})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return wait.NewResolver(c, mapper, pollInterval), nil
|
||||
}
|
||||
|
||||
// CaptureIdentifiersFilter implements the Filter interface in the kio package. It
|
||||
// captures the identifiers for all resources passed through the pipeline.
|
||||
type CaptureIdentifiersFilter struct {
|
||||
Identifiers []wait.ResourceIdentifier
|
||||
}
|
||||
|
||||
var _ kio.Filter = &CaptureIdentifiersFilter{}
|
||||
|
||||
func (f *CaptureIdentifiersFilter) Filter(slice []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
for i := range slice {
|
||||
meta, err := slice[i].GetMeta()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO(mortent): Update kyaml library
|
||||
id := meta.GetIdentifier()
|
||||
gv, err := schema.ParseGroupVersion(id.APIVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.Identifiers = append(f.Identifiers, wait.ResourceIdentifier{
|
||||
Name: id.Name,
|
||||
Namespace: id.Namespace,
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: gv.Group,
|
||||
Kind: id.Kind,
|
||||
},
|
||||
})
|
||||
}
|
||||
return slice, nil
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/resource/status/generateddocs/commands"
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
"sigs.k8s.io/kustomize/kstatus/wait"
|
||||
"sigs.k8s.io/kustomize/kyaml/kio"
|
||||
)
|
||||
|
||||
// GetWaitRunner return a command WaitRunner.
|
||||
func GetWaitRunner() *WaitRunner {
|
||||
r := &WaitRunner{
|
||||
newResolverFunc: newResolver,
|
||||
}
|
||||
c := &cobra.Command{
|
||||
Use: "wait DIR...",
|
||||
Short: commands.WaitShort,
|
||||
Long: commands.WaitLong,
|
||||
Example: commands.WaitExamples,
|
||||
RunE: r.runE,
|
||||
}
|
||||
c.Flags().BoolVar(&r.IncludeSubpackages, "include-subpackages", true,
|
||||
"also print resources from subpackages.")
|
||||
c.Flags().DurationVar(&r.Interval, "interval", 2*time.Second,
|
||||
"check every n seconds. Default is every 2 seconds.")
|
||||
c.Flags().DurationVar(&r.Timeout, "timeout", 60*time.Second,
|
||||
"give up after n seconds. Default is 60 seconds.")
|
||||
|
||||
r.Command = c
|
||||
return r
|
||||
}
|
||||
|
||||
func WaitCommand() *cobra.Command {
|
||||
return GetWaitRunner().Command
|
||||
}
|
||||
|
||||
// WaitRunner captures the parameters for the command and contains
|
||||
// the run function.
|
||||
type WaitRunner struct {
|
||||
IncludeSubpackages bool
|
||||
Interval time.Duration
|
||||
Timeout time.Duration
|
||||
Command *cobra.Command
|
||||
|
||||
newResolverFunc newResolverFunc
|
||||
}
|
||||
|
||||
// runE implements the logic of the command and will call the Wait command in the wait
|
||||
// package, use a ResourceStatusCollector to capture the events from the channel, and the
|
||||
// TablePrinter to display the information.
|
||||
func (r *WaitRunner) runE(c *cobra.Command, args []string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
resolver, err := r.newResolverFunc(r.Interval)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "errors creating resolver")
|
||||
}
|
||||
|
||||
captureFilter := &CaptureIdentifiersFilter{}
|
||||
filters := []kio.Filter{captureFilter}
|
||||
|
||||
var inputs []kio.Reader
|
||||
for _, a := range args {
|
||||
inputs = append(inputs, kio.LocalPackageReader{
|
||||
PackagePath: a,
|
||||
IncludeSubpackages: r.IncludeSubpackages,
|
||||
})
|
||||
}
|
||||
if len(inputs) == 0 {
|
||||
inputs = append(inputs, &kio.ByteReader{Reader: c.InOrStdin()})
|
||||
}
|
||||
|
||||
err = kio.Pipeline{
|
||||
Inputs: inputs,
|
||||
Filters: filters,
|
||||
}.Execute()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading manifests")
|
||||
}
|
||||
|
||||
collector := newResourceStatusCollector(captureFilter.Identifiers)
|
||||
|
||||
stop := make(chan struct{})
|
||||
printer := newTablePrinter(CollectorStatusInfo{collector}, c.OutOrStdout(), c.OutOrStderr(), true)
|
||||
printFinished := printer.PrintUntil(stop, 1*time.Second)
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, r.Timeout)
|
||||
defer cancel()
|
||||
resChannel := resolver.WaitForStatus(ctx, captureFilter.Identifiers)
|
||||
|
||||
for msg := range resChannel {
|
||||
switch msg.Type {
|
||||
case wait.ResourceUpdate:
|
||||
collector.updateResourceStatus(msg)
|
||||
case wait.Aborted:
|
||||
collector.updateAggregateStatus(msg.AggregateStatus)
|
||||
case wait.Completed:
|
||||
collector.updateAggregateStatus(msg.AggregateStatus)
|
||||
}
|
||||
}
|
||||
close(stop)
|
||||
<-printFinished // Wait for printer to finish work.
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResourceStatusCollector captures the latest state seen for all resources
|
||||
// based on the events from the Wait channel. This is used by the TablePrinter
|
||||
// to display status for all resources.
|
||||
type ResourceStatusCollector struct {
|
||||
mux sync.RWMutex
|
||||
|
||||
AggregateStatus status.Status
|
||||
ResourceStatuses []*ResourceStatus
|
||||
}
|
||||
|
||||
// updateResourceStatus takes the given event and update the status info
|
||||
// in the ResourceStatusCollector.
|
||||
func (r *ResourceStatusCollector) updateResourceStatus(msg wait.Event) {
|
||||
r.mux.Lock()
|
||||
defer r.mux.Unlock()
|
||||
r.AggregateStatus = msg.AggregateStatus
|
||||
eventResource := msg.EventResource
|
||||
for _, resourceState := range r.ResourceStatuses {
|
||||
if resourceState.Identifier.GroupKind == eventResource.ResourceIdentifier.GroupKind &&
|
||||
resourceState.Identifier.Namespace == eventResource.ResourceIdentifier.Namespace &&
|
||||
resourceState.Identifier.Name == eventResource.ResourceIdentifier.Name {
|
||||
resourceState.Status = eventResource.Status
|
||||
resourceState.Message = eventResource.Message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// updateAggregateStatus sets the aggregate status of the ResourceStatusCollector to the
|
||||
// given value.
|
||||
func (r *ResourceStatusCollector) updateAggregateStatus(aggregateStatus status.Status) {
|
||||
r.mux.Lock()
|
||||
defer r.mux.Unlock()
|
||||
r.AggregateStatus = aggregateStatus
|
||||
}
|
||||
|
||||
// ResourceStatus contains the status information for a single resource.
|
||||
type ResourceStatus struct {
|
||||
Identifier wait.ResourceIdentifier
|
||||
Status status.Status
|
||||
Message string
|
||||
}
|
||||
|
||||
// newResourceStatusCollector creates a new ResourceStatusCollector with the given
|
||||
// resources and sets the status for all of them to Unknown.
|
||||
func newResourceStatusCollector(identifiers []wait.ResourceIdentifier) *ResourceStatusCollector {
|
||||
var statuses []*ResourceStatus
|
||||
|
||||
for _, id := range identifiers {
|
||||
statuses = append(statuses, &ResourceStatus{
|
||||
Identifier: id,
|
||||
Status: status.UnknownStatus,
|
||||
Message: "",
|
||||
})
|
||||
}
|
||||
|
||||
return &ResourceStatusCollector{
|
||||
AggregateStatus: status.UnknownStatus,
|
||||
ResourceStatuses: statuses,
|
||||
}
|
||||
}
|
||||
|
||||
// CollectorStatusInfo is a wrapper around the ResourceStatusCollector
|
||||
// to make it adhere to the interface of the TableWriter.
|
||||
type CollectorStatusInfo struct {
|
||||
Collector *ResourceStatusCollector
|
||||
}
|
||||
|
||||
// CurrentStatus implements the interface for the TableWriter and
|
||||
// returns a copy of the current status of the resources in the
|
||||
// ResourceStatusCollector. This is done to make sure the TableWriter
|
||||
// does not have to deal with synchronization when accessing the data.
|
||||
func (f CollectorStatusInfo) CurrentStatus() StatusData {
|
||||
f.Collector.mux.RLock()
|
||||
defer f.Collector.mux.RUnlock()
|
||||
|
||||
var resourceData []ResourceStatusData
|
||||
for _, res := range f.Collector.ResourceStatuses {
|
||||
resourceData = append(resourceData, ResourceStatusData{
|
||||
Identifier: res.Identifier,
|
||||
Status: res.Status,
|
||||
Message: res.Message,
|
||||
})
|
||||
}
|
||||
|
||||
return StatusData{
|
||||
AggregateStatus: f.Collector.AggregateStatus,
|
||||
ResourceStatuses: resourceData,
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/acarl005/stripansi"
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"sigs.k8s.io/kustomize/kstatus/status"
|
||||
)
|
||||
|
||||
func TestWaitNoResources(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
fakeClient := &FakeClient{}
|
||||
|
||||
r := GetWaitRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient)
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err := r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
cleanOutput := stripansi.Strip(outBuffer.String())
|
||||
tableOutput := parseTableOutput(t, cleanOutput)
|
||||
|
||||
if want, got := 2, len(tableOutput.Frames); want != got {
|
||||
t.Errorf("expected %d frames, but found %d", want, got)
|
||||
}
|
||||
|
||||
aggStatuses := tableOutput.allAggStatuses()
|
||||
expectedAggStatuses := []status.Status{
|
||||
status.UnknownStatus,
|
||||
status.CurrentStatus,
|
||||
}
|
||||
if !reflect.DeepEqual(aggStatuses, expectedAggStatuses) {
|
||||
t.Errorf("expected agg statuses to be %s, but got %s", joinStatuses(expectedAggStatuses),
|
||||
joinStatuses(aggStatuses))
|
||||
}
|
||||
|
||||
resources := tableOutput.resources()
|
||||
if want, got := 0, len(resources); want != got {
|
||||
t.Errorf("expected %d resources, but found %d", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitMultipleUpdates(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
_, err := fmt.Fprint(inBuffer, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: bar
|
||||
namespace: default
|
||||
`)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
fakeClient := &FakeClient{
|
||||
resourceCallbackMap: map[string]ResourceGetCallback{
|
||||
"Deployment": createDeploymentStatusFunc(),
|
||||
},
|
||||
}
|
||||
|
||||
r := GetWaitRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient, appsv1.SchemeGroupVersion.WithKind("Deployment"))
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err = r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
cleanOutput := stripansi.Strip(outBuffer.String())
|
||||
tableOutput := parseTableOutput(t, cleanOutput)
|
||||
|
||||
aggStatuses := tableOutput.dedupedAggStatuses()
|
||||
expectedStatuses := []status.Status{
|
||||
status.UnknownStatus,
|
||||
status.InProgressStatus,
|
||||
status.CurrentStatus,
|
||||
}
|
||||
if !reflect.DeepEqual(aggStatuses, expectedStatuses) {
|
||||
t.Errorf("expected deduped agg statuses to be %s, but got %s", joinStatuses(expectedStatuses),
|
||||
joinStatuses(aggStatuses))
|
||||
}
|
||||
|
||||
resources := tableOutput.resources()
|
||||
if want, got := 1, len(resources); got != want {
|
||||
t.Errorf("expected %d resource, but got %d", want, got)
|
||||
}
|
||||
|
||||
resource := resources[0]
|
||||
resourceStatuses := tableOutput.dedupedStatusesForResource(resource)
|
||||
expectedResourceStatuses := []status.Status{
|
||||
status.InProgressStatus,
|
||||
status.CurrentStatus,
|
||||
}
|
||||
if !reflect.DeepEqual(expectedResourceStatuses, resourceStatuses) {
|
||||
t.Errorf("expected resource %q to have statuses %s, but got %s", resource.name,
|
||||
joinStatuses(expectedResourceStatuses), joinStatuses(resourceStatuses))
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitMultipleResources(t *testing.T) {
|
||||
inBuffer := &bytes.Buffer{}
|
||||
outBuffer := &bytes.Buffer{}
|
||||
|
||||
_, err := fmt.Fprint(inBuffer, `
|
||||
apiVersion: v1
|
||||
kind: List
|
||||
items:
|
||||
- apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: default
|
||||
- apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: bar
|
||||
namespace: default
|
||||
`)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
fakeClient := &FakeClient{
|
||||
resourceCallbackMap: map[string]ResourceGetCallback{
|
||||
"Pod": createPodStatusFunc(),
|
||||
"Service": createServiceStatusFunc(),
|
||||
},
|
||||
}
|
||||
|
||||
r := GetWaitRunner()
|
||||
r.newResolverFunc = fakeResolver(fakeClient, corev1.SchemeGroupVersion.WithKind("Pod"),
|
||||
corev1.SchemeGroupVersion.WithKind("Service"))
|
||||
r.Command.SetArgs([]string{})
|
||||
r.Command.SetIn(inBuffer)
|
||||
r.Command.SetOut(outBuffer)
|
||||
|
||||
err = r.Command.Execute()
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
cleanOutput := stripansi.Strip(outBuffer.String())
|
||||
tableOutput := parseTableOutput(t, cleanOutput)
|
||||
|
||||
aggStatuses := tableOutput.dedupedAggStatuses()
|
||||
if want, got := status.CurrentStatus, aggStatuses[len(aggStatuses)-1]; want != got {
|
||||
t.Errorf("expected final agg statuses to be %s, but got %s", want, got)
|
||||
}
|
||||
|
||||
resources := tableOutput.resources()
|
||||
if want, got := 2, len(resources); got != want {
|
||||
t.Errorf("expected %d resource, but got %d", want, got)
|
||||
}
|
||||
|
||||
for _, resource := range resources {
|
||||
resourceStatuses := tableOutput.dedupedStatusesForResource(resource)
|
||||
if want, got := status.CurrentStatus, resourceStatuses[len(resourceStatuses)-1]; want != got {
|
||||
t.Errorf("expected resource %q to have final status %s, but got %s", resource.name, want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
## events
|
||||
|
||||
[Alpha] Poll the cluster until all provided resources have become Current and list the status change events.
|
||||
|
||||
### Synopsis
|
||||
|
||||
[Alpha] Poll the cluster for the state of all the provided resources until either they have all become
|
||||
Current or the timeout is reached. The output will be status change events.
|
||||
|
||||
The list of resources which should be polled are provided as manifests either on the filesystem or
|
||||
on StdIn.
|
||||
|
||||
DIR:
|
||||
Path to local directory. If not provided, input is expected on StdIn.
|
||||
|
||||
### Examples
|
||||
|
||||
# Read resources from the filesystem and wait up to 1 minute for all of them to become Current
|
||||
resource status events my-dir/
|
||||
|
||||
# Fetch all resources in the cluster and wait up to 5 minutes for all of them to become Current
|
||||
kubectl get all --all-namespaces -oyaml | resource status events --timeout=5m
|
||||
@@ -1,21 +0,0 @@
|
||||
## fetch
|
||||
|
||||
[Alpha] Fetch the state of the provided resources from the cluster and display status in a table.
|
||||
|
||||
### Synopsis
|
||||
|
||||
[Alpha] Fetches the state of all provided resources from the cluster and displays the status in
|
||||
a table.
|
||||
|
||||
The list of resources are provided as manifests either on the filesystem or on StdIn.
|
||||
|
||||
DIR:
|
||||
Path to local directory.
|
||||
|
||||
### Examples
|
||||
|
||||
# Read resources from the filesystem and wait up to 1 minute for all of them to become Current
|
||||
resource status fetch my-dir/
|
||||
|
||||
# Fetch all resources in the cluster and wait up to 5 minutes for all of them to become Current
|
||||
kubectl get all --all-namespaces -oyaml | resource status fetch
|
||||
@@ -1,22 +0,0 @@
|
||||
## wait
|
||||
|
||||
[Alpha] Poll the cluster until all provided resources have become Current and display progress in a table.
|
||||
|
||||
### Synopsis
|
||||
|
||||
[Alpha] Poll the cluster for the state of all the provided resources until either they have all become
|
||||
Current or the timeout is reached. The output will be presented as a table.
|
||||
|
||||
The list of resources which should be polled are provided as manifests either on the filesystem or
|
||||
on StdIn.
|
||||
|
||||
DIR:
|
||||
Path to local directory. If not provided, input is expected on StdIn.
|
||||
|
||||
### Examples
|
||||
|
||||
# Read resources from the filesystem and wait up to 1 minute for all of them to become Current
|
||||
resource status wait my-dir/
|
||||
|
||||
# Fetch all resources in the cluster and wait up to 5 minutes for all of them to become Current
|
||||
kubectl get all --all-namespaces -oyaml | resource status wait --timeout=5m
|
||||
@@ -1,55 +0,0 @@
|
||||
// Code generated by "mdtogo"; DO NOT EDIT.
|
||||
package commands
|
||||
|
||||
var EventsShort = `[Alpha] Poll the cluster until all provided resources have become Current and list the status change events.`
|
||||
var EventsLong = `
|
||||
[Alpha] Poll the cluster for the state of all the provided resources until either they have all become
|
||||
Current or the timeout is reached. The output will be status change events.
|
||||
|
||||
The list of resources which should be polled are provided as manifests either on the filesystem or
|
||||
on StdIn.
|
||||
|
||||
DIR:
|
||||
Path to local directory. If not provided, input is expected on StdIn.
|
||||
`
|
||||
var EventsExamples = `
|
||||
# Read resources from the filesystem and wait up to 1 minute for all of them to become Current
|
||||
resource status events my-dir/
|
||||
|
||||
# Fetch all resources in the cluster and wait up to 5 minutes for all of them to become Current
|
||||
kubectl get all --all-namespaces -oyaml | resource status events --timeout=5m`
|
||||
|
||||
var FetchShort = `[Alpha] Fetch the state of the provided resources from the cluster and display status in a table.`
|
||||
var FetchLong = `
|
||||
[Alpha] Fetches the state of all provided resources from the cluster and displays the status in
|
||||
a table.
|
||||
|
||||
The list of resources are provided as manifests either on the filesystem or on StdIn.
|
||||
|
||||
DIR:
|
||||
Path to local directory.
|
||||
`
|
||||
var FetchExamples = `
|
||||
# Read resources from the filesystem and wait up to 1 minute for all of them to become Current
|
||||
resource status fetch my-dir/
|
||||
|
||||
# Fetch all resources in the cluster and wait up to 5 minutes for all of them to become Current
|
||||
kubectl get all --all-namespaces -oyaml | resource status fetch`
|
||||
|
||||
var WaitShort = `[Alpha] Poll the cluster until all provided resources have become Current and display progress in a table. `
|
||||
var WaitLong = `
|
||||
[Alpha] Poll the cluster for the state of all the provided resources until either they have all become
|
||||
Current or the timeout is reached. The output will be presented as a table.
|
||||
|
||||
The list of resources which should be polled are provided as manifests either on the filesystem or
|
||||
on StdIn.
|
||||
|
||||
DIR:
|
||||
Path to local directory. If not provided, input is expected on StdIn.
|
||||
`
|
||||
var WaitExamples = `
|
||||
# Read resources from the filesystem and wait up to 1 minute for all of them to become Current
|
||||
resource status wait my-dir/
|
||||
|
||||
# Fetch all resources in the cluster and wait up to 5 minutes for all of them to become Current
|
||||
kubectl get all --all-namespaces -oyaml | resource status wait --timeout=5m`
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//go:generate $GOBIN/mdtogo docs/commands generateddocs/commands --license=none
|
||||
|
||||
package status
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/resource/status/cmd"
|
||||
)
|
||||
|
||||
func StatusCommand() *cobra.Command {
|
||||
var status = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "[Alpha] Commands for working with resource status.",
|
||||
}
|
||||
|
||||
status.AddCommand(cmd.FetchCommand())
|
||||
status.AddCommand(cmd.WaitCommand())
|
||||
status.AddCommand(cmd.EventsCommand())
|
||||
|
||||
return status
|
||||
}
|
||||
Reference in New Issue
Block a user