diff --git a/pkg/kinflate/app/application.go b/pkg/kinflate/app/application.go index a2b0f0f63..13e8fa469 100644 --- a/pkg/kinflate/app/application.go +++ b/pkg/kinflate/app/application.go @@ -17,6 +17,9 @@ limitations under the License. package app import ( + "bytes" + "encoding/json" + "github.com/ghodss/yaml" manifest "k8s.io/kubectl/pkg/apis/manifest/v1alpha1" @@ -52,7 +55,7 @@ func New(loader loader.Loader) (Application, error) { } var m manifest.Manifest - err = yaml.Unmarshal(manifestBytes, &m) + err = unmarshal(manifestBytes, &m) if err != nil { return nil, err } @@ -221,3 +224,14 @@ func reindexResourceCollection(rc resource.ResourceCollection) resource.Resource } return result } + +func unmarshal(y []byte, o interface{}) error { + j, err := yaml.YAMLToJSON(y) + if err != nil { + return err + } + + dec := json.NewDecoder(bytes.NewReader(j)) + dec.DisallowUnknownFields() + return dec.Decode(o) +} diff --git a/pkg/kinflate/app/application_test.go b/pkg/kinflate/app/application_test.go index aad297246..c96fb5666 100644 --- a/pkg/kinflate/app/application_test.go +++ b/pkg/kinflate/app/application_test.go @@ -36,7 +36,6 @@ func setupTest(t *testing.T) loader.Loader { kind: Manifest metadata: name: nginx-app -description: nginx app namePrefix: foo- objectLabels: app: nginx diff --git a/pkg/kinflate/commands/testdata/testcase-base-only/in/Kube-manifest.yaml b/pkg/kinflate/commands/testdata/testcase-base-only/in/Kube-manifest.yaml index 9f35bbacd..bfd9e811e 100644 --- a/pkg/kinflate/commands/testdata/testcase-base-only/in/Kube-manifest.yaml +++ b/pkg/kinflate/commands/testdata/testcase-base-only/in/Kube-manifest.yaml @@ -2,7 +2,6 @@ apiVersion: manifest.k8s.io/v1alpha1 kind: Manifest metadata: name: nginx-app -description: nginx app for team foo namePrefix: team-foo- objectLabels: app: mynginx diff --git a/pkg/kinflate/commands/testdata/testcase-single-overlay/in/overlay/Kube-manifest.yaml b/pkg/kinflate/commands/testdata/testcase-single-overlay/in/overlay/Kube-manifest.yaml index 965075872..b3b373b56 100644 --- a/pkg/kinflate/commands/testdata/testcase-single-overlay/in/overlay/Kube-manifest.yaml +++ b/pkg/kinflate/commands/testdata/testcase-single-overlay/in/overlay/Kube-manifest.yaml @@ -2,7 +2,6 @@ apiVersion: manifest.k8s.io/v1alpha1 kind: Manifest metadata: name: nginx-app -description: an overlay for staging env namePrefix: staging- objectLabels: env: staging diff --git a/pkg/kinflate/commands/testdata/testcase-single-overlay/in/package/Kube-manifest.yaml b/pkg/kinflate/commands/testdata/testcase-single-overlay/in/package/Kube-manifest.yaml index 60ea5ec0a..18c4f4cd3 100644 --- a/pkg/kinflate/commands/testdata/testcase-single-overlay/in/package/Kube-manifest.yaml +++ b/pkg/kinflate/commands/testdata/testcase-single-overlay/in/package/Kube-manifest.yaml @@ -2,7 +2,6 @@ apiVersion: manifest.k8s.io/v1alpha1 kind: Manifest metadata: name: nginx-app -description: nginx app for team foo namePrefix: team-foo- objectLabels: app: mynginx diff --git a/pkg/kinflate/examples/simple/instances/exampleinstance/Kube-manifest.yaml b/pkg/kinflate/examples/simple/instances/exampleinstance/Kube-manifest.yaml index c07964a7b..93489a459 100644 --- a/pkg/kinflate/examples/simple/instances/exampleinstance/Kube-manifest.yaml +++ b/pkg/kinflate/examples/simple/instances/exampleinstance/Kube-manifest.yaml @@ -4,7 +4,6 @@ apiVersion: manifest.k8s.io/v1alpha1 kind: Manifest metadata: name: test-infra-mungebot -description: Mungebot config for test-infra repo namePrefix: test-infra- # Labels to add to all objects and selectors. # These labels would also be used to form the selector for apply --prune @@ -34,5 +33,4 @@ secretGenerators: tls.crt: "cat secret/tls.cert" tls.key: "cat secret/tls.key" type: "kubernetes.io/tls" -recursive: false prune: true # I’d make this the default diff --git a/pkg/kinflate/examples/simple/package/Kube-manifest.yaml b/pkg/kinflate/examples/simple/package/Kube-manifest.yaml index 02cdf0ef7..e5ab6d507 100644 --- a/pkg/kinflate/examples/simple/package/Kube-manifest.yaml +++ b/pkg/kinflate/examples/simple/package/Kube-manifest.yaml @@ -17,7 +17,3 @@ objectAnnotations: resources: - deployment/deployment.yaml - service/service.yaml -#Recursive would be similar to kubectl --recursive behavior, extended to look for Kube-manifest.yaml -recursive: false -#Whether PersistentVolumeClaims should be deleted with the other resources -ownPersistentVolumeClaims: true