diff --git a/e2e/testdata/fn-eval/no-op/.expected/config.yaml b/e2e/testdata/fn-eval/no-op/.expected/config.yaml new file mode 100644 index 0000000000..3d51e062c6 --- /dev/null +++ b/e2e/testdata/fn-eval/no-op/.expected/config.yaml @@ -0,0 +1,16 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +testType: eval +image: gcr.io/kpt-functions/no-op diff --git a/e2e/testdata/fn-eval/no-op/.krmignore b/e2e/testdata/fn-eval/no-op/.krmignore new file mode 100644 index 0000000000..9d7a4007d6 --- /dev/null +++ b/e2e/testdata/fn-eval/no-op/.krmignore @@ -0,0 +1 @@ +.expected diff --git a/e2e/testdata/fn-eval/no-op/resources.yaml b/e2e/testdata/fn-eval/no-op/resources.yaml new file mode 100644 index 0000000000..217512b2af --- /dev/null +++ b/e2e/testdata/fn-eval/no-op/resources.yaml @@ -0,0 +1,82 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-nginx + namespace: my-space + labels: + env: dev + foo: bar +spec: + # comment 1 + replicas: 3 + selector: + # comment 2 + matchLabels: # comment 3 + # comment 4 + app: nginx # comment 5 + template: + metadata: + labels: + app: nginx + spec: + # comment 6 + containers: + # comment 7 + - name: nginx + image: 'nginx:1.14.2' # comment 8 + ports: + # comment 9 + - containerPort: 80 # comment 10 +--- +apiVersion: v1 +kind: Service +metadata: + name: my-service +spec: + ports: + # comment 1 + - name: etcd-server-ssl + port: 2380 + # comment 2 + - name: etcd-client-ssl + port: 2379 +--- +apiVersion: constraints.gatekeeper.sh/v1beta1 +kind: EnforceFoo +metadata: + name: enforce-foo +spec: + parameters: + naming_rules: + - kind: Folder + patterns: + # comment 1 + - ^(dev|prod|staging|qa|shared)$ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: setters-config +data: + # This should be the name of your Config Controller instance + cluster-name: cluster-name + # This should be the project where you deployed Config Controller + project-id: project-id + project-number: '1234567890123' + # You can leave these defaults + namespace: config-control + deployment-repo: deployment-repo + source-repo: source-repo diff --git a/go.mod b/go.mod index 14672c5f69..231d9cf506 100644 --- a/go.mod +++ b/go.mod @@ -22,5 +22,5 @@ require ( k8s.io/kubectl v0.21.1 sigs.k8s.io/cli-utils v0.25.1-0.20210603052138-670dee18a123 sigs.k8s.io/kustomize/api v0.8.10 // indirect - sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210709002654-259fcfcef879 + sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210714004626-0f736ec7fde8 ) diff --git a/go.sum b/go.sum index 47eab8fa0e..22d78b82cf 100644 --- a/go.sum +++ b/go.sum @@ -999,6 +999,10 @@ sigs.k8s.io/kustomize/kyaml v0.11.0 h1:9KhiCPKaVyuPcgOLJXkvytOvjMJLoxpjodiycb4gH sigs.k8s.io/kustomize/kyaml v0.11.0/go.mod h1:GNMwjim4Ypgp/MueD3zXHLRJEjz7RvtPae0AwlvEMFM= sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210709002654-259fcfcef879 h1:J8XJIWFsqNP98pSR403Pwp/5PwnZakqoxaDajyjm5GQ= sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210709002654-259fcfcef879/go.mod h1:GNMwjim4Ypgp/MueD3zXHLRJEjz7RvtPae0AwlvEMFM= +sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210713172430-4a1372567847 h1:/TeAV/OkruglyU89qkwPI1Ts2QpzaIHbrdWT4waxcCY= +sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210713172430-4a1372567847/go.mod h1:GNMwjim4Ypgp/MueD3zXHLRJEjz7RvtPae0AwlvEMFM= +sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210714004626-0f736ec7fde8 h1:dpXEULvZRsEPXyn025xHq6TsBMm3nQZg3icbCNLind4= +sigs.k8s.io/kustomize/kyaml v0.11.1-0.20210714004626-0f736ec7fde8/go.mod h1:GNMwjim4Ypgp/MueD3zXHLRJEjz7RvtPae0AwlvEMFM= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/structured-merge-diff/v4 v4.1.0 h1:C4r9BgJ98vrKnnVCjwCSXcWjWe0NKcUQkmzDXZXGwH8= sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= diff --git a/internal/fnruntime/runner_test.go b/internal/fnruntime/runner_test.go index e66fb6459f..06b875394c 100644 --- a/internal/fnruntime/runner_test.go +++ b/internal/fnruntime/runner_test.go @@ -571,7 +571,7 @@ file: assert.NoError(t, err) assert.NoError(t, populateResourceRef(yml, result)) - out, err := yaml.MarshalWithOptions(result, &yaml.EncoderOptions{SeqIndent: yaml.WideSeqIndent}) + out, err := yaml.MarshalWithOptions(result, &yaml.EncoderOptions{SeqIndent: yaml.WideSequenceStyle}) assert.NoError(t, err) assert.Equal(t, tc.expected, string(out)) } diff --git a/internal/fnruntime/utils.go b/internal/fnruntime/utils.go index 493da9e4bb..ef373c8716 100644 --- a/internal/fnruntime/utils.go +++ b/internal/fnruntime/utils.go @@ -32,7 +32,7 @@ func SaveResults(resultsDir string, fnResults *fnresult.ResultList) (string, err out := &bytes.Buffer{} // use kyaml encoder to ensure consistent indentation - e := yaml.NewEncoderWithOptions(out, &yaml.EncoderOptions{SeqIndent: yaml.WideSeqIndent}) + e := yaml.NewEncoderWithOptions(out, &yaml.EncoderOptions{SeqIndent: yaml.WideSequenceStyle}) err := e.Encode(fnResults) if err != nil { return "", err diff --git a/pkg/kptfile/kptfileutil/util.go b/pkg/kptfile/kptfileutil/util.go index 661df82925..830095d741 100644 --- a/pkg/kptfile/kptfileutil/util.go +++ b/pkg/kptfile/kptfileutil/util.go @@ -34,7 +34,7 @@ import ( func WriteFile(dir string, k *kptfilev1.KptFile) error { const op errors.Op = "kptfileutil.WriteFile" - b, err := yaml.MarshalWithOptions(k, &yaml.EncoderOptions{SeqIndent: yaml.WideSeqIndent}) + b, err := yaml.MarshalWithOptions(k, &yaml.EncoderOptions{SeqIndent: yaml.WideSequenceStyle}) if err != nil { return err }