Skip to content

Commit

Permalink
update kyaml and cli-utils to latest (#2523)
Browse files Browse the repository at this point in the history
  • Loading branch information
natasha41575 committed Nov 2, 2021
1 parent 8675781 commit ec02edf
Show file tree
Hide file tree
Showing 36 changed files with 723 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
Expand All @@ -52,6 +54,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "1"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "1"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
Expand Down
4 changes: 4 additions & 0 deletions e2e/testdata/fn-eval/output-to-stdout/.expected/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
namespace: staging
spec:
Expand All @@ -47,6 +49,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "1"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "1"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
namespace: staging
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ source: |-
"metadata": {
"name": "httpbin",
"annotations": {
"config.kubernetes.io/index": 0,
"internal.config.kubernetes.io/index": 0,
# generates resource in parent directory
"config.kubernetes.io/path": "/another/file/out.yaml"
"internal.config.kubernetes.io/path": "/another/file/out.yaml"
}
},
"spec": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/x.yaml b/y.yaml
similarity index 100%
rename from x.yaml
rename to y.yaml
index 7a494c9..e284e52 100644
--- a/x.yaml
+++ b/y.yaml
@@ -1,3 +1,10 @@
+apiVersion: custom.io/v1
+kind: Custom
+metadata:
+ name: custom
+spec:
+ image: nginx:1.2.3
+---
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,10 +24,3 @@ metadata:
name: nginx-deployment
spec:
replicas: 3
----
-apiVersion: custom.io/v1
-kind: Custom
-metadata:
- name: custom
-spec:
- image: nginx:1.2.3
1 change: 1 addition & 0 deletions e2e/testdata/fn-render/mutate-legacy-path-index/.krmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
8 changes: 8 additions & 0 deletions e2e/testdata/fn-render/mutate-legacy-path-index/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: app
pipeline:
mutators:
- image: gcr.io/kpt-fn/starlark:v0.3.0
configPath: starlark-mutate-path-index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata:
name: httpbin-gen
source: |-
def change_path_index(resources):
for r in resources:
pathElems = r["metadata"]["annotations"]["config.kubernetes.io/path"].split("/")
if pathElems[-1] == "y.yaml":
return
pathElems[-1] = "y.yaml"
r["metadata"]["annotations"]["config.kubernetes.io/path"] = "/".join(pathElems)
index = r["metadata"]["annotations"]["config.kubernetes.io/index"]
if index == "0":
r["metadata"]["annotations"]["config.kubernetes.io/index"] = "1"
else:
r["metadata"]["annotations"]["config.kubernetes.io/index"] = "0"
change_path_index(ctx.resource_list["items"])
26 changes: 26 additions & 0 deletions e2e/testdata/fn-render/mutate-legacy-path-index/x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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: nginx-deployment
spec:
replicas: 3
---
apiVersion: custom.io/v1
kind: Custom
metadata:
name: custom
spec:
image: nginx:1.2.3
29 changes: 29 additions & 0 deletions e2e/testdata/fn-render/mutate-path-index/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/x.yaml b/y.yaml
similarity index 100%
rename from x.yaml
rename to y.yaml
index 7a494c9..e284e52 100644
--- a/x.yaml
+++ b/y.yaml
@@ -1,3 +1,10 @@
+apiVersion: custom.io/v1
+kind: Custom
+metadata:
+ name: custom
+spec:
+ image: nginx:1.2.3
+---
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,10 +24,3 @@ metadata:
name: nginx-deployment
spec:
replicas: 3
----
-apiVersion: custom.io/v1
-kind: Custom
-metadata:
- name: custom
-spec:
- image: nginx:1.2.3
1 change: 1 addition & 0 deletions e2e/testdata/fn-render/mutate-path-index/.krmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
8 changes: 8 additions & 0 deletions e2e/testdata/fn-render/mutate-path-index/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: app
pipeline:
mutators:
- image: gcr.io/kpt-fn/starlark:v0.3.0
configPath: starlark-mutate-path-index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata:
name: httpbin-gen
source: |-
def change_path_index(resources):
for r in resources:
pathElems = r["metadata"]["annotations"]["internal.config.kubernetes.io/path"].split("/")
if pathElems[-1] == "y.yaml":
return
pathElems[-1] = "y.yaml"
r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "/".join(pathElems)
index = r["metadata"]["annotations"]["internal.config.kubernetes.io/index"]
if index == "0":
r["metadata"]["annotations"]["internal.config.kubernetes.io/index"] = "1"
else:
r["metadata"]["annotations"]["internal.config.kubernetes.io/index"] = "0"
change_path_index(ctx.resource_list["items"])
26 changes: 26 additions & 0 deletions e2e/testdata/fn-render/mutate-path-index/x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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: nginx-deployment
spec:
replicas: 3
---
apiVersion: custom.io/v1
kind: Custom
metadata:
name: custom
spec:
image: nginx:1.2.3
18 changes: 16 additions & 2 deletions e2e/testdata/fn-render/no-resources/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
diff --git a/another/file/out.yaml b/another/file/out.yaml
new file mode 100644
index 0000000..f36c98e
index 0000000..fe3c0c6
--- /dev/null
+++ b/another/file/out.yaml
@@ -0,0 +1,13 @@
@@ -0,0 +1,27 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
Expand All @@ -17,3 +17,17 @@ index 0000000..f36c98e
+ name: httpbin
+ ports:
+ - containerPort: 9876
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: httpbin-2
+spec:
+ replicas: 4
+ template:
+ spec:
+ containers:
+ - image: kennethreitz/httpbin
+ name: httpbin
+ ports:
+ - containerPort: 9876
37 changes: 34 additions & 3 deletions e2e/testdata/fn-render/no-resources/starlark-httpbin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,43 @@ kind: StarlarkRun
metadata:
name: httpbin-gen
source: |-
httpbin_deployment = {
httpbin_deployment_internal = {
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "httpbin",
"annotations": {
"config.kubernetes.io/index": 0,
"internal.config.kubernetes.io/index": 0,
# generates resource in parent directory
"internal.config.kubernetes.io/path": "/another/file/out.yaml"
}
},
"spec": {
"replicas": 4,
"template": {
"spec": {
"containers": [
{
"name": "httpbin",
"image": "kennethreitz/httpbin",
"ports": [
{
"containerPort": 9876
}
]
}
]
}
}
}
}
httpbin_deployment_legacy = {
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "httpbin-2",
"annotations": {
"config.kubernetes.io/index": 1,
# generates resource in parent directory
"config.kubernetes.io/path": "/another/file/out.yaml"
}
Expand Down Expand Up @@ -55,6 +85,7 @@ source: |-
if is_httpbin(r):
return
resources.append(httpbin_deployment)
resources.append(httpbin_deployment_internal)
resources.append(httpbin_deployment_legacy)
ensure_httpbin(ctx.resource_list["items"])
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
Expand All @@ -45,6 +47,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "1"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "1"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
Expand All @@ -54,6 +56,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "1"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "1"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
namespace: staging
spec:
Expand All @@ -37,6 +39,8 @@ stdOut: |
annotations:
config.kubernetes.io/index: "1"
config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/index: "1"
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
namespace: staging
spec:
Expand Down
Loading

0 comments on commit ec02edf

Please sign in to comment.