-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f3db3c
commit 2a73a75
Showing
10 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
e2e/testdata/fn-render/mutate-legacy-path-index/.expected/diff.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.2.1 | ||
configPath: starlark-mutate-path-index.yaml |
34 changes: 34 additions & 0 deletions
34
e2e/testdata/fn-render/mutate-legacy-path-index/starlark-mutate-path-index.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
e2e/testdata/fn-render/mutate-path-index/.expected/diff.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.2.1 | ||
configPath: starlark-mutate-path-index.yaml |
34 changes: 34 additions & 0 deletions
34
e2e/testdata/fn-render/mutate-path-index/starlark-mutate-path-index.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |