Skip to content

Commit

Permalink
Add no-op test
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimarupaka committed Jul 14, 2021
1 parent c52869f commit 72f6948
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 4 deletions.
16 changes: 16 additions & 0 deletions e2e/testdata/fn-eval/no-op/.expected/config.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions e2e/testdata/fn-eval/no-op/.krmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
82 changes: 82 additions & 0 deletions e2e/testdata/fn-eval/no-op/resources.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion internal/fnruntime/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/fnruntime/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/kptfile/kptfileutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 72f6948

Please # to comment.