From 0cca76fbb8f1b587529e56a9cca84c67df372f17 Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Tue, 7 Jan 2020 11:29:18 -0800 Subject: [PATCH] Clear config.kubernetes.io/path annotation in cmd/cat --- cmd/config/internal/commands/cat.go | 8 ++++++++ cmd/config/internal/commands/cat_test.go | 14 -------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/cmd/config/internal/commands/cat.go b/cmd/config/internal/commands/cat.go index 48b2a542e..5db747fdb 100644 --- a/cmd/config/internal/commands/cat.go +++ b/cmd/config/internal/commands/cat.go @@ -121,6 +121,13 @@ func (r *CatRunner) runE(c *cobra.Command, args []string) error { out = o } + // remove this annotation explicitly, the ByteWriter won't clear it by + // default because it doesn't set it + clear := []string{"config.kubernetes.io/path"} + if r.KeepAnnotations { + clear = nil + } + var outputs []kio.Writer outputs = append(outputs, kio.ByteWriter{ Writer: out, @@ -129,6 +136,7 @@ func (r *CatRunner) runE(c *cobra.Command, args []string) error { WrappingAPIVersion: r.WrapApiVersion, FunctionConfig: functionConfig, Style: yaml.GetStyle(r.Styles...), + ClearAnnotations: clear, }) return handleError(c, kio.Pipeline{Inputs: inputs, Filters: fltr, Outputs: outputs}.Execute()) diff --git a/cmd/config/internal/commands/cat_test.go b/cmd/config/internal/commands/cat_test.go index ad543b132..089d8c9b5 100644 --- a/cmd/config/internal/commands/cat_test.go +++ b/cmd/config/internal/commands/cat_test.go @@ -90,7 +90,6 @@ metadata: name: foo annotations: app: nginx2 - config.kubernetes.io/path: 'f1.yaml' spec: replicas: 1 --- @@ -99,7 +98,6 @@ metadata: name: foo annotations: app: nginx - config.kubernetes.io/path: 'f1.yaml' spec: selector: app: nginx @@ -112,7 +110,6 @@ metadata: app: nginx annotations: app: nginx - config.kubernetes.io/path: 'f2.yaml' spec: replicas: 3 `, b.String()) { @@ -193,7 +190,6 @@ metadata: name: foo annotations: app: nginx2 - config.kubernetes.io/path: 'f1.yaml' spec: replicas: 1 --- @@ -202,7 +198,6 @@ metadata: name: foo annotations: app: nginx - config.kubernetes.io/path: 'f1.yaml' spec: selector: app: nginx @@ -213,7 +208,6 @@ metadata: name: foo annotations: config.kubernetes.io/local-config: "true" - config.kubernetes.io/path: 'f2.yaml' configFn: container: image: gcr.io/example/image:version @@ -227,7 +221,6 @@ metadata: name: bar annotations: app: nginx - config.kubernetes.io/path: 'f2.yaml' spec: replicas: 3 `, b.String()) { @@ -307,7 +300,6 @@ metadata: name: foo annotations: config.kubernetes.io/local-config: "true" - config.kubernetes.io/path: 'f2.yaml' configFn: container: image: gcr.io/example/reconciler:v1 @@ -406,7 +398,6 @@ metadata: name: foo annotations: app: nginx2 - config.kubernetes.io/path: 'f1.yaml' spec: replicas: 1 --- @@ -415,7 +406,6 @@ metadata: name: foo annotations: app: nginx - config.kubernetes.io/path: 'f1.yaml' spec: selector: app: nginx @@ -428,7 +418,6 @@ metadata: app: nginx annotations: app: nginx - config.kubernetes.io/path: 'f2.yaml' spec: replicas: 3 `, string(actual)) { @@ -525,7 +514,6 @@ metadata: name: foo annotations: app: nginx2 - config.kubernetes.io/path: 'f1.yaml' spec: replicas: 1 --- @@ -534,7 +522,6 @@ metadata: name: foo annotations: app: nginx - config.kubernetes.io/path: 'f1.yaml' spec: selector: app: nginx @@ -547,7 +534,6 @@ metadata: app: nginx annotations: app: nginx - config.kubernetes.io/path: 'f2.yaml' spec: replicas: 3 `, string(actual)) {