From fcc8ccae88f75f473bdeb1b266188df076028ba4 Mon Sep 17 00:00:00 2001 From: Surbhi Date: Thu, 5 Mar 2026 18:30:59 +0530 Subject: [PATCH 1/6] test: Update set-namespace E2E tests to use :latest Updates all E2E tests to use set-namespace:latest instead of pinned versions (v0.2.0, v0.4.1, v0.4). This ensures tests automatically use the current function version and catch breaking changes early. Also updates internal/kptops/functions.go to :latest for compiled-in function resolution. Fixes #4297 Signed-off-by: Surbhi --- .../fn-eval/fn-config-file-in-pkg/.expected/config.yaml | 2 +- .../fn-eval/fn-config-file/pkg/.expected/config.yaml | 2 +- .../fnconfig-missing-name/pkg/.expected/config.yaml | 2 +- .../include-meta-resources-v1alpha1/.expected/config.yaml | 2 +- .../include-meta-resources-v1alpha2/.expected/config.yaml | 2 +- .../fn-eval/include-meta-resources/.expected/config.yaml | 2 +- .../invalid-fn-config-file/pkg/.expected/config.yaml | 2 +- .../fn-eval/missing-fn-config/.expected/config.yaml | 2 +- .../multiple-fn-config-one-file/pkg/.expected/config.yaml | 2 +- .../fn-eval/non-krm-resource/.expected/config.yaml | 4 ++-- .../fn-eval/out-of-place-dir/.expected/config.yaml | 4 ++-- .../out-of-place-fnchain-stdout/.expected/config.yaml | 4 ++-- .../out-of-place-fnchain-unwrap/.expected/config.yaml | 4 ++-- .../.expected/config.yaml | 2 +- .../preserve-order-null-values/.expected/config.yaml | 2 +- .../fn-eval/save-fn/custom-pkg-path/.expected/config.yaml | 8 ++++---- e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml | 8 ++++---- .../fn-eval/save-fn/match-selector/.expected/config.yaml | 6 +++--- .../save-fn/no-save-when-fail/.expected/config.yaml | 6 +++--- .../fn-eval/save-fn/override-fn/.expected/config.yaml | 8 ++++---- .../preserve-kptfile-comments/.expected/config.yaml | 8 ++++---- .../fn-eval/save-fn/validator-type/.expected/config.yaml | 8 ++++---- .../fn-eval/selectors/basicpipeline/.expected/config.yaml | 4 ++-- .../fn-eval/selectors/exclude/.expected/config.yaml | 4 ++-- .../out-of-place-fnchain-unwrap/.expected/config.yaml | 4 ++-- .../selectors-with-exclude/.expected/config.yaml | 4 ++-- .../fn-eval/short-image-path/.expected/config.yaml | 6 +++--- .../fn-eval/short-image-path/.expected/results.yaml | 2 +- .../fn-eval/simple-function-symlink/.expected/config.yaml | 4 ++-- .../fn-eval/simple-function/.expected/config.yaml | 2 +- .../.expected/config.yaml | 2 +- .../subpkg-has-samename-subdir/.expected/config.yaml | 2 +- .../subpkg-include-meta-resources/.expected/config.yaml | 2 +- .../fn-eval/subpkgs-with-krmignore/.expected/config.yaml | 2 +- e2e/testdata/fn-eval/subpkgs/.expected/config.yaml | 2 +- e2e/testdata/fn-eval/wasm-function/.expected/config.yaml | 4 ++-- e2e/testdata/fn-render/all-resource-deletion/Kptfile | 2 +- e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile | 2 +- .../fn-render/basicpipeline-symlink/.expected/config.yaml | 4 ++-- e2e/testdata/fn-render/basicpipeline-symlink/Kptfile | 2 +- e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile | 2 +- e2e/testdata/fn-render/basicpipeline-wasm/Kptfile | 4 ++-- e2e/testdata/fn-render/basicpipeline/Kptfile | 2 +- e2e/testdata/fn-render/default-runtime/Kptfile | 2 +- e2e/testdata/fn-render/fn-failure/Kptfile | 2 +- .../fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile | 2 +- e2e/testdata/fn-render/fnconfig-missing-name/Kptfile | 2 +- e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile | 2 +- e2e/testdata/fn-render/fnconfig/Kptfile | 2 +- e2e/testdata/fn-render/fnconfig/db/Kptfile | 2 +- e2e/testdata/fn-render/format-on-success/Kptfile | 2 +- e2e/testdata/fn-render/format-on-success/db/Kptfile | 2 +- e2e/testdata/fn-render/generator/Kptfile | 2 +- e2e/testdata/fn-render/generator/db/Kptfile | 2 +- e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile | 2 +- e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile | 2 +- e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile | 2 +- e2e/testdata/fn-render/krmignore/Kptfile | 2 +- e2e/testdata/fn-render/missing-fn-image/Kptfile | 2 +- e2e/testdata/fn-render/missing-fnconfig/Kptfile | 2 +- e2e/testdata/fn-render/missing-fnconfig/db/Kptfile | 2 +- e2e/testdata/fn-render/multiple-fnconfig/Kptfile | 2 +- e2e/testdata/fn-render/no-fnconfig/Kptfile | 2 +- e2e/testdata/fn-render/no-format-on-failure/Kptfile | 2 +- e2e/testdata/fn-render/no-format-on-failure/db/Kptfile | 2 +- e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile | 2 +- e2e/testdata/fn-render/non-krm-resource/Kptfile | 2 +- .../fn-render/out-of-place-dir-exists-error/Kptfile | 2 +- .../fn-render/out-of-place-dir/.expected/config.yaml | 4 ++-- e2e/testdata/fn-render/out-of-place-dir/Kptfile | 2 +- .../.expected/config.yaml | 6 +++--- .../fn-render/out-of-place-fnchain-stdout-results/Kptfile | 2 +- .../out-of-place-fnchain-stdout/.expected/config.yaml | 6 +++--- .../fn-render/out-of-place-fnchain-stdout/Kptfile | 2 +- .../fn-render/out-of-place-fnchain-unwrap/Kptfile | 2 +- .../fn-render/out-of-place-stdout/.expected/config.yaml | 6 +++--- e2e/testdata/fn-render/out-of-place-stdout/Kptfile | 2 +- .../fn-render/out-of-place-unwrap/.expected/config.yaml | 4 ++-- e2e/testdata/fn-render/out-of-place-unwrap/Kptfile | 2 +- e2e/testdata/fn-render/preserve-order-null-values/Kptfile | 2 +- e2e/testdata/fn-render/resource-deletion/Kptfile | 2 +- .../save-on-render-failure/bfs-basicpipeline/Kptfile | 2 +- .../bfs-parent-mutator-fails/subpkg/Kptfile | 2 +- .../bfs-parent-validator-fails/subpkg/Kptfile | 2 +- .../bfs-subpkg-mutator-fails/subpkg/Kptfile | 2 +- .../bfs-subpkg-validator-fails/subpkg/Kptfile | 2 +- .../save-on-render-failure/dfs-basicpipeline/Kptfile | 2 +- .../dfs-parent-mutator-fails/subpkg/Kptfile | 2 +- .../dfs-parent-validator-fails/subpkg/Kptfile | 2 +- .../dfs-subpkg-mutator-fails/subpkg/Kptfile | 2 +- .../dfs-subpkg-validator-fails/subpkg/Kptfile | 2 +- .../no-save-on-render-failure/Kptfile | 2 +- .../selectors/basicpipeline/.expected/config.yaml | 4 ++-- e2e/testdata/fn-render/selectors/basicpipeline/Kptfile | 2 +- .../fn-render/selectors/exclude/.expected/config.yaml | 4 ++-- e2e/testdata/fn-render/selectors/exclude/Kptfile | 2 +- .../fn-render/selectors/generator/.expected/config.yaml | 8 ++++---- e2e/testdata/fn-render/selectors/generator/Kptfile | 2 +- e2e/testdata/fn-render/selectors/generator/db/Kptfile | 2 +- .../selectors-with-exclude/.expected/config.yaml | 4 ++-- .../fn-render/selectors/selectors-with-exclude/Kptfile | 2 +- .../fn-render/short-image-path/.expected/config.yaml | 4 ++-- .../fn-render/short-image-path/.expected/results.yaml | 2 +- e2e/testdata/fn-render/short-image-path/Kptfile | 2 +- e2e/testdata/fn-render/subpkg-fn-failure/Kptfile | 2 +- e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile | 2 +- e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile | 2 +- .../fn-render/subpkg-has-invalid-kptfile/db/Kptfile | 2 +- .../fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile | 2 +- e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile | 2 +- .../fn-render/subpkg-resource-deletion/db/Kptfile | 2 +- e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile | 2 +- e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile | 2 +- e2e/testdata/fn-render/subpkgs/Kptfile | 2 +- e2e/testdata/fn-render/subpkgs/db/Kptfile | 2 +- e2e/testdata/fn-render/success-stdout/Kptfile | 2 +- internal/kptops/functions.go | 2 +- pkg/lib/kptops/fs_test.go | 6 +++--- 118 files changed, 168 insertions(+), 168 deletions(-) diff --git a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml index 137ef487af..41105abedd 100644 --- a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest fnConfig: ../config.yaml diff --git a/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml index 70b3c3ed7b..c7156ac8dc 100644 --- a/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest fnConfig: ../../config.yaml diff --git a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml index e55509d01d..3e7df546ea 100644 --- a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml @@ -13,7 +13,7 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest fnConfig: ../../config.yaml exitCode: 1 stdErr: "resource must have `metadata.name`" diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml index 377e9fd8c1..63e976d46b 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml @@ -14,7 +14,7 @@ runCount: 2 testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest includeMetaResources: true exitCode: 1 args: diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml index 377e9fd8c1..63e976d46b 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml @@ -14,7 +14,7 @@ runCount: 2 testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest includeMetaResources: true exitCode: 1 args: diff --git a/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml b/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml index 377e9fd8c1..63e976d46b 100644 --- a/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml @@ -14,7 +14,7 @@ runCount: 2 testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest includeMetaResources: true exitCode: 1 args: diff --git a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml index b8bd60d8a4..fc96a355dd 100644 --- a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml @@ -14,6 +14,6 @@ testType: eval exitCode: 1 -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest fnConfig: ../../config.yaml stdErr: "wrong node kind: expected MappingNode but got ScalarNode: node contents:\nI am not a valid config file\n" diff --git a/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml b/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml index a4babc9a30..6f67004bba 100644 --- a/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml +++ b/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml @@ -14,5 +14,5 @@ testType: eval exitCode: 1 -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest stdErr: "failed to configure function: input namespace cannot be empty" diff --git a/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml index cb95e80324..853cc5535b 100644 --- a/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml @@ -13,7 +13,7 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest fnConfig: ../../config.yaml exitCode: 1 stdErr: "must not contain more than one config, got 2" diff --git a/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml b/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml index 4a532c5db9..6f0f4278c8 100644 --- a/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml +++ b/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml @@ -13,10 +13,10 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: staging exitCode: 1 stdErr: | - [FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s error: input resource list must contain only KRM resources: nonkrm.yaml: resource must have `apiVersion` diff --git a/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml index 0b1837e3f3..fed31a7989 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s \ No newline at end of file + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s \ No newline at end of file diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml index 9974ae4b79..1c0a45a689 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml @@ -6,8 +6,8 @@ stdErrStripLines: - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml index d3f1e7360f..6ab4ff020c 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml @@ -20,8 +20,8 @@ stdErrStripLines: - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} diff --git a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml index 577099f001..21110ef268 100644 --- a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml +++ b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml @@ -13,7 +13,7 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest includeMetaResources: true exitCode: 1 args: diff --git a/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml b/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml index e6e3bed593..eb0dfa04f8 100644 --- a/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml +++ b/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml @@ -13,6 +13,6 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: staging diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml index 06a23be0c3..aa27fdc85e 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml @@ -18,12 +18,12 @@ stdErrStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" as mutator in the Kptfile. + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml index 06a23be0c3..aa27fdc85e 100644 --- a/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml @@ -18,12 +18,12 @@ stdErrStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" as mutator in the Kptfile. + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml index 089c8b4566..3950ae0213 100644 --- a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml @@ -17,6 +17,6 @@ stdErrStripLines: - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" as mutator in the Kptfile. + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml index e83f88abe8..c0e3f581fa 100644 --- a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml @@ -18,12 +18,12 @@ stdErrStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s function not added: Kptfile not exists diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml index 1ec3c82a08..c4344df5ea 100644 --- a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml @@ -18,12 +18,12 @@ stdErrStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s - Updated "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" as mutator in the Kptfile. + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Updated "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml index 06a23be0c3..aa27fdc85e 100644 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml @@ -18,12 +18,12 @@ stdErrStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" as mutator in the Kptfile. + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml index d62d1603c1..af337678c4 100644 --- a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml @@ -18,12 +18,12 @@ stdErrStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" as validator in the Kptfile. + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as validator in the Kptfile. diff --git a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml index 4f41d86184..c77db4e32f 100644 --- a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml index 4f41d86184..c77db4e32f 100644 --- a/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml index 8e7ba3ecd0..3f9b4db1c7 100644 --- a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml @@ -17,8 +17,8 @@ stdErrStripLines: - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" on 1 resource(s) [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"} diff --git a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml index 4f41d86184..c77db4e32f 100644 --- a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml b/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml index ed37ade626..8cf6e1787d 100644 --- a/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml +++ b/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml @@ -17,11 +17,11 @@ actualStripLines: testType: eval -image: set-namespace:v0.2.0 +image: set-namespace:latest args: namespace: staging stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml b/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml index 8708417d0d..d20fbc5b56 100755 --- a/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml +++ b/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml @@ -4,5 +4,5 @@ metadata: name: fnresults exitCode: 0 items: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest exitCode: 0 diff --git a/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml b/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml index 71fe148636..50cb6a8da9 100644 --- a/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml +++ b/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml @@ -14,5 +14,5 @@ stdErr: |- [WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" diff --git a/e2e/testdata/fn-eval/simple-function/.expected/config.yaml b/e2e/testdata/fn-eval/simple-function/.expected/config.yaml index e6e3bed593..eb0dfa04f8 100644 --- a/e2e/testdata/fn-eval/simple-function/.expected/config.yaml +++ b/e2e/testdata/fn-eval/simple-function/.expected/config.yaml @@ -13,6 +13,6 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: staging diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml index e6e3bed593..eb0dfa04f8 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml @@ -13,6 +13,6 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: staging diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml index 47844502bf..72644e4089 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml @@ -13,6 +13,6 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: dev diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml b/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml index 377e9fd8c1..63e976d46b 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml @@ -14,7 +14,7 @@ runCount: 2 testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest includeMetaResources: true exitCode: 1 args: diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml index e6e3bed593..eb0dfa04f8 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml @@ -13,6 +13,6 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: staging diff --git a/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml b/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml index e6e3bed593..eb0dfa04f8 100644 --- a/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml @@ -13,6 +13,6 @@ # limitations under the License. testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest args: namespace: staging diff --git a/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml b/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml index 85c35915f4..15907fa66c 100644 --- a/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml +++ b/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml @@ -13,8 +13,8 @@ # limitations under the License. testType: eval -#image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:v0.5.0 -image: gcr.io/kpt-fn-demo/set-namespace:v0.5.0 +#image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest +image: gcr.io/kpt-fn-demo/set-namespace:latest args: namespace: staging allowWasm: true diff --git a/e2e/testdata/fn-render/all-resource-deletion/Kptfile b/e2e/testdata/fn-render/all-resource-deletion/Kptfile index 3c93e9eba7..faf208d647 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/Kptfile +++ b/e2e/testdata/fn-render/all-resource-deletion/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: delete-all.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile b/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml index 21bdfde15f..7662b2c61e 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml @@ -22,8 +22,8 @@ stdErrStripLines: stdErr: |- [WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored Package: "basicpipeline-symlink" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile b/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile b/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile index 1b38316f00..1648ad9067 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile b/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile index ffcf186b10..12457eadf0 100644 --- a/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile @@ -7,8 +7,8 @@ metadata: pipeline: mutators: # The following 2 images are built from https://github.com/kptdev/krm-functions-catalog/pull/898. - - image: gcr.io/kpt-fn-demo/set-namespace:v0.5.0 - # ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:v0.5.0 + - image: gcr.io/kpt-fn-demo/set-namespace:latest + # ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest configMap: namespace: staging - image: gcr.io/kpt-fn-demo/set-labels:v0.2.0 diff --git a/e2e/testdata/fn-render/basicpipeline/Kptfile b/e2e/testdata/fn-render/basicpipeline/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/default-runtime/Kptfile b/e2e/testdata/fn-render/default-runtime/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/default-runtime/Kptfile +++ b/e2e/testdata/fn-render/default-runtime/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/fn-failure/Kptfile b/e2e/testdata/fn-render/fn-failure/Kptfile index 3447ba32a5..ad0c67219a 100644 --- a/e2e/testdata/fn-render/fn-failure/Kptfile +++ b/e2e/testdata/fn-render/fn-failure/Kptfile @@ -7,7 +7,7 @@ pipeline: # invalid starlark input results in failure of first fn - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: starlark-failure-fn.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile index dbab15c299..8d8916eff3 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile @@ -4,6 +4,6 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile b/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile index 043dcac9aa..e93b78ae8f 100644 --- a/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile b/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile index 950565f8c2..abfc9c12e6 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile @@ -10,7 +10,7 @@ info: description: sample description pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.1 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configPath: package-context.yaml - image: ghcr.io/kptdev/krm-functions-catalog/apply-replacements:latest configPath: update-labels.yaml diff --git a/e2e/testdata/fn-render/fnconfig/Kptfile b/e2e/testdata/fn-render/fnconfig/Kptfile index 043dcac9aa..e93b78ae8f 100644 --- a/e2e/testdata/fn-render/fnconfig/Kptfile +++ b/e2e/testdata/fn-render/fnconfig/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/fnconfig/db/Kptfile b/e2e/testdata/fn-render/fnconfig/db/Kptfile index 264dd2eb78..0c2b57a9b6 100644 --- a/e2e/testdata/fn-render/fnconfig/db/Kptfile +++ b/e2e/testdata/fn-render/fnconfig/db/Kptfile @@ -4,7 +4,7 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/format-on-success/Kptfile b/e2e/testdata/fn-render/format-on-success/Kptfile index dbab15c299..8d8916eff3 100644 --- a/e2e/testdata/fn-render/format-on-success/Kptfile +++ b/e2e/testdata/fn-render/format-on-success/Kptfile @@ -4,6 +4,6 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/format-on-success/db/Kptfile b/e2e/testdata/fn-render/format-on-success/db/Kptfile index 92bb0fc1dd..5953cfadf1 100644 --- a/e2e/testdata/fn-render/format-on-success/db/Kptfile +++ b/e2e/testdata/fn-render/format-on-success/db/Kptfile @@ -4,6 +4,6 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db diff --git a/e2e/testdata/fn-render/generator/Kptfile b/e2e/testdata/fn-render/generator/Kptfile index 8050168891..bf73fbddf4 100644 --- a/e2e/testdata/fn-render/generator/Kptfile +++ b/e2e/testdata/fn-render/generator/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-generator pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/generator/db/Kptfile b/e2e/testdata/fn-render/generator/db/Kptfile index 3091f7558a..d589972c67 100644 --- a/e2e/testdata/fn-render/generator/db/Kptfile +++ b/e2e/testdata/fn-render/generator/db/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile b/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile index a5dc8fd08c..64a434f0a7 100644 --- a/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile b/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile index cf6f134769..84c025e495 100644 --- a/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile b/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile index 959d09205a..b9113a16e9 100644 --- a/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile +++ b/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/krmignore/Kptfile b/e2e/testdata/fn-render/krmignore/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/krmignore/Kptfile +++ b/e2e/testdata/fn-render/krmignore/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/missing-fn-image/Kptfile b/e2e/testdata/fn-render/missing-fn-image/Kptfile index 11012deead..e60b7a42e2 100644 --- a/e2e/testdata/fn-render/missing-fn-image/Kptfile +++ b/e2e/testdata/fn-render/missing-fn-image/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/dne # non-existing image diff --git a/e2e/testdata/fn-render/missing-fnconfig/Kptfile b/e2e/testdata/fn-render/missing-fnconfig/Kptfile index c54283c5d2..b5d6abecb5 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/missing-fnconfig/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile b/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile index 264dd2eb78..0c2b57a9b6 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile +++ b/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile @@ -4,7 +4,7 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/multiple-fnconfig/Kptfile b/e2e/testdata/fn-render/multiple-fnconfig/Kptfile index 9aa4dd9658..6103bc8b39 100644 --- a/e2e/testdata/fn-render/multiple-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/multiple-fnconfig/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging configPath: configmap.yaml diff --git a/e2e/testdata/fn-render/no-fnconfig/Kptfile b/e2e/testdata/fn-render/no-fnconfig/Kptfile index f2d124905c..4e59b34039 100644 --- a/e2e/testdata/fn-render/no-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/no-fnconfig/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/no-format-on-failure/Kptfile b/e2e/testdata/fn-render/no-format-on-failure/Kptfile index 90d0c08e23..972feaeda4 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/Kptfile +++ b/e2e/testdata/fn-render/no-format-on-failure/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: hello: world diff --git a/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile b/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile index 92bb0fc1dd..5953cfadf1 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile +++ b/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile @@ -4,6 +4,6 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db diff --git a/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile b/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile +++ b/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/non-krm-resource/Kptfile b/e2e/testdata/fn-render/non-krm-resource/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/non-krm-resource/Kptfile +++ b/e2e/testdata/fn-render/non-krm-resource/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile b/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml index 0b1837e3f3..fed31a7989 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml @@ -13,5 +13,5 @@ # limitations under the License. stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s \ No newline at end of file + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s \ No newline at end of file diff --git a/e2e/testdata/fn-render/out-of-place-dir/Kptfile b/e2e/testdata/fn-render/out-of-place-dir/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-dir/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml index 5bd1ac26be..a3e1bafdd3 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml @@ -22,7 +22,7 @@ stdOut: | tier: backend pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging # Copyright 2021 The kpt Authors @@ -80,5 +80,5 @@ stdOut: | spec: image: nginx:1.2.3 stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml index 61e6015d10..8fe48132be 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml @@ -4,8 +4,8 @@ stdErrStripLines: stdErr: | Package: "out-of-place-fnchain-stdout" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} @@ -32,7 +32,7 @@ stdOut: | tier: backend pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging # Copyright 2021 The kpt Authors diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml index 26b78dacab..c96712620c 100644 --- a/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml @@ -3,8 +3,8 @@ stdErrStripLines: - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s stdOut: | apiVersion: config.kubernetes.io/v1 @@ -23,7 +23,7 @@ stdOut: | namespace: staging pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging # Copyright 2021 The kpt Authors diff --git a/e2e/testdata/fn-render/out-of-place-stdout/Kptfile b/e2e/testdata/fn-render/out-of-place-stdout/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-stdout/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-stdout/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml index 855f9dfb0f..381a5d2d3a 100644 --- a/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml @@ -13,8 +13,8 @@ # limitations under the License. stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s stdOut: | apiVersion: apps/v1 diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile b/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile index b3a89e3911..710f44a846 100644 --- a/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile @@ -4,6 +4,6 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging diff --git a/e2e/testdata/fn-render/preserve-order-null-values/Kptfile b/e2e/testdata/fn-render/preserve-order-null-values/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/preserve-order-null-values/Kptfile +++ b/e2e/testdata/fn-render/preserve-order-null-values/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/resource-deletion/Kptfile b/e2e/testdata/fn-render/resource-deletion/Kptfile index 364e274d3e..7316bb0b1a 100644 --- a/e2e/testdata/fn-render/resource-deletion/Kptfile +++ b/e2e/testdata/fn-render/resource-deletion/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile index ec2c042dc7..223faf01af 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile @@ -7,7 +7,7 @@ metadata: name: save-on-render-failure pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile index e940ae88b9..fd277c8250 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile @@ -6,6 +6,6 @@ info: description: Subpackage that succeeds pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile index e940ae88b9..fd277c8250 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile @@ -6,6 +6,6 @@ info: description: Subpackage that succeeds pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile index ec4ce38547..65639042a0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile @@ -6,7 +6,7 @@ info: description: Subpackage with failing mutator pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile index f147d84027..7dd3a25143 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile @@ -6,7 +6,7 @@ info: description: Subpackage with failing validator pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns validators: diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile index c6fc0c546a..2dafd970cb 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile @@ -6,7 +6,7 @@ metadata: name: save-on-render-failure pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile index e940ae88b9..fd277c8250 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile @@ -6,6 +6,6 @@ info: description: Subpackage that succeeds pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile index e940ae88b9..fd277c8250 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile @@ -6,6 +6,6 @@ info: description: Subpackage that succeeds pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile index ec4ce38547..65639042a0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile @@ -6,7 +6,7 @@ info: description: Subpackage with failing mutator pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile index f147d84027..7dd3a25143 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile @@ -6,7 +6,7 @@ info: description: Subpackage with failing validator pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: subpkg-ns validators: diff --git a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile index 6e26cd3f3e..0cb6c3e75a 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile @@ -4,7 +4,7 @@ metadata: name: no-save-on-render-failure pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml b/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml index 57b3444047..609c132e4a 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml @@ -21,8 +21,8 @@ stdErrStripLines: stdErr: | Package: "basicpipeline" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile b/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile index abc7b972c9..351f2feb05 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging selectors: diff --git a/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml b/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml index c3726a64be..a606d03525 100644 --- a/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml @@ -21,8 +21,8 @@ stdErrStripLines: stdErr: | Package: "exclude" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 2 resource(s) [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/selectors/exclude/Kptfile b/e2e/testdata/fn-render/selectors/exclude/Kptfile index 266b33a717..6632e9cd74 100644 --- a/e2e/testdata/fn-render/selectors/exclude/Kptfile +++ b/e2e/testdata/fn-render/selectors/exclude/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging selectors: diff --git a/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml b/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml index e8c0181cc4..10e7c3733f 100644 --- a/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml @@ -23,13 +23,13 @@ stdErr: | Package: "generator/db" [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 1 resource(s) [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s Package: "generator" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 1 resource(s) [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s Successfully executed 5 function(s) in 2 package(s). diff --git a/e2e/testdata/fn-render/selectors/generator/Kptfile b/e2e/testdata/fn-render/selectors/generator/Kptfile index eb2f084f63..15df83b26a 100644 --- a/e2e/testdata/fn-render/selectors/generator/Kptfile +++ b/e2e/testdata/fn-render/selectors/generator/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-generator pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging selectors: diff --git a/e2e/testdata/fn-render/selectors/generator/db/Kptfile b/e2e/testdata/fn-render/selectors/generator/db/Kptfile index 0eeaac2a4e..913523f0d3 100644 --- a/e2e/testdata/fn-render/selectors/generator/db/Kptfile +++ b/e2e/testdata/fn-render/selectors/generator/db/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db selectors: diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml index c777aff6b4..aff411b9db 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml @@ -21,8 +21,8 @@ stdErrStripLines: stdErr: | Package: "selectors-with-exclude" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile b/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile index c16cdcab24..bc106717b4 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging selectors: diff --git a/e2e/testdata/fn-render/short-image-path/.expected/config.yaml b/e2e/testdata/fn-render/short-image-path/.expected/config.yaml index 4ea574d071..359f4574b0 100644 --- a/e2e/testdata/fn-render/short-image-path/.expected/config.yaml +++ b/e2e/testdata/fn-render/short-image-path/.expected/config.yaml @@ -16,8 +16,8 @@ actualStripLines: - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s diff --git a/e2e/testdata/fn-render/short-image-path/.expected/results.yaml b/e2e/testdata/fn-render/short-image-path/.expected/results.yaml index bc3a869a98..2e5fc6b753 100755 --- a/e2e/testdata/fn-render/short-image-path/.expected/results.yaml +++ b/e2e/testdata/fn-render/short-image-path/.expected/results.yaml @@ -4,7 +4,7 @@ metadata: name: fnresults exitCode: 0 items: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest exitCode: 0 - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 exitCode: 0 diff --git a/e2e/testdata/fn-render/short-image-path/Kptfile b/e2e/testdata/fn-render/short-image-path/Kptfile index d4e59353ef..5e29eb2fa8 100644 --- a/e2e/testdata/fn-render/short-image-path/Kptfile +++ b/e2e/testdata/fn-render/short-image-path/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: set-namespace:v0.2.0 + - image: set-namespace:latest configMap: namespace: staging - image: set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile b/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile index 364e274d3e..7316bb0b1a 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile +++ b/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile b/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile index 6c7674c0af..9295ee3a83 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile +++ b/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: statefulset-filter.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile index c235ded584..ea39e22f9f 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile @@ -7,7 +7,7 @@ pipeline: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest # malformed Kptfile configPath: statefulset-filter.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile b/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile index 088bc0319c..4a4ab87785 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile @@ -6,6 +6,6 @@ info: description: sample description pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: dev diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile b/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile index 364e274d3e..7316bb0b1a 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile b/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile index 6c7674c0af..9295ee3a83 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile @@ -6,7 +6,7 @@ pipeline: mutators: - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest configPath: statefulset-filter.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile b/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile index 82686a8952..f97e8a4746 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile index 264dd2eb78..0c2b57a9b6 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile @@ -4,7 +4,7 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkgs/Kptfile b/e2e/testdata/fn-render/subpkgs/Kptfile index 82686a8952..f97e8a4746 100644 --- a/e2e/testdata/fn-render/subpkgs/Kptfile +++ b/e2e/testdata/fn-render/subpkgs/Kptfile @@ -4,7 +4,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/subpkgs/db/Kptfile b/e2e/testdata/fn-render/subpkgs/db/Kptfile index 264dd2eb78..0c2b57a9b6 100644 --- a/e2e/testdata/fn-render/subpkgs/db/Kptfile +++ b/e2e/testdata/fn-render/subpkgs/db/Kptfile @@ -4,7 +4,7 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/success-stdout/Kptfile b/e2e/testdata/fn-render/success-stdout/Kptfile index 1307fb5426..93ae454de7 100644 --- a/e2e/testdata/fn-render/success-stdout/Kptfile +++ b/e2e/testdata/fn-render/success-stdout/Kptfile @@ -4,7 +4,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/internal/kptops/functions.go b/internal/kptops/functions.go index b7dda286f2..ff002bfacd 100644 --- a/internal/kptops/functions.go +++ b/internal/kptops/functions.go @@ -21,7 +21,7 @@ import ( var functions map[string]framework.ResourceListProcessorFunc = map[string]framework.ResourceListProcessorFunc{ "ghcr.io/kptdev/krm-functions-catalog/apply-setters:v0.2.0": applySetters, "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5": setLabels, - "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.1": setNamespace, + "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest": setNamespace, } func FindProcessor(image string) framework.ResourceListProcessorFunc { diff --git a/pkg/lib/kptops/fs_test.go b/pkg/lib/kptops/fs_test.go index d989f2fe15..ae6d087df9 100644 --- a/pkg/lib/kptops/fs_test.go +++ b/pkg/lib/kptops/fs_test.go @@ -63,7 +63,7 @@ metadata: name: app pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.1 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 @@ -141,7 +141,7 @@ metadata: name: app-with-db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.1 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: staging - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 @@ -160,7 +160,7 @@ metadata: name: db pipeline: mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.1 + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest configMap: namespace: db - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 From 200e0f6f325cd2bee885630c2aeb572ce4480806 Mon Sep 17 00:00:00 2001 From: SurbhiAgarwal1 Date: Sat, 7 Mar 2026 17:20:59 +0000 Subject: [PATCH 2/6] Update expected test outputs for set-namespace:latest --- e2e/README.md | 104 +- e2e/fn_test.go | 186 +- e2e/live/end-to-end-test.sh | 2632 ++++++++--------- e2e/live/testdata/Kptfile | 22 +- e2e/live/testdata/continue-on-error/Kptfile | 22 +- .../testdata/continue-on-error/namespace.yaml | 14 +- .../testdata/continue-on-error/pod-a.yaml | 28 +- .../testdata/continue-on-error/pod-b.yaml | 28 +- .../example-resource-group.yaml | 40 +- e2e/live/testdata/inventory-template.yaml | 96 +- .../testdata/rbac-error-step-1/namespace.yaml | 36 +- .../rbac-error-step-1/role-binding.yaml | 56 +- .../rbac-error-step-1/service-account.yaml | 38 +- .../rbac-error-step-2/user-secret.yaml | 42 +- e2e/live/testdata/rbac-error-step-3/Kptfile | 28 +- .../rbac-error-step-3/config-map.yaml | 42 +- .../rbac-error-step-3/error-config-map.yaml | 38 +- e2e/live/testdata/rg-test-case-1a/Kptfile | 22 +- .../testdata/rg-test-case-1a/namespace.yaml | 14 +- e2e/live/testdata/rg-test-case-1a/pod-a.yaml | 28 +- e2e/live/testdata/rg-test-case-1a/pod-b.yaml | 28 +- e2e/live/testdata/rg-test-case-1a/pod-c.yaml | 28 +- e2e/live/testdata/rg-test-case-1b/Kptfile | 22 +- .../testdata/rg-test-case-1b/namespace.yaml | 14 +- e2e/live/testdata/rg-test-case-1b/pod-b.yaml | 28 +- e2e/live/testdata/rg-test-case-1b/pod-c.yaml | 28 +- e2e/live/testdata/rg-test-case-1b/pod-d.yaml | 28 +- e2e/live/testdata/stdin-test/pods.yaml | 138 +- e2e/live/testdata/template-rg-namespace.yaml | 96 +- .../testdata/template-test-namespace.yaml | 96 +- e2e/live/testdata/test-case-1a/Kptfile | 22 +- .../test-case-1a/inventory-template.yaml | 96 +- e2e/live/testdata/test-case-1a/namespace.yaml | 14 +- e2e/live/testdata/test-case-1a/pod-a.yaml | 28 +- e2e/live/testdata/test-case-1a/pod-b.yaml | 28 +- e2e/live/testdata/test-case-1a/pod-c.yaml | 28 +- e2e/live/testdata/test-case-1b/Kptfile | 22 +- .../test-case-1b/inventory-template.yaml | 96 +- e2e/live/testdata/test-case-1b/namespace.yaml | 14 +- e2e/live/testdata/test-case-1b/pod-b.yaml | 28 +- e2e/live/testdata/test-case-1b/pod-c.yaml | 28 +- e2e/live/testdata/test-case-1b/pod-d.yaml | 28 +- e2e/live/testdata/test-case-1c/Kptfile | 22 +- e2e/live/testdata/test-case-1c/namespace.yaml | 14 +- e2e/live/testdata/test-case-1c/pod-a.yaml | 28 +- e2e/live/testdata/test-case-1c/pod-b.yaml | 28 +- e2e/live/testdata/test-case-1c/pod-c.yaml | 28 +- e2e/live_test.go | 196 +- .../pkg/.expected/config.yaml | 34 +- .../pkg/.expected/diff.patch | 64 +- .../all-resource-deletion/pkg/.krmignore | 2 +- .../all-resource-deletion/pkg/resources.yaml | 52 +- .../starlark-delete-resource.yaml | 38 +- .../default-runtime/.expected/diff.patch | 38 +- .../fn-eval/default-runtime/.expected/exec.sh | 50 +- .../fn-eval/default-runtime/.krmignore | 2 +- .../fn-eval/default-runtime/resources.yaml | 52 +- .../error-in-pipe/.expected/config.yaml | 32 +- .../fn-eval/error-in-pipe/.expected/exec.sh | 46 +- e2e/testdata/fn-eval/error-in-pipe/.krmignore | 4 +- .../.expected/config.yaml | 40 +- .../exec-function-stderr/.expected/diff.patch | 42 +- .../exec-function-stderr/.expected/exec.sh | 36 +- .../fn-eval/exec-function-stderr/.krmignore | 2 +- .../fn-eval/exec-function-stderr/function.sh | 42 +- .../exec-function-stderr/resources.yaml | 56 +- .../.expected/diff.patch | 42 +- .../exec-function-with-args/.expected/exec.sh | 36 +- .../exec-function-with-args/.krmignore | 2 +- .../exec-function-with-args/resources.yaml | 56 +- .../exec-function/.expected/config.yaml | 32 +- .../exec-function/.expected/diff.patch | 42 +- e2e/testdata/fn-eval/exec-function/.krmignore | 2 +- .../fn-eval/exec-function/function.sh | 34 +- .../fn-eval/exec-function/resources.yaml | 56 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 60 +- .../fn-eval/fn-config-file-in-pkg/.krmignore | 2 +- .../fn-eval/fn-config-file-in-pkg/config.yaml | 38 +- .../fn-config-file-in-pkg/resources.yaml | 52 +- .../fn-eval/fn-config-file/config.yaml | 38 +- .../fn-config-file/pkg/.expected/config.yaml | 34 +- .../fn-config-file/pkg/.expected/diff.patch | 38 +- .../fn-eval/fn-config-file/pkg/.krmignore | 2 +- .../fn-eval/fn-config-file/pkg/resources.yaml | 52 +- .../.expected/diff.patch | 150 +- .../.expected/exec.sh | 44 +- .../.krmignore | 4 +- .../Kptfile | 16 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/diff.patch | 150 +- .../include-meta-resources/.expected/exec.sh | 44 +- .../include-meta-resources/.krmignore | 2 +- .../fn-source/include-meta-resources/Kptfile | 16 +- .../include-meta-resources/labelconfig.yaml | 38 +- .../include-meta-resources/resources.yaml | 52 +- .../pkg/.expected/config.yaml | 32 +- .../pkg/.expected/results.yaml | 18 +- .../fn-success-with-stderr/pkg/.krmignore | 2 +- .../fn-success-with-stderr/pkg/resources.yaml | 52 +- .../fn-success-with-stderr/starlark.yaml | 40 +- .../fn-eval/fnconfig-missing-name/config.yaml | 34 +- .../pkg/.expected/config.yaml | 38 +- .../fnconfig-missing-name/pkg/.krmignore | 2 +- .../fnconfig-missing-name/pkg/resources.yaml | 52 +- .../function-chain/.expected/diff.patch | 90 +- .../fn-eval/function-chain/.expected/exec.sh | 46 +- .../fn-eval/function-chain/.krmignore | 2 +- .../fn-eval/function-chain/resources.yaml | 52 +- .../function-env/.expected/config.yaml | 32 +- .../fn-eval/function-env/.expected/exec.sh | 44 +- e2e/testdata/fn-eval/function-env/.krmignore | 2 +- .../.expected/config.yaml | 40 +- .../.expected/setup.sh | 50 +- .../image-pull-policy-always/.krmignore | 2 +- .../.expected/config.yaml | 40 +- .../.expected/setup.sh | 48 +- .../.krmignore | 2 +- .../.expected/config.yaml | 42 +- .../image-pull-policy-never/.krmignore | 2 +- .../image-pull-policy-never/resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../.krmignore | 2 +- .../include-meta-resources-v1alpha1/Kptfile | 202 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../.krmignore | 2 +- .../include-meta-resources-v1alpha2/Kptfile | 16 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../fn-eval/include-meta-resources/.krmignore | 2 +- .../fn-eval/include-meta-resources/Kptfile | 16 +- .../include-meta-resources/labelconfig.yaml | 38 +- .../include-meta-resources/resources.yaml | 52 +- .../invalid-fn-config-file/config.yaml | 30 +- .../pkg/.expected/config.yaml | 38 +- .../invalid-fn-config-file/pkg/.krmignore | 2 +- .../invalid-fn-config-file/pkg/resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 112 +- .../krm-check-exclude-kustomize/.krmignore | 2 +- .../krm-check-exclude-kustomize/Kptfile | 18 +- .../kustomization.yaml | 34 +- .../resources.yaml | 52 +- .../missing-fn-config/.expected/config.yaml | 36 +- .../fn-eval/missing-fn-config/.krmignore | 2 +- .../fn-eval/missing-fn-config/resources.yaml | 52 +- .../missing-fn-image/.expected/config.yaml | 40 +- .../fn-eval/missing-fn-image/.krmignore | 2 +- .../fn-eval/missing-fn-image/resources.yaml | 52 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 8 +- .../modify-legacy-path-annotation/.krmignore | 2 +- .../deployment.yaml | 70 +- .../starlark-fn.yaml | 42 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 8 +- .../fn-eval/modify-path-annotation/.krmignore | 2 +- .../modify-path-annotation/deployment.yaml | 70 +- .../modify-path-annotation/starlark-fn.yaml | 42 +- .../multiple-fn-config-one-file/config.yaml | 52 +- .../pkg/.expected/config.yaml | 38 +- .../pkg/resources.yaml | 52 +- .../no-image-pull/.expected/config.yaml | 2 +- .../fn-eval/no-image-pull/.expected/exec.sh | 52 +- .../fn-eval/no-image-pull/.expected/setup.sh | 44 +- e2e/testdata/fn-eval/no-image-pull/.krmignore | 2 +- .../fn-eval/no-image-pull/resources.yaml | 38 +- .../fn-eval/no-op/.expected/config.yaml | 32 +- e2e/testdata/fn-eval/no-op/.krmignore | 2 +- e2e/testdata/fn-eval/no-op/resources.yaml | 164 +- .../non-krm-resource/.expected/config.yaml | 44 +- .../fn-eval/non-krm-resource/.krmignore | 2 +- .../fn-eval/non-krm-resource/nonkrm.yaml | 26 +- .../fn-eval/non-krm-resource/resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/exec.sh | 40 +- .../out-of-place-dir-exists-error/.krmignore | 4 +- .../resources.yaml | 52 +- .../out-of-place-dir/.expected/config.yaml | 32 +- .../out-of-place-dir/.expected/diff.patch | 68 +- .../out-of-place-dir/.expected/exec.sh | 40 +- .../fn-eval/out-of-place-dir/.krmignore | 4 +- .../fn-eval/out-of-place-dir/resources.yaml | 52 +- .../.expected/config.yaml | 148 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-stdout/.krmignore | 2 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 152 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-unwrap/.krmignore | 2 +- .../out-of-place-fnchain-unwrap/Kptfile | 18 +- .../resources.yaml | 54 +- .../output-to-stdout/.expected/config.yaml | 114 +- .../output-to-stdout/.expected/exec.sh | 38 +- .../fn-eval/output-to-stdout/.krmignore | 2 +- .../fn-eval/output-to-stdout/resources.yaml | 52 +- .../preserve-comments/.expected/config.yaml | 32 +- .../fn-eval/preserve-comments/.krmignore | 2 +- .../fn-eval/preserve-comments/resources.yaml | 134 +- .../.expected/config.yaml | 40 +- .../.krmignore | 2 +- .../Kptfile | 98 +- .../resources.yaml | 70 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 38 +- .../preserve-order-null-values/.krmignore | 2 +- .../preserve-order-null-values/resources.yaml | 54 +- .../disable-network/.expected/config.yaml | 30 +- .../disable-network/.expected/exec.sh | 42 +- .../disable-network/.krmginore | 2 +- .../disable-network/resources.yaml | 42 +- .../enable-network/.expected/exec.sh | 44 +- .../enable-network/.krmginore | 2 +- .../enable-network/resources.yaml | 42 +- .../mount/.expected/config.yaml | 4 +- .../privilege-options/mount/.expected/exec.sh | 60 +- .../privilege-options/mount/.krmignore | 4 +- .../privilege-options/mount/resources.yaml | 42 +- .../pkg/.expected/config.yaml | 34 +- .../pkg/.expected/diff.patch | 30 +- .../fn-eval/resource-deletion/pkg/.krmignore | 2 +- .../resource-deletion/pkg/resources.yaml | 52 +- .../starlark-delete-resource.yaml | 58 +- .../custom-pkg-path/.expected/config.yaml | 58 +- .../custom-pkg-path/.expected/diff.patch | 86 +- .../save-fn/custom-pkg-path/.expected/exec.sh | 36 +- .../save-fn/custom-pkg-path/.krmignore | 2 +- .../save-fn/custom-pkg-path/sub-pkg/Kptfile | 8 +- .../custom-pkg-path/sub-pkg/fn-config.yaml | 38 +- .../custom-pkg-path/sub-pkg/resources.yaml | 52 +- .../save-fn/exec/.expected/config.yaml | 36 +- .../fn-eval/save-fn/exec/.expected/diff.patch | 66 +- .../fn-eval/save-fn/exec/.expected/exec.sh | 34 +- e2e/testdata/fn-eval/save-fn/exec/.krmignore | 2 +- e2e/testdata/fn-eval/save-fn/exec/Kptfile | 8 +- .../fn-eval/save-fn/exec/fn-config.yaml | 42 +- e2e/testdata/fn-eval/save-fn/exec/function.sh | 32 +- .../fn-eval/save-fn/exec/resources.yaml | 56 +- .../save-fn/image/.expected/config.yaml | 58 +- .../save-fn/image/.expected/diff.patch | 66 +- .../fn-eval/save-fn/image/.expected/exec.sh | 36 +- e2e/testdata/fn-eval/save-fn/image/.krmignore | 2 +- e2e/testdata/fn-eval/save-fn/image/Kptfile | 8 +- .../fn-eval/save-fn/image/resources.yaml | 52 +- .../match-selector/.expected/config.yaml | 44 +- .../match-selector/.expected/diff.patch | 54 +- .../save-fn/match-selector/.expected/exec.sh | 38 +- .../fn-eval/save-fn/match-selector/.krmignore | 2 +- .../fn-eval/save-fn/match-selector/Kptfile | 8 +- .../save-fn/match-selector/resources.yaml | 52 +- .../no-save-when-fail/.expected/config.yaml | 58 +- .../no-save-when-fail/.expected/diff.patch | 38 +- .../no-save-when-fail/.expected/exec.sh | 36 +- .../save-fn/no-save-when-fail/.krmignore | 2 +- .../save-fn/no-save-when-fail/resources.yaml | 52 +- .../save-fn/override-fn/.expected/config.yaml | 58 +- .../save-fn/override-fn/.expected/diff.patch | 74 +- .../save-fn/override-fn/.expected/exec.sh | 36 +- .../fn-eval/save-fn/override-fn/.krmignore | 2 +- .../fn-eval/save-fn/override-fn/Kptfile | 20 +- .../save-fn/override-fn/resources.yaml | 52 +- .../.expected/config.yaml | 58 +- .../.expected/diff.patch | 64 +- .../.expected/exec.sh | 36 +- .../preserve-kptfile-comments/.krmignore | 2 +- .../save-fn/preserve-kptfile-comments/Kptfile | 12 +- .../preserve-kptfile-comments/resources.yaml | 52 +- .../validator-type/.expected/config.yaml | 58 +- .../validator-type/.expected/diff.patch | 66 +- .../save-fn/validator-type/.expected/exec.sh | 36 +- .../fn-eval/save-fn/validator-type/.krmignore | 2 +- .../fn-eval/save-fn/validator-type/Kptfile | 8 +- .../save-fn/validator-type/resources.yaml | 52 +- .../basicpipeline/.expected/config.yaml | 34 +- .../basicpipeline/.expected/diff.patch | 24 +- .../selectors/basicpipeline/.expected/exec.sh | 36 +- .../selectors/basicpipeline/.krmignore | 2 +- .../selectors/basicpipeline/resources.yaml | 52 +- .../selectors/exclude/.expected/config.yaml | 34 +- .../selectors/exclude/.expected/diff.patch | 24 +- .../selectors/exclude/.expected/exec.sh | 36 +- .../fn-eval/selectors/exclude/.krmignore | 2 +- .../fn-eval/selectors/exclude/resources.yaml | 52 +- .../.expected/config.yaml | 110 +- .../.expected/exec.sh | 44 +- .../out-of-place-fnchain-unwrap/.krmignore | 2 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 24 +- .../selectors-with-exclude/.expected/exec.sh | 36 +- .../selectors-with-exclude/.krmignore | 2 +- .../selectors-with-exclude/resources.yaml | 82 +- .../short-image-path/.expected/config.yaml | 54 +- .../short-image-path/.expected/diff.patch | 38 +- .../short-image-path/.expected/results.yaml | 16 +- .../fn-eval/short-image-path/.krmignore | 2 +- .../fn-eval/short-image-path/resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 38 +- .../simple-function-symlink/.expected/exec.sh | 42 +- .../simple-function-symlink/.krmignore | 2 +- .../simple-function-symlink/resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../.expected/diff.patch | 22 +- .../simple-function-with-tag/.krmignore | 2 +- .../simple-function-with-tag/resources.yaml | 52 +- .../simple-function/.expected/config.yaml | 36 +- .../simple-function/.expected/diff.patch | 38 +- .../fn-eval/simple-function/.krmignore | 2 +- .../fn-eval/simple-function/resources.yaml | 52 +- .../.expected/config.yaml | 46 +- .../.expected/diff.patch | 26 +- .../.expected/results.yaml | 28 +- .../structured-results-in-stdout/.krmignore | 4 +- .../resources.yaml | 52 +- .../search-replace-conf.yaml | 44 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 152 +- .../.krmignore | 2 +- .../Kptfile | 16 +- .../db/Kptfile | 16 +- .../db/labelconfig.yaml | 42 +- .../db/resources.yaml | 38 +- .../labelconfig.yaml | 42 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 82 +- .../subpkg-has-samename-subdir/.krmignore | 2 +- .../subpkg-has-samename-subdir/Kptfile | 12 +- .../subpkg-has-samename-subdir/pkg-a/Kptfile | 12 +- .../pkg-a/pkg-a/resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../subpkg-include-meta-resources/.krmignore | 2 +- .../subpkg-include-meta-resources/Kptfile | 16 +- .../subpkg-include-meta-resources/db/Kptfile | 16 +- .../db/labelconfig.yaml | 38 +- .../db/resources.yaml | 38 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 60 +- .../fn-eval/subpkgs-with-krmignore/.krmignore | 4 +- .../subpkgs-with-krmignore/db/non-krm.yaml | 34 +- .../subpkgs-with-krmignore/db/resources.yaml | 38 +- .../subpkgs-with-krmignore/resources.yaml | 52 +- .../fn-eval/subpkgs/.expected/config.yaml | 36 +- .../fn-eval/subpkgs/.expected/diff.patch | 60 +- e2e/testdata/fn-eval/subpkgs/.krmignore | 2 +- .../fn-eval/subpkgs/db/resources.yaml | 38 +- e2e/testdata/fn-eval/subpkgs/resources.yaml | 52 +- .../wasm-function/.expected/config.yaml | 40 +- .../wasm-function/.expected/diff.patch | 22 +- e2e/testdata/fn-eval/wasm-function/.krmignore | 2 +- .../fn-eval/wasm-function/resources.yaml | 38 +- .../.expected/diff.patch | 186 +- .../all-resource-deletion/.krmignore | 2 +- .../fn-render/all-resource-deletion/Kptfile | 28 +- .../all-resource-deletion/delete-all.yaml | 44 +- .../all-resource-deletion/deployment.yaml | 48 +- .../all-resource-deletion/resources.yaml | 38 +- .../.expected/diff.patch | 132 +- .../.expected/exec.sh | 42 +- .../basicpipeline-out-of-place/.krmignore | 4 +- .../basicpipeline-out-of-place/Kptfile | 24 +- .../basicpipeline-out-of-place/resources.yaml | 52 +- .../.expected/config.yaml | 28 +- .../basicpipeline-semver/.expected/diff.patch | 106 +- .../fn-render/basicpipeline-semver/.krmignore | 2 +- .../fn-render/basicpipeline-semver/Kptfile | 28 +- .../basicpipeline-semver/resources.yaml | 52 +- .../.expected/config.yaml | 58 +- .../.expected/diff.patch | 88 +- .../basicpipeline-symlink/.expected/exec.sh | 42 +- .../basicpipeline-symlink/.krmignore | 2 +- .../fn-render/basicpipeline-symlink/Kptfile | 24 +- .../basicpipeline-symlink/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../basicpipeline-v1alpha1/.krmignore | 2 +- .../fn-render/basicpipeline-v1alpha1/Kptfile | 202 +- .../basicpipeline-v1alpha1/labelconfig.yaml | 38 +- .../basicpipeline-v1alpha1/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../basicpipeline-v1alpha2/.krmignore | 2 +- .../fn-render/basicpipeline-v1alpha2/Kptfile | 24 +- .../basicpipeline-v1alpha2/resources.yaml | 52 +- .../basicpipeline-wasm/.expected/config.yaml | 32 +- .../basicpipeline-wasm/.expected/diff.patch | 58 +- .../basicpipeline-wasm/.expected/setup.sh | 32 +- .../basicpipeline-wasm/.expected/teardown.sh | 32 +- .../fn-render/basicpipeline-wasm/.krmignore | 2 +- .../fn-render/basicpipeline-wasm/Kptfile | 34 +- .../basicpipeline-wasm/resources.yaml | 52 +- .../basicpipeline/.expected/config.yaml | 28 +- .../basicpipeline/.expected/diff.patch | 104 +- .../fn-render/basicpipeline/.krmignore | 2 +- e2e/testdata/fn-render/basicpipeline/Kptfile | 24 +- .../fn-render/basicpipeline/resources.yaml | 52 +- .../default-runtime/.expected/diff.patch | 88 +- .../default-runtime/.expected/exec.sh | 50 +- .../fn-render/default-runtime/.krmignore | 2 +- .../fn-render/default-runtime/Kptfile | 24 +- .../fn-render/default-runtime/resources.yaml | 52 +- .../fn-render/empty-pipeline/.krmignore | 2 +- e2e/testdata/fn-render/empty-pipeline/Kptfile | 8 +- .../fn-render/empty-pipeline/resources.yaml | 52 +- .../.expected/config.yaml | 40 +- .../exec-function-stderr/.expected/diff.patch | 42 +- .../fn-render/exec-function-stderr/.krmignore | 2 +- .../fn-render/exec-function-stderr/Kptfile | 14 +- .../exec-function-stderr/function.sh | 42 +- .../exec-function-stderr/resources.yaml | 56 +- .../.expected/config.yaml | 30 +- .../.expected/diff.patch | 93 +- .../exec-function-with-args/.krmignore | 2 +- .../fn-render/exec-function-with-args/Kptfile | 14 +- .../exec-function-with-args/resources.yaml | 56 +- .../.expected/config.yaml | 30 +- .../exec-without-permissions/.krmignore | 2 +- .../exec-without-permissions/Kptfile | 14 +- .../exec-without-permissions/resources.yaml | 56 +- .../.expected/config.yaml | 38 +- .../fn-failure-output-no-truncate/.krmignore | 2 +- .../fn-failure-output-no-truncate/Kptfile | 18 +- .../resources.yaml | 52 +- .../fn-failure/.expected/config.yaml | 48 +- e2e/testdata/fn-render/fn-failure/.krmignore | 2 +- e2e/testdata/fn-render/fn-failure/Kptfile | 30 +- .../fn-failure/deployment_httpbin.yaml | 74 +- .../fn-render/fn-failure/resources.yaml | 52 +- .../fn-failure/starlark-failure-fn.yaml | 52 +- .../.expected/diff.patch | 123 + .../fn-success-with-stderr/.krmignore | 2 +- .../fn-render/fn-success-with-stderr/Kptfile | 16 +- .../fn-success-with-stderr/resources.yaml | 52 +- .../fn-success-with-stderr/starlark.yaml | 40 +- .../.expected/diff.patch | 219 +- .../.krmignore | 2 +- .../Kptfile | 18 +- .../db/Kptfile | 16 +- .../db/labelconfig.yaml | 38 +- .../db/resources.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../fnconfig-cannot-refer-subpkgs/.krmignore | 2 +- .../fnconfig-cannot-refer-subpkgs/Kptfile | 16 +- .../fnconfig-cannot-refer-subpkgs/db/Kptfile | 8 +- .../db/labelconfig.yaml | 38 +- .../db/resources.yaml | 58 +- .../resources.yaml | 78 +- .../fnconfig-in-subdir/.expected/config.yaml | 28 +- .../fnconfig-in-subdir/.expected/diff.patch | 141 +- .../fn-render/fnconfig-in-subdir/.krmignore | 2 +- .../fn-render/fnconfig-in-subdir/Kptfile | 16 +- .../fnconfig-in-subdir/db/labelconfig.yaml | 38 +- .../fnconfig-in-subdir/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../fnconfig-missing-name/.krmignore | 2 +- .../fn-render/fnconfig-missing-name/Kptfile | 22 +- .../fnconfig-missing-name/labelconfig.yaml | 34 +- .../fnconfig-missing-name/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../fnconfig-multiple-config-one-file/Kptfile | 16 +- .../labelconfig.yaml | 52 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../fnconfig-not-relative/.krmignore | 2 +- .../fn-render/fnconfig-not-relative/Kptfile | 16 +- .../fnconfig-not-relative/labelconfig.yaml | 38 +- .../fnconfig-not-relative/resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../fnconfig-outside-package/.krmignore | 2 +- .../fnconfig-outside-package/Kptfile | 20 +- .../fnconfig-outside-package/labelconfig.yaml | 38 +- .../fnconfig-outside-package/resources.yaml | 52 +- .../.expected/diff.patch | 141 +- .../fnconfig-pkgfn-refers-subdir/.krmignore | 2 +- .../fnconfig-pkgfn-refers-subdir/Kptfile | 16 +- .../confs/labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/diff.patch | 229 +- .../fnconfig-updated-in-render/.krmignore | 2 +- .../fnconfig-updated-in-render/Kptfile | 36 +- .../fnconfig-updated-in-render/app.yaml | 44 +- .../label-input.yaml | 20 +- .../fnconfig-updated-in-render/namespace.yaml | 14 +- .../package-context.yaml | 16 +- .../update-labels.yaml | 38 +- .../fn-render/fnconfig/.expected/diff.patch | 231 +- e2e/testdata/fn-render/fnconfig/.krmignore | 2 +- e2e/testdata/fn-render/fnconfig/Kptfile | 22 +- e2e/testdata/fn-render/fnconfig/db/Kptfile | 24 +- .../fn-render/fnconfig/db/resources.yaml | 38 +- .../fn-render/fnconfig/labelconfig.yaml | 38 +- .../fn-render/fnconfig/resources.yaml | 52 +- .../fnresult-fn-failure/.expected/config.yaml | 36 +- .../fn-render/fnresult-fn-failure/.krmignore | 2 +- .../fn-render/fnresult-fn-failure/Kptfile | 18 +- .../fnresult-fn-failure/resources.yaml | 52 +- .../fnresult-fn-success/.expected/config.yaml | 36 +- .../fnresult-fn-success/.expected/diff.patch | 130 +- .../fn-render/fnresult-fn-success/.krmignore | 2 +- .../fn-render/fnresult-fn-success/Kptfile | 16 +- .../fnresult-fn-success/resources.yaml | 52 +- .../search-replace-conf.yaml | 42 +- .../format-on-success/.expected/diff.patch | 179 +- .../fn-render/format-on-success/.krmignore | 2 +- .../fn-render/format-on-success/Kptfile | 18 +- .../fn-render/format-on-success/db/Kptfile | 18 +- .../format-on-success/db/resources.yaml | 38 +- .../format-on-success/resources.yaml | 64 +- .../.expected/diff.patch | 189 ++ .../generator-absolute-path/.krmignore | 2 +- .../fn-render/generator-absolute-path/Kptfile | 16 +- .../generator-absolute-path/resources.yaml | 38 +- .../starlark-httpbin.yaml | 120 +- .../fn-render/generator-subpkgs/.krmignore | 2 +- .../fn-render/generator-subpkgs/Kptfile | 16 +- .../fn-render/generator-subpkgs/db/Kptfile | 16 +- .../generator-subpkgs/db/fn-config.yaml | 12 +- .../generator-subpkgs/db/resources.yaml | 38 +- .../generator-subpkgs/fn-config.yaml | 14 +- .../generator-subpkgs/resources.yaml | 52 +- .../fn-render/generator/.expected/diff.patch | 311 +- e2e/testdata/fn-render/generator/.krmignore | 2 +- e2e/testdata/fn-render/generator/Kptfile | 24 +- e2e/testdata/fn-render/generator/db/Kptfile | 28 +- .../fn-render/generator/db/resources.yaml | 38 +- .../generator/db/starlark-httpbin.yaml | 110 +- .../fn-render/generator/resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/setup.sh | 50 +- .../image-pull-policy-always/.krmignore | 2 +- .../image-pull-policy-always/Kptfile | 14 +- .../image-pull-policy-always/resources.yaml | 38 +- .../.expected/config.yaml | 36 +- .../.expected/setup.sh | 48 +- .../.krmignore | 2 +- .../image-pull-policy-if-not-present/Kptfile | 14 +- .../resources.yaml | 38 +- .../.expected/config.yaml | 38 +- .../image-pull-policy-never/.krmignore | 2 +- .../fn-render/image-pull-policy-never/Kptfile | 14 +- .../image-pull-policy-never/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../invalid-configmap-fnconfig/.krmignore | 2 +- .../invalid-configmap-fnconfig/Kptfile | 32 +- .../invalid-configmap-fnconfig/resources.yaml | 52 +- .../fn-render/invalid-inline-fnconfig/Kptfile | 32 +- .../invalid-kptfile/.expected/config.yaml | 30 +- .../fn-render/invalid-kptfile/.krmignore | 2 +- .../fn-render/invalid-kptfile/Kptfile | 8 +- .../fn-render/invalid-kptfile/resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../kptfile-unknown-fields/.krmignore | 2 +- .../fn-render/kptfile-unknown-fields/Kptfile | 28 +- .../kptfile-unknown-fields/resources.yaml | 52 +- .../.expected/diff.patch | 140 +- .../krm-check-exclude-kustomize/Kptfile | 18 +- .../kustomization.yaml | 34 +- .../resources.yaml | 52 +- e2e/testdata/fn-render/krmignore/.krmignore | 4 +- e2e/testdata/fn-render/krmignore/Kptfile | 18 +- .../fn-render/krmignore/resources.yaml | 48 +- .../kubeval-failure/.expected/config.yaml | 34 +- .../fn-render/kubeval-failure/.krmignore | 2 +- .../fn-render/kubeval-failure/Kptfile | 18 +- .../fn-render/kubeval-failure/resources.yaml | 52 +- .../missing-fn-image/.expected/config.yaml | 32 +- .../fn-render/missing-fn-image/.krmignore | 2 +- .../fn-render/missing-fn-image/Kptfile | 24 +- .../fn-render/missing-fn-image/resources.yaml | 52 +- .../missing-fnconfig/.expected/config.yaml | 40 +- .../fn-render/missing-fnconfig/.krmignore | 2 +- .../fn-render/missing-fnconfig/Kptfile | 22 +- .../fn-render/missing-fnconfig/db/Kptfile | 24 +- .../missing-fnconfig/db/resources.yaml | 38 +- .../missing-fnconfig/labelconfig.yaml | 38 +- .../fn-render/missing-fnconfig/resources.yaml | 52 +- .../missing-kptfile/.expected/config.yaml | 30 +- .../fn-render/missing-kptfile/.krmignore | 2 +- .../fn-render/missing-kptfile/resources.yaml | 52 +- .../.expected/diff.patch | 118 +- .../modify-legacy-path-annotation/.krmignore | 2 +- .../modify-legacy-path-annotation/Kptfile | 16 +- .../deployment.yaml | 38 +- .../starlark-fn.yaml | 44 +- .../.expected/diff.patch | 121 +- .../modify-path-annotation/.krmignore | 2 +- .../fn-render/modify-path-annotation/Kptfile | 16 +- .../modify-path-annotation/deployment.yaml | 38 +- .../modify-path-annotation/starlark-fn.yaml | 44 +- .../multiple-fnconfig/.expected/config.yaml | 32 +- .../fn-render/multiple-fnconfig/.krmignore | 2 +- .../fn-render/multiple-fnconfig/Kptfile | 20 +- .../multiple-fnconfig/configmap.yaml | 38 +- .../multiple-fnconfig/resources.yaml | 56 +- .../.expected/diff.patch | 169 +- .../mutate-legacy-path-index/.krmignore | 2 +- .../mutate-legacy-path-index/Kptfile | 16 +- .../starlark-mutate-path-index.yaml | 76 +- .../fn-render/mutate-legacy-path-index/x.yaml | 52 +- .../mutate-path-index/.expected/diff.patch | 169 +- .../fn-render/mutate-path-index/.krmignore | 2 +- .../fn-render/mutate-path-index/Kptfile | 16 +- .../starlark-mutate-path-index.yaml | 76 +- .../fn-render/mutate-path-index/x.yaml | 52 +- .../no-fnconfig/.expected/config.yaml | 48 +- e2e/testdata/fn-render/no-fnconfig/.krmignore | 2 +- e2e/testdata/fn-render/no-fnconfig/Kptfile | 20 +- .../fn-render/no-fnconfig/resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../fn-render/no-format-on-failure/.krmignore | 2 +- .../fn-render/no-format-on-failure/Kptfile | 20 +- .../fn-render/no-format-on-failure/db/Kptfile | 18 +- .../no-format-on-failure/db/resources.yaml | 38 +- .../no-format-on-failure/resources.yaml | 52 +- .../fn-render/no-op/.expected/config.yaml | 28 +- .../fn-render/no-op/.expected/diff.patch | 188 ++ e2e/testdata/fn-render/no-op/.krmignore | 2 +- e2e/testdata/fn-render/no-op/Kptfile | 14 +- e2e/testdata/fn-render/no-op/resources.yaml | 164 +- .../.expected/diff.patch | 120 +- .../no-pipeline-in-subpackage/.krmignore | 2 +- .../no-pipeline-in-subpackage/Kptfile | 24 +- .../no-pipeline-in-subpackage/db/Kptfile | 8 +- .../db/resources.yaml | 52 +- e2e/testdata/fn-render/no-pipeline/.krmignore | 2 +- e2e/testdata/fn-render/no-pipeline/Kptfile | 8 +- .../fn-render/no-pipeline/resources.yaml | 52 +- .../no-resources/.expected/diff.patch | 208 ++ .../fn-render/no-resources/.krmignore | 2 +- e2e/testdata/fn-render/no-resources/Kptfile | 16 +- .../no-resources/starlark-httpbin.yaml | 182 +- .../.expected/config.yaml | 30 +- .../non-krm-resource-no-pipeline/.krmignore | 2 +- .../non-krm-resource-no-pipeline/Kptfile | 8 +- .../non-krm-resource-no-pipeline/non-krm.yaml | 26 +- .../resources.yaml | 52 +- .../non-krm-resource/.expected/config.yaml | 30 +- .../fn-render/non-krm-resource/.krmignore | 2 +- .../fn-render/non-krm-resource/Kptfile | 24 +- .../fn-render/non-krm-resource/non-krm.yaml | 26 +- .../fn-render/non-krm-resource/resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/exec.sh | 42 +- .../out-of-place-dir-exists-error/.krmignore | 4 +- .../out-of-place-dir-exists-error/Kptfile | 18 +- .../resources.yaml | 54 +- .../out-of-place-dir/.expected/config.yaml | 32 +- .../out-of-place-dir/.expected/diff.patch | 100 +- .../out-of-place-dir/.expected/exec.sh | 42 +- .../fn-render/out-of-place-dir/.krmignore | 4 +- .../fn-render/out-of-place-dir/Kptfile | 18 +- .../fn-render/out-of-place-dir/resources.yaml | 54 +- .../.expected/config.yaml | 168 +- .../.expected/exec.sh | 52 +- .../.krmignore | 2 +- .../Kptfile | 18 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 182 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-stdout/.krmignore | 2 +- .../out-of-place-fnchain-stdout/Kptfile | 18 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 120 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-unwrap/.krmignore | 2 +- .../out-of-place-fnchain-unwrap/Kptfile | 18 +- .../resources.yaml | 54 +- .../out-of-place-stdout/.expected/config.yaml | 134 +- .../out-of-place-stdout/.expected/exec.sh | 38 +- .../fn-render/out-of-place-stdout/.krmignore | 2 +- .../fn-render/out-of-place-stdout/Kptfile | 18 +- .../out-of-place-stdout/resources.yaml | 54 +- .../out-of-place-unwrap/.expected/config.yaml | 68 +- .../out-of-place-unwrap/.expected/exec.sh | 38 +- .../fn-render/out-of-place-unwrap/.krmignore | 2 +- .../fn-render/out-of-place-unwrap/Kptfile | 18 +- .../out-of-place-unwrap/resources.yaml | 54 +- .../path-index-ancestor/.expected/config.yaml | 30 +- .../fn-render/path-index-ancestor/.krmignore | 2 +- .../fn-render/path-index-ancestor/Kptfile | 8 +- .../fn-render/path-index-ancestor/db/Kptfile | 16 +- .../path-index-ancestor/db/resources.yaml | 38 +- .../db/starlark-httpbin-gen.yaml | 118 +- .../path-index-ancestor/resources.yaml | 52 +- .../path-index-current/.expected/diff.patch | 203 ++ .../fn-render/path-index-current/.krmignore | 2 +- .../fn-render/path-index-current/Kptfile | 16 +- .../path-index-current/resources.yaml | 52 +- .../starlark-httpbin-gen.yaml | 120 +- .../.expected/diff.patch | 259 ++ .../path-index-descendent/.krmignore | 2 +- .../fn-render/path-index-descendent/Kptfile | 16 +- .../path-index-descendent/db/Kptfile | 8 +- .../path-index-descendent/db/resources.yaml | 38 +- .../path-index-descendent/resources.yaml | 52 +- .../starlark-httpbin-gen.yaml | 120 +- .../.expected/config.yaml | 36 +- .../fn-render/path-index-duplicate/.krmignore | 2 +- .../fn-render/path-index-duplicate/Kptfile | 16 +- .../path-index-duplicate/resources.yaml | 38 +- .../starlark-gen-duplicate-path.yaml | 120 +- .../.expected/config.yaml | 30 +- .../path-index-outofpackage/.krmignore | 2 +- .../fn-render/path-index-outofpackage/Kptfile | 8 +- .../path-index-outofpackage/db/Kptfile | 16 +- .../path-index-outofpackage/db/resources.yaml | 38 +- .../db/starlark-httpbin-gen.yaml | 118 +- .../preserve-comments/.expected/config.yaml | 28 +- .../preserve-comments/.expected/diff.patch | 158 + .../fn-render/preserve-comments/.krmignore | 2 +- .../fn-render/preserve-comments/Kptfile | 14 +- .../preserve-comments/resources.yaml | 134 +- .../.expected/diff.patch | 106 +- .../preserve-order-null-values/.krmignore | 2 +- .../preserve-order-null-values/Kptfile | 24 +- .../preserve-order-null-values/resources.yaml | 54 +- .../resource-deletion/.expected/diff.patch | 243 +- .../fn-render/resource-deletion/.krmignore | 2 +- .../fn-render/resource-deletion/Kptfile | 28 +- .../resource-deletion/deployment_httpbin.yaml | 72 +- .../resource-deletion/resources.yaml | 52 +- .../resource-deletion/starlark-httpbin.yaml | 48 +- .../.expected/diff.patch | 442 ++- .../resource-has-pkgname-prefix/.krmignore | 2 +- .../resource-has-pkgname-prefix/Kptfile | 18 +- .../resource-has-pkgname-prefix/mysql/Kptfile | 18 +- .../mysql/mysql-deployment.yaml | 162 +- .../wordpress-deployment.yaml | 162 +- .../bfs-basicpipeline/.expected/config.yaml | 4 +- .../bfs-basicpipeline/.expected/diff.patch | 69 +- .../bfs-basicpipeline/.krmignore | 2 +- .../bfs-basicpipeline/Kptfile | 36 +- .../bfs-basicpipeline/resources.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 175 +- .../bfs-deep-nested-middle-fails/.krmignore | 2 +- .../bfs-deep-nested-middle-fails/Kptfile | 28 +- .../configmap.yaml | 12 +- .../level1/Kptfile | 26 +- .../level1/configmap.yaml | 12 +- .../level1/level2/Kptfile | 22 +- .../level1/level2/configmap.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 213 +- .../bfs-multiple-subpkgs-one-fails/.krmignore | 2 +- .../bfs-multiple-subpkgs-one-fails/Kptfile | 28 +- .../service.yaml | 14 +- .../sub1/Kptfile | 18 +- .../sub1/deployment.yaml | 12 +- .../sub2/Kptfile | 22 +- .../sub2/deployment.yaml | 12 +- .../sub3/Kptfile | 18 +- .../sub3/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 123 +- .../.krmignore | 2 +- .../bfs-parent-and-subpkg-both-fail/Kptfile | 32 +- .../configmap.yaml | 12 +- .../subpkg/Kptfile | 26 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 121 +- .../bfs-parent-mutator-fails/.krmignore | 2 +- .../bfs-parent-mutator-fails/Kptfile | 30 +- .../bfs-parent-mutator-fails/configmap.yaml | 12 +- .../bfs-parent-mutator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 124 +- .../bfs-parent-validator-fails/.krmignore | 2 +- .../bfs-parent-validator-fails/Kptfile | 32 +- .../bfs-parent-validator-fails/configmap.yaml | 12 +- .../bfs-parent-validator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 118 +- .../bfs-subpkg-mutator-fails/.krmignore | 2 +- .../bfs-subpkg-mutator-fails/Kptfile | 28 +- .../bfs-subpkg-mutator-fails/deployment.yaml | 12 +- .../bfs-subpkg-mutator-fails/subpkg/Kptfile | 24 +- .../subpkg/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 124 +- .../bfs-subpkg-validator-fails/.krmignore | 2 +- .../bfs-subpkg-validator-fails/Kptfile | 30 +- .../deployment.yaml | 14 +- .../bfs-subpkg-validator-fails/subpkg/Kptfile | 26 +- .../subpkg/deployment.yaml | 12 +- .../dfs-basicpipeline/.expected/config.yaml | 4 +- .../dfs-basicpipeline/.expected/diff.patch | 67 +- .../dfs-basicpipeline/.krmignore | 2 +- .../dfs-basicpipeline/Kptfile | 34 +- .../dfs-basicpipeline/resources.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 161 +- .../dfs-deep-nested-middle-fails/.krmignore | 2 +- .../dfs-deep-nested-middle-fails/Kptfile | 26 +- .../configmap.yaml | 12 +- .../level1/Kptfile | 26 +- .../level1/configmap.yaml | 12 +- .../level1/level2/Kptfile | 22 +- .../level1/level2/configmap.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 152 +- .../dfs-multiple-subpkgs-one-fails/.krmignore | 2 +- .../dfs-multiple-subpkgs-one-fails/Kptfile | 26 +- .../service.yaml | 14 +- .../sub1/Kptfile | 18 +- .../sub1/deployment.yaml | 12 +- .../sub2/Kptfile | 22 +- .../sub2/deployment.yaml | 12 +- .../sub3/Kptfile | 18 +- .../sub3/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 112 +- .../.krmignore | 2 +- .../dfs-parent-and-subpkg-both-fail/Kptfile | 30 +- .../configmap.yaml | 12 +- .../subpkg/Kptfile | 26 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 120 +- .../dfs-parent-mutator-fails/.krmignore | 2 +- .../dfs-parent-mutator-fails/Kptfile | 28 +- .../dfs-parent-mutator-fails/configmap.yaml | 12 +- .../dfs-parent-mutator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 123 +- .../dfs-parent-validator-fails/.krmignore | 2 +- .../dfs-parent-validator-fails/Kptfile | 30 +- .../dfs-parent-validator-fails/configmap.yaml | 12 +- .../dfs-parent-validator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 104 +- .../dfs-subpkg-mutator-fails/.krmignore | 2 +- .../dfs-subpkg-mutator-fails/Kptfile | 26 +- .../dfs-subpkg-mutator-fails/deployment.yaml | 12 +- .../dfs-subpkg-mutator-fails/subpkg/Kptfile | 24 +- .../subpkg/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 110 +- .../dfs-subpkg-validator-fails/.krmignore | 2 +- .../dfs-subpkg-validator-fails/Kptfile | 28 +- .../deployment.yaml | 14 +- .../dfs-subpkg-validator-fails/subpkg/Kptfile | 26 +- .../subpkg/deployment.yaml | 12 +- .../.expected/config.yaml | 6 +- .../no-save-on-render-failure/.krmignore | 2 +- .../no-save-on-render-failure/Kptfile | 30 +- .../no-save-on-render-failure/resources.yaml | 12 +- .../basicpipeline/.expected/config.yaml | 58 +- .../basicpipeline/.expected/diff.patch | 108 +- .../selectors/basicpipeline/.krmignore | 2 +- .../fn-render/selectors/basicpipeline/Kptfile | 30 +- .../selectors/basicpipeline/resources.yaml | 52 +- .../selectors/exclude/.expected/config.yaml | 56 +- .../selectors/exclude/.expected/diff.patch | 107 +- .../fn-render/selectors/exclude/.krmignore | 2 +- .../fn-render/selectors/exclude/Kptfile | 34 +- .../selectors/exclude/resources.yaml | 52 +- .../selectors/generator/.expected/config.yaml | 70 +- .../selectors/generator/.expected/diff.patch | 293 ++ .../fn-render/selectors/generator/.krmignore | 2 +- .../fn-render/selectors/generator/Kptfile | 32 +- .../fn-render/selectors/generator/db/Kptfile | 36 +- .../selectors/generator/db/resources.yaml | 38 +- .../generator/db/starlark-httpbin.yaml | 110 +- .../selectors/generator/resources.yaml | 52 +- .../.expected/config.yaml | 56 +- .../.expected/diff.patch | 122 +- .../selectors-with-exclude/.krmignore | 2 +- .../selectors/selectors-with-exclude/Kptfile | 34 +- .../selectors-with-exclude/resources.yaml | 60 +- .../selectors/validate-subset/.krmignore | 2 +- .../selectors/validate-subset/Kptfile | 20 +- .../selectors/validate-subset/resources.yaml | 54 +- .../validate-subset/starlark-httpbin-val.yaml | 48 +- .../short-image-path/.expected/config.yaml | 56 +- .../short-image-path/.expected/diff.patch | 104 +- .../short-image-path/.expected/results.yaml | 6 +- .../fn-render/short-image-path/.krmignore | 2 +- .../fn-render/short-image-path/Kptfile | 24 +- .../fn-render/short-image-path/resources.yaml | 52 +- .../.expected/config.yaml | 34 +- .../.krmignore | 2 +- .../Kptfile | 22 +- .../resources.yaml | 178 +- .../subpkg-fn-failure/.expected/config.yaml | 32 +- .../fn-render/subpkg-fn-failure/.krmignore | 2 +- .../fn-render/subpkg-fn-failure/Kptfile | 28 +- .../fn-render/subpkg-fn-failure/db/Kptfile | 28 +- .../subpkg-fn-failure/db/resources.yaml | 52 +- .../db/statefulset-filter.yaml | 52 +- .../subpkg-fn-failure/deployment_httpbin.yaml | 72 +- .../subpkg-fn-failure/resources.yaml | 38 +- .../subpkg-fn-failure/starlark-httpbin.yaml | 50 +- .../.expected/config.yaml | 30 +- .../subpkg-has-invalid-kptfile/.krmignore | 2 +- .../subpkg-has-invalid-kptfile/Kptfile | 24 +- .../subpkg-has-invalid-kptfile/db/Kptfile | 30 +- .../db/resources.yaml | 52 +- .../db/statefulset-filter.yaml | 50 +- .../subpkg-has-invalid-kptfile/resources.yaml | 38 +- .../.krmignore | 2 +- .../Kptfile | 12 +- .../pkg-a/Kptfile | 12 +- .../pkg-a/pkg-a/resources.yaml | 52 +- .../.expected/diff.patch | 119 +- .../subpkg-has-samename-subdir/.krmignore | 2 +- .../subpkg-has-samename-subdir/Kptfile | 12 +- .../subpkg-has-samename-subdir/pkg-a/Kptfile | 22 +- .../pkg-a/pkg-a/resources.yaml | 52 +- .../.expected/diff.patch | 382 ++- .../subpkg-resource-deletion/.krmignore | 2 +- .../subpkg-resource-deletion/Kptfile | 28 +- .../subpkg-resource-deletion/db/Kptfile | 28 +- .../db/resources.yaml | 52 +- .../db/statefulset-filter.yaml | 48 +- .../deployment_httpbin.yaml | 72 +- .../subpkg-resource-deletion/resources.yaml | 38 +- .../starlark-httpbin.yaml | 48 +- .../.expected/diff.patch | 186 +- .../subpkgs-with-krmignore/.krmignore | 2 +- .../fn-render/subpkgs-with-krmignore/Kptfile | 24 +- .../subpkgs-with-krmignore/db/Kptfile | 24 +- .../subpkgs-with-krmignore/db/non-krm.yaml | 34 +- .../subpkgs-with-krmignore/db/resources.yaml | 38 +- .../subpkgs-with-krmignore/resources.yaml | 52 +- .../fn-render/subpkgs/.expected/diff.patch | 186 +- e2e/testdata/fn-render/subpkgs/.krmignore | 2 +- e2e/testdata/fn-render/subpkgs/Kptfile | 24 +- e2e/testdata/fn-render/subpkgs/db/Kptfile | 24 +- .../fn-render/subpkgs/db/resources.yaml | 38 +- e2e/testdata/fn-render/subpkgs/resources.yaml | 52 +- .../success-stdout/.expected/config.yaml | 30 +- .../success-stdout/.expected/diff.patch | 104 +- .../fn-render/success-stdout/.krmignore | 2 +- e2e/testdata/fn-render/success-stdout/Kptfile | 24 +- .../fn-render/success-stdout/resources.yaml | 52 +- .../.expected/diff.patch | 252 ++ .../validate-generated-resource/.krmignore | 2 +- .../validate-generated-resource/Kptfile | 22 +- .../resources.yaml | 52 +- .../starlark-httpbin-gen.yaml | 110 +- .../starlark-httpbin-val.yaml | 48 +- .../.expected/config.yaml | 38 +- .../validate-resource-failure/.krmignore | 2 +- .../validate-resource-failure/Kptfile | 16 +- .../validate-resource-failure/resources.yaml | 52 +- .../starlark-httpbin-val.yaml | 48 +- .../validator-mutates-resources/.krmignore | 2 +- .../validator-mutates-resources/Kptfile | 18 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/exec.sh | 42 +- .../.krmignore | 4 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/diff.patch | 66 +- .../.expected/exec.sh | 44 +- .../out-of-place-source-sink/.krmignore | 4 +- .../out-of-place-source-sink/resources.yaml | 52 +- .../.expected/config.yaml | 130 +- .../subpkgs-with-krmignore/.expected/exec.sh | 38 +- .../subpkgs-with-krmignore/.krmignore | 2 +- .../fn-source/subpkgs-with-krmignore/Kptfile | 24 +- .../subpkgs-with-krmignore/db/Kptfile | 24 +- .../subpkgs-with-krmignore/db/non-krm.yaml | 34 +- .../subpkgs-with-krmignore/db/resources.yaml | 38 +- .../subpkgs-with-krmignore/resources.yaml | 52 +- .../live-apply/apply-depends-on/config.yaml | 106 +- .../apply-depends-on/resources/Kptfile | 6 +- .../apply-depends-on/resources/first.yaml | 74 +- .../resources/resourcegroup.yaml | 12 +- .../apply-depends-on/resources/second.yaml | 78 +- .../live-apply/crd-and-cr/config.yaml | 102 +- .../live-apply/crd-and-cr/resources/Kptfile | 8 +- .../live-apply/crd-and-cr/resources/cr.yaml | 36 +- .../live-apply/crd-and-cr/resources/crd.yaml | 86 +- .../crd-and-cr/resources/resourcegroup.yaml | 12 +- .../dry-run-with-install-rg/config.yaml | 52 +- .../dry-run-with-install-rg/resources/Kptfile | 8 +- .../resources/deployment.yaml | 84 +- .../resources/resourcegroup.yaml | 12 +- .../live-apply/dry-run-without-rg/config.yaml | 44 +- .../dry-run-without-rg/resources/Kptfile | 8 +- .../resources/deployment.yaml | 84 +- .../resources/resourcegroup.yaml | 12 +- .../install-rg-on-apply/config.yaml | 58 +- .../install-rg-on-apply/resources/Kptfile | 8 +- .../resources/deployment.yaml | 84 +- .../resources/resourcegroup.yaml | 12 +- .../invalid-annotation-type/config.yaml | 52 +- .../invalid-annotation-type/resources/Kptfile | 8 +- .../resources/configmap.yaml | 16 +- .../resources/resourcegroup.yaml | 14 +- .../live-apply/invalid-label-type/config.yaml | 52 +- .../invalid-label-type/resources/Kptfile | 8 +- .../resources/configmap.yaml | 16 +- .../resources/resourcegroup.yaml | 14 +- .../live-apply/json-output/config.yaml | 132 +- .../json-output/pre-apply/first.yaml | 70 +- .../live-apply/json-output/pre-apply/rg.yaml | 60 +- .../json-output/pre-apply/second.yaml | 72 +- .../live-apply/json-output/resources/Kptfile | 8 +- .../live-apply/json-output/resources/cm.yaml | 40 +- .../live-apply/json-output/resources/dep.yaml | 70 +- .../json-output/resources/resourcegroup.yaml | 12 +- .../live-apply/prune-depends-on/config.yaml | 114 +- .../prune-depends-on/pre-apply/first.yaml | 70 +- .../prune-depends-on/pre-apply/rg.yaml | 60 +- .../prune-depends-on/pre-apply/second.yaml | 72 +- .../prune-depends-on/resources/Kptfile | 8 +- .../prune-depends-on/resources/cm.yaml | 40 +- .../resources/resourcegroup.yaml | 12 +- e2e/testdata/live-plan/create/config.yaml | 122 +- .../live-plan/create/resources/Kptfile | 16 +- .../live-plan/create/resources/cm.yaml | 40 +- e2e/testdata/live-plan/prune/config.yaml | 420 +-- .../live-plan/prune/pre-apply/cm.yaml | 44 +- .../live-plan/prune/pre-apply/dep.yaml | 70 +- .../live-plan/prune/pre-apply/rg.yaml | 60 +- .../live-plan/prune/resources/Kptfile | 14 +- .../live-plan/prune/resources/cm.yaml | 40 +- 1032 files changed, 25748 insertions(+), 19825 deletions(-) create mode 100644 e2e/testdata/fn-render/fn-success-with-stderr/.expected/diff.patch create mode 100644 e2e/testdata/fn-render/no-op/.expected/diff.patch create mode 100644 e2e/testdata/fn-render/preserve-comments/.expected/diff.patch diff --git a/e2e/README.md b/e2e/README.md index 6417dac01b..1b0cc19dac 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -1,53 +1,53 @@ -# End-to-end testing of kpt - -## kpt live e2e tests - -We currently have two different solutions for running e2e tests for the kpt -live functionality. We are working on reconciling this into one approach that -we can use consistently. - -All e2e tests for live requires that kind is available. - -### Testing with go - -We have a framework for running e2e tests based on specifying test cases -under testdata/live-apply folder (tests for other kpt live commands will be -added). The entry point for the test framework is in -the `live_test.go` file. - -In order to run all the tests for live apply, there is a make target -```sh -make test-live-apply -``` - -It is possible to run a single test by specifying the name of the test case: -```sh -make test-live-apply T=crd-and-cr -``` - -#### Structure of a test case - -Each test case is a folder directly under `testdata/live-apply`. In the root -of each test case folder there must be a `config.yaml` file that provides the -configuration of the test case (like whether a clean cluster is required and -the expected output). The package that will be applied with `kpt live apply` is -provided in the `resources` folder. - -#### Configuration options - -These are the configuration options available in the `config.yaml` file: - * `exitCode`: Defines the expected exit code after running the kpt live command. Defaults to 0. - * `stdErr`: Defines the expected output to stdErr after running the command. Defaults to "". - * `stdOut`: Defines the expected output to stdOut after running the command. Defaults to "". - * `inventory`: Defines the expected inventory after running the command. - * `requiresCleanCluster`: Defines whether a new kind cluster should be created prior to running the test. - * `preinstallResourceGroup`: Defines whether the framework should make sure the RG CRD is available before running the test. - * `kptArgs`: Defines the arguments that will be used with executing the kpt live command. - -## Testing with bash - -This approach uses a bash script that runs through several scenarios for -kpt live in sequence. Run it by running -```sh -./live/end-to-end-test.sh +# End-to-end testing of kpt + +## kpt live e2e tests + +We currently have two different solutions for running e2e tests for the kpt +live functionality. We are working on reconciling this into one approach that +we can use consistently. + +All e2e tests for live requires that kind is available. + +### Testing with go + +We have a framework for running e2e tests based on specifying test cases +under testdata/live-apply folder (tests for other kpt live commands will be +added). The entry point for the test framework is in +the `live_test.go` file. + +In order to run all the tests for live apply, there is a make target +```sh +make test-live-apply +``` + +It is possible to run a single test by specifying the name of the test case: +```sh +make test-live-apply T=crd-and-cr +``` + +#### Structure of a test case + +Each test case is a folder directly under `testdata/live-apply`. In the root +of each test case folder there must be a `config.yaml` file that provides the +configuration of the test case (like whether a clean cluster is required and +the expected output). The package that will be applied with `kpt live apply` is +provided in the `resources` folder. + +#### Configuration options + +These are the configuration options available in the `config.yaml` file: + * `exitCode`: Defines the expected exit code after running the kpt live command. Defaults to 0. + * `stdErr`: Defines the expected output to stdErr after running the command. Defaults to "". + * `stdOut`: Defines the expected output to stdOut after running the command. Defaults to "". + * `inventory`: Defines the expected inventory after running the command. + * `requiresCleanCluster`: Defines whether a new kind cluster should be created prior to running the test. + * `preinstallResourceGroup`: Defines whether the framework should make sure the RG CRD is available before running the test. + * `kptArgs`: Defines the arguments that will be used with executing the kpt live command. + +## Testing with bash + +This approach uses a bash script that runs through several scenarios for +kpt live in sequence. Run it by running +```sh +./live/end-to-end-test.sh ``` \ No newline at end of file diff --git a/e2e/fn_test.go b/e2e/fn_test.go index 8fe42b7331..a01201e94c 100644 --- a/e2e/fn_test.go +++ b/e2e/fn_test.go @@ -1,93 +1,93 @@ -//go:build docker -// +build docker - -// Copyright 2021,2026 The kpt Authors -// -// 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. - -package e2e_test - -import ( - "os" - "path/filepath" - "strings" - "testing" - - "github.com/kptdev/kpt/internal/fnruntime" - "github.com/kptdev/kpt/pkg/test/runner" -) - -func TestFnRender(t *testing.T) { - runAllTests(t, filepath.Join(".", "testdata", "fn-render")) -} - -func TestFnEval(t *testing.T) { - runAllTests(t, filepath.Join(".", "testdata", "fn-eval")) -} - -func TestFnSink(t *testing.T) { - runAllTests(t, filepath.Join(".", "testdata", "fn-sink")) -} - -// runTests will scan test cases in 'path', run the command -// on all of the packages in path, and test that -// the diff between the results and the original package is as -// expected -func runAllTests(t *testing.T, path string) { - cases, err := runner.ScanTestCases(path) - if err != nil { - t.Fatalf("failed to scan test cases: %s", err) - } - // Run all the sequential tests first then run the parallel tests. - runTests(t, cases, true) - runTests(t, cases, false) -} - -func runTests(t *testing.T, cases *runner.TestCases, sequential bool) { - for _, c := range *cases { - c := c // capture range variable - if c.Config.Sequential != sequential { - continue - } - // If the current function runtime doesn't match, we skip this test case. - currRuntime := strings.ToLower(os.Getenv(fnruntime.ContainerRuntimeEnv)) - if len(c.Config.Runtimes) > 0 { - skip := true - for _, rt := range c.Config.Runtimes { - if currRuntime == strings.ToLower(rt) { - skip = false - break - } - } - if skip { - continue - } - } - t.Run(c.Path, func(t *testing.T) { - if !c.Config.Sequential { - t.Parallel() - } - r, err := runner.NewRunner(t, c, c.Config.TestType) - if err != nil { - t.Fatalf("failed to create test runner: %s", err) - } - if r.Skip() { - t.Skip() - } - err = r.Run() - if err != nil { - t.Fatalf("failed when running test: %s", err) - } - }) - } -} +//go:build docker +// +build docker + +// Copyright 2021,2026 The kpt Authors +// +// 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. + +package e2e_test + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/kptdev/kpt/internal/fnruntime" + "github.com/kptdev/kpt/pkg/test/runner" +) + +func TestFnRender(t *testing.T) { + runAllTests(t, filepath.Join(".", "testdata", "fn-render")) +} + +func TestFnEval(t *testing.T) { + runAllTests(t, filepath.Join(".", "testdata", "fn-eval")) +} + +func TestFnSink(t *testing.T) { + runAllTests(t, filepath.Join(".", "testdata", "fn-sink")) +} + +// runTests will scan test cases in 'path', run the command +// on all of the packages in path, and test that +// the diff between the results and the original package is as +// expected +func runAllTests(t *testing.T, path string) { + cases, err := runner.ScanTestCases(path) + if err != nil { + t.Fatalf("failed to scan test cases: %s", err) + } + // Run all the sequential tests first then run the parallel tests. + runTests(t, cases, true) + runTests(t, cases, false) +} + +func runTests(t *testing.T, cases *runner.TestCases, sequential bool) { + for _, c := range *cases { + c := c // capture range variable + if c.Config.Sequential != sequential { + continue + } + // If the current function runtime doesn't match, we skip this test case. + currRuntime := strings.ToLower(os.Getenv(fnruntime.ContainerRuntimeEnv)) + if len(c.Config.Runtimes) > 0 { + skip := true + for _, rt := range c.Config.Runtimes { + if currRuntime == strings.ToLower(rt) { + skip = false + break + } + } + if skip { + continue + } + } + t.Run(c.Path, func(t *testing.T) { + if !c.Config.Sequential { + t.Parallel() + } + r, err := runner.NewRunner(t, c, c.Config.TestType) + if err != nil { + t.Fatalf("failed to create test runner: %s", err) + } + if r.Skip() { + t.Skip() + } + err = r.Run() + if err != nil { + t.Fatalf("failed when running test: %s", err) + } + }) + } +} diff --git a/e2e/live/end-to-end-test.sh b/e2e/live/end-to-end-test.sh index c939a8b887..044162e010 100755 --- a/e2e/live/end-to-end-test.sh +++ b/e2e/live/end-to-end-test.sh @@ -1,1317 +1,1317 @@ -#!/usr/bin/env bash -########################################################################### -# Copyright 2020 The kpt Authors -# -# 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. -# -# Description: -# Validates multiple scenarios for kpt live commands. -# -# How to use this script: -# FROM KPT ROOT DIR: ./e2e/live/end-to-end-test.sh -# -# Example KPT ROOT DIR: -# ~/go/src/github.com/kptdev/kpt -# -# Flags: -# -b) Build the kpt binary with dependencies at HEAD. Downloads HEAD -# for cli-utils and kustomize repositories, and builds kpt using -# these downloaded repositories. -# -k) Run against this Kubernetes version. Creates a local Kubernetes -# cluster at this version using "kind". Only accepts MAJOR.MINOR. -# Example: 1.17. This is translated to a patch version. Example: -# 1.17 runs version 1.17.11. -# -# Prerequisites (must be in $PATH): -# kind - Kubernetes in Docker -# kubectl - version of kubectl should be within +/- 1 version of cluster. -# CHECK: $ kubectl version -# -# Examples: -# $ ./e2e/live/end-to-end-test.sh -b -# $ ./e2e/live/end-to-end-test.sh -k 1.17 -# $ ./e2e/live/end-to-end-test.sh -bk 1.17 -# -########################################################################### - -# TODO -# 1) Validate prerequisites (e.g. kind, kubectl) -# 2) Refactor helper functions into another file -# 3) Fix -k -# 4) Add "-v" verbosity level flags -# 5) Count the test cases and print it out -# 6) Print timing for the tests - - -########################################################################### -# Parameters/args -########################################################################### - -# A POSIX variable; reset in case getopts has been used previously in the shell. -OPTIND=1 - -# Kind/Kubernetes versions. - -KIND_1_34_VERSION=1.34.0@sha256:7416a61b42b1662ca6ca89f02028ac133a309a2a30ba309614e8ec94d976dc5a -KIND_1_33_VERSION=1.33.4@sha256:25a6018e48dfcaee478f4a59af81157a437f15e6e140bf103f85a2e7cd0cbbf2 -KIND_1_32_VERSION=1.32.8@sha256:abd489f042d2b644e2d033f5c2d900bc707798d075e8186cb65e3f1367a9d5a1 -KIND_1_31_VERSION=1.31.12@sha256:0f5cc49c5e73c0c2bb6e2df56e7df189240d83cf94edfa30946482eb08ec57d2 -KIND_1_30_VERSION=1.30.13@sha256:397209b3d947d154f6641f2d0ce8d473732bd91c87d9575ade99049aa33cd648 -KIND_1_29_VERSION=1.29.12@sha256:62c0672ba99a4afd7396512848d6fc382906b8f33349ae68fb1dbfe549f70dec -KIND_1_28_VERSION=1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31 -KIND_1_27_VERSION=1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 -KIND_1_26_VERSION=1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb -KIND_1_25_VERSION=1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 -KIND_1_24_VERSION=1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab -KIND_1_23_VERSION=1.23.17@sha256:59c989ff8a517a93127d4a536e7014d28e235fb3529d9fba91b3951d461edfdb -KIND_1_22_VERSION=1.22.17@sha256:f5b2e5698c6c9d6d0adc419c0deae21a425c07d81bbf3b6a6834042f25d4fba2 -KIND_1_21_VERSION=1.21.14@sha256:8a4e9bb3f415d2bb81629ce33ef9c76ba514c14d707f9797a01e3216376ba093 - - - -NOTE: You must use the @sha256 digest to guarantee an image built for this release, until such a time as we switch to a different tagging scheme. Even then we will highly encourage digest pinning for security and reproducibility reasons. - -DEFAULT_K8S_VERSION=${KIND_1_34_VERSION} - -# Change from empty string to build the kpt binary from the downloaded -# repositories at HEAD, including dependencies cli-utils and kustomize. -BUILD_DEPS_AT_HEAD="" - -# Default Kubernetes cluster version to run test against. -K8S_VERSION=${DEFAULT_K8S_VERSION} - -HAS_TEST_FAILURE=0 - -# Parse/validate parameters -options="bk:" -while getopts $options opt; do - case "$opt" in - b) BUILD_DEPS_AT_HEAD=1;; - k) short_version=$OPTARG - case "$short_version" in - 1.21) K8S_VERSION=$KIND_1_21_VERSION - ;; - 1.22) K8S_VERSION=$KIND_1_22_VERSION - ;; - 1.23) K8S_VERSION=$KIND_1_23_VERSION - ;; - 1.24) K8S_VERSION=$KIND_1_24_VERSION - ;; - 1.25) K8S_VERSION=$KIND_1_25_VERSION - ;; - 1.26) K8S_VERSION=$KIND_1_26_VERSION - ;; - 1.27) K8S_VERSION=$KIND_1_27_VERSION - ;; - 1.28) K8S_VERSION=$KIND_1_28_VERSION - ;; - 1.29) K8S_VERSION=$KIND_1_29_VERSION - ;; - 1.30) K8S_VERSION=$KIND_1_30_VERSION - ;; - 1.31) K8S_VERSION=$KIND_1_31_VERSION - ;; - 1.32) K8S_VERSION=$KIND_1_32_VERSION - ;; - 1.33) K8S_VERSION=$KIND_1_33_VERSION - ;; - 1.34) K8S_VERSION=$KIND_1_34_VERSION - ;; - *) K8S_VERSION=$short_version - ;; - esac - ;; - \? ) echo "Usage: $0 [-b] [-k k8s-version]" >&2; exit 1;; - esac -done - -shift $((OPTIND-1)) - -[ "${1:-}" = "--" ] && shift - -########################################################################### -# Colors -########################################################################### - -GREEN='\033[0;32m' -RED='\033[0;31m' -NC='\033[0m' # No Color - -########################################################################### -# Helper functions -########################################################################### - -# buildKpt builds the kpt binary, storing it in the temporary directory. -# To check the stdout output of the build check $OUTPUT_DIR/kptbuild. -# stderr output will be output to the terminal. -function buildKpt { - set -e - if [ -z $BUILD_DEPS_AT_HEAD ]; then - echo "checking go version" - go version - echo "Building kpt locally..." - go build -o $BIN_DIR -v . > $OUTPUT_DIR/kptbuild 2>&1 - echo -e "Building kpt locally...${GREEN}SUCCESS${NC}" - - else - echo "Building kpt using dependencies at HEAD..." - echo - # Clone kpt repository into kpt source directory - KPT_SRC_DIR="${SRC_DIR}/github.com/kptdev/kpt" - mkdir -p $KPT_SRC_DIR - echo "Downloading kpt repository at HEAD..." - git clone https://github.com/kptdev/kpt ${KPT_SRC_DIR} > ${OUTPUT_DIR}/kptbuild 2>&1 - echo -e "Downloading kpt repository at HEAD...${GREEN}SUCCESS${NC}" - # Clone cli-utils repository into source directory - CLI_UTILS_SRC_DIR="${SRC_DIR}/sigs.k8s.io/cli-utils" - mkdir -p $CLI_UTILS_SRC_DIR - echo "Downloading cli-utils repository at HEAD..." - git clone https://github.com/kubernetes-sigs/cli-utils ${CLI_UTILS_SRC_DIR} > ${OUTPUT_DIR}/kptbuild 2>&1 - echo -e "Downloading cli-utils repository at HEAD...${GREEN}SUCCESS${NC}" - # Clone kustomize respository into source directory - KUSTOMIZE_SRC_DIR="${SRC_DIR}/sigs.k8s.io/kustomize" - mkdir -p $KUSTOMIZE_SRC_DIR - echo "Downloading kustomize repository at HEAD..." - git clone https://github.com/kubernetes-sigs/kustomize ${KUSTOMIZE_SRC_DIR} > ${OUTPUT_DIR}/kptbuild 2>&1 - echo -e "Downloading kustomize repository at HEAD...${GREEN}SUCCESS${NC}" - # Tell kpt to build using the locally downloaded dependencies - echo "Updating kpt/go.mod to reference locally downloaded repositories..." - echo -e "\n\nreplace sigs.k8s.io/cli-utils => ../../../sigs.k8s.io/cli-utils" >> ${KPT_SRC_DIR}/go.mod - echo -e "replace sigs.k8s.io/kustomize/cmd/config => ../../../sigs.k8s.io/kustomize/cmd/config" >> ${KPT_SRC_DIR}/go.mod - echo -e "replace sigs.k8s.io/kustomize/kyaml => ../../../sigs.k8s.io/kustomize/kyaml\n" >> ${KPT_SRC_DIR}/go.mod - echo -e "Updating kpt/go.mod to reference locally downloaded repositories...${GREEN}SUCCESS${NC}" - # Build kpt using the cloned directories - export GOPATH=${TMP_DIR} - echo "Building kpt..." - (cd -- ${KPT_SRC_DIR} && go build -o $BIN_DIR -v . > ${OUTPUT_DIR}/kptbuild) - echo -e "Building kpt...${GREEN}SUCCESS${NC}" - echo - echo -e "Building kpt using dependencies at HEAD...${GREEN}SUCCESS${NC}" - fi - set +e -} - -# createTestSuite deletes then creates the kind cluster. We wait for the node -# to become ready before we run the tests. -function createTestSuite { - set -e - echo "Setting Up Test Suite..." - echo - # Create the k8s cluster - echo "Deleting kind cluster..." - kind delete cluster > /dev/null 2>&1 - echo -e "Deleting kind cluster...${GREEN}SUCCESS${NC}" - echo "Creating kind cluster..." - kind create cluster --image=kindest/node:v${K8S_VERSION} --wait=2m > $OUTPUT_DIR/k8sstartup 2>&1 - kubectl wait node/kind-control-plane --for condition=ready --timeout=2m - echo -e "Creating kind cluster...${GREEN}SUCCESS${NC}" - echo - echo -e "Setting Up Test Suite...${GREEN}SUCCESS${NC}" - echo - set +e -} - -function waitForDefaultServiceAccount { - # Necessary to ensure default service account is created before pods. - echo -n "Waiting for default service account..." - echo -n ' ' - sp="/-\|" - n=1 - until ((n >= 300)); do - kubectl -n default get serviceaccount default -o name 2>&1 | tee $OUTPUT_DIR/status - test 1 == $(grep "serviceaccount/default" $OUTPUT_DIR/status | wc -l) - if [ $? == 0 ]; then - echo - break - fi - printf "\b${sp:n++%${#sp}:1}" - sleep 0.2 - done - ((n < 300)) - echo "Waiting for default service account...CREATED" - echo -} - -# assertKptLiveApplyEquals checks that the STDIN equals the content of the -# $OUTPUT_DIR/status file, after filtering and sorting. -function assertKptLiveApplyEquals { - local expected="$(cat | processKptLiveOutput)" - local received="$(cat "$OUTPUT_DIR/status" | processKptLiveOutput)" - local diff_result="$( diff -u <(echo -e "${expected}") <(echo -e "${received}") --label "expected" --label "received")" - if [[ -z "${diff_result}" ]]; then - echo -n '.' - else - echo -n 'E' - echo -e "error: expected output ():\n${diff_result}" >> "$OUTPUT_DIR/errors" - HAS_TEST_FAILURE=1 - fi -} - -function processKptLiveOutput { - trimTrailingNewlines | \ - filterReconcilePending | \ - filterWarning | \ - sortReconcileEvents | \ - sortActuationEvents -} - -function trimTrailingNewlines { - sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' -} - -function filterReconcilePending { - grep -v " reconcile pending$" | \ - grep -v " unrecognized format .*int64.*$" || true -} - -function filterWarning { - grep -v " unknown field" || true -} - -# sortReconcileEvents sorts reconcile events: successful > failed. -# Not sorted: skipped (always first) & timeout (always last). -function sortReconcileEvents { - local input="$(cat)" # read full input before sorting - local status="" - local successfulBuffer="" - local failedBuffer="" - local pattern="^.* reconcile (successful|failed).*$" - while IFS="" read -r line; do - if [[ "${line}" =~ ${pattern} ]]; then - # match - add line to buffer - status="${BASH_REMATCH[1]}" - if [[ "${status}" == "successful" ]]; then - successfulBuffer+="${line}\n" - elif [[ "${status}" == "failed" ]]; then - failedBuffer+="${line}\n" - else - echo "ERROR: Unexpected reconcile status: ${status}" - return - fi - else - # no match - dump buffers & print line - if [[ -n "${successfulBuffer}" ]]; then - echo -en "${successfulBuffer}" | sort - successfulBuffer="" - fi - if [[ -n "${failedBuffer}" ]]; then - echo -en "${failedBuffer}" | sort - failedBuffer="" - fi - echo "${line}" - fi - done <<< "${input}" - # end of input - dump buffers - if [[ -n "${successfulBuffer}" ]]; then - echo -en "${successfulBuffer}" | sort - successfulBuffer="" - fi - if [[ -n "${failedBuffer}" ]]; then - echo -en "${failedBuffer}" | sort - failedBuffer="" - fi -} - -# sortActuationEvents sorts apply/prune/delete events: skipped > successful > failed. -# Only events with the same actuation type and resource type are sorted. -function sortActuationEvents { - local input="$(cat)" # read full input before sorting - local status="" - local resource="" - local actuation="" - local skippedBuffer="" - local successfulBuffer="" - local failedBuffer="" - local pattern="^(.*)/(.*) (apply|prune|delete) (skipped|successful|failed).*$" - while IFS="" read -r line; do - if [[ "${line}" =~ ${pattern} ]]; then - # match - if [[ "${resource}" != "${BASH_REMATCH[1]}" ]] || [[ "${actuation}" != "${BASH_REMATCH[3]}" ]]; then - # different resource/actuation - dump buffers & update resource/actuation - if [[ -n "${skippedBuffer}" ]]; then - echo -en "${skippedBuffer}" | sort - skippedBuffer="" - fi - if [[ -n "${successfulBuffer}" ]]; then - echo -en "${successfulBuffer}" | sort - successfulBuffer="" - fi - if [[ -n "${failedBuffer}" ]]; then - echo -en "${failedBuffer}" | sort - failedBuffer="" - fi - resource="${BASH_REMATCH[1]}" - actuation="${BASH_REMATCH[3]}" - fi - - # add line to buffer - status="${BASH_REMATCH[4]}" - if [[ "${status}" == "skipped" ]]; then - skippedBuffer+="${line}\n" - elif [[ "${status}" == "successful" ]]; then - successfulBuffer+="${line}\n" - elif [[ "${status}" == "failed" ]]; then - failedBuffer+="${line}\n" - else - echo "ERROR: Unexpected ${actuation} status: ${status}" - return - fi - else - # no match - dump buffers & print line - if [[ -n "${skippedBuffer}" ]]; then - echo -en "${skippedBuffer}" | sort - skippedBuffer="" - fi - if [[ -n "${successfulBuffer}" ]]; then - echo -en "${successfulBuffer}" | sort - successfulBuffer="" - fi - if [[ -n "${failedBuffer}" ]]; then - echo -en "${failedBuffer}" | sort - failedBuffer="" - fi - echo "${line}" - resource="" - actuation="" - fi - done <<< "${input}" - # end of input - dump buffers - if [[ -n "${skippedBuffer}" ]]; then - echo -en "${skippedBuffer}" | sort - skippedBuffer="" - fi - if [[ -n "${successfulBuffer}" ]]; then - echo -en "${successfulBuffer}" | sort - successfulBuffer="" - fi - if [[ -n "${failedBuffer}" ]]; then - echo -en "${failedBuffer}" | sort - failedBuffer="" - fi -} - -# assertContains checks that the passed string is a substring of -# the $OUTPUT_DIR/status file. -function assertContains { - local test_arg="$@" - test 1 == \ - $(grep "$test_arg" $OUTPUT_DIR/status | wc -l); \ - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: expected missing text \"${test_arg}\"" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi -} - -# assertNotContains checks that the passed string is NOT a substring of -# the $OUTPUT_DIR/status file. -function assertNotContains { - local test_arg="$@" - test 0 == \ - $(grep "$test_arg" $OUTPUT_DIR/status | wc -l); \ - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: unexpected text \"${test_arg}\" found" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi -} - -# assertCMInventory checks that a ConfigMap inventory object exists in -# the passed namespace with the passed number of inventory items. -# Assumes the inventory object name begins with "inventory-". -function assertCMInventory { - local ns=$1 - local numInv=$2 - - echo "kubectl get cm -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers" - inv=$(kubectl get cm -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers) - echo $inv | awk '{print $1}' > $OUTPUT_DIR/invname - echo $inv | awk '{print $2}' > $OUTPUT_DIR/numinv - - test 1 == $(grep "inventory-" $OUTPUT_DIR/invname | wc -l); - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: expected missing ConfigMap inventory object in ${ns} namespace" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi - - test 1 == $(grep $numInv $OUTPUT_DIR/numinv | wc -l); - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: expected ConfigMap inventory to have $numInv inventory items" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi -} - -# assertRGInventory checks that a ResourceGroup inventory object exists -# in the passed namespace. Assumes the inventory object name begins -# with "inventory-". -function assertRGInventory { - local ns=$1 - - echo "kubectl get resourcegroups.kpt.dev -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | awk '{print $1}'" - kubectl get resourcegroups.kpt.dev -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | awk '{print $1}' > $OUTPUT_DIR/invname - - test 1 == $(grep "inventory-" $OUTPUT_DIR/invname | wc -l); - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: expected missing ResourceGroup inventory in ${ns} namespace" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi -} - -# assertPodExists checks that a pod with the passed podName and passed -# namespace exists in the cluster. -TIMEOUT_SECS=30 -function assertPodExists { - local podName=$1 - local namespace=$2 - - echo "kubectl wait --for=condition=Ready -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s" - kubectl wait --for=condition=Ready -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s > /dev/null 2>&1 - echo "kubectl get po -n $namespace $podName -o name | awk '{print $1}'" - kubectl get po -n $namespace $podName -o name | awk '{print $1}' > $OUTPUT_DIR/podname - - test 1 == $(grep $podName $OUTPUT_DIR/podname | wc -l); - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: expected missing pod $namespace/$podName in ${namespace} namespace" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi -} - -# assertPodNotExists checks that a pod with the passed podName and passed -# namespace DOES NOT exist in the cluster. Waits 20 seconds for pod -# termination if pod has not finished deleting. -function assertPodNotExists { - local podName=$1 - local namespace=$2 - - echo "kubectl wait --for=delete -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s" - kubectl wait --for=delete -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s > /dev/null 2>&1 - echo "kubectl get po -n $namespace $podName -o name" - kubectl get po -n $namespace $podName -o name > $OUTPUT_DIR/podname 2>&1 - - test 1 == $(grep "(NotFound)" $OUTPUT_DIR/podname | wc -l); - if [ $? == 0 ]; then - echo -n '.' - else - echo -n 'E' - if [ ! -f $OUTPUT_DIR/errors ]; then - touch $OUTPUT_DIR/errors - fi - echo "error: unexpected pod $namespace/$podName found in ${namespace} namespace" >> $OUTPUT_DIR/errors - HAS_TEST_FAILURE=1 - fi -} - -# printResult prints the results of the previous assert statements -function printResult { - if [ -f $OUTPUT_DIR/errors ]; then - echo -e "${RED}ERROR${NC}" - cat $OUTPUT_DIR/errors - echo - rm -f $OUTPUT_DIR/errors - else - echo -e "${GREEN}SUCCESS${NC}" - fi - echo -} - -# wait sleeps for the passed number of seconds. -function wait { - local numSecs=$1 - - sleep $numSecs -} - -SEMVER_PATTERN="v(.*)\.(.*)\.(.*)" - -function kubeServerVersion { - kubectl version --output=json | jq -r '.serverVersion.gitVersion' -} - -function kubeServerMinorVersion { - if [[ "$(kubeServerVersion)" =~ ${SEMVER_PATTERN} ]]; then - echo "${BASH_REMATCH[2]}" - else - return 1 - fi -} - -########################################################################### -# Main -########################################################################### - -# Setup temporary directory for src, bin, and output. -TMP_DIR=$(mktemp -d -t kpt-e2e-XXXXXXXXXX) -SRC_DIR="${TMP_DIR}/src" -mkdir -p $SRC_DIR -BIN_DIR="${TMP_DIR}/bin" -mkdir -p ${BIN_DIR} -OUTPUT_DIR="${TMP_DIR}/output" -mkdir -p $OUTPUT_DIR - -# Build the kpt binary and copy it to the temp dir. If BUILD_DEPS_AT_HEAD -# is set, then copy the kpt repository AND dependency directories into -# TMP_DIR and build from there. -echo "kpt end-to-end test" -echo -echo "Kubernetes Version: ${K8S_VERSION}" -echo "Temp Dir: $TMP_DIR" -echo - -buildKpt - -echo -set +e # Do not stop the test for errors - -############################################################# -# Tests without initial ResourceGroup inventory installation -############################################################# - -createTestSuite -waitForDefaultServiceAccount - -# Basic init as setup for follow-on tests -# Test: Apply dry-run without ResourceGroup CRD installation fails -echo "[ResourceGroup] Testing initial apply dry-run without ResourceGroup inventory CRD" -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ -echo "kpt live init --quiet e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live init --quiet e2e/live/testdata/rg-test-case-1a -echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertContains "Error: The ResourceGroup CRD was not found in the cluster. Please install it either by using the '--install-resource-group' flag or the 'kpt live install-resource-group' command." -printResult - -# Test: Apply installs ResourceGroup CRD -echo "[ResourceGroup] Testing create inventory CRD before basic apply" -echo "kpt live apply e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -# The ResourceGroup inventory CRD is automatically installed on the initial apply. -assertKptLiveApplyEquals << EOF -installing inventory ResourceGroup CRD. -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -reconcile phase started -namespace/rg-test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -reconcile phase started -pod/pod-a reconcile successful -pod/pod-b reconcile successful -pod/pod-c reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Validate resources in the cluster -# ConfigMap inventory with four inventory items. -assertRGInventory "rg-test-namespace" "4" -printResult - -# Apply again, but the ResourceGroup CRD is not re-installed. -echo "kpt live apply e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertNotContains "installing inventory ResourceGroup CRD" # Not applied again -assertKptLiveApplyEquals << EOF -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -reconcile phase started -namespace/rg-test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -reconcile phase started -pod/pod-a reconcile successful -pod/pod-b reconcile successful -pod/pod-c reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Cleanup by resetting Kptfile and deleting resourcegroup file -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ -rm e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml - -########################################################### -# Tests operations with ResourceGroup inventory CRD -########################################################### - -createTestSuite -waitForDefaultServiceAccount - -# Test: Installing ResourceGroup CRD -echo "Installing ResourceGroup CRD" -# First, check that the ResourceGroup CRD does NOT exist -echo "kubectl get resourcegroups.kpt.dev" -kubectl get resourcegroups.kpt.dev 2>&1 | tee $OUTPUT_DIR/status -assertContains "error: the server doesn't have a resource type \"resourcegroups\"" -# Next, add the ResourceGroup CRD -echo "kpt live install-resource-group" -${BIN_DIR}/kpt live install-resource-group 2> /dev/null | tee $OUTPUT_DIR/status -assertContains "installing inventory ResourceGroup CRD...success" -echo "kubectl get resourcegroups.kpt.dev" -kubectl get resourcegroups.kpt.dev 2>&1 | tee $OUTPUT_DIR/status -assertContains "No resources found" -# Add a simple ResourceGroup custom resource, and verify it exists in the cluster. -echo "kubectl apply -f e2e/live/testdata/install-rg-crd/example-resource-group.yaml" -kubectl apply -f e2e/live/testdata/install-rg-crd/example-resource-group.yaml 2>&1 | tee $OUTPUT_DIR/status -assertContains "resourcegroup.kpt.dev/example-inventory created" -echo "kubectl get resourcegroups.kpt.dev --no-headers" -kubectl get resourcegroups.kpt.dev --no-headers 2>&1 | tee $OUTPUT_DIR/status -assertContains "example-inventory" -# Finally, add the ResourceGroup CRD again, and check it says it already exists. -echo "kpt live install-resource-group" -${BIN_DIR}/kpt live install-resource-group 2> /dev/null | tee $OUTPUT_DIR/status -assertContains "...success" -printResult - -# Test: Basic Kptfile/ResourceGroup inititalizing inventory info -echo "Testing init for Kptfile/ResourceGroup" -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ -echo "kpt live init e2e/live/testdata/rg-test-case-1a" -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a -${BIN_DIR}/kpt live init e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertContains "initializing \"resourcegroup.yaml\" data (namespace: rg-test-namespace)...success" -# Difference in Kptfile should have inventory data -diff e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/Kptfile 2>&1 | tee $OUTPUT_DIR/status -assertNotContains "inventory:" -assertNotContains "namespace: rg-test-namespace" -assertNotContains "name: inventory-" -assertNotContains "inventoryID:" -# ResourceGroup file should contain inventory information -cat e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml 2>&1 | tee $OUTPUT_DIR/status -assertContains "kind: ResourceGroup" -assertContains "namespace: rg-test-namespace" -assertContains "name: inventory-" -printResult - -echo "Testing init Kptfile/ResourceGroup already initialized" -echo "kpt live init e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live init e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertContains "initializing \"resourcegroup.yaml\" data (namespace: rg-test-namespace)...failed" -assertContains "Error: Inventory information has already been added to the package ResourceGroup object." -printResult - -echo "Testing init force Kptfile/ResourceGroup" -echo "kpt live init --force --name inventory-18030002 e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live init --force --name inventory-18030002 e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertContains "initializing \"resourcegroup.yaml\" data (namespace: rg-test-namespace)...success" -cat e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml 2>&1 | tee $OUTPUT_DIR/status -assertContains "name: inventory-18030002" -printResult - -echo "Testing init quiet Kptfile/ResourceGroup" -echo "kpt live init --quiet e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live init --quiet e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertNotContains "initializing resourcegroup" -printResult - -# Test: Basic kpt live apply dry-run -# Apply run-run for "rg-test-case-1a" directory -echo "[ResourceGroup] Testing initial apply dry-run" -echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -Dry-run strategy: client -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -EOF -printResult - -# Test: Basic kpt live apply -# Apply run for "rg-test-case-1a" directory -echo "[ResourceGroup] Testing basic apply" -echo "kpt live apply e2e/live/testdata/rg-test-case-1a" -${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -# The ResourceGroup CRD is already installed. -assertKptLiveApplyEquals << EOF -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -reconcile phase started -namespace/rg-test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -reconcile phase started -pod/pod-a reconcile successful -pod/pod-b reconcile successful -pod/pod-c reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Validate resources in the cluster -# ConfigMap inventory with four inventory items. -assertRGInventory "rg-test-namespace" "4" -printResult - -# Test: Basic kpt live apply on symlink -# Apply run for "rg-test-case-1a" directory -echo "[ResourceGroup] Testing basic apply on symlink" -rm -f link-to-rg-test-case-1a # Delete if exists -ln -s e2e/live/testdata/rg-test-case-1a/ link-to-rg-test-case-1a -trap "rm -f ${PWD}/link-to-rg-test-case-1a" EXIT -echo "kpt live apply link-to-rg-test-case-1a" -${BIN_DIR}/kpt live apply link-to-rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -# The ResourceGroup CRD is already installed. -assertNotContains "installing inventory ResourceGroup CRD" -assertKptLiveApplyEquals << EOF -[WARN] resolved symlink "link-to-rg-test-case-1a" to "e2e/live/testdata/rg-test-case-1a", please note that the symlinks within the package are ignored -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -reconcile phase started -namespace/rg-test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -reconcile phase started -pod/pod-a reconcile successful -pod/pod-b reconcile successful -pod/pod-c reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Validate resources in the cluster -# ConfigMap inventory with four inventory items. -assertRGInventory "rg-test-namespace" "4" -printResult - -# Test: Basic kpt live status on symlink -# Apply run for "rg-test-case-1a" directory -echo "[ResourceGroup] Testing basic status on symlink" -rm -f link-to-rg-test-case-1a # Delete if exists -ln -s e2e/live/testdata/rg-test-case-1a/ link-to-rg-test-case-1a -trap "rm -f ${PWD}/link-to-rg-test-case-1a" EXIT -echo "kpt live status link-to-rg-test-case-1a" -${BIN_DIR}/kpt live status link-to-rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status -# The ResourceGroup CRD is already installed. -assertNotContains "installing inventory ResourceGroup CRD" -assertKptLiveApplyEquals << EOF -[WARN] resolved symlink "link-to-rg-test-case-1a" to "e2e/live/testdata/rg-test-case-1a", please note that the symlinks within the package are ignored -inventory-18030002/namespace//rg-test-namespace is Current: Resource is current -inventory-18030002/pod/rg-test-namespace/pod-a is Current: Pod is Ready -inventory-18030002/pod/rg-test-namespace/pod-b is Current: Pod is Ready -inventory-18030002/pod/rg-test-namespace/pod-c is Current: Pod is Ready -EOF -printResult - -# Validate resources in the cluster -# ConfigMap inventory with four inventory items. -assertRGInventory "rg-test-namespace" "4" -printResult - -rm -rf link-to-rg-test-case-1a - -# Test: kpt live apply dry-run of with prune -# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added. -echo "[ResourceGroup] Testing basic apply dry-run" -cp -f e2e/live/testdata/rg-test-case-1a/Kptfile e2e/live/testdata/rg-test-case-1b/ -echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1b" -cp -f e2e/live/testdata/rg-test-case-1a/Kptfile e2e/live/testdata/rg-test-case-1b -cp -f e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml e2e/live/testdata/rg-test-case-1b -${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -Dry-run strategy: client -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -apply phase started -pod/pod-b apply successful -pod/pod-c apply successful -pod/pod-d apply successful -apply phase finished -prune phase started -pod/pod-a prune successful -prune phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -prune result: 1 attempted, 1 successful, 0 skipped, 0 failed -EOF -printResult - -# Validate resources in the cluster -# ConfigMap inventory with four inventory items. -assertRGInventory "rg-test-namespace" "4" -assertPodExists "pod-a" "rg-test-namespace" -assertPodExists "pod-b" "rg-test-namespace" -assertPodExists "pod-c" "rg-test-namespace" -printResult - -# Test: Basic kpt live apply/prune -# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added. -echo "[ResourceGroup] Testing basic prune" -echo "kpt live apply e2e/live/testdata/rg-test-case-1b" -${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status -assertNotContains "installing inventory ResourceGroup CRD" # CRD already installed -assertKptLiveApplyEquals << EOF -inventory update started -inventory update finished -apply phase started -namespace/rg-test-namespace apply successful -apply phase finished -reconcile phase started -namespace/rg-test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-b apply successful -pod/pod-c apply successful -pod/pod-d apply successful -apply phase finished -reconcile phase started -pod/pod-b reconcile successful -pod/pod-c reconcile successful -pod/pod-d reconcile successful -reconcile phase finished -prune phase started -pod/pod-a prune successful -prune phase finished -reconcile phase started -pod/pod-a reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -prune result: 1 attempted, 1 successful, 0 skipped, 0 failed -reconcile result: 5 attempted, 5 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Validate resources in the cluster -# ConfigMap inventory with four inventory items. -assertRGInventory "rg-test-namespace" "4" -assertPodExists "pod-b" "rg-test-namespace" -assertPodExists "pod-c" "rg-test-namespace" -assertPodExists "pod-d" "rg-test-namespace" -assertPodNotExists "pod-a" "rg-test-namespace" -printResult - -# Basic kpt live destroy --dry-run -echo "[ResourceGroup] Testing basic destroy dry-run" -echo "kpt live destroy --dry-run e2e/live/testdata/rg-test-case-1b" -${BIN_DIR}/kpt live destroy --dry-run e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -Dry-run strategy: client -delete phase started -pod/pod-d delete successful -pod/pod-c delete successful -pod/pod-b delete successful -delete phase finished -delete phase started -namespace/rg-test-namespace delete successful -delete phase finished -inventory update started -inventory update finished -delete result: 4 attempted, 4 successful, 0 skipped, 0 failed -EOF -printResult - -# Validate resources NOT DESTROYED in the cluster -assertPodExists "pod-b" "rg-test-namespace" -assertPodExists "pod-c" "rg-test-namespace" -assertPodExists "pod-d" "rg-test-namespace" -printResult - -# Test: Basic kpt live destroy -# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added. -echo "[ResourceGroup] Testing basic destroy" -echo "kpt live destroy e2e/live/testdata/rg-test-case-1b" -${BIN_DIR}/kpt live destroy e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -delete phase started -pod/pod-d delete successful -pod/pod-c delete successful -pod/pod-b delete successful -delete phase finished -reconcile phase started -pod/pod-c reconcile successful -pod/pod-b reconcile successful -pod/pod-d reconcile successful -reconcile phase finished -delete phase started -namespace/rg-test-namespace delete successful -delete phase finished -reconcile phase started -namespace/rg-test-namespace reconcile successful -reconcile phase finished -inventory update started -inventory update finished -delete result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Validate resources NOT in the cluster -assertPodNotExists "pod-b" "rg-test-namespace" -assertPodNotExists "pod-c" "rg-test-namespace" -assertPodNotExists "pod-d" "rg-test-namespace" -printResult - -# Test: Basic kpt live apply/status/destroy from stdin -# -echo "Testing apply/status/destroy from stdin" -echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live apply -" -cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live apply - 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -inventory update started -inventory update finished -apply phase started -namespace/stdin-test-namespace apply successful -apply phase finished -reconcile phase started -namespace/stdin-test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -reconcile phase started -pod/pod-a reconcile successful -pod/pod-b reconcile successful -pod/pod-c reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live status -" -cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live status - 2>&1 | tee $OUTPUT_DIR/status -assertContains "inventory-18030002/namespace//stdin-test-namespace is Current: Resource is current" -assertContains "inventory-18030002/pod/stdin-test-namespace/pod-a is Current: Pod is Ready" -assertContains "inventory-18030002/pod/stdin-test-namespace/pod-b is Current: Pod is Ready" -assertContains "inventory-18030002/pod/stdin-test-namespace/pod-c is Current: Pod is Ready" -printResult - -echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live destroy -" -cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live destroy - 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -delete phase started -pod/pod-c delete successful -pod/pod-b delete successful -pod/pod-a delete successful -delete phase finished -reconcile phase started -pod/pod-c reconcile successful -pod/pod-b reconcile successful -pod/pod-a reconcile successful -reconcile phase finished -delete phase started -namespace/stdin-test-namespace delete successful -delete phase finished -reconcile phase started -namespace/stdin-test-namespace reconcile successful -reconcile phase finished -inventory update started -inventory update finished -delete result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -printResult - -# Test: kpt live apply continue-on-error -echo "[ResourceGroup] Testing continue-on-error" -echo "kpt live apply e2e/live/testdata/continue-on-error" -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/continue-on-error -${BIN_DIR}/kpt live init e2e/live/testdata/continue-on-error 2>&1 | tee $OUTPUT_DIR/status -diff e2e/live/testdata/Kptfile e2e/live/testdata/continue-on-error/resourcegroup.yaml 2>&1 | tee $OUTPUT_DIR/status -assertContains "namespace: continue-err-namespace" -printResult - -echo "kpt live apply e2e/live/testdata/continue-on-error" -${BIN_DIR}/kpt live apply e2e/live/testdata/continue-on-error 2>&1 | tee $OUTPUT_DIR/status - -if [[ "$(kubeServerMinorVersion)" -ge 20 ]]; then # >= 1.20.x - # https://github.com/kubernetes/kubernetes/blob/v1.20.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L199 - RFC1123_ERROR="a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character" -else # < 1.20.x - # https://github.com/kubernetes/kubernetes/blob/v1.19.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L199 - RFC1123_ERROR="a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character" -fi - -assertKptLiveApplyEquals << EOF -inventory update started -inventory update finished -apply phase started -namespace/continue-err-namespace apply successful -apply phase finished -reconcile phase started -namespace/continue-err-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-B apply failed: error when creating "pod-b.yaml": Pod "pod-B" is invalid: metadata.name: Invalid value: "pod-B": ${RFC1123_ERROR} (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*') -apply phase finished -reconcile phase started -pod/pod-B reconcile skipped -pod/pod-a reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 3 attempted, 2 successful, 0 skipped, 1 failed -reconcile result: 3 attempted, 2 successful, 1 skipped, 0 failed, 0 timed out -EOF -printResult - -assertRGInventory "continue-err-namespace" "2" -assertPodExists "pod-a" "continue-err-namespace" -assertPodNotExists "pod-B" "continue-err-namespace" -printResult - -# Test: RBAC error applying a resource -echo "Testing RBAC error during apply" -# Setup: create a service account and bind a Role to it so it has administrative -# privileges on the "test" namespace, but no permissions on the default -# namespace. -echo "kubectl apply -f e2e/live/testdata/rbac-error-step-1" -kubectl apply -f e2e/live/testdata/rbac-error-step-1 2>&1 | tee $OUTPUT_DIR/status -assertContains "namespace/rbac-error created" -assertContains "rolebinding.rbac.authorization.k8s.io/admin created" -assertContains "serviceaccount/user created" -printResult -wait 2 - -# Setup: use the service account just created. It does not have permissions -# on the default namespace, so it will give a permissions error on apply -# for anything attempted to apply to the default namespace. -echo "kubectl apply -f e2e/live/testdata/rbac-error-step-2" -kubectl apply -f e2e/live/testdata/rbac-error-step-2 2>&1 | tee $OUTPUT_DIR/status -assertContains "secret/user-credentials created" -wait 2 -SECRET_NAME="user-credentials" -echo "kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d" -SECRET_TOKEN="$(kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d)" -echo "kubectl config set-credentials user --token \"\"" -kubectl config set-credentials user --token "${SECRET_TOKEN}" 2>&1 | tee $OUTPUT_DIR/status -echo "kubectl config set-context kind-kind:user --cluster=kind-kind" -kubectl config set-context kind-kind:user --cluster=kind-kind --user=user 2>&1 | tee $OUTPUT_DIR/status -echo "kubectl config use-context kind-kind:user" -kubectl config use-context kind-kind:user 2>&1 | tee $OUTPUT_DIR/status -printResult -wait 2 - -# Attempt to apply two ConfigMaps: one in the default namespace (fails), and one -# in the "rbac-error" namespace (succeeds). -echo "kpt live apply --install-resource-group=false e2e/live/testdata/rbac-error-step-3" -${BIN_DIR}/kpt live apply --install-resource-group=false e2e/live/testdata/rbac-error-step-3 2>&1 | tee $OUTPUT_DIR/status -assertNotContains "installing inventory ResourceGroup CRD" # CRD already installed -assertContains 'error: polling for status failed: failed to list /v1, Kind=ConfigMap: configmaps is forbidden: User "system:serviceaccount:default:user" cannot list resource "configmaps" in API group "" at the cluster scope' -printResult - -# No inventory expected - permission error causes early exit -echo "kubectl get resourcegroups.kpt.dev -n 'rbac-error' --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers" -kubectl get resourcegroups.kpt.dev -n 'rbac-error' --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers 2>&1 | tee $OUTPUT_DIR/status -assertContains "No resources found" -printResult - -########################################################### -# Test --rg-file flag on live init commands -########################################################### - -createTestSuite -waitForDefaultServiceAccount - -# Setup: kpt live init with custom resourcegroup file -# Applies resources in "test-case-1c" directory -echo "Testing kpt live init with custom ResourceGroup file" -echo "kpt live init --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c" -${BIN_DIR}/kpt live init --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status -assertContains "initializing \"custom-rg.yaml\" data (namespace: test-namespace)...success" -printResult -# Re-running live init should fail as ResourceGroup file already exists -${BIN_DIR}/kpt live init --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status -assertContains "initializing \"custom-rg.yaml\" data (namespace: test-namespace)...failed" -printResult - -# Run: kpt live apply with custom resourcegroup file -echo "Testing kpt live apply with custom ResourceGroup filename" -echo "kpt live apply e2e/live/testdata/test-case-1c" -${BIN_DIR}/kpt live apply e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status -cat $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -installing inventory ResourceGroup CRD. -inventory update started -inventory update finished -apply phase started -namespace/test-namespace apply successful -apply phase finished -reconcile phase started -namespace/test-namespace reconcile successful -reconcile phase finished -apply phase started -pod/pod-a apply successful -pod/pod-b apply successful -pod/pod-c apply successful -apply phase finished -reconcile phase started -pod/pod-a reconcile pending -pod/pod-b reconcile pending -pod/pod-c reconcile pending -pod/pod-a reconcile successful -pod/pod-b reconcile successful -pod/pod-c reconcile successful -reconcile phase finished -inventory update started -inventory update finished -apply result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -# Validate resources in the cluster -# ResourceGroup inventory with four inventory items. -assertRGInventory "test-namespace" "4" -assertPodExists "pod-a" "test-namespace" -assertPodExists "pod-b" "test-namespace" -assertPodExists "pod-c" "test-namespace" -printResult - -echo "Testing live destroy with custom ResourceGroup filename" -echo "kpt live destroy --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c" -${BIN_DIR}/kpt live destroy e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status -assertKptLiveApplyEquals << EOF -delete phase started -pod/pod-c delete successful -pod/pod-b delete successful -pod/pod-a delete successful -delete phase finished -reconcile phase started -pod/pod-c reconcile pending -pod/pod-b reconcile pending -pod/pod-a reconcile pending -pod/pod-b reconcile successful -pod/pod-c reconcile successful -pod/pod-a reconcile successful -reconcile phase finished -delete phase started -namespace/test-namespace delete successful -delete phase finished -reconcile phase started -namespace/test-namespace reconcile pending -namespace/test-namespace reconcile successful -reconcile phase finished -inventory update started -inventory update finished -delete result: 4 attempted, 4 successful, 0 skipped, 0 failed -reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out -EOF -# Validate resources DESTROYED in the cluster -assertPodNotExists "pod-a" "test-namespace" -assertPodNotExists "pod-b" "test-namespace" -assertPodNotExists "pod-c" "test-namespace" -printResult - -# Clean-up the k8s cluster -echo "Cleaning up cluster" -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1b/ -cp -f e2e/live/testdata/Kptfile e2e/live/testdata/continue-on-error/ -kind delete cluster -echo -e "Cleaning up cluster...${GREEN}SUCCESS${NC}" - -# Return error code if tests have failed -if [[ ${HAS_TEST_FAILURE} -gt 0 ]]; then - echo -e "${RED}ERROR: E2E Tests Failed${NC}" - exit ${HAS_TEST_FAILURE} -else - echo -e "${GREEN}SUCCESS: E2E Tests Passed${NC}" - exit 0 +#!/usr/bin/env bash +########################################################################### +# Copyright 2020 The kpt Authors +# +# 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. +# +# Description: +# Validates multiple scenarios for kpt live commands. +# +# How to use this script: +# FROM KPT ROOT DIR: ./e2e/live/end-to-end-test.sh +# +# Example KPT ROOT DIR: +# ~/go/src/github.com/kptdev/kpt +# +# Flags: +# -b) Build the kpt binary with dependencies at HEAD. Downloads HEAD +# for cli-utils and kustomize repositories, and builds kpt using +# these downloaded repositories. +# -k) Run against this Kubernetes version. Creates a local Kubernetes +# cluster at this version using "kind". Only accepts MAJOR.MINOR. +# Example: 1.17. This is translated to a patch version. Example: +# 1.17 runs version 1.17.11. +# +# Prerequisites (must be in $PATH): +# kind - Kubernetes in Docker +# kubectl - version of kubectl should be within +/- 1 version of cluster. +# CHECK: $ kubectl version +# +# Examples: +# $ ./e2e/live/end-to-end-test.sh -b +# $ ./e2e/live/end-to-end-test.sh -k 1.17 +# $ ./e2e/live/end-to-end-test.sh -bk 1.17 +# +########################################################################### + +# TODO +# 1) Validate prerequisites (e.g. kind, kubectl) +# 2) Refactor helper functions into another file +# 3) Fix -k +# 4) Add "-v" verbosity level flags +# 5) Count the test cases and print it out +# 6) Print timing for the tests + + +########################################################################### +# Parameters/args +########################################################################### + +# A POSIX variable; reset in case getopts has been used previously in the shell. +OPTIND=1 + +# Kind/Kubernetes versions. + +KIND_1_34_VERSION=1.34.0@sha256:7416a61b42b1662ca6ca89f02028ac133a309a2a30ba309614e8ec94d976dc5a +KIND_1_33_VERSION=1.33.4@sha256:25a6018e48dfcaee478f4a59af81157a437f15e6e140bf103f85a2e7cd0cbbf2 +KIND_1_32_VERSION=1.32.8@sha256:abd489f042d2b644e2d033f5c2d900bc707798d075e8186cb65e3f1367a9d5a1 +KIND_1_31_VERSION=1.31.12@sha256:0f5cc49c5e73c0c2bb6e2df56e7df189240d83cf94edfa30946482eb08ec57d2 +KIND_1_30_VERSION=1.30.13@sha256:397209b3d947d154f6641f2d0ce8d473732bd91c87d9575ade99049aa33cd648 +KIND_1_29_VERSION=1.29.12@sha256:62c0672ba99a4afd7396512848d6fc382906b8f33349ae68fb1dbfe549f70dec +KIND_1_28_VERSION=1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31 +KIND_1_27_VERSION=1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 +KIND_1_26_VERSION=1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb +KIND_1_25_VERSION=1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 +KIND_1_24_VERSION=1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab +KIND_1_23_VERSION=1.23.17@sha256:59c989ff8a517a93127d4a536e7014d28e235fb3529d9fba91b3951d461edfdb +KIND_1_22_VERSION=1.22.17@sha256:f5b2e5698c6c9d6d0adc419c0deae21a425c07d81bbf3b6a6834042f25d4fba2 +KIND_1_21_VERSION=1.21.14@sha256:8a4e9bb3f415d2bb81629ce33ef9c76ba514c14d707f9797a01e3216376ba093 + + + +NOTE: You must use the @sha256 digest to guarantee an image built for this release, until such a time as we switch to a different tagging scheme. Even then we will highly encourage digest pinning for security and reproducibility reasons. + +DEFAULT_K8S_VERSION=${KIND_1_34_VERSION} + +# Change from empty string to build the kpt binary from the downloaded +# repositories at HEAD, including dependencies cli-utils and kustomize. +BUILD_DEPS_AT_HEAD="" + +# Default Kubernetes cluster version to run test against. +K8S_VERSION=${DEFAULT_K8S_VERSION} + +HAS_TEST_FAILURE=0 + +# Parse/validate parameters +options="bk:" +while getopts $options opt; do + case "$opt" in + b) BUILD_DEPS_AT_HEAD=1;; + k) short_version=$OPTARG + case "$short_version" in + 1.21) K8S_VERSION=$KIND_1_21_VERSION + ;; + 1.22) K8S_VERSION=$KIND_1_22_VERSION + ;; + 1.23) K8S_VERSION=$KIND_1_23_VERSION + ;; + 1.24) K8S_VERSION=$KIND_1_24_VERSION + ;; + 1.25) K8S_VERSION=$KIND_1_25_VERSION + ;; + 1.26) K8S_VERSION=$KIND_1_26_VERSION + ;; + 1.27) K8S_VERSION=$KIND_1_27_VERSION + ;; + 1.28) K8S_VERSION=$KIND_1_28_VERSION + ;; + 1.29) K8S_VERSION=$KIND_1_29_VERSION + ;; + 1.30) K8S_VERSION=$KIND_1_30_VERSION + ;; + 1.31) K8S_VERSION=$KIND_1_31_VERSION + ;; + 1.32) K8S_VERSION=$KIND_1_32_VERSION + ;; + 1.33) K8S_VERSION=$KIND_1_33_VERSION + ;; + 1.34) K8S_VERSION=$KIND_1_34_VERSION + ;; + *) K8S_VERSION=$short_version + ;; + esac + ;; + \? ) echo "Usage: $0 [-b] [-k k8s-version]" >&2; exit 1;; + esac +done + +shift $((OPTIND-1)) + +[ "${1:-}" = "--" ] && shift + +########################################################################### +# Colors +########################################################################### + +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +########################################################################### +# Helper functions +########################################################################### + +# buildKpt builds the kpt binary, storing it in the temporary directory. +# To check the stdout output of the build check $OUTPUT_DIR/kptbuild. +# stderr output will be output to the terminal. +function buildKpt { + set -e + if [ -z $BUILD_DEPS_AT_HEAD ]; then + echo "checking go version" + go version + echo "Building kpt locally..." + go build -o $BIN_DIR -v . > $OUTPUT_DIR/kptbuild 2>&1 + echo -e "Building kpt locally...${GREEN}SUCCESS${NC}" + + else + echo "Building kpt using dependencies at HEAD..." + echo + # Clone kpt repository into kpt source directory + KPT_SRC_DIR="${SRC_DIR}/github.com/kptdev/kpt" + mkdir -p $KPT_SRC_DIR + echo "Downloading kpt repository at HEAD..." + git clone https://github.com/kptdev/kpt ${KPT_SRC_DIR} > ${OUTPUT_DIR}/kptbuild 2>&1 + echo -e "Downloading kpt repository at HEAD...${GREEN}SUCCESS${NC}" + # Clone cli-utils repository into source directory + CLI_UTILS_SRC_DIR="${SRC_DIR}/sigs.k8s.io/cli-utils" + mkdir -p $CLI_UTILS_SRC_DIR + echo "Downloading cli-utils repository at HEAD..." + git clone https://github.com/kubernetes-sigs/cli-utils ${CLI_UTILS_SRC_DIR} > ${OUTPUT_DIR}/kptbuild 2>&1 + echo -e "Downloading cli-utils repository at HEAD...${GREEN}SUCCESS${NC}" + # Clone kustomize respository into source directory + KUSTOMIZE_SRC_DIR="${SRC_DIR}/sigs.k8s.io/kustomize" + mkdir -p $KUSTOMIZE_SRC_DIR + echo "Downloading kustomize repository at HEAD..." + git clone https://github.com/kubernetes-sigs/kustomize ${KUSTOMIZE_SRC_DIR} > ${OUTPUT_DIR}/kptbuild 2>&1 + echo -e "Downloading kustomize repository at HEAD...${GREEN}SUCCESS${NC}" + # Tell kpt to build using the locally downloaded dependencies + echo "Updating kpt/go.mod to reference locally downloaded repositories..." + echo -e "\n\nreplace sigs.k8s.io/cli-utils => ../../../sigs.k8s.io/cli-utils" >> ${KPT_SRC_DIR}/go.mod + echo -e "replace sigs.k8s.io/kustomize/cmd/config => ../../../sigs.k8s.io/kustomize/cmd/config" >> ${KPT_SRC_DIR}/go.mod + echo -e "replace sigs.k8s.io/kustomize/kyaml => ../../../sigs.k8s.io/kustomize/kyaml\n" >> ${KPT_SRC_DIR}/go.mod + echo -e "Updating kpt/go.mod to reference locally downloaded repositories...${GREEN}SUCCESS${NC}" + # Build kpt using the cloned directories + export GOPATH=${TMP_DIR} + echo "Building kpt..." + (cd -- ${KPT_SRC_DIR} && go build -o $BIN_DIR -v . > ${OUTPUT_DIR}/kptbuild) + echo -e "Building kpt...${GREEN}SUCCESS${NC}" + echo + echo -e "Building kpt using dependencies at HEAD...${GREEN}SUCCESS${NC}" + fi + set +e +} + +# createTestSuite deletes then creates the kind cluster. We wait for the node +# to become ready before we run the tests. +function createTestSuite { + set -e + echo "Setting Up Test Suite..." + echo + # Create the k8s cluster + echo "Deleting kind cluster..." + kind delete cluster > /dev/null 2>&1 + echo -e "Deleting kind cluster...${GREEN}SUCCESS${NC}" + echo "Creating kind cluster..." + kind create cluster --image=kindest/node:v${K8S_VERSION} --wait=2m > $OUTPUT_DIR/k8sstartup 2>&1 + kubectl wait node/kind-control-plane --for condition=ready --timeout=2m + echo -e "Creating kind cluster...${GREEN}SUCCESS${NC}" + echo + echo -e "Setting Up Test Suite...${GREEN}SUCCESS${NC}" + echo + set +e +} + +function waitForDefaultServiceAccount { + # Necessary to ensure default service account is created before pods. + echo -n "Waiting for default service account..." + echo -n ' ' + sp="/-\|" + n=1 + until ((n >= 300)); do + kubectl -n default get serviceaccount default -o name 2>&1 | tee $OUTPUT_DIR/status + test 1 == $(grep "serviceaccount/default" $OUTPUT_DIR/status | wc -l) + if [ $? == 0 ]; then + echo + break + fi + printf "\b${sp:n++%${#sp}:1}" + sleep 0.2 + done + ((n < 300)) + echo "Waiting for default service account...CREATED" + echo +} + +# assertKptLiveApplyEquals checks that the STDIN equals the content of the +# $OUTPUT_DIR/status file, after filtering and sorting. +function assertKptLiveApplyEquals { + local expected="$(cat | processKptLiveOutput)" + local received="$(cat "$OUTPUT_DIR/status" | processKptLiveOutput)" + local diff_result="$( diff -u <(echo -e "${expected}") <(echo -e "${received}") --label "expected" --label "received")" + if [[ -z "${diff_result}" ]]; then + echo -n '.' + else + echo -n 'E' + echo -e "error: expected output ():\n${diff_result}" >> "$OUTPUT_DIR/errors" + HAS_TEST_FAILURE=1 + fi +} + +function processKptLiveOutput { + trimTrailingNewlines | \ + filterReconcilePending | \ + filterWarning | \ + sortReconcileEvents | \ + sortActuationEvents +} + +function trimTrailingNewlines { + sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' +} + +function filterReconcilePending { + grep -v " reconcile pending$" | \ + grep -v " unrecognized format .*int64.*$" || true +} + +function filterWarning { + grep -v " unknown field" || true +} + +# sortReconcileEvents sorts reconcile events: successful > failed. +# Not sorted: skipped (always first) & timeout (always last). +function sortReconcileEvents { + local input="$(cat)" # read full input before sorting + local status="" + local successfulBuffer="" + local failedBuffer="" + local pattern="^.* reconcile (successful|failed).*$" + while IFS="" read -r line; do + if [[ "${line}" =~ ${pattern} ]]; then + # match - add line to buffer + status="${BASH_REMATCH[1]}" + if [[ "${status}" == "successful" ]]; then + successfulBuffer+="${line}\n" + elif [[ "${status}" == "failed" ]]; then + failedBuffer+="${line}\n" + else + echo "ERROR: Unexpected reconcile status: ${status}" + return + fi + else + # no match - dump buffers & print line + if [[ -n "${successfulBuffer}" ]]; then + echo -en "${successfulBuffer}" | sort + successfulBuffer="" + fi + if [[ -n "${failedBuffer}" ]]; then + echo -en "${failedBuffer}" | sort + failedBuffer="" + fi + echo "${line}" + fi + done <<< "${input}" + # end of input - dump buffers + if [[ -n "${successfulBuffer}" ]]; then + echo -en "${successfulBuffer}" | sort + successfulBuffer="" + fi + if [[ -n "${failedBuffer}" ]]; then + echo -en "${failedBuffer}" | sort + failedBuffer="" + fi +} + +# sortActuationEvents sorts apply/prune/delete events: skipped > successful > failed. +# Only events with the same actuation type and resource type are sorted. +function sortActuationEvents { + local input="$(cat)" # read full input before sorting + local status="" + local resource="" + local actuation="" + local skippedBuffer="" + local successfulBuffer="" + local failedBuffer="" + local pattern="^(.*)/(.*) (apply|prune|delete) (skipped|successful|failed).*$" + while IFS="" read -r line; do + if [[ "${line}" =~ ${pattern} ]]; then + # match + if [[ "${resource}" != "${BASH_REMATCH[1]}" ]] || [[ "${actuation}" != "${BASH_REMATCH[3]}" ]]; then + # different resource/actuation - dump buffers & update resource/actuation + if [[ -n "${skippedBuffer}" ]]; then + echo -en "${skippedBuffer}" | sort + skippedBuffer="" + fi + if [[ -n "${successfulBuffer}" ]]; then + echo -en "${successfulBuffer}" | sort + successfulBuffer="" + fi + if [[ -n "${failedBuffer}" ]]; then + echo -en "${failedBuffer}" | sort + failedBuffer="" + fi + resource="${BASH_REMATCH[1]}" + actuation="${BASH_REMATCH[3]}" + fi + + # add line to buffer + status="${BASH_REMATCH[4]}" + if [[ "${status}" == "skipped" ]]; then + skippedBuffer+="${line}\n" + elif [[ "${status}" == "successful" ]]; then + successfulBuffer+="${line}\n" + elif [[ "${status}" == "failed" ]]; then + failedBuffer+="${line}\n" + else + echo "ERROR: Unexpected ${actuation} status: ${status}" + return + fi + else + # no match - dump buffers & print line + if [[ -n "${skippedBuffer}" ]]; then + echo -en "${skippedBuffer}" | sort + skippedBuffer="" + fi + if [[ -n "${successfulBuffer}" ]]; then + echo -en "${successfulBuffer}" | sort + successfulBuffer="" + fi + if [[ -n "${failedBuffer}" ]]; then + echo -en "${failedBuffer}" | sort + failedBuffer="" + fi + echo "${line}" + resource="" + actuation="" + fi + done <<< "${input}" + # end of input - dump buffers + if [[ -n "${skippedBuffer}" ]]; then + echo -en "${skippedBuffer}" | sort + skippedBuffer="" + fi + if [[ -n "${successfulBuffer}" ]]; then + echo -en "${successfulBuffer}" | sort + successfulBuffer="" + fi + if [[ -n "${failedBuffer}" ]]; then + echo -en "${failedBuffer}" | sort + failedBuffer="" + fi +} + +# assertContains checks that the passed string is a substring of +# the $OUTPUT_DIR/status file. +function assertContains { + local test_arg="$@" + test 1 == \ + $(grep "$test_arg" $OUTPUT_DIR/status | wc -l); \ + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: expected missing text \"${test_arg}\"" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi +} + +# assertNotContains checks that the passed string is NOT a substring of +# the $OUTPUT_DIR/status file. +function assertNotContains { + local test_arg="$@" + test 0 == \ + $(grep "$test_arg" $OUTPUT_DIR/status | wc -l); \ + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: unexpected text \"${test_arg}\" found" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi +} + +# assertCMInventory checks that a ConfigMap inventory object exists in +# the passed namespace with the passed number of inventory items. +# Assumes the inventory object name begins with "inventory-". +function assertCMInventory { + local ns=$1 + local numInv=$2 + + echo "kubectl get cm -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers" + inv=$(kubectl get cm -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers) + echo $inv | awk '{print $1}' > $OUTPUT_DIR/invname + echo $inv | awk '{print $2}' > $OUTPUT_DIR/numinv + + test 1 == $(grep "inventory-" $OUTPUT_DIR/invname | wc -l); + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: expected missing ConfigMap inventory object in ${ns} namespace" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi + + test 1 == $(grep $numInv $OUTPUT_DIR/numinv | wc -l); + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: expected ConfigMap inventory to have $numInv inventory items" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi +} + +# assertRGInventory checks that a ResourceGroup inventory object exists +# in the passed namespace. Assumes the inventory object name begins +# with "inventory-". +function assertRGInventory { + local ns=$1 + + echo "kubectl get resourcegroups.kpt.dev -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | awk '{print $1}'" + kubectl get resourcegroups.kpt.dev -n $ns --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers | awk '{print $1}' > $OUTPUT_DIR/invname + + test 1 == $(grep "inventory-" $OUTPUT_DIR/invname | wc -l); + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: expected missing ResourceGroup inventory in ${ns} namespace" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi +} + +# assertPodExists checks that a pod with the passed podName and passed +# namespace exists in the cluster. +TIMEOUT_SECS=30 +function assertPodExists { + local podName=$1 + local namespace=$2 + + echo "kubectl wait --for=condition=Ready -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s" + kubectl wait --for=condition=Ready -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s > /dev/null 2>&1 + echo "kubectl get po -n $namespace $podName -o name | awk '{print $1}'" + kubectl get po -n $namespace $podName -o name | awk '{print $1}' > $OUTPUT_DIR/podname + + test 1 == $(grep $podName $OUTPUT_DIR/podname | wc -l); + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: expected missing pod $namespace/$podName in ${namespace} namespace" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi +} + +# assertPodNotExists checks that a pod with the passed podName and passed +# namespace DOES NOT exist in the cluster. Waits 20 seconds for pod +# termination if pod has not finished deleting. +function assertPodNotExists { + local podName=$1 + local namespace=$2 + + echo "kubectl wait --for=delete -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s" + kubectl wait --for=delete -n $namespace pod/$podName --timeout=${TIMEOUT_SECS}s > /dev/null 2>&1 + echo "kubectl get po -n $namespace $podName -o name" + kubectl get po -n $namespace $podName -o name > $OUTPUT_DIR/podname 2>&1 + + test 1 == $(grep "(NotFound)" $OUTPUT_DIR/podname | wc -l); + if [ $? == 0 ]; then + echo -n '.' + else + echo -n 'E' + if [ ! -f $OUTPUT_DIR/errors ]; then + touch $OUTPUT_DIR/errors + fi + echo "error: unexpected pod $namespace/$podName found in ${namespace} namespace" >> $OUTPUT_DIR/errors + HAS_TEST_FAILURE=1 + fi +} + +# printResult prints the results of the previous assert statements +function printResult { + if [ -f $OUTPUT_DIR/errors ]; then + echo -e "${RED}ERROR${NC}" + cat $OUTPUT_DIR/errors + echo + rm -f $OUTPUT_DIR/errors + else + echo -e "${GREEN}SUCCESS${NC}" + fi + echo +} + +# wait sleeps for the passed number of seconds. +function wait { + local numSecs=$1 + + sleep $numSecs +} + +SEMVER_PATTERN="v(.*)\.(.*)\.(.*)" + +function kubeServerVersion { + kubectl version --output=json | jq -r '.serverVersion.gitVersion' +} + +function kubeServerMinorVersion { + if [[ "$(kubeServerVersion)" =~ ${SEMVER_PATTERN} ]]; then + echo "${BASH_REMATCH[2]}" + else + return 1 + fi +} + +########################################################################### +# Main +########################################################################### + +# Setup temporary directory for src, bin, and output. +TMP_DIR=$(mktemp -d -t kpt-e2e-XXXXXXXXXX) +SRC_DIR="${TMP_DIR}/src" +mkdir -p $SRC_DIR +BIN_DIR="${TMP_DIR}/bin" +mkdir -p ${BIN_DIR} +OUTPUT_DIR="${TMP_DIR}/output" +mkdir -p $OUTPUT_DIR + +# Build the kpt binary and copy it to the temp dir. If BUILD_DEPS_AT_HEAD +# is set, then copy the kpt repository AND dependency directories into +# TMP_DIR and build from there. +echo "kpt end-to-end test" +echo +echo "Kubernetes Version: ${K8S_VERSION}" +echo "Temp Dir: $TMP_DIR" +echo + +buildKpt + +echo +set +e # Do not stop the test for errors + +############################################################# +# Tests without initial ResourceGroup inventory installation +############################################################# + +createTestSuite +waitForDefaultServiceAccount + +# Basic init as setup for follow-on tests +# Test: Apply dry-run without ResourceGroup CRD installation fails +echo "[ResourceGroup] Testing initial apply dry-run without ResourceGroup inventory CRD" +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ +echo "kpt live init --quiet e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live init --quiet e2e/live/testdata/rg-test-case-1a +echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertContains "Error: The ResourceGroup CRD was not found in the cluster. Please install it either by using the '--install-resource-group' flag or the 'kpt live install-resource-group' command." +printResult + +# Test: Apply installs ResourceGroup CRD +echo "[ResourceGroup] Testing create inventory CRD before basic apply" +echo "kpt live apply e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +# The ResourceGroup inventory CRD is automatically installed on the initial apply. +assertKptLiveApplyEquals << EOF +installing inventory ResourceGroup CRD. +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +reconcile phase started +namespace/rg-test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +reconcile phase started +pod/pod-a reconcile successful +pod/pod-b reconcile successful +pod/pod-c reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Validate resources in the cluster +# ConfigMap inventory with four inventory items. +assertRGInventory "rg-test-namespace" "4" +printResult + +# Apply again, but the ResourceGroup CRD is not re-installed. +echo "kpt live apply e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertNotContains "installing inventory ResourceGroup CRD" # Not applied again +assertKptLiveApplyEquals << EOF +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +reconcile phase started +namespace/rg-test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +reconcile phase started +pod/pod-a reconcile successful +pod/pod-b reconcile successful +pod/pod-c reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Cleanup by resetting Kptfile and deleting resourcegroup file +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ +rm e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml + +########################################################### +# Tests operations with ResourceGroup inventory CRD +########################################################### + +createTestSuite +waitForDefaultServiceAccount + +# Test: Installing ResourceGroup CRD +echo "Installing ResourceGroup CRD" +# First, check that the ResourceGroup CRD does NOT exist +echo "kubectl get resourcegroups.kpt.dev" +kubectl get resourcegroups.kpt.dev 2>&1 | tee $OUTPUT_DIR/status +assertContains "error: the server doesn't have a resource type \"resourcegroups\"" +# Next, add the ResourceGroup CRD +echo "kpt live install-resource-group" +${BIN_DIR}/kpt live install-resource-group 2> /dev/null | tee $OUTPUT_DIR/status +assertContains "installing inventory ResourceGroup CRD...success" +echo "kubectl get resourcegroups.kpt.dev" +kubectl get resourcegroups.kpt.dev 2>&1 | tee $OUTPUT_DIR/status +assertContains "No resources found" +# Add a simple ResourceGroup custom resource, and verify it exists in the cluster. +echo "kubectl apply -f e2e/live/testdata/install-rg-crd/example-resource-group.yaml" +kubectl apply -f e2e/live/testdata/install-rg-crd/example-resource-group.yaml 2>&1 | tee $OUTPUT_DIR/status +assertContains "resourcegroup.kpt.dev/example-inventory created" +echo "kubectl get resourcegroups.kpt.dev --no-headers" +kubectl get resourcegroups.kpt.dev --no-headers 2>&1 | tee $OUTPUT_DIR/status +assertContains "example-inventory" +# Finally, add the ResourceGroup CRD again, and check it says it already exists. +echo "kpt live install-resource-group" +${BIN_DIR}/kpt live install-resource-group 2> /dev/null | tee $OUTPUT_DIR/status +assertContains "...success" +printResult + +# Test: Basic Kptfile/ResourceGroup inititalizing inventory info +echo "Testing init for Kptfile/ResourceGroup" +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ +echo "kpt live init e2e/live/testdata/rg-test-case-1a" +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a +${BIN_DIR}/kpt live init e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertContains "initializing \"resourcegroup.yaml\" data (namespace: rg-test-namespace)...success" +# Difference in Kptfile should have inventory data +diff e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/Kptfile 2>&1 | tee $OUTPUT_DIR/status +assertNotContains "inventory:" +assertNotContains "namespace: rg-test-namespace" +assertNotContains "name: inventory-" +assertNotContains "inventoryID:" +# ResourceGroup file should contain inventory information +cat e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml 2>&1 | tee $OUTPUT_DIR/status +assertContains "kind: ResourceGroup" +assertContains "namespace: rg-test-namespace" +assertContains "name: inventory-" +printResult + +echo "Testing init Kptfile/ResourceGroup already initialized" +echo "kpt live init e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live init e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertContains "initializing \"resourcegroup.yaml\" data (namespace: rg-test-namespace)...failed" +assertContains "Error: Inventory information has already been added to the package ResourceGroup object." +printResult + +echo "Testing init force Kptfile/ResourceGroup" +echo "kpt live init --force --name inventory-18030002 e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live init --force --name inventory-18030002 e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertContains "initializing \"resourcegroup.yaml\" data (namespace: rg-test-namespace)...success" +cat e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml 2>&1 | tee $OUTPUT_DIR/status +assertContains "name: inventory-18030002" +printResult + +echo "Testing init quiet Kptfile/ResourceGroup" +echo "kpt live init --quiet e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live init --quiet e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertNotContains "initializing resourcegroup" +printResult + +# Test: Basic kpt live apply dry-run +# Apply run-run for "rg-test-case-1a" directory +echo "[ResourceGroup] Testing initial apply dry-run" +echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +Dry-run strategy: client +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +EOF +printResult + +# Test: Basic kpt live apply +# Apply run for "rg-test-case-1a" directory +echo "[ResourceGroup] Testing basic apply" +echo "kpt live apply e2e/live/testdata/rg-test-case-1a" +${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +# The ResourceGroup CRD is already installed. +assertKptLiveApplyEquals << EOF +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +reconcile phase started +namespace/rg-test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +reconcile phase started +pod/pod-a reconcile successful +pod/pod-b reconcile successful +pod/pod-c reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Validate resources in the cluster +# ConfigMap inventory with four inventory items. +assertRGInventory "rg-test-namespace" "4" +printResult + +# Test: Basic kpt live apply on symlink +# Apply run for "rg-test-case-1a" directory +echo "[ResourceGroup] Testing basic apply on symlink" +rm -f link-to-rg-test-case-1a # Delete if exists +ln -s e2e/live/testdata/rg-test-case-1a/ link-to-rg-test-case-1a +trap "rm -f ${PWD}/link-to-rg-test-case-1a" EXIT +echo "kpt live apply link-to-rg-test-case-1a" +${BIN_DIR}/kpt live apply link-to-rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +# The ResourceGroup CRD is already installed. +assertNotContains "installing inventory ResourceGroup CRD" +assertKptLiveApplyEquals << EOF +[WARN] resolved symlink "link-to-rg-test-case-1a" to "e2e/live/testdata/rg-test-case-1a", please note that the symlinks within the package are ignored +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +reconcile phase started +namespace/rg-test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +reconcile phase started +pod/pod-a reconcile successful +pod/pod-b reconcile successful +pod/pod-c reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Validate resources in the cluster +# ConfigMap inventory with four inventory items. +assertRGInventory "rg-test-namespace" "4" +printResult + +# Test: Basic kpt live status on symlink +# Apply run for "rg-test-case-1a" directory +echo "[ResourceGroup] Testing basic status on symlink" +rm -f link-to-rg-test-case-1a # Delete if exists +ln -s e2e/live/testdata/rg-test-case-1a/ link-to-rg-test-case-1a +trap "rm -f ${PWD}/link-to-rg-test-case-1a" EXIT +echo "kpt live status link-to-rg-test-case-1a" +${BIN_DIR}/kpt live status link-to-rg-test-case-1a 2>&1 | tee $OUTPUT_DIR/status +# The ResourceGroup CRD is already installed. +assertNotContains "installing inventory ResourceGroup CRD" +assertKptLiveApplyEquals << EOF +[WARN] resolved symlink "link-to-rg-test-case-1a" to "e2e/live/testdata/rg-test-case-1a", please note that the symlinks within the package are ignored +inventory-18030002/namespace//rg-test-namespace is Current: Resource is current +inventory-18030002/pod/rg-test-namespace/pod-a is Current: Pod is Ready +inventory-18030002/pod/rg-test-namespace/pod-b is Current: Pod is Ready +inventory-18030002/pod/rg-test-namespace/pod-c is Current: Pod is Ready +EOF +printResult + +# Validate resources in the cluster +# ConfigMap inventory with four inventory items. +assertRGInventory "rg-test-namespace" "4" +printResult + +rm -rf link-to-rg-test-case-1a + +# Test: kpt live apply dry-run of with prune +# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added. +echo "[ResourceGroup] Testing basic apply dry-run" +cp -f e2e/live/testdata/rg-test-case-1a/Kptfile e2e/live/testdata/rg-test-case-1b/ +echo "kpt live apply --dry-run e2e/live/testdata/rg-test-case-1b" +cp -f e2e/live/testdata/rg-test-case-1a/Kptfile e2e/live/testdata/rg-test-case-1b +cp -f e2e/live/testdata/rg-test-case-1a/resourcegroup.yaml e2e/live/testdata/rg-test-case-1b +${BIN_DIR}/kpt live apply --dry-run e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +Dry-run strategy: client +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +apply phase started +pod/pod-b apply successful +pod/pod-c apply successful +pod/pod-d apply successful +apply phase finished +prune phase started +pod/pod-a prune successful +prune phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +prune result: 1 attempted, 1 successful, 0 skipped, 0 failed +EOF +printResult + +# Validate resources in the cluster +# ConfigMap inventory with four inventory items. +assertRGInventory "rg-test-namespace" "4" +assertPodExists "pod-a" "rg-test-namespace" +assertPodExists "pod-b" "rg-test-namespace" +assertPodExists "pod-c" "rg-test-namespace" +printResult + +# Test: Basic kpt live apply/prune +# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added. +echo "[ResourceGroup] Testing basic prune" +echo "kpt live apply e2e/live/testdata/rg-test-case-1b" +${BIN_DIR}/kpt live apply e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status +assertNotContains "installing inventory ResourceGroup CRD" # CRD already installed +assertKptLiveApplyEquals << EOF +inventory update started +inventory update finished +apply phase started +namespace/rg-test-namespace apply successful +apply phase finished +reconcile phase started +namespace/rg-test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-b apply successful +pod/pod-c apply successful +pod/pod-d apply successful +apply phase finished +reconcile phase started +pod/pod-b reconcile successful +pod/pod-c reconcile successful +pod/pod-d reconcile successful +reconcile phase finished +prune phase started +pod/pod-a prune successful +prune phase finished +reconcile phase started +pod/pod-a reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +prune result: 1 attempted, 1 successful, 0 skipped, 0 failed +reconcile result: 5 attempted, 5 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Validate resources in the cluster +# ConfigMap inventory with four inventory items. +assertRGInventory "rg-test-namespace" "4" +assertPodExists "pod-b" "rg-test-namespace" +assertPodExists "pod-c" "rg-test-namespace" +assertPodExists "pod-d" "rg-test-namespace" +assertPodNotExists "pod-a" "rg-test-namespace" +printResult + +# Basic kpt live destroy --dry-run +echo "[ResourceGroup] Testing basic destroy dry-run" +echo "kpt live destroy --dry-run e2e/live/testdata/rg-test-case-1b" +${BIN_DIR}/kpt live destroy --dry-run e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +Dry-run strategy: client +delete phase started +pod/pod-d delete successful +pod/pod-c delete successful +pod/pod-b delete successful +delete phase finished +delete phase started +namespace/rg-test-namespace delete successful +delete phase finished +inventory update started +inventory update finished +delete result: 4 attempted, 4 successful, 0 skipped, 0 failed +EOF +printResult + +# Validate resources NOT DESTROYED in the cluster +assertPodExists "pod-b" "rg-test-namespace" +assertPodExists "pod-c" "rg-test-namespace" +assertPodExists "pod-d" "rg-test-namespace" +printResult + +# Test: Basic kpt live destroy +# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added. +echo "[ResourceGroup] Testing basic destroy" +echo "kpt live destroy e2e/live/testdata/rg-test-case-1b" +${BIN_DIR}/kpt live destroy e2e/live/testdata/rg-test-case-1b 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +delete phase started +pod/pod-d delete successful +pod/pod-c delete successful +pod/pod-b delete successful +delete phase finished +reconcile phase started +pod/pod-c reconcile successful +pod/pod-b reconcile successful +pod/pod-d reconcile successful +reconcile phase finished +delete phase started +namespace/rg-test-namespace delete successful +delete phase finished +reconcile phase started +namespace/rg-test-namespace reconcile successful +reconcile phase finished +inventory update started +inventory update finished +delete result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Validate resources NOT in the cluster +assertPodNotExists "pod-b" "rg-test-namespace" +assertPodNotExists "pod-c" "rg-test-namespace" +assertPodNotExists "pod-d" "rg-test-namespace" +printResult + +# Test: Basic kpt live apply/status/destroy from stdin +# +echo "Testing apply/status/destroy from stdin" +echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live apply -" +cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live apply - 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +inventory update started +inventory update finished +apply phase started +namespace/stdin-test-namespace apply successful +apply phase finished +reconcile phase started +namespace/stdin-test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +reconcile phase started +pod/pod-a reconcile successful +pod/pod-b reconcile successful +pod/pod-c reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live status -" +cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live status - 2>&1 | tee $OUTPUT_DIR/status +assertContains "inventory-18030002/namespace//stdin-test-namespace is Current: Resource is current" +assertContains "inventory-18030002/pod/stdin-test-namespace/pod-a is Current: Pod is Ready" +assertContains "inventory-18030002/pod/stdin-test-namespace/pod-b is Current: Pod is Ready" +assertContains "inventory-18030002/pod/stdin-test-namespace/pod-c is Current: Pod is Ready" +printResult + +echo "cat e2e/live/testdata/stdin-test/pods.yaml | kpt live destroy -" +cat e2e/live/testdata/stdin-test/pods.yaml | ${BIN_DIR}/kpt live destroy - 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +delete phase started +pod/pod-c delete successful +pod/pod-b delete successful +pod/pod-a delete successful +delete phase finished +reconcile phase started +pod/pod-c reconcile successful +pod/pod-b reconcile successful +pod/pod-a reconcile successful +reconcile phase finished +delete phase started +namespace/stdin-test-namespace delete successful +delete phase finished +reconcile phase started +namespace/stdin-test-namespace reconcile successful +reconcile phase finished +inventory update started +inventory update finished +delete result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +printResult + +# Test: kpt live apply continue-on-error +echo "[ResourceGroup] Testing continue-on-error" +echo "kpt live apply e2e/live/testdata/continue-on-error" +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/continue-on-error +${BIN_DIR}/kpt live init e2e/live/testdata/continue-on-error 2>&1 | tee $OUTPUT_DIR/status +diff e2e/live/testdata/Kptfile e2e/live/testdata/continue-on-error/resourcegroup.yaml 2>&1 | tee $OUTPUT_DIR/status +assertContains "namespace: continue-err-namespace" +printResult + +echo "kpt live apply e2e/live/testdata/continue-on-error" +${BIN_DIR}/kpt live apply e2e/live/testdata/continue-on-error 2>&1 | tee $OUTPUT_DIR/status + +if [[ "$(kubeServerMinorVersion)" -ge 20 ]]; then # >= 1.20.x + # https://github.com/kubernetes/kubernetes/blob/v1.20.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L199 + RFC1123_ERROR="a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character" +else # < 1.20.x + # https://github.com/kubernetes/kubernetes/blob/v1.19.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L199 + RFC1123_ERROR="a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character" +fi + +assertKptLiveApplyEquals << EOF +inventory update started +inventory update finished +apply phase started +namespace/continue-err-namespace apply successful +apply phase finished +reconcile phase started +namespace/continue-err-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-B apply failed: error when creating "pod-b.yaml": Pod "pod-B" is invalid: metadata.name: Invalid value: "pod-B": ${RFC1123_ERROR} (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*') +apply phase finished +reconcile phase started +pod/pod-B reconcile skipped +pod/pod-a reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 3 attempted, 2 successful, 0 skipped, 1 failed +reconcile result: 3 attempted, 2 successful, 1 skipped, 0 failed, 0 timed out +EOF +printResult + +assertRGInventory "continue-err-namespace" "2" +assertPodExists "pod-a" "continue-err-namespace" +assertPodNotExists "pod-B" "continue-err-namespace" +printResult + +# Test: RBAC error applying a resource +echo "Testing RBAC error during apply" +# Setup: create a service account and bind a Role to it so it has administrative +# privileges on the "test" namespace, but no permissions on the default +# namespace. +echo "kubectl apply -f e2e/live/testdata/rbac-error-step-1" +kubectl apply -f e2e/live/testdata/rbac-error-step-1 2>&1 | tee $OUTPUT_DIR/status +assertContains "namespace/rbac-error created" +assertContains "rolebinding.rbac.authorization.k8s.io/admin created" +assertContains "serviceaccount/user created" +printResult +wait 2 + +# Setup: use the service account just created. It does not have permissions +# on the default namespace, so it will give a permissions error on apply +# for anything attempted to apply to the default namespace. +echo "kubectl apply -f e2e/live/testdata/rbac-error-step-2" +kubectl apply -f e2e/live/testdata/rbac-error-step-2 2>&1 | tee $OUTPUT_DIR/status +assertContains "secret/user-credentials created" +wait 2 +SECRET_NAME="user-credentials" +echo "kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d" +SECRET_TOKEN="$(kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d)" +echo "kubectl config set-credentials user --token \"\"" +kubectl config set-credentials user --token "${SECRET_TOKEN}" 2>&1 | tee $OUTPUT_DIR/status +echo "kubectl config set-context kind-kind:user --cluster=kind-kind" +kubectl config set-context kind-kind:user --cluster=kind-kind --user=user 2>&1 | tee $OUTPUT_DIR/status +echo "kubectl config use-context kind-kind:user" +kubectl config use-context kind-kind:user 2>&1 | tee $OUTPUT_DIR/status +printResult +wait 2 + +# Attempt to apply two ConfigMaps: one in the default namespace (fails), and one +# in the "rbac-error" namespace (succeeds). +echo "kpt live apply --install-resource-group=false e2e/live/testdata/rbac-error-step-3" +${BIN_DIR}/kpt live apply --install-resource-group=false e2e/live/testdata/rbac-error-step-3 2>&1 | tee $OUTPUT_DIR/status +assertNotContains "installing inventory ResourceGroup CRD" # CRD already installed +assertContains 'error: polling for status failed: failed to list /v1, Kind=ConfigMap: configmaps is forbidden: User "system:serviceaccount:default:user" cannot list resource "configmaps" in API group "" at the cluster scope' +printResult + +# No inventory expected - permission error causes early exit +echo "kubectl get resourcegroups.kpt.dev -n 'rbac-error' --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers" +kubectl get resourcegroups.kpt.dev -n 'rbac-error' --selector='cli-utils.sigs.k8s.io/inventory-id' --no-headers 2>&1 | tee $OUTPUT_DIR/status +assertContains "No resources found" +printResult + +########################################################### +# Test --rg-file flag on live init commands +########################################################### + +createTestSuite +waitForDefaultServiceAccount + +# Setup: kpt live init with custom resourcegroup file +# Applies resources in "test-case-1c" directory +echo "Testing kpt live init with custom ResourceGroup file" +echo "kpt live init --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c" +${BIN_DIR}/kpt live init --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status +assertContains "initializing \"custom-rg.yaml\" data (namespace: test-namespace)...success" +printResult +# Re-running live init should fail as ResourceGroup file already exists +${BIN_DIR}/kpt live init --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status +assertContains "initializing \"custom-rg.yaml\" data (namespace: test-namespace)...failed" +printResult + +# Run: kpt live apply with custom resourcegroup file +echo "Testing kpt live apply with custom ResourceGroup filename" +echo "kpt live apply e2e/live/testdata/test-case-1c" +${BIN_DIR}/kpt live apply e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status +cat $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +installing inventory ResourceGroup CRD. +inventory update started +inventory update finished +apply phase started +namespace/test-namespace apply successful +apply phase finished +reconcile phase started +namespace/test-namespace reconcile successful +reconcile phase finished +apply phase started +pod/pod-a apply successful +pod/pod-b apply successful +pod/pod-c apply successful +apply phase finished +reconcile phase started +pod/pod-a reconcile pending +pod/pod-b reconcile pending +pod/pod-c reconcile pending +pod/pod-a reconcile successful +pod/pod-b reconcile successful +pod/pod-c reconcile successful +reconcile phase finished +inventory update started +inventory update finished +apply result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +# Validate resources in the cluster +# ResourceGroup inventory with four inventory items. +assertRGInventory "test-namespace" "4" +assertPodExists "pod-a" "test-namespace" +assertPodExists "pod-b" "test-namespace" +assertPodExists "pod-c" "test-namespace" +printResult + +echo "Testing live destroy with custom ResourceGroup filename" +echo "kpt live destroy --rg-file=custom-rg.yaml e2e/live/testdata/test-case-1c" +${BIN_DIR}/kpt live destroy e2e/live/testdata/test-case-1c 2>&1 | tee $OUTPUT_DIR/status +assertKptLiveApplyEquals << EOF +delete phase started +pod/pod-c delete successful +pod/pod-b delete successful +pod/pod-a delete successful +delete phase finished +reconcile phase started +pod/pod-c reconcile pending +pod/pod-b reconcile pending +pod/pod-a reconcile pending +pod/pod-b reconcile successful +pod/pod-c reconcile successful +pod/pod-a reconcile successful +reconcile phase finished +delete phase started +namespace/test-namespace delete successful +delete phase finished +reconcile phase started +namespace/test-namespace reconcile pending +namespace/test-namespace reconcile successful +reconcile phase finished +inventory update started +inventory update finished +delete result: 4 attempted, 4 successful, 0 skipped, 0 failed +reconcile result: 4 attempted, 4 successful, 0 skipped, 0 failed, 0 timed out +EOF +# Validate resources DESTROYED in the cluster +assertPodNotExists "pod-a" "test-namespace" +assertPodNotExists "pod-b" "test-namespace" +assertPodNotExists "pod-c" "test-namespace" +printResult + +# Clean-up the k8s cluster +echo "Cleaning up cluster" +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1a/ +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/rg-test-case-1b/ +cp -f e2e/live/testdata/Kptfile e2e/live/testdata/continue-on-error/ +kind delete cluster +echo -e "Cleaning up cluster...${GREEN}SUCCESS${NC}" + +# Return error code if tests have failed +if [[ ${HAS_TEST_FAILURE} -gt 0 ]]; then + echo -e "${RED}ERROR: E2E Tests Failed${NC}" + exit ${HAS_TEST_FAILURE} +else + echo -e "${GREEN}SUCCESS: E2E Tests Passed${NC}" + exit 0 fi \ No newline at end of file diff --git a/e2e/live/testdata/Kptfile b/e2e/live/testdata/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/Kptfile +++ b/e2e/live/testdata/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/continue-on-error/Kptfile b/e2e/live/testdata/continue-on-error/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/continue-on-error/Kptfile +++ b/e2e/live/testdata/continue-on-error/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/continue-on-error/namespace.yaml b/e2e/live/testdata/continue-on-error/namespace.yaml index ebfc0910e1..34453a692a 100644 --- a/e2e/live/testdata/continue-on-error/namespace.yaml +++ b/e2e/live/testdata/continue-on-error/namespace.yaml @@ -1,7 +1,7 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Namespace -metadata: - name: continue-err-namespace +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: continue-err-namespace diff --git a/e2e/live/testdata/continue-on-error/pod-a.yaml b/e2e/live/testdata/continue-on-error/pod-a.yaml index 68ff0a19a1..04a575b3ce 100644 --- a/e2e/live/testdata/continue-on-error/pod-a.yaml +++ b/e2e/live/testdata/continue-on-error/pod-a.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-a - namespace: continue-err-namespace - labels: - name: test-pod-label-foo -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-a + namespace: continue-err-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/continue-on-error/pod-b.yaml b/e2e/live/testdata/continue-on-error/pod-b.yaml index 5909411659..3bb0664561 100644 --- a/e2e/live/testdata/continue-on-error/pod-b.yaml +++ b/e2e/live/testdata/continue-on-error/pod-b.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-B - namespace: continue-err-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-B + namespace: continue-err-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/install-rg-crd/example-resource-group.yaml b/e2e/live/testdata/install-rg-crd/example-resource-group.yaml index 27d85e576f..c0dbf3b1cc 100644 --- a/e2e/live/testdata/install-rg-crd/example-resource-group.yaml +++ b/e2e/live/testdata/install-rg-crd/example-resource-group.yaml @@ -1,20 +1,20 @@ -# Copyright 2020 The kpt Authors -# -# 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. - -# Example ResourceGroup custom resource -apiVersion: "kpt.dev/v1alpha1" -kind: ResourceGroup -metadata: - namespace: default - name: example-inventory +# Copyright 2020 The kpt Authors +# +# 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. + +# Example ResourceGroup custom resource +apiVersion: "kpt.dev/v1alpha1" +kind: ResourceGroup +metadata: + namespace: default + name: example-inventory diff --git a/e2e/live/testdata/inventory-template.yaml b/e2e/live/testdata/inventory-template.yaml index fbb9210355..2a31782ba9 100644 --- a/e2e/live/testdata/inventory-template.yaml +++ b/e2e/live/testdata/inventory-template.yaml @@ -1,48 +1,48 @@ -# Copyright 2020 The kpt Authors -# -# 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. - -# NOTE: auto-generated. Some fields should NOT be modified. -# Date: 2020-11-19 12:50:49 PST -# -# Contains the "inventory object" template ConfigMap. -# When this object is applied, it is handled specially, -# storing the metadata of all the other objects applied. -# This object and its stored inventory is subsequently -# used to calculate the set of objects to automatically -# delete (prune), when an object is omitted from further -# applies. When applied, this "inventory object" is also -# used to identify the entire set of objects to delete. -# -# NOTE: The name of this inventory template file -# does NOT have any impact on group-related functionality -# such as deletion or pruning. -# -apiVersion: v1 -kind: ConfigMap -metadata: - # DANGER: Do not change the inventory object namespace. - # Changing the namespace will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - namespace: test-rg-namespace - # NOTE: The name of the inventory object does NOT have - # any impact on group-related functionality such as - # deletion or pruning. - name: inventory-26306433 - labels: - # DANGER: Do not change the value of this label. - # Changing this value will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - cli-utils.sigs.k8s.io/inventory-id: 46d8946c-c1fa-4e1d-9357-b37fb9bae25f +# Copyright 2020 The kpt Authors +# +# 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. + +# NOTE: auto-generated. Some fields should NOT be modified. +# Date: 2020-11-19 12:50:49 PST +# +# Contains the "inventory object" template ConfigMap. +# When this object is applied, it is handled specially, +# storing the metadata of all the other objects applied. +# This object and its stored inventory is subsequently +# used to calculate the set of objects to automatically +# delete (prune), when an object is omitted from further +# applies. When applied, this "inventory object" is also +# used to identify the entire set of objects to delete. +# +# NOTE: The name of this inventory template file +# does NOT have any impact on group-related functionality +# such as deletion or pruning. +# +apiVersion: v1 +kind: ConfigMap +metadata: + # DANGER: Do not change the inventory object namespace. + # Changing the namespace will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + namespace: test-rg-namespace + # NOTE: The name of the inventory object does NOT have + # any impact on group-related functionality such as + # deletion or pruning. + name: inventory-26306433 + labels: + # DANGER: Do not change the value of this label. + # Changing this value will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + cli-utils.sigs.k8s.io/inventory-id: 46d8946c-c1fa-4e1d-9357-b37fb9bae25f diff --git a/e2e/live/testdata/rbac-error-step-1/namespace.yaml b/e2e/live/testdata/rbac-error-step-1/namespace.yaml index fce628007c..3c3658a40e 100644 --- a/e2e/live/testdata/rbac-error-step-1/namespace.yaml +++ b/e2e/live/testdata/rbac-error-step-1/namespace.yaml @@ -1,18 +1,18 @@ -# Copyright 2019 The kpt Authors -# -# 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: v1 -kind: Namespace -metadata: - name: rbac-error +# Copyright 2019 The kpt Authors +# +# 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: v1 +kind: Namespace +metadata: + name: rbac-error diff --git a/e2e/live/testdata/rbac-error-step-1/role-binding.yaml b/e2e/live/testdata/rbac-error-step-1/role-binding.yaml index c5b85bae36..9430e84bb4 100644 --- a/e2e/live/testdata/rbac-error-step-1/role-binding.yaml +++ b/e2e/live/testdata/rbac-error-step-1/role-binding.yaml @@ -1,28 +1,28 @@ -# Copyright 2019 The kpt Authors -# -# 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: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: admin - namespace: rbac-error -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: cluster-admin -subjects: -- kind: User - name: system:serviceaccount:default:user - apiGroup: rbac.authorization.k8s.io - +# Copyright 2019 The kpt Authors +# +# 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: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: admin + namespace: rbac-error +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: User + name: system:serviceaccount:default:user + apiGroup: rbac.authorization.k8s.io + diff --git a/e2e/live/testdata/rbac-error-step-1/service-account.yaml b/e2e/live/testdata/rbac-error-step-1/service-account.yaml index 10e5cc695e..7c390ddcd8 100644 --- a/e2e/live/testdata/rbac-error-step-1/service-account.yaml +++ b/e2e/live/testdata/rbac-error-step-1/service-account.yaml @@ -1,19 +1,19 @@ -# Copyright 2019 The kpt Authors -# -# 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: v1 -kind: ServiceAccount -metadata: - name: user - +# Copyright 2019 The kpt Authors +# +# 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: v1 +kind: ServiceAccount +metadata: + name: user + diff --git a/e2e/live/testdata/rbac-error-step-2/user-secret.yaml b/e2e/live/testdata/rbac-error-step-2/user-secret.yaml index dae163a978..2e59b4eacc 100644 --- a/e2e/live/testdata/rbac-error-step-2/user-secret.yaml +++ b/e2e/live/testdata/rbac-error-step-2/user-secret.yaml @@ -1,21 +1,21 @@ -# Copyright 2022 The kpt Authors -# -# 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: v1 -kind: Secret -metadata: - name: user-credentials - annotations: - kubernetes.io/service-account.name: user -type: kubernetes.io/service-account-token +# Copyright 2022 The kpt Authors +# +# 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: v1 +kind: Secret +metadata: + name: user-credentials + annotations: + kubernetes.io/service-account.name: user +type: kubernetes.io/service-account-token diff --git a/e2e/live/testdata/rbac-error-step-3/Kptfile b/e2e/live/testdata/rbac-error-step-3/Kptfile index a189ddea28..1d0382227b 100644 --- a/e2e/live/testdata/rbac-error-step-3/Kptfile +++ b/e2e/live/testdata/rbac-error-step-3/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master -inventory: - namespace: rbac-error - name: inventory-82393036 - inventoryID: ed68c3d787d4355ac1886ee852f7a4c0537d9818-1618448890187393263 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master +inventory: + namespace: rbac-error + name: inventory-82393036 + inventoryID: ed68c3d787d4355ac1886ee852f7a4c0537d9818-1618448890187393263 diff --git a/e2e/live/testdata/rbac-error-step-3/config-map.yaml b/e2e/live/testdata/rbac-error-step-3/config-map.yaml index 15c70aecd2..fcd04f6b7b 100644 --- a/e2e/live/testdata/rbac-error-step-3/config-map.yaml +++ b/e2e/live/testdata/rbac-error-step-3/config-map.yaml @@ -1,21 +1,21 @@ -# Copyright 2019 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: valid-config-map - namespace: rbac-error -data: {} - +# Copyright 2019 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: valid-config-map + namespace: rbac-error +data: {} + diff --git a/e2e/live/testdata/rbac-error-step-3/error-config-map.yaml b/e2e/live/testdata/rbac-error-step-3/error-config-map.yaml index fce1fa9750..3d8075b9e3 100644 --- a/e2e/live/testdata/rbac-error-step-3/error-config-map.yaml +++ b/e2e/live/testdata/rbac-error-step-3/error-config-map.yaml @@ -1,19 +1,19 @@ -# Copyright 2019 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: error-config-map -data: {} +# Copyright 2019 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: error-config-map +data: {} diff --git a/e2e/live/testdata/rg-test-case-1a/Kptfile b/e2e/live/testdata/rg-test-case-1a/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/rg-test-case-1a/Kptfile +++ b/e2e/live/testdata/rg-test-case-1a/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/rg-test-case-1a/namespace.yaml b/e2e/live/testdata/rg-test-case-1a/namespace.yaml index c13ebfcba4..a99ec55dcf 100644 --- a/e2e/live/testdata/rg-test-case-1a/namespace.yaml +++ b/e2e/live/testdata/rg-test-case-1a/namespace.yaml @@ -1,7 +1,7 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Namespace -metadata: - name: rg-test-namespace +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: rg-test-namespace diff --git a/e2e/live/testdata/rg-test-case-1a/pod-a.yaml b/e2e/live/testdata/rg-test-case-1a/pod-a.yaml index 701945fca0..d1c88f6e99 100644 --- a/e2e/live/testdata/rg-test-case-1a/pod-a.yaml +++ b/e2e/live/testdata/rg-test-case-1a/pod-a.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-a - namespace: rg-test-namespace - labels: - name: test-pod-label-foo -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-a + namespace: rg-test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/rg-test-case-1a/pod-b.yaml b/e2e/live/testdata/rg-test-case-1a/pod-b.yaml index 0e635150f4..1ff136ab57 100644 --- a/e2e/live/testdata/rg-test-case-1a/pod-b.yaml +++ b/e2e/live/testdata/rg-test-case-1a/pod-b.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-b - namespace: rg-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-b + namespace: rg-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/rg-test-case-1a/pod-c.yaml b/e2e/live/testdata/rg-test-case-1a/pod-c.yaml index 05a6ae44cb..cb0d6781b2 100644 --- a/e2e/live/testdata/rg-test-case-1a/pod-c.yaml +++ b/e2e/live/testdata/rg-test-case-1a/pod-c.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-c - namespace: rg-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-c + namespace: rg-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/rg-test-case-1b/Kptfile b/e2e/live/testdata/rg-test-case-1b/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/rg-test-case-1b/Kptfile +++ b/e2e/live/testdata/rg-test-case-1b/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/rg-test-case-1b/namespace.yaml b/e2e/live/testdata/rg-test-case-1b/namespace.yaml index c13ebfcba4..a99ec55dcf 100644 --- a/e2e/live/testdata/rg-test-case-1b/namespace.yaml +++ b/e2e/live/testdata/rg-test-case-1b/namespace.yaml @@ -1,7 +1,7 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Namespace -metadata: - name: rg-test-namespace +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: rg-test-namespace diff --git a/e2e/live/testdata/rg-test-case-1b/pod-b.yaml b/e2e/live/testdata/rg-test-case-1b/pod-b.yaml index 0e635150f4..1ff136ab57 100644 --- a/e2e/live/testdata/rg-test-case-1b/pod-b.yaml +++ b/e2e/live/testdata/rg-test-case-1b/pod-b.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-b - namespace: rg-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-b + namespace: rg-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/rg-test-case-1b/pod-c.yaml b/e2e/live/testdata/rg-test-case-1b/pod-c.yaml index 05a6ae44cb..cb0d6781b2 100644 --- a/e2e/live/testdata/rg-test-case-1b/pod-c.yaml +++ b/e2e/live/testdata/rg-test-case-1b/pod-c.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-c - namespace: rg-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-c + namespace: rg-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/rg-test-case-1b/pod-d.yaml b/e2e/live/testdata/rg-test-case-1b/pod-d.yaml index d0c97c587e..2f91bcdcf6 100644 --- a/e2e/live/testdata/rg-test-case-1b/pod-d.yaml +++ b/e2e/live/testdata/rg-test-case-1b/pod-d.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-d - namespace: rg-test-namespace - labels: - name: test-pod-label-foo -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-d + namespace: rg-test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/stdin-test/pods.yaml b/e2e/live/testdata/stdin-test/pods.yaml index c5b1ef08c4..512e02bc38 100644 --- a/e2e/live/testdata/stdin-test/pods.yaml +++ b/e2e/live/testdata/stdin-test/pods.yaml @@ -1,69 +1,69 @@ -# Copyright 2021 The kpt Authors -# -# 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: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master -inventory: - namespace: stdin-test-namespace - name: inventory-18030002 - inventoryID: 4a1bc0b4df68e583e23a7351a0a4d149edc0fa61-1627067858058570061 ---- -apiVersion: v1 -kind: Pod -metadata: - name: pod-b - namespace: stdin-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 ---- -apiVersion: v1 -kind: Namespace -metadata: - name: stdin-test-namespace ---- -apiVersion: v1 -kind: Pod -metadata: - name: pod-c - namespace: stdin-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 ---- -apiVersion: v1 -kind: Pod -metadata: - name: pod-a - namespace: stdin-test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2021 The kpt Authors +# +# 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: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master +inventory: + namespace: stdin-test-namespace + name: inventory-18030002 + inventoryID: 4a1bc0b4df68e583e23a7351a0a4d149edc0fa61-1627067858058570061 +--- +apiVersion: v1 +kind: Pod +metadata: + name: pod-b + namespace: stdin-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: stdin-test-namespace +--- +apiVersion: v1 +kind: Pod +metadata: + name: pod-c + namespace: stdin-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 +--- +apiVersion: v1 +kind: Pod +metadata: + name: pod-a + namespace: stdin-test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/template-rg-namespace.yaml b/e2e/live/testdata/template-rg-namespace.yaml index fbb9210355..2a31782ba9 100644 --- a/e2e/live/testdata/template-rg-namespace.yaml +++ b/e2e/live/testdata/template-rg-namespace.yaml @@ -1,48 +1,48 @@ -# Copyright 2020 The kpt Authors -# -# 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. - -# NOTE: auto-generated. Some fields should NOT be modified. -# Date: 2020-11-19 12:50:49 PST -# -# Contains the "inventory object" template ConfigMap. -# When this object is applied, it is handled specially, -# storing the metadata of all the other objects applied. -# This object and its stored inventory is subsequently -# used to calculate the set of objects to automatically -# delete (prune), when an object is omitted from further -# applies. When applied, this "inventory object" is also -# used to identify the entire set of objects to delete. -# -# NOTE: The name of this inventory template file -# does NOT have any impact on group-related functionality -# such as deletion or pruning. -# -apiVersion: v1 -kind: ConfigMap -metadata: - # DANGER: Do not change the inventory object namespace. - # Changing the namespace will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - namespace: test-rg-namespace - # NOTE: The name of the inventory object does NOT have - # any impact on group-related functionality such as - # deletion or pruning. - name: inventory-26306433 - labels: - # DANGER: Do not change the value of this label. - # Changing this value will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - cli-utils.sigs.k8s.io/inventory-id: 46d8946c-c1fa-4e1d-9357-b37fb9bae25f +# Copyright 2020 The kpt Authors +# +# 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. + +# NOTE: auto-generated. Some fields should NOT be modified. +# Date: 2020-11-19 12:50:49 PST +# +# Contains the "inventory object" template ConfigMap. +# When this object is applied, it is handled specially, +# storing the metadata of all the other objects applied. +# This object and its stored inventory is subsequently +# used to calculate the set of objects to automatically +# delete (prune), when an object is omitted from further +# applies. When applied, this "inventory object" is also +# used to identify the entire set of objects to delete. +# +# NOTE: The name of this inventory template file +# does NOT have any impact on group-related functionality +# such as deletion or pruning. +# +apiVersion: v1 +kind: ConfigMap +metadata: + # DANGER: Do not change the inventory object namespace. + # Changing the namespace will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + namespace: test-rg-namespace + # NOTE: The name of the inventory object does NOT have + # any impact on group-related functionality such as + # deletion or pruning. + name: inventory-26306433 + labels: + # DANGER: Do not change the value of this label. + # Changing this value will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + cli-utils.sigs.k8s.io/inventory-id: 46d8946c-c1fa-4e1d-9357-b37fb9bae25f diff --git a/e2e/live/testdata/template-test-namespace.yaml b/e2e/live/testdata/template-test-namespace.yaml index f7ff4c6515..9ea3d010be 100644 --- a/e2e/live/testdata/template-test-namespace.yaml +++ b/e2e/live/testdata/template-test-namespace.yaml @@ -1,48 +1,48 @@ -# Copyright 2020 The kpt Authors -# -# 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. - -# NOTE: auto-generated. Some fields should NOT be modified. -# Date: 2020-11-17 02:17:32 PST -# -# Contains the "inventory object" template ConfigMap. -# When this object is applied, it is handled specially, -# storing the metadata of all the other objects applied. -# This object and its stored inventory is subsequently -# used to calculate the set of objects to automatically -# delete (prune), when an object is omitted from further -# applies. When applied, this "inventory object" is also -# used to identify the entire set of objects to delete. -# -# NOTE: The name of this inventory template file -# does NOT have any impact on group-related functionality -# such as deletion or pruning. -# -apiVersion: v1 -kind: ConfigMap -metadata: - # DANGER: Do not change the inventory object namespace. - # Changing the namespace will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - namespace: test-namespace - # NOTE: The name of the inventory object does NOT have - # any impact on group-related functionality such as - # deletion or pruning. - name: inventory-40897991 - labels: - # DANGER: Do not change the value of this label. - # Changing this value will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - cli-utils.sigs.k8s.io/inventory-id: 0d433e0b-d9dd-4313-a58c-53f939a38fe1 +# Copyright 2020 The kpt Authors +# +# 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. + +# NOTE: auto-generated. Some fields should NOT be modified. +# Date: 2020-11-17 02:17:32 PST +# +# Contains the "inventory object" template ConfigMap. +# When this object is applied, it is handled specially, +# storing the metadata of all the other objects applied. +# This object and its stored inventory is subsequently +# used to calculate the set of objects to automatically +# delete (prune), when an object is omitted from further +# applies. When applied, this "inventory object" is also +# used to identify the entire set of objects to delete. +# +# NOTE: The name of this inventory template file +# does NOT have any impact on group-related functionality +# such as deletion or pruning. +# +apiVersion: v1 +kind: ConfigMap +metadata: + # DANGER: Do not change the inventory object namespace. + # Changing the namespace will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + namespace: test-namespace + # NOTE: The name of the inventory object does NOT have + # any impact on group-related functionality such as + # deletion or pruning. + name: inventory-40897991 + labels: + # DANGER: Do not change the value of this label. + # Changing this value will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + cli-utils.sigs.k8s.io/inventory-id: 0d433e0b-d9dd-4313-a58c-53f939a38fe1 diff --git a/e2e/live/testdata/test-case-1a/Kptfile b/e2e/live/testdata/test-case-1a/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/test-case-1a/Kptfile +++ b/e2e/live/testdata/test-case-1a/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/test-case-1a/inventory-template.yaml b/e2e/live/testdata/test-case-1a/inventory-template.yaml index f7ff4c6515..9ea3d010be 100644 --- a/e2e/live/testdata/test-case-1a/inventory-template.yaml +++ b/e2e/live/testdata/test-case-1a/inventory-template.yaml @@ -1,48 +1,48 @@ -# Copyright 2020 The kpt Authors -# -# 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. - -# NOTE: auto-generated. Some fields should NOT be modified. -# Date: 2020-11-17 02:17:32 PST -# -# Contains the "inventory object" template ConfigMap. -# When this object is applied, it is handled specially, -# storing the metadata of all the other objects applied. -# This object and its stored inventory is subsequently -# used to calculate the set of objects to automatically -# delete (prune), when an object is omitted from further -# applies. When applied, this "inventory object" is also -# used to identify the entire set of objects to delete. -# -# NOTE: The name of this inventory template file -# does NOT have any impact on group-related functionality -# such as deletion or pruning. -# -apiVersion: v1 -kind: ConfigMap -metadata: - # DANGER: Do not change the inventory object namespace. - # Changing the namespace will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - namespace: test-namespace - # NOTE: The name of the inventory object does NOT have - # any impact on group-related functionality such as - # deletion or pruning. - name: inventory-40897991 - labels: - # DANGER: Do not change the value of this label. - # Changing this value will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - cli-utils.sigs.k8s.io/inventory-id: 0d433e0b-d9dd-4313-a58c-53f939a38fe1 +# Copyright 2020 The kpt Authors +# +# 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. + +# NOTE: auto-generated. Some fields should NOT be modified. +# Date: 2020-11-17 02:17:32 PST +# +# Contains the "inventory object" template ConfigMap. +# When this object is applied, it is handled specially, +# storing the metadata of all the other objects applied. +# This object and its stored inventory is subsequently +# used to calculate the set of objects to automatically +# delete (prune), when an object is omitted from further +# applies. When applied, this "inventory object" is also +# used to identify the entire set of objects to delete. +# +# NOTE: The name of this inventory template file +# does NOT have any impact on group-related functionality +# such as deletion or pruning. +# +apiVersion: v1 +kind: ConfigMap +metadata: + # DANGER: Do not change the inventory object namespace. + # Changing the namespace will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + namespace: test-namespace + # NOTE: The name of the inventory object does NOT have + # any impact on group-related functionality such as + # deletion or pruning. + name: inventory-40897991 + labels: + # DANGER: Do not change the value of this label. + # Changing this value will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + cli-utils.sigs.k8s.io/inventory-id: 0d433e0b-d9dd-4313-a58c-53f939a38fe1 diff --git a/e2e/live/testdata/test-case-1a/namespace.yaml b/e2e/live/testdata/test-case-1a/namespace.yaml index e5e747b2c6..5c92ff7826 100644 --- a/e2e/live/testdata/test-case-1a/namespace.yaml +++ b/e2e/live/testdata/test-case-1a/namespace.yaml @@ -1,7 +1,7 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Namespace -metadata: - name: test-namespace +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: test-namespace diff --git a/e2e/live/testdata/test-case-1a/pod-a.yaml b/e2e/live/testdata/test-case-1a/pod-a.yaml index d009500548..861b6559d7 100644 --- a/e2e/live/testdata/test-case-1a/pod-a.yaml +++ b/e2e/live/testdata/test-case-1a/pod-a.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-a - namespace: test-namespace - labels: - name: test-pod-label-foo -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-a + namespace: test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1a/pod-b.yaml b/e2e/live/testdata/test-case-1a/pod-b.yaml index 69a7831030..6f9e2a3739 100644 --- a/e2e/live/testdata/test-case-1a/pod-b.yaml +++ b/e2e/live/testdata/test-case-1a/pod-b.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-b - namespace: test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-b + namespace: test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1a/pod-c.yaml b/e2e/live/testdata/test-case-1a/pod-c.yaml index c6a52b6746..ebd3ca2928 100644 --- a/e2e/live/testdata/test-case-1a/pod-c.yaml +++ b/e2e/live/testdata/test-case-1a/pod-c.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-c - namespace: test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-c + namespace: test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1b/Kptfile b/e2e/live/testdata/test-case-1b/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/test-case-1b/Kptfile +++ b/e2e/live/testdata/test-case-1b/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/test-case-1b/inventory-template.yaml b/e2e/live/testdata/test-case-1b/inventory-template.yaml index f7ff4c6515..9ea3d010be 100644 --- a/e2e/live/testdata/test-case-1b/inventory-template.yaml +++ b/e2e/live/testdata/test-case-1b/inventory-template.yaml @@ -1,48 +1,48 @@ -# Copyright 2020 The kpt Authors -# -# 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. - -# NOTE: auto-generated. Some fields should NOT be modified. -# Date: 2020-11-17 02:17:32 PST -# -# Contains the "inventory object" template ConfigMap. -# When this object is applied, it is handled specially, -# storing the metadata of all the other objects applied. -# This object and its stored inventory is subsequently -# used to calculate the set of objects to automatically -# delete (prune), when an object is omitted from further -# applies. When applied, this "inventory object" is also -# used to identify the entire set of objects to delete. -# -# NOTE: The name of this inventory template file -# does NOT have any impact on group-related functionality -# such as deletion or pruning. -# -apiVersion: v1 -kind: ConfigMap -metadata: - # DANGER: Do not change the inventory object namespace. - # Changing the namespace will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - namespace: test-namespace - # NOTE: The name of the inventory object does NOT have - # any impact on group-related functionality such as - # deletion or pruning. - name: inventory-40897991 - labels: - # DANGER: Do not change the value of this label. - # Changing this value will cause a loss of continuity - # with previously applied grouped objects. Set deletion - # and pruning functionality will be impaired. - cli-utils.sigs.k8s.io/inventory-id: 0d433e0b-d9dd-4313-a58c-53f939a38fe1 +# Copyright 2020 The kpt Authors +# +# 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. + +# NOTE: auto-generated. Some fields should NOT be modified. +# Date: 2020-11-17 02:17:32 PST +# +# Contains the "inventory object" template ConfigMap. +# When this object is applied, it is handled specially, +# storing the metadata of all the other objects applied. +# This object and its stored inventory is subsequently +# used to calculate the set of objects to automatically +# delete (prune), when an object is omitted from further +# applies. When applied, this "inventory object" is also +# used to identify the entire set of objects to delete. +# +# NOTE: The name of this inventory template file +# does NOT have any impact on group-related functionality +# such as deletion or pruning. +# +apiVersion: v1 +kind: ConfigMap +metadata: + # DANGER: Do not change the inventory object namespace. + # Changing the namespace will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + namespace: test-namespace + # NOTE: The name of the inventory object does NOT have + # any impact on group-related functionality such as + # deletion or pruning. + name: inventory-40897991 + labels: + # DANGER: Do not change the value of this label. + # Changing this value will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + cli-utils.sigs.k8s.io/inventory-id: 0d433e0b-d9dd-4313-a58c-53f939a38fe1 diff --git a/e2e/live/testdata/test-case-1b/namespace.yaml b/e2e/live/testdata/test-case-1b/namespace.yaml index e5e747b2c6..5c92ff7826 100644 --- a/e2e/live/testdata/test-case-1b/namespace.yaml +++ b/e2e/live/testdata/test-case-1b/namespace.yaml @@ -1,7 +1,7 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Namespace -metadata: - name: test-namespace +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: test-namespace diff --git a/e2e/live/testdata/test-case-1b/pod-b.yaml b/e2e/live/testdata/test-case-1b/pod-b.yaml index 69a7831030..6f9e2a3739 100644 --- a/e2e/live/testdata/test-case-1b/pod-b.yaml +++ b/e2e/live/testdata/test-case-1b/pod-b.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-b - namespace: test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-b + namespace: test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1b/pod-c.yaml b/e2e/live/testdata/test-case-1b/pod-c.yaml index c6a52b6746..ebd3ca2928 100644 --- a/e2e/live/testdata/test-case-1b/pod-c.yaml +++ b/e2e/live/testdata/test-case-1b/pod-c.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-c - namespace: test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-c + namespace: test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1b/pod-d.yaml b/e2e/live/testdata/test-case-1b/pod-d.yaml index dadfe21f11..875e5fd647 100644 --- a/e2e/live/testdata/test-case-1b/pod-d.yaml +++ b/e2e/live/testdata/test-case-1b/pod-d.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-d - namespace: test-namespace - labels: - name: test-pod-label-foo -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-d + namespace: test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1c/Kptfile b/e2e/live/testdata/test-case-1c/Kptfile index 09651424c0..f3cfe1d28c 100644 --- a/e2e/live/testdata/test-case-1c/Kptfile +++ b/e2e/live/testdata/test-case-1c/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: test1 -upstream: - type: git - git: - repo: git@github.com:yuwenma/blueprint-helloworld - directory: / - ref: master - +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: test1 +upstream: + type: git + git: + repo: git@github.com:yuwenma/blueprint-helloworld + directory: / + ref: master + diff --git a/e2e/live/testdata/test-case-1c/namespace.yaml b/e2e/live/testdata/test-case-1c/namespace.yaml index e5e747b2c6..5c92ff7826 100644 --- a/e2e/live/testdata/test-case-1c/namespace.yaml +++ b/e2e/live/testdata/test-case-1c/namespace.yaml @@ -1,7 +1,7 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Namespace -metadata: - name: test-namespace +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: test-namespace diff --git a/e2e/live/testdata/test-case-1c/pod-a.yaml b/e2e/live/testdata/test-case-1c/pod-a.yaml index d009500548..861b6559d7 100644 --- a/e2e/live/testdata/test-case-1c/pod-a.yaml +++ b/e2e/live/testdata/test-case-1c/pod-a.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-a - namespace: test-namespace - labels: - name: test-pod-label-foo -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-a + namespace: test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1c/pod-b.yaml b/e2e/live/testdata/test-case-1c/pod-b.yaml index 69a7831030..6f9e2a3739 100644 --- a/e2e/live/testdata/test-case-1c/pod-b.yaml +++ b/e2e/live/testdata/test-case-1c/pod-b.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-b - namespace: test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-b + namespace: test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live/testdata/test-case-1c/pod-c.yaml b/e2e/live/testdata/test-case-1c/pod-c.yaml index c6a52b6746..ebd3ca2928 100644 --- a/e2e/live/testdata/test-case-1c/pod-c.yaml +++ b/e2e/live/testdata/test-case-1c/pod-c.yaml @@ -1,14 +1,14 @@ -# Copyright 2019 The Kubernetes Authors. -# SPDX-License-Identifier: Apache-2.0 - -apiVersion: v1 -kind: Pod -metadata: - name: pod-c - namespace: test-namespace - labels: - name: test-pod-label -spec: - containers: - - name: kubernetes-pause - image: k8s.gcr.io/pause:1.0 +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: pod-c + namespace: test-namespace + labels: + name: test-pod-label +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:1.0 diff --git a/e2e/live_test.go b/e2e/live_test.go index ea0f190ecd..67f9bf1eb2 100644 --- a/e2e/live_test.go +++ b/e2e/live_test.go @@ -1,98 +1,98 @@ -//go:build kind -// +build kind - -// Copyright 2021 The kpt Authors -// -// 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. - -package e2e - -import ( - "os" - "path/filepath" - "testing" - - livetest "github.com/kptdev/kpt/pkg/test/live" - "github.com/stretchr/testify/require" -) - -func TestLiveApply(t *testing.T) { - runTests(t, filepath.Join(".", "testdata", "live-apply")) -} - -func TestLivePlan(t *testing.T) { - runTests(t, filepath.Join(".", "testdata", "live-plan")) -} - -func runTests(t *testing.T, path string) { - testCases := scanTestCases(t, path) - - livetest.RemoveKindCluster(t) - livetest.CreateKindCluster(t) - - for p := range testCases { - p := p - c := testCases[p] - - if !c.Parallel { - continue - } - - t.Run(p, func(t *testing.T) { - if c.Parallel { - t.Parallel() - } - - if c.NoResourceGroup { - require.False(t, c.Parallel, "Parallel tests can not modify the RG CRD") - if livetest.CheckIfResourceGroupInstalled(t) { - livetest.RemoveResourceGroup(t) - } - } else { - livetest.InstallResourceGroup(t) - } - - ns := filepath.Base(p) - livetest.CreateNamespace(t, ns) - defer livetest.RemoveNamespace(t, ns) - - (&livetest.Runner{ - Config: c, - Path: p, - }).Run(t) - }) - } -} - -func scanTestCases(t *testing.T, path string) map[string]livetest.TestCaseConfig { - testCases := make(map[string]livetest.TestCaseConfig) - err := filepath.Walk(path, func(p string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - if !info.IsDir() { - return nil - } - if path == p { - return nil - } - - testCases[p] = livetest.ReadTestCaseConfig(t, p) - return filepath.SkipDir - }) - if err != nil { - t.Fatalf("failed to scan for test cases in %s", path) - } - return testCases -} +//go:build kind +// +build kind + +// Copyright 2021 The kpt Authors +// +// 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. + +package e2e + +import ( + "os" + "path/filepath" + "testing" + + livetest "github.com/kptdev/kpt/pkg/test/live" + "github.com/stretchr/testify/require" +) + +func TestLiveApply(t *testing.T) { + runTests(t, filepath.Join(".", "testdata", "live-apply")) +} + +func TestLivePlan(t *testing.T) { + runTests(t, filepath.Join(".", "testdata", "live-plan")) +} + +func runTests(t *testing.T, path string) { + testCases := scanTestCases(t, path) + + livetest.RemoveKindCluster(t) + livetest.CreateKindCluster(t) + + for p := range testCases { + p := p + c := testCases[p] + + if !c.Parallel { + continue + } + + t.Run(p, func(t *testing.T) { + if c.Parallel { + t.Parallel() + } + + if c.NoResourceGroup { + require.False(t, c.Parallel, "Parallel tests can not modify the RG CRD") + if livetest.CheckIfResourceGroupInstalled(t) { + livetest.RemoveResourceGroup(t) + } + } else { + livetest.InstallResourceGroup(t) + } + + ns := filepath.Base(p) + livetest.CreateNamespace(t, ns) + defer livetest.RemoveNamespace(t, ns) + + (&livetest.Runner{ + Config: c, + Path: p, + }).Run(t) + }) + } +} + +func scanTestCases(t *testing.T, path string) map[string]livetest.TestCaseConfig { + testCases := make(map[string]livetest.TestCaseConfig) + err := filepath.Walk(path, func(p string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if !info.IsDir() { + return nil + } + if path == p { + return nil + } + + testCases[p] = livetest.ReadTestCaseConfig(t, p) + return filepath.SkipDir + }) + if err != nil { + t.Fatalf("failed to scan for test cases in %s", path) + } + return testCases +} diff --git a/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/config.yaml index 8aef046c6b..c6f7a63c08 100644 --- a/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest -fnConfig: ../../starlark-delete-resource.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +fnConfig: ../../starlark-delete-resource.yaml diff --git a/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/diff.patch b/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/diff.patch index 65cee17bf5..84f0ab75bf 100644 --- a/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/diff.patch +++ b/e2e/testdata/fn-eval/all-resource-deletion/pkg/.expected/diff.patch @@ -1,32 +1,32 @@ -diff --git a/resources.yaml b/resources.yaml -deleted file mode 100644 -index f2eec52..0000000 ---- a/resources.yaml -+++ /dev/null -@@ -1,26 +0,0 @@ --# Copyright 2021 The kpt Authors --# --# 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 +diff --git a/resources.yaml b/resources.yaml +deleted file mode 100644 +index f2eec52..0000000 +--- a/resources.yaml ++++ /dev/null +@@ -1,26 +0,0 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 diff --git a/e2e/testdata/fn-eval/all-resource-deletion/pkg/.krmignore b/e2e/testdata/fn-eval/all-resource-deletion/pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/all-resource-deletion/pkg/.krmignore +++ b/e2e/testdata/fn-eval/all-resource-deletion/pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/all-resource-deletion/pkg/resources.yaml b/e2e/testdata/fn-eval/all-resource-deletion/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/all-resource-deletion/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/all-resource-deletion/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/all-resource-deletion/starlark-delete-resource.yaml b/e2e/testdata/fn-eval/all-resource-deletion/starlark-delete-resource.yaml index 7d70656e2c..e3d3827745 100644 --- a/e2e/testdata/fn-eval/all-resource-deletion/starlark-delete-resource.yaml +++ b/e2e/testdata/fn-eval/all-resource-deletion/starlark-delete-resource.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: delete-all-resource -source: | - ctx.resource_list["items"] = [] +# Copyright 2021 The kpt Authors +# +# 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: delete-all-resource +source: | + ctx.resource_list["items"] = [] diff --git a/e2e/testdata/fn-eval/default-runtime/.expected/diff.patch b/e2e/testdata/fn-eval/default-runtime/.expected/diff.patch index 551c6bfb48..8af6c0ffea 100644 --- a/e2e/testdata/fn-eval/default-runtime/.expected/diff.patch +++ b/e2e/testdata/fn-eval/default-runtime/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/default-runtime/.expected/exec.sh b/e2e/testdata/fn-eval/default-runtime/.expected/exec.sh index 37e7616fdc..1ca62f2162 100755 --- a/e2e/testdata/fn-eval/default-runtime/.expected/exec.sh +++ b/e2e/testdata/fn-eval/default-runtime/.expected/exec.sh @@ -1,25 +1,25 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -# clear environment variable KRM_FN_RUNTIME if it matches the default -if [ "${KRM_FN_RUNTIME}" = "docker" ]; then - unset KRM_FN_RUNTIME -fi - -echo "KRM_FN_RUNTIME is ${KRM_FN_RUNTIME}" -# run eval with KRM_FN_RUNTIME unset. -kpt fn eval -i ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +# clear environment variable KRM_FN_RUNTIME if it matches the default +if [ "${KRM_FN_RUNTIME}" = "docker" ]; then + unset KRM_FN_RUNTIME +fi + +echo "KRM_FN_RUNTIME is ${KRM_FN_RUNTIME}" +# run eval with KRM_FN_RUNTIME unset. +kpt fn eval -i ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging diff --git a/e2e/testdata/fn-eval/default-runtime/.krmignore b/e2e/testdata/fn-eval/default-runtime/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/default-runtime/.krmignore +++ b/e2e/testdata/fn-eval/default-runtime/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/default-runtime/resources.yaml b/e2e/testdata/fn-eval/default-runtime/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/default-runtime/resources.yaml +++ b/e2e/testdata/fn-eval/default-runtime/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/error-in-pipe/.expected/config.yaml b/e2e/testdata/fn-eval/error-in-pipe/.expected/config.yaml index faaa67e0e4..01481e94b2 100644 --- a/e2e/testdata/fn-eval/error-in-pipe/.expected/config.yaml +++ b/e2e/testdata/fn-eval/error-in-pipe/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-eval/error-in-pipe/.expected/exec.sh b/e2e/testdata/fn-eval/error-in-pipe/.expected/exec.sh index 785f5ba180..89933f3d1a 100755 --- a/e2e/testdata/fn-eval/error-in-pipe/.expected/exec.sh +++ b/e2e/testdata/fn-eval/error-in-pipe/.expected/exec.sh @@ -1,23 +1,23 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out - -kpt fn source \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/dne -- foo=bar \ -| kpt fn sink out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out + +kpt fn source \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/dne -- foo=bar \ +| kpt fn sink out diff --git a/e2e/testdata/fn-eval/error-in-pipe/.krmignore b/e2e/testdata/fn-eval/error-in-pipe/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-eval/error-in-pipe/.krmignore +++ b/e2e/testdata/fn-eval/error-in-pipe/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-eval/exec-function-stderr/.expected/config.yaml b/e2e/testdata/fn-eval/exec-function-stderr/.expected/config.yaml index 1e6fe2f040..d16a5ff2a1 100644 --- a/e2e/testdata/fn-eval/exec-function-stderr/.expected/config.yaml +++ b/e2e/testdata/fn-eval/exec-function-stderr/.expected/config.yaml @@ -1,21 +1,21 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -# This test tests `fn eval` UX with a function that succeeds with stderr output -# -testType: eval -stdErr: | - [RUNNING] "./function.sh" - [PASS] "./function.sh" in 0s +# Copyright 2021,2026 The kpt Authors +# +# 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. + +# This test tests `fn eval` UX with a function that succeeds with stderr output +# +testType: eval +stdErr: | + [RUNNING] "./function.sh" + [PASS] "./function.sh" in 0s Stderr: Hello world 0!, Hello world 1!, Hello world 2!, Hello world 3!, Hello world 4!, Hello world 5!, Hello world 6!, Hello world 7!, Hello world 8!, Hello world 9!, Hello world 10!, Hello world 11!, Hello world 12!, Hello world 13!, Hello world 14!, Hello world 15!, Hello world 16!, Hello world 17!, Hello world 18!, Hello world 19!, Hello world 20!, \ No newline at end of file diff --git a/e2e/testdata/fn-eval/exec-function-stderr/.expected/diff.patch b/e2e/testdata/fn-eval/exec-function-stderr/.expected/diff.patch index c35d542fb0..e23467f595 100644 --- a/e2e/testdata/fn-eval/exec-function-stderr/.expected/diff.patch +++ b/e2e/testdata/fn-eval/exec-function-stderr/.expected/diff.patch @@ -1,21 +1,21 @@ -diff --git a/resources.yaml b/resources.yaml -index 0f69886..ff4bde7 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,7 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -- namespace: foo -+ namespace: bar - spec: - replicas: 3 - --- -@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -- namespace: foo -+ namespace: bar - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index 0f69886..ff4bde7 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,7 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment +- namespace: foo ++ namespace: bar + spec: + replicas: 3 + --- +@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom +- namespace: foo ++ namespace: bar + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/exec-function-stderr/.expected/exec.sh b/e2e/testdata/fn-eval/exec-function-stderr/.expected/exec.sh index 76a6605880..dfeaa99bf5 100755 --- a/e2e/testdata/fn-eval/exec-function-stderr/.expected/exec.sh +++ b/e2e/testdata/fn-eval/exec-function-stderr/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval --exec ./function.sh +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval --exec ./function.sh diff --git a/e2e/testdata/fn-eval/exec-function-stderr/.krmignore b/e2e/testdata/fn-eval/exec-function-stderr/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/exec-function-stderr/.krmignore +++ b/e2e/testdata/fn-eval/exec-function-stderr/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/exec-function-stderr/function.sh b/e2e/testdata/fn-eval/exec-function-stderr/function.sh index 66bf707286..307507f8ff 100755 --- a/e2e/testdata/fn-eval/exec-function-stderr/function.sh +++ b/e2e/testdata/fn-eval/exec-function-stderr/function.sh @@ -1,21 +1,21 @@ -#! /usr/bin/env bash -# Copyright 2021 The kpt Authors -# -# 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. - -sed -e 's/foo/bar/' - -for i in {0..20} -do - >&2 echo "Hello world $i!" -done +#! /usr/bin/env bash +# Copyright 2021 The kpt Authors +# +# 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. + +sed -e 's/foo/bar/' + +for i in {0..20} +do + >&2 echo "Hello world $i!" +done diff --git a/e2e/testdata/fn-eval/exec-function-stderr/resources.yaml b/e2e/testdata/fn-eval/exec-function-stderr/resources.yaml index 0f69886ef5..159de16b1f 100644 --- a/e2e/testdata/fn-eval/exec-function-stderr/resources.yaml +++ b/e2e/testdata/fn-eval/exec-function-stderr/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/exec-function-with-args/.expected/diff.patch b/e2e/testdata/fn-eval/exec-function-with-args/.expected/diff.patch index c35d542fb0..e23467f595 100644 --- a/e2e/testdata/fn-eval/exec-function-with-args/.expected/diff.patch +++ b/e2e/testdata/fn-eval/exec-function-with-args/.expected/diff.patch @@ -1,21 +1,21 @@ -diff --git a/resources.yaml b/resources.yaml -index 0f69886..ff4bde7 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,7 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -- namespace: foo -+ namespace: bar - spec: - replicas: 3 - --- -@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -- namespace: foo -+ namespace: bar - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index 0f69886..ff4bde7 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,7 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment +- namespace: foo ++ namespace: bar + spec: + replicas: 3 + --- +@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom +- namespace: foo ++ namespace: bar + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/exec-function-with-args/.expected/exec.sh b/e2e/testdata/fn-eval/exec-function-with-args/.expected/exec.sh index ae6e3811c7..b8b4398782 100755 --- a/e2e/testdata/fn-eval/exec-function-with-args/.expected/exec.sh +++ b/e2e/testdata/fn-eval/exec-function-with-args/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval --exec "sed -e 's/foo/bar/'" +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval --exec "sed -e 's/foo/bar/'" diff --git a/e2e/testdata/fn-eval/exec-function-with-args/.krmignore b/e2e/testdata/fn-eval/exec-function-with-args/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/exec-function-with-args/.krmignore +++ b/e2e/testdata/fn-eval/exec-function-with-args/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/exec-function-with-args/resources.yaml b/e2e/testdata/fn-eval/exec-function-with-args/resources.yaml index 0f69886ef5..159de16b1f 100644 --- a/e2e/testdata/fn-eval/exec-function-with-args/resources.yaml +++ b/e2e/testdata/fn-eval/exec-function-with-args/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/exec-function/.expected/config.yaml b/e2e/testdata/fn-eval/exec-function/.expected/config.yaml index b61b4c3bd7..5e24dfb257 100644 --- a/e2e/testdata/fn-eval/exec-function/.expected/config.yaml +++ b/e2e/testdata/fn-eval/exec-function/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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 -execPath: ../function.sh +# Copyright 2021 The kpt Authors +# +# 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 +execPath: ../function.sh diff --git a/e2e/testdata/fn-eval/exec-function/.expected/diff.patch b/e2e/testdata/fn-eval/exec-function/.expected/diff.patch index c35d542fb0..e23467f595 100644 --- a/e2e/testdata/fn-eval/exec-function/.expected/diff.patch +++ b/e2e/testdata/fn-eval/exec-function/.expected/diff.patch @@ -1,21 +1,21 @@ -diff --git a/resources.yaml b/resources.yaml -index 0f69886..ff4bde7 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,7 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -- namespace: foo -+ namespace: bar - spec: - replicas: 3 - --- -@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -- namespace: foo -+ namespace: bar - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index 0f69886..ff4bde7 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,7 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment +- namespace: foo ++ namespace: bar + spec: + replicas: 3 + --- +@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom +- namespace: foo ++ namespace: bar + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/exec-function/.krmignore b/e2e/testdata/fn-eval/exec-function/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/exec-function/.krmignore +++ b/e2e/testdata/fn-eval/exec-function/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/exec-function/function.sh b/e2e/testdata/fn-eval/exec-function/function.sh index db929d2164..1e663ea696 100755 --- a/e2e/testdata/fn-eval/exec-function/function.sh +++ b/e2e/testdata/fn-eval/exec-function/function.sh @@ -1,17 +1,17 @@ -#! /usr/bin/env bash -# Copyright 2021 The kpt Authors -# -# 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. - - -sed -e 's/foo/bar/' +#! /usr/bin/env bash +# Copyright 2021 The kpt Authors +# +# 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. + + +sed -e 's/foo/bar/' diff --git a/e2e/testdata/fn-eval/exec-function/resources.yaml b/e2e/testdata/fn-eval/exec-function/resources.yaml index 0f69886ef5..159de16b1f 100644 --- a/e2e/testdata/fn-eval/exec-function/resources.yaml +++ b/e2e/testdata/fn-eval/exec-function/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml index 41105abedd..740ef6a9d1 100644 --- a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -fnConfig: ../config.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +fnConfig: ../config.yaml diff --git a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/diff.patch b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/diff.patch index 90fa637676..7fafa414a5 100644 --- a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/diff.patch +++ b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/diff.patch @@ -1,30 +1,30 @@ -diff --git a/config.yaml b/config.yaml -index 003e3fe..7a2ceea 100644 ---- a/config.yaml -+++ b/config.yaml -@@ -15,5 +15,6 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: config -+ namespace: staging - data: - namespace: staging -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/config.yaml b/config.yaml +index 003e3fe..7a2ceea 100644 +--- a/config.yaml ++++ b/config.yaml +@@ -15,5 +15,6 @@ apiVersion: v1 + kind: ConfigMap + metadata: + name: config ++ namespace: staging + data: + namespace: staging +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.krmignore b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/fn-config-file-in-pkg/.krmignore +++ b/e2e/testdata/fn-eval/fn-config-file-in-pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/fn-config-file-in-pkg/config.yaml b/e2e/testdata/fn-eval/fn-config-file-in-pkg/config.yaml index 003e3fe922..52e51d3303 100644 --- a/e2e/testdata/fn-eval/fn-config-file-in-pkg/config.yaml +++ b/e2e/testdata/fn-eval/fn-config-file-in-pkg/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: config -data: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: config +data: + namespace: staging diff --git a/e2e/testdata/fn-eval/fn-config-file-in-pkg/resources.yaml b/e2e/testdata/fn-eval/fn-config-file-in-pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/fn-config-file-in-pkg/resources.yaml +++ b/e2e/testdata/fn-eval/fn-config-file-in-pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/fn-config-file/config.yaml b/e2e/testdata/fn-eval/fn-config-file/config.yaml index 003e3fe922..52e51d3303 100644 --- a/e2e/testdata/fn-eval/fn-config-file/config.yaml +++ b/e2e/testdata/fn-eval/fn-config-file/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: config -data: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: config +data: + namespace: staging diff --git a/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml index c7156ac8dc..5195be8056 100644 --- a/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -fnConfig: ../../config.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +fnConfig: ../../config.yaml diff --git a/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/diff.patch b/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/diff.patch index 551c6bfb48..8af6c0ffea 100644 --- a/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/diff.patch +++ b/e2e/testdata/fn-eval/fn-config-file/pkg/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/fn-config-file/pkg/.krmignore b/e2e/testdata/fn-eval/fn-config-file/pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/fn-config-file/pkg/.krmignore +++ b/e2e/testdata/fn-eval/fn-config-file/pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/fn-config-file/pkg/resources.yaml b/e2e/testdata/fn-eval/fn-config-file/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/fn-config-file/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/fn-config-file/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/diff.patch b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/diff.patch index cb6d3bc36a..de1ac330a8 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/diff.patch +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/diff.patch @@ -1,75 +1,75 @@ -diff --git a/out/Kptfile b/out/Kptfile -new file mode 100644 -index 0000000..ede2393 ---- /dev/null -+++ b/out/Kptfile -@@ -0,0 +1,9 @@ -+apiVersion: kpt.dev/v1 -+kind: Kptfile -+metadata: -+ name: app -+ namespace: staging -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -+ configPath: labelconfig.yaml -diff --git a/out/labelconfig.yaml b/out/labelconfig.yaml -new file mode 100644 -index 0000000..37baaa2 ---- /dev/null -+++ b/out/labelconfig.yaml -@@ -0,0 +1,20 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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: v1 -+kind: ConfigMap -+metadata: -+ name: label-config -+ namespace: staging -+data: -+ tier: app -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..b66c419 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,28 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+spec: -+ replicas: 3 -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+ namespace: staging -+spec: -+ image: nginx:1.2.3 +diff --git a/out/Kptfile b/out/Kptfile +new file mode 100644 +index 0000000..ede2393 +--- /dev/null ++++ b/out/Kptfile +@@ -0,0 +1,9 @@ ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++ namespace: staging ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: labelconfig.yaml +diff --git a/out/labelconfig.yaml b/out/labelconfig.yaml +new file mode 100644 +index 0000000..37baaa2 +--- /dev/null ++++ b/out/labelconfig.yaml +@@ -0,0 +1,20 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: label-config ++ namespace: staging ++data: ++ tier: app +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..b66c419 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,28 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ namespace: staging ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/exec.sh b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/exec.sh index c89af94657..6e531a60d9 100755 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/exec.sh +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out - -kpt fn source \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging \ -| kpt fn sink out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out + +kpt fn source \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging \ +| kpt fn sink out diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.krmignore b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.krmignore +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/Kptfile b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/Kptfile index 92a643d65f..10a45e6946 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/Kptfile +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/labelconfig.yaml b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/labelconfig.yaml +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/resources.yaml b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/resources.yaml +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resource-out-of-place/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/diff.patch b/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/diff.patch index cb6d3bc36a..de1ac330a8 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/diff.patch +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/diff.patch @@ -1,75 +1,75 @@ -diff --git a/out/Kptfile b/out/Kptfile -new file mode 100644 -index 0000000..ede2393 ---- /dev/null -+++ b/out/Kptfile -@@ -0,0 +1,9 @@ -+apiVersion: kpt.dev/v1 -+kind: Kptfile -+metadata: -+ name: app -+ namespace: staging -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -+ configPath: labelconfig.yaml -diff --git a/out/labelconfig.yaml b/out/labelconfig.yaml -new file mode 100644 -index 0000000..37baaa2 ---- /dev/null -+++ b/out/labelconfig.yaml -@@ -0,0 +1,20 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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: v1 -+kind: ConfigMap -+metadata: -+ name: label-config -+ namespace: staging -+data: -+ tier: app -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..b66c419 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,28 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+spec: -+ replicas: 3 -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+ namespace: staging -+spec: -+ image: nginx:1.2.3 +diff --git a/out/Kptfile b/out/Kptfile +new file mode 100644 +index 0000000..ede2393 +--- /dev/null ++++ b/out/Kptfile +@@ -0,0 +1,9 @@ ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++ namespace: staging ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: labelconfig.yaml +diff --git a/out/labelconfig.yaml b/out/labelconfig.yaml +new file mode 100644 +index 0000000..37baaa2 +--- /dev/null ++++ b/out/labelconfig.yaml +@@ -0,0 +1,20 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: label-config ++ namespace: staging ++data: ++ tier: app +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..b66c419 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,28 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ namespace: staging ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/exec.sh b/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/exec.sh index c89af94657..6e531a60d9 100755 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/exec.sh +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resources/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out - -kpt fn source \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging \ -| kpt fn sink out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out + +kpt fn source \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging \ +| kpt fn sink out diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resources/.krmignore b/e2e/testdata/fn-eval/fn-source/include-meta-resources/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resources/.krmignore +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resources/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resources/Kptfile b/e2e/testdata/fn-eval/fn-source/include-meta-resources/Kptfile index 92a643d65f..10a45e6946 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resources/Kptfile +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resources/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resources/labelconfig.yaml b/e2e/testdata/fn-eval/fn-source/include-meta-resources/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resources/labelconfig.yaml +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resources/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-eval/fn-source/include-meta-resources/resources.yaml b/e2e/testdata/fn-eval/fn-source/include-meta-resources/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/fn-source/include-meta-resources/resources.yaml +++ b/e2e/testdata/fn-eval/fn-source/include-meta-resources/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/config.yaml index 7dc5d1242d..3018124bb0 100644 --- a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest -fnConfig: ../../starlark.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +fnConfig: ../../starlark.yaml diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/results.yaml b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/results.yaml index cf502766a9..e6090e4f88 100644 --- a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/results.yaml +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/results.yaml @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: FunctionResultList -metadata: - name: fnresults -exitCode: 0 -items: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - stderr: function succeeded, reporting it on stderr - exitCode: 0 +apiVersion: kpt.dev/v1 +kind: FunctionResultList +metadata: + name: fnresults +exitCode: 0 +items: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + stderr: function succeeded, reporting it on stderr + exitCode: 0 diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.krmignore b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.krmignore +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/resources.yaml b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/starlark.yaml b/e2e/testdata/fn-eval/fn-success-with-stderr/starlark.yaml index d49296a556..4509f9eeb9 100644 --- a/e2e/testdata/fn-eval/fn-success-with-stderr/starlark.yaml +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/starlark.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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: | - print("function succeeded, reporting it on stderr") +# Copyright 2021 The kpt Authors +# +# 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: | + print("function succeeded, reporting it on stderr") diff --git a/e2e/testdata/fn-eval/fnconfig-missing-name/config.yaml b/e2e/testdata/fn-eval/fnconfig-missing-name/config.yaml index a5cc978ead..8679530e2f 100644 --- a/e2e/testdata/fn-eval/fnconfig-missing-name/config.yaml +++ b/e2e/testdata/fn-eval/fnconfig-missing-name/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -data: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +data: + namespace: staging diff --git a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml index 3e7df546ea..db3061ab09 100644 --- a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -fnConfig: ../../config.yaml -exitCode: 1 -stdErr: "resource must have `metadata.name`" +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +fnConfig: ../../config.yaml +exitCode: 1 +stdErr: "resource must have `metadata.name`" diff --git a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.krmignore b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.krmignore +++ b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/resources.yaml b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/fnconfig-missing-name/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/function-chain/.expected/diff.patch b/e2e/testdata/fn-eval/function-chain/.expected/diff.patch index cbb36e085e..50d4a2cdb1 100644 --- a/e2e/testdata/fn-eval/function-chain/.expected/diff.patch +++ b/e2e/testdata/fn-eval/function-chain/.expected/diff.patch @@ -1,45 +1,45 @@ -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..94ced72 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,39 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+ labels: -+ foo: bar -+spec: -+ replicas: 3 -+ selector: -+ matchLabels: -+ foo: bar -+ template: -+ metadata: -+ labels: -+ foo: bar -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+ namespace: staging -+ labels: -+ foo: bar -+spec: -+ image: nginx:1.2.3 +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..94ced72 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,39 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++ labels: ++ foo: bar ++spec: ++ replicas: 3 ++ selector: ++ matchLabels: ++ foo: bar ++ template: ++ metadata: ++ labels: ++ foo: bar ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ namespace: staging ++ labels: ++ foo: bar ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/function-chain/.expected/exec.sh b/e2e/testdata/fn-eval/function-chain/.expected/exec.sh index 87f11f11a7..8c2f0144a5 100755 --- a/e2e/testdata/fn-eval/function-chain/.expected/exec.sh +++ b/e2e/testdata/fn-eval/function-chain/.expected/exec.sh @@ -1,23 +1,23 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out - -kpt fn source \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -- foo=bar \ -| kpt fn sink out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out + +kpt fn source \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -- foo=bar \ +| kpt fn sink out diff --git a/e2e/testdata/fn-eval/function-chain/.krmignore b/e2e/testdata/fn-eval/function-chain/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/function-chain/.krmignore +++ b/e2e/testdata/fn-eval/function-chain/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/function-chain/resources.yaml b/e2e/testdata/fn-eval/function-chain/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/function-chain/resources.yaml +++ b/e2e/testdata/fn-eval/function-chain/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/function-env/.expected/config.yaml b/e2e/testdata/fn-eval/function-env/.expected/config.yaml index 12804f728c..89cffa4c4f 100644 --- a/e2e/testdata/fn-eval/function-env/.expected/config.yaml +++ b/e2e/testdata/fn-eval/function-env/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: "EXPORT_ENV=export_env_value" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: "EXPORT_ENV=export_env_value" diff --git a/e2e/testdata/fn-eval/function-env/.expected/exec.sh b/e2e/testdata/fn-eval/function-env/.expected/exec.sh index 936e20ae18..bce89e5270 100755 --- a/e2e/testdata/fn-eval/function-env/.expected/exec.sh +++ b/e2e/testdata/fn-eval/function-env/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -IMAGE_TAG="ghcr.io/kptdev/krm-functions-catalog/printenv:v0.1" -export EXPORT_ENV="export_env_value" - -kpt fn source \ -| kpt fn eval - --image $IMAGE_TAG -e EXPORT_ENV -e FOO=BAR +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +IMAGE_TAG="ghcr.io/kptdev/krm-functions-catalog/printenv:v0.1" +export EXPORT_ENV="export_env_value" + +kpt fn source \ +| kpt fn eval - --image $IMAGE_TAG -e EXPORT_ENV -e FOO=BAR diff --git a/e2e/testdata/fn-eval/function-env/.krmignore b/e2e/testdata/fn-eval/function-env/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/function-env/.krmignore +++ b/e2e/testdata/fn-eval/function-env/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/image-pull-policy-always/.expected/config.yaml b/e2e/testdata/fn-eval/image-pull-policy-always/.expected/config.yaml index b56e8bb95e..70dc4cdc1f 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-always/.expected/config.yaml +++ b/e2e/testdata/fn-eval/image-pull-policy-always/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 -sequential: true -imagePullPolicy: Always -exitCode: 1 -stdErr: foo +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +sequential: true +imagePullPolicy: Always +exitCode: 1 +stdErr: foo diff --git a/e2e/testdata/fn-eval/image-pull-policy-always/.expected/setup.sh b/e2e/testdata/fn-eval/image-pull-policy-always/.expected/setup.sh index 4d3f77f4f6..9c11e1b2a3 100755 --- a/e2e/testdata/fn-eval/image-pull-policy-always/.expected/setup.sh +++ b/e2e/testdata/fn-eval/image-pull-policy-always/.expected/setup.sh @@ -1,25 +1,25 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" - -# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and -# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. -# We intentionally tag a wrong image as ghcr.io/kptdev/krm-functions-catalog/foo:v0.1, since we -# expect the correct image to be pulled and override the wrong image. -${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 -${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" + +# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and +# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. +# We intentionally tag a wrong image as ghcr.io/kptdev/krm-functions-catalog/foo:v0.1, since we +# expect the correct image to be pulled and override the wrong image. +${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 diff --git a/e2e/testdata/fn-eval/image-pull-policy-always/.krmignore b/e2e/testdata/fn-eval/image-pull-policy-always/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-always/.krmignore +++ b/e2e/testdata/fn-eval/image-pull-policy-always/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/config.yaml b/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/config.yaml index 5922201b9a..0f5c9d0673 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/config.yaml +++ b/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 -sequential: true -imagePullPolicy: IfNotPresent -exitCode: 1 -stdErr: foo +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +sequential: true +imagePullPolicy: IfNotPresent +exitCode: 1 +stdErr: foo diff --git a/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/setup.sh b/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/setup.sh index c1aeb03f12..7e65f24a80 100755 --- a/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/setup.sh +++ b/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.expected/setup.sh @@ -1,24 +1,24 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" - -# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and -# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. -# We intentionally tag a wrong image as pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 -${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 -${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" + +# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and +# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. +# We intentionally tag a wrong image as pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 diff --git a/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.krmignore b/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.krmignore +++ b/e2e/testdata/fn-eval/image-pull-policy-if-not-present/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/image-pull-policy-never/.expected/config.yaml b/e2e/testdata/fn-eval/image-pull-policy-never/.expected/config.yaml index ade70f82ca..5ca8dd1a78 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-never/.expected/config.yaml +++ b/e2e/testdata/fn-eval/image-pull-policy-never/.expected/config.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/not-exist:latest -imagePullPolicy: Never -exitCode: 1 -# The output in stderr is different depending on the runtime. -# "No such image" is from docker and "image not known" is from podman. -stdErrRegEx: No such image|image not known +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/not-exist:latest +imagePullPolicy: Never +exitCode: 1 +# The output in stderr is different depending on the runtime. +# "No such image" is from docker and "image not known" is from podman. +stdErrRegEx: No such image|image not known diff --git a/e2e/testdata/fn-eval/image-pull-policy-never/.krmignore b/e2e/testdata/fn-eval/image-pull-policy-never/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-never/.krmignore +++ b/e2e/testdata/fn-eval/image-pull-policy-never/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/image-pull-policy-never/resources.yaml b/e2e/testdata/fn-eval/image-pull-policy-never/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/image-pull-policy-never/resources.yaml +++ b/e2e/testdata/fn-eval/image-pull-policy-never/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml index 63e976d46b..525a047f43 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -runCount: 2 -testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -includeMetaResources: true -exitCode: 1 -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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. + +runCount: 2 +testType: eval +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +includeMetaResources: true +exitCode: 1 +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.krmignore b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.krmignore +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/Kptfile b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/Kptfile index f5d3715446..0365122bbb 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/Kptfile +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/Kptfile @@ -1,101 +1,101 @@ -apiVersion: kpt.dev/v1alpha1 -kind: Kptfile -metadata: - name: nginx -dependencies: - - name: hello-world - updateStrategy: fast-forward - stdin: - filenamePattern: foo* - original: bar - autoSet: false - ensureNotExists: false - functions: - - image: ghcr.io/kptdev/krm-functions-catalog/my-func:latest - config: - apiVersion: v1 - kind: ConfigMap - metadata: - name: function-config - data: - param1: value1 - git: - directory: /package-examples/helloworld-set - ref: master - repo: https://github.com/kptdev/kpt -functions: - autoRunStarlark: true - starlarkFunctions: - - name: foo-star - path: path/to/foo-star.yaml -inventory: - name: inventory-00933591 - namespace: some-space - labels: - foo: bar - annotations: - abc: def - inventoryID: 92c234b7e9267815b0c3e17c9e4d7139a16c104f-1620493522822890000 -openAPI: - definitions: - io.k8s.cli.setters.image: - x-k8s-cli: - setter: - name: image - value: nginx - io.k8s.cli.setters.list: - type: array - x-k8s-cli: - setter: - name: list - value: "" - listValues: - - dev - - stage - io.k8s.cli.setters.namespace: - type: string - maxLength: 10 - x-k8s-cli: - setter: - name: namespace - value: some-space - io.k8s.cli.setters.tag: - x-k8s-cli: - setter: - name: tag - value: 1.14.1 - io.k8s.cli.substitutions.fullimage: - x-k8s-cli: - substitution: - name: fullimage - pattern: ${image}:${tag} - values: - - marker: ${image} - ref: '#/definitions/io.k8s.cli.setters.image' - - marker: ${tag} - ref: '#/definitions/io.k8s.cli.setters.tag' - io.k8s.cli.substitutions.imageidentifier: - x-k8s-cli: - substitution: - name: imageidentifier - pattern: deployment-${fullimage} - values: - - marker: ${fullimage} - ref: '#/definitions/io.k8s.cli.substitutions.fullimage' -packageMetadata: - email: foo@gmail.com - license: license text - man: nginx man text - shortDescription: describe this package - tags: - - tag1 - - tag2 - url: https://github.com/kptdev/kpt - version: v0.1 -upstream: - type: git - git: - commit: 4d2aa98b45ddee4b5fa45fbca16f2ff887de9efb - directory: package-examples/nginx - ref: v0.2 - repo: https://github.com/kptdev/kpt +apiVersion: kpt.dev/v1alpha1 +kind: Kptfile +metadata: + name: nginx +dependencies: + - name: hello-world + updateStrategy: fast-forward + stdin: + filenamePattern: foo* + original: bar + autoSet: false + ensureNotExists: false + functions: + - image: ghcr.io/kptdev/krm-functions-catalog/my-func:latest + config: + apiVersion: v1 + kind: ConfigMap + metadata: + name: function-config + data: + param1: value1 + git: + directory: /package-examples/helloworld-set + ref: master + repo: https://github.com/kptdev/kpt +functions: + autoRunStarlark: true + starlarkFunctions: + - name: foo-star + path: path/to/foo-star.yaml +inventory: + name: inventory-00933591 + namespace: some-space + labels: + foo: bar + annotations: + abc: def + inventoryID: 92c234b7e9267815b0c3e17c9e4d7139a16c104f-1620493522822890000 +openAPI: + definitions: + io.k8s.cli.setters.image: + x-k8s-cli: + setter: + name: image + value: nginx + io.k8s.cli.setters.list: + type: array + x-k8s-cli: + setter: + name: list + value: "" + listValues: + - dev + - stage + io.k8s.cli.setters.namespace: + type: string + maxLength: 10 + x-k8s-cli: + setter: + name: namespace + value: some-space + io.k8s.cli.setters.tag: + x-k8s-cli: + setter: + name: tag + value: 1.14.1 + io.k8s.cli.substitutions.fullimage: + x-k8s-cli: + substitution: + name: fullimage + pattern: ${image}:${tag} + values: + - marker: ${image} + ref: '#/definitions/io.k8s.cli.setters.image' + - marker: ${tag} + ref: '#/definitions/io.k8s.cli.setters.tag' + io.k8s.cli.substitutions.imageidentifier: + x-k8s-cli: + substitution: + name: imageidentifier + pattern: deployment-${fullimage} + values: + - marker: ${fullimage} + ref: '#/definitions/io.k8s.cli.substitutions.fullimage' +packageMetadata: + email: foo@gmail.com + license: license text + man: nginx man text + shortDescription: describe this package + tags: + - tag1 + - tag2 + url: https://github.com/kptdev/kpt + version: v0.1 +upstream: + type: git + git: + commit: 4d2aa98b45ddee4b5fa45fbca16f2ff887de9efb + directory: package-examples/nginx + ref: v0.2 + repo: https://github.com/kptdev/kpt diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/labelconfig.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/labelconfig.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/resources.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/resources.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha1/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml index 63e976d46b..525a047f43 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -runCount: 2 -testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -includeMetaResources: true -exitCode: 1 -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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. + +runCount: 2 +testType: eval +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +includeMetaResources: true +exitCode: 1 +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.krmignore b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.krmignore +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/Kptfile b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/Kptfile index 41039c990c..65ef41591f 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/Kptfile +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1alpha2 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1alpha2 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/labelconfig.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/labelconfig.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/resources.yaml b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/resources.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources-v1alpha2/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml b/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml index 63e976d46b..525a047f43 100644 --- a/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -runCount: 2 -testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -includeMetaResources: true -exitCode: 1 -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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. + +runCount: 2 +testType: eval +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +includeMetaResources: true +exitCode: 1 +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/include-meta-resources/.krmignore b/e2e/testdata/fn-eval/include-meta-resources/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/include-meta-resources/.krmignore +++ b/e2e/testdata/fn-eval/include-meta-resources/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/include-meta-resources/Kptfile b/e2e/testdata/fn-eval/include-meta-resources/Kptfile index 92a643d65f..10a45e6946 100644 --- a/e2e/testdata/fn-eval/include-meta-resources/Kptfile +++ b/e2e/testdata/fn-eval/include-meta-resources/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/include-meta-resources/labelconfig.yaml b/e2e/testdata/fn-eval/include-meta-resources/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-eval/include-meta-resources/labelconfig.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-eval/include-meta-resources/resources.yaml b/e2e/testdata/fn-eval/include-meta-resources/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/include-meta-resources/resources.yaml +++ b/e2e/testdata/fn-eval/include-meta-resources/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/invalid-fn-config-file/config.yaml b/e2e/testdata/fn-eval/invalid-fn-config-file/config.yaml index 2634f542fc..8343c9581c 100644 --- a/e2e/testdata/fn-eval/invalid-fn-config-file/config.yaml +++ b/e2e/testdata/fn-eval/invalid-fn-config-file/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -I am not a valid config file +# Copyright 2021 The kpt Authors +# +# 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. + +I am not a valid config file diff --git a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml index fc96a355dd..4b03b51b63 100644 --- a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 -exitCode: 1 -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -fnConfig: ../../config.yaml -stdErr: "wrong node kind: expected MappingNode but got ScalarNode: node contents:\nI am not a valid config file\n" +# Copyright 2021 The kpt Authors +# +# 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 +exitCode: 1 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +fnConfig: ../../config.yaml +stdErr: "wrong node kind: expected MappingNode but got ScalarNode: node contents:\nI am not a valid config file\n" diff --git a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.krmignore b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.krmignore +++ b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/resources.yaml b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/invalid-fn-config-file/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/config.yaml b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/config.yaml index 78d89a4de0..64ee6501ee 100644 --- a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/config.yaml +++ b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -args: - tier: backend +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +args: + tier: backend diff --git a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/diff.patch b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/diff.patch index d851cb49cd..60ffa699d0 100644 --- a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/diff.patch +++ b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.expected/diff.patch @@ -1,56 +1,56 @@ -diff --git a/Kptfile b/Kptfile -index 2985a1a..3dfdcf6 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ labels: -+ tier: backend - pipeline: - mutators: - - image: set-labels:v0.1.5 -diff --git a/kustomization.yaml b/kustomization.yaml -index f3f0207..6c517af 100644 ---- a/kustomization.yaml -+++ b/kustomization.yaml -@@ -11,7 +11,9 @@ - # 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. -- - # kustomization.yaml contents - resources: - - resources.yaml -+metadata: -+ labels: -+ tier: backend -diff --git a/resources.yaml b/resources.yaml -index 40a033d..eb585ba 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,12 +15,23 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ labels: -+ tier: backend - spec: - replicas: 3 -+ selector: -+ matchLabels: -+ tier: backend -+ template: -+ metadata: -+ labels: -+ tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ labels: -+ tier: backend - spec: - image: nginx:1.2.3 # kpt-set: {something} +diff --git a/Kptfile b/Kptfile +index 2985a1a..3dfdcf6 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ labels: ++ tier: backend + pipeline: + mutators: + - image: set-labels:v0.1.5 +diff --git a/kustomization.yaml b/kustomization.yaml +index f3f0207..6c517af 100644 +--- a/kustomization.yaml ++++ b/kustomization.yaml +@@ -11,7 +11,9 @@ + # 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. +- + # kustomization.yaml contents + resources: + - resources.yaml ++metadata: ++ labels: ++ tier: backend +diff --git a/resources.yaml b/resources.yaml +index 40a033d..eb585ba 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,12 +15,23 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ labels: ++ tier: backend + spec: + replicas: 3 ++ selector: ++ matchLabels: ++ tier: backend ++ template: ++ metadata: ++ labels: ++ tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ labels: ++ tier: backend + spec: + image: nginx:1.2.3 # kpt-set: {something} diff --git a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.krmignore b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.krmignore +++ b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/Kptfile b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/Kptfile index 2985a1af95..a75ee2b0d9 100644 --- a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/Kptfile +++ b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/kustomization.yaml b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/kustomization.yaml index f3f0207b7c..f4af88c33a 100644 --- a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/kustomization.yaml +++ b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/kustomization.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# kustomization.yaml contents -resources: -- resources.yaml +# Copyright 2021 The kpt Authors +# +# 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. + +# kustomization.yaml contents +resources: +- resources.yaml diff --git a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/resources.yaml b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/resources.yaml index 40a033d97a..cc403eb351 100644 --- a/e2e/testdata/fn-eval/krm-check-exclude-kustomize/resources.yaml +++ b/e2e/testdata/fn-eval/krm-check-exclude-kustomize/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 # kpt-set: {something} +# Copyright 2021 The kpt Authors +# +# 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 # kpt-set: {something} diff --git a/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml b/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml index 6f67004bba..5dbf8a82ce 100644 --- a/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml +++ b/e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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 -exitCode: 1 -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -stdErr: "failed to configure function: input namespace cannot be empty" +# Copyright 2021 The kpt Authors +# +# 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 +exitCode: 1 +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +stdErr: "failed to configure function: input namespace cannot be empty" diff --git a/e2e/testdata/fn-eval/missing-fn-config/.krmignore b/e2e/testdata/fn-eval/missing-fn-config/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/missing-fn-config/.krmignore +++ b/e2e/testdata/fn-eval/missing-fn-config/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/missing-fn-config/resources.yaml b/e2e/testdata/fn-eval/missing-fn-config/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/missing-fn-config/resources.yaml +++ b/e2e/testdata/fn-eval/missing-fn-config/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/missing-fn-image/.expected/config.yaml b/e2e/testdata/fn-eval/missing-fn-image/.expected/config.yaml index e4214c3ba0..ea644da168 100644 --- a/e2e/testdata/fn-eval/missing-fn-image/.expected/config.yaml +++ b/e2e/testdata/fn-eval/missing-fn-image/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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 -exitCode: 1 -image: ghcr.io/kptdev/krm-functions-catalog/dne # non-existing image -args: - namespace: staging -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error: initializing source docker:)" +# Copyright 2021 The kpt Authors +# +# 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 +exitCode: 1 +image: ghcr.io/kptdev/krm-functions-catalog/dne # non-existing image +args: + namespace: staging +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error: initializing source docker:)" diff --git a/e2e/testdata/fn-eval/missing-fn-image/.krmignore b/e2e/testdata/fn-eval/missing-fn-image/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/missing-fn-image/.krmignore +++ b/e2e/testdata/fn-eval/missing-fn-image/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/missing-fn-image/resources.yaml b/e2e/testdata/fn-eval/missing-fn-image/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/missing-fn-image/resources.yaml +++ b/e2e/testdata/fn-eval/missing-fn-image/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/config.yaml b/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/config.yaml index d62367c485..bf7f23d8d4 100644 --- a/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/config.yaml +++ b/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest -fnConfig: ../starlark-fn.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +fnConfig: ../starlark-fn.yaml diff --git a/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/diff.patch b/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/diff.patch index 532465c2d7..374206578a 100644 --- a/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/diff.patch +++ b/e2e/testdata/fn-eval/modify-legacy-path-annotation/.expected/diff.patch @@ -1,4 +1,4 @@ -diff --git a/deployment.yaml b/newfilename.yaml -similarity index 100% -rename from deployment.yaml -rename to newfilename.yaml +diff --git a/deployment.yaml b/newfilename.yaml +similarity index 100% +rename from deployment.yaml +rename to newfilename.yaml diff --git a/e2e/testdata/fn-eval/modify-legacy-path-annotation/.krmignore b/e2e/testdata/fn-eval/modify-legacy-path-annotation/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/modify-legacy-path-annotation/.krmignore +++ b/e2e/testdata/fn-eval/modify-legacy-path-annotation/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/modify-legacy-path-annotation/deployment.yaml b/e2e/testdata/fn-eval/modify-legacy-path-annotation/deployment.yaml index eedcce0e6e..910325cd6f 100644 --- a/e2e/testdata/fn-eval/modify-legacy-path-annotation/deployment.yaml +++ b/e2e/testdata/fn-eval/modify-legacy-path-annotation/deployment.yaml @@ -1,35 +1,35 @@ -# Copyright 2021 The kpt Authors -# -# 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: - labels: - foo: bar - name: my-nginx -spec: - replicas: 3 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - image: nginx:1.14.2 - name: nginx - ports: - - containerPort: 80 - protocol: TCP +# Copyright 2021 The kpt Authors +# +# 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: + labels: + foo: bar + name: my-nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - image: nginx:1.14.2 + name: nginx + ports: + - containerPort: 80 + protocol: TCP diff --git a/e2e/testdata/fn-eval/modify-legacy-path-annotation/starlark-fn.yaml b/e2e/testdata/fn-eval/modify-legacy-path-annotation/starlark-fn.yaml index 2dbdee7938..d55e458052 100644 --- a/e2e/testdata/fn-eval/modify-legacy-path-annotation/starlark-fn.yaml +++ b/e2e/testdata/fn-eval/modify-legacy-path-annotation/starlark-fn.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: update-path -source: | - for r in ctx.resource_list["items"]: - if r["kind"] == "Deployment": - r["metadata"]["annotations"]["config.kubernetes.io/path"] = "newfilename.yaml" +# Copyright 2021 The kpt Authors +# +# 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: update-path +source: | + for r in ctx.resource_list["items"]: + if r["kind"] == "Deployment": + r["metadata"]["annotations"]["config.kubernetes.io/path"] = "newfilename.yaml" diff --git a/e2e/testdata/fn-eval/modify-path-annotation/.expected/config.yaml b/e2e/testdata/fn-eval/modify-path-annotation/.expected/config.yaml index d62367c485..bf7f23d8d4 100644 --- a/e2e/testdata/fn-eval/modify-path-annotation/.expected/config.yaml +++ b/e2e/testdata/fn-eval/modify-path-annotation/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest -fnConfig: ../starlark-fn.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +fnConfig: ../starlark-fn.yaml diff --git a/e2e/testdata/fn-eval/modify-path-annotation/.expected/diff.patch b/e2e/testdata/fn-eval/modify-path-annotation/.expected/diff.patch index 532465c2d7..374206578a 100644 --- a/e2e/testdata/fn-eval/modify-path-annotation/.expected/diff.patch +++ b/e2e/testdata/fn-eval/modify-path-annotation/.expected/diff.patch @@ -1,4 +1,4 @@ -diff --git a/deployment.yaml b/newfilename.yaml -similarity index 100% -rename from deployment.yaml -rename to newfilename.yaml +diff --git a/deployment.yaml b/newfilename.yaml +similarity index 100% +rename from deployment.yaml +rename to newfilename.yaml diff --git a/e2e/testdata/fn-eval/modify-path-annotation/.krmignore b/e2e/testdata/fn-eval/modify-path-annotation/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/modify-path-annotation/.krmignore +++ b/e2e/testdata/fn-eval/modify-path-annotation/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/modify-path-annotation/deployment.yaml b/e2e/testdata/fn-eval/modify-path-annotation/deployment.yaml index eedcce0e6e..910325cd6f 100644 --- a/e2e/testdata/fn-eval/modify-path-annotation/deployment.yaml +++ b/e2e/testdata/fn-eval/modify-path-annotation/deployment.yaml @@ -1,35 +1,35 @@ -# Copyright 2021 The kpt Authors -# -# 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: - labels: - foo: bar - name: my-nginx -spec: - replicas: 3 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - image: nginx:1.14.2 - name: nginx - ports: - - containerPort: 80 - protocol: TCP +# Copyright 2021 The kpt Authors +# +# 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: + labels: + foo: bar + name: my-nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - image: nginx:1.14.2 + name: nginx + ports: + - containerPort: 80 + protocol: TCP diff --git a/e2e/testdata/fn-eval/modify-path-annotation/starlark-fn.yaml b/e2e/testdata/fn-eval/modify-path-annotation/starlark-fn.yaml index 0ef906e41b..74f90161bb 100644 --- a/e2e/testdata/fn-eval/modify-path-annotation/starlark-fn.yaml +++ b/e2e/testdata/fn-eval/modify-path-annotation/starlark-fn.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: update-path -source: | - for r in ctx.resource_list["items"]: - if r["kind"] == "Deployment": - r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "newfilename.yaml" +# Copyright 2021 The kpt Authors +# +# 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: update-path +source: | + for r in ctx.resource_list["items"]: + if r["kind"] == "Deployment": + r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "newfilename.yaml" diff --git a/e2e/testdata/fn-eval/multiple-fn-config-one-file/config.yaml b/e2e/testdata/fn-eval/multiple-fn-config-one-file/config.yaml index b45a94ef54..3ad0db7a38 100644 --- a/e2e/testdata/fn-eval/multiple-fn-config-one-file/config.yaml +++ b/e2e/testdata/fn-eval/multiple-fn-config-one-file/config.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: config -data: - namespace: staging ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: config -data: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: config +data: + namespace: staging +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: config +data: + namespace: staging diff --git a/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml index 853cc5535b..c3b1c54f83 100644 --- a/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -fnConfig: ../../config.yaml -exitCode: 1 -stdErr: "must not contain more than one config, got 2" +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +fnConfig: ../../config.yaml +exitCode: 1 +stdErr: "must not contain more than one config, got 2" diff --git a/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/resources.yaml b/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/multiple-fn-config-one-file/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/no-image-pull/.expected/config.yaml b/e2e/testdata/fn-eval/no-image-pull/.expected/config.yaml index 5adf29717d..12fe62f7fc 100644 --- a/e2e/testdata/fn-eval/no-image-pull/.expected/config.yaml +++ b/e2e/testdata/fn-eval/no-image-pull/.expected/config.yaml @@ -1 +1 @@ -sequential: true +sequential: true diff --git a/e2e/testdata/fn-eval/no-image-pull/.expected/exec.sh b/e2e/testdata/fn-eval/no-image-pull/.expected/exec.sh index 1bb7904c9e..91c4fa1961 100755 --- a/e2e/testdata/fn-eval/no-image-pull/.expected/exec.sh +++ b/e2e/testdata/fn-eval/no-image-pull/.expected/exec.sh @@ -1,26 +1,26 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" - -kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/search-replace:latest - -${KRM_FN_RUNTIME} image inspect ghcr.io/kptdev/krm-functions-catalog/search-replace:latest -if [[ $? != 0 ]]; then - echo "ERR: Image could not be found locally and may not have been pulled" - exit 1 -fi +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" + +kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/search-replace:latest + +${KRM_FN_RUNTIME} image inspect ghcr.io/kptdev/krm-functions-catalog/search-replace:latest +if [[ $? != 0 ]]; then + echo "ERR: Image could not be found locally and may not have been pulled" + exit 1 +fi diff --git a/e2e/testdata/fn-eval/no-image-pull/.expected/setup.sh b/e2e/testdata/fn-eval/no-image-pull/.expected/setup.sh index e52eb3c5c0..57a6ba9fc7 100755 --- a/e2e/testdata/fn-eval/no-image-pull/.expected/setup.sh +++ b/e2e/testdata/fn-eval/no-image-pull/.expected/setup.sh @@ -1,22 +1,22 @@ -#!/bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" - -${KRM_FN_RUNTIME} image inspect ghcr.io/kptdev/krm-functions-catalog/search-replace:latest -# if inspect exits with a 0 exit code the image was found locally, remove it -if [[ $? == 0 ]]; then - ${KRM_FN_RUNTIME} image rm ghcr.io/kptdev/krm-functions-catalog/search-replace:latest -fi +#!/bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" + +${KRM_FN_RUNTIME} image inspect ghcr.io/kptdev/krm-functions-catalog/search-replace:latest +# if inspect exits with a 0 exit code the image was found locally, remove it +if [[ $? == 0 ]]; then + ${KRM_FN_RUNTIME} image rm ghcr.io/kptdev/krm-functions-catalog/search-replace:latest +fi diff --git a/e2e/testdata/fn-eval/no-image-pull/.krmignore b/e2e/testdata/fn-eval/no-image-pull/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/no-image-pull/.krmignore +++ b/e2e/testdata/fn-eval/no-image-pull/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/no-image-pull/resources.yaml b/e2e/testdata/fn-eval/no-image-pull/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-eval/no-image-pull/resources.yaml +++ b/e2e/testdata/fn-eval/no-image-pull/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/no-op/.expected/config.yaml b/e2e/testdata/fn-eval/no-op/.expected/config.yaml index 8c1d5d688b..adffc65636 100644 --- a/e2e/testdata/fn-eval/no-op/.expected/config.yaml +++ b/e2e/testdata/fn-eval/no-op/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/no-op +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/no-op diff --git a/e2e/testdata/fn-eval/no-op/.krmignore b/e2e/testdata/fn-eval/no-op/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/no-op/.krmignore +++ b/e2e/testdata/fn-eval/no-op/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/no-op/resources.yaml b/e2e/testdata/fn-eval/no-op/resources.yaml index 60f96f2d25..c0974f0944 100644 --- a/e2e/testdata/fn-eval/no-op/resources.yaml +++ b/e2e/testdata/fn-eval/no-op/resources.yaml @@ -1,82 +1,82 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml b/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml index 6f0f4278c8..ace808c7c2 100644 --- a/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml +++ b/e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml @@ -1,22 +1,22 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: staging -exitCode: 1 -stdErr: | - [FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - error: input resource list must contain only KRM resources: nonkrm.yaml: resource must have `apiVersion` +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: staging +exitCode: 1 +stdErr: | + [FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + error: input resource list must contain only KRM resources: nonkrm.yaml: resource must have `apiVersion` diff --git a/e2e/testdata/fn-eval/non-krm-resource/.krmignore b/e2e/testdata/fn-eval/non-krm-resource/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/non-krm-resource/.krmignore +++ b/e2e/testdata/fn-eval/non-krm-resource/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/non-krm-resource/nonkrm.yaml b/e2e/testdata/fn-eval/non-krm-resource/nonkrm.yaml index 81b7d5c618..d3a5f65e1b 100644 --- a/e2e/testdata/fn-eval/non-krm-resource/nonkrm.yaml +++ b/e2e/testdata/fn-eval/non-krm-resource/nonkrm.yaml @@ -1,14 +1,14 @@ -# Copyright 2021 The kpt Authors -# -# 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. +# Copyright 2021 The kpt Authors +# +# 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. Non-krm-resource: true \ No newline at end of file diff --git a/e2e/testdata/fn-eval/non-krm-resource/resources.yaml b/e2e/testdata/fn-eval/non-krm-resource/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/non-krm-resource/resources.yaml +++ b/e2e/testdata/fn-eval/non-krm-resource/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/config.yaml index 83c61c0af1..856281d55b 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | directory "out" already exists, please delete the directory and retry \ No newline at end of file diff --git a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/exec.sh b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/exec.sh index c5efb9fb33..28f021fa17 100755 --- a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/exec.sh +++ b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.expected/exec.sh @@ -1,20 +1,20 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out; mkdir out - -kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o out -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out; mkdir out + +kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o out -- namespace=staging diff --git a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.krmignore b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.krmignore +++ b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/resources.yaml b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir-exists-error/resources.yaml +++ b/e2e/testdata/fn-eval/out-of-place-dir-exists-error/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml index fed31a7989..2681b480cb 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s \ No newline at end of file diff --git a/e2e/testdata/fn-eval/out-of-place-dir/.expected/diff.patch b/e2e/testdata/fn-eval/out-of-place-dir/.expected/diff.patch index 1fab50c10f..d76207941e 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir/.expected/diff.patch +++ b/e2e/testdata/fn-eval/out-of-place-dir/.expected/diff.patch @@ -1,34 +1,34 @@ -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..b66c419 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,28 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+spec: -+ replicas: 3 -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+ namespace: staging -+spec: -+ image: nginx:1.2.3 +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..b66c419 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,28 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ namespace: staging ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/out-of-place-dir/.expected/exec.sh b/e2e/testdata/fn-eval/out-of-place-dir/.expected/exec.sh index ea4c6dec1e..337d1eddc4 100755 --- a/e2e/testdata/fn-eval/out-of-place-dir/.expected/exec.sh +++ b/e2e/testdata/fn-eval/out-of-place-dir/.expected/exec.sh @@ -1,20 +1,20 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out - -kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o out -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out + +kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o out -- namespace=staging diff --git a/e2e/testdata/fn-eval/out-of-place-dir/.krmignore b/e2e/testdata/fn-eval/out-of-place-dir/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir/.krmignore +++ b/e2e/testdata/fn-eval/out-of-place-dir/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-eval/out-of-place-dir/resources.yaml b/e2e/testdata/fn-eval/out-of-place-dir/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/out-of-place-dir/resources.yaml +++ b/e2e/testdata/fn-eval/out-of-place-dir/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml index 1c0a45a689..9e3fd33a76 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml @@ -1,74 +1,74 @@ -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s - [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - # Copyright 2021 The kpt Authors - # - # 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 - 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 - labels: - tier: backend - spec: - replicas: 3 - template: - metadata: - annotations: - foo: bar - labels: - tier: backend - selector: - matchLabels: - tier: backend - - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - 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 - labels: - tier: backend - spec: - image: nginx:1.2.3 +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s + [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + # Copyright 2021 The kpt Authors + # + # 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 + 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 + labels: + tier: backend + spec: + replicas: 3 + template: + metadata: + annotations: + foo: bar + labels: + tier: backend + selector: + matchLabels: + tier: backend + - apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + 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 + labels: + tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/exec.sh b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/exec.sh index 5334860ffe..983ed18288 100755 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/exec.sh +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o stdout -- namespace=staging \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -- tier=backend +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o stdout -- namespace=staging \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -- tier=backend diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.krmignore b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.krmignore +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/resources.yaml b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/resources.yaml +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-stdout/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml index 6ab4ff020c..1ccce7ce4b 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml @@ -1,76 +1,76 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s - [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - -stdOut: | - # Copyright 2021 The kpt Authors - # - # 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 - annotations: - foo: bar - namespace: staging - labels: - tier: backend - spec: - replicas: 3 - template: - metadata: - annotations: - foo: bar - labels: - tier: backend - selector: - matchLabels: - tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - annotations: - foo: bar - namespace: staging - labels: - tier: backend - spec: - image: nginx:1.2.3 +# Copyright 2021,2026 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s + [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + +stdOut: | + # Copyright 2021 The kpt Authors + # + # 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 + annotations: + foo: bar + namespace: staging + labels: + tier: backend + spec: + replicas: 3 + template: + metadata: + annotations: + foo: bar + labels: + tier: backend + selector: + matchLabels: + tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + annotations: + foo: bar + namespace: staging + labels: + tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/exec.sh b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/exec.sh index 5ab47a31d1..4fd8fe13be 100755 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/exec.sh +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o stdout -- namespace=staging \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -o unwrap -- tier=backend +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -o stdout -- namespace=staging \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -o unwrap -- tier=backend diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.krmignore b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.krmignore +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/Kptfile b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/Kptfile index b3a89e3911..10cc213226 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/Kptfile +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + configMap: + namespace: staging diff --git a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/resources.yaml b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/resources.yaml +++ b/e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/output-to-stdout/.expected/config.yaml b/e2e/testdata/fn-eval/output-to-stdout/.expected/config.yaml index de17b3ee69..3c473be865 100644 --- a/e2e/testdata/fn-eval/output-to-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-eval/output-to-stdout/.expected/config.yaml @@ -1,57 +1,57 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - # Copyright 2021 The kpt Authors - # - # 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 - 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: - replicas: 3 - - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - 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: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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. + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - # Copyright 2021 The kpt Authors + # + # 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 + 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: + replicas: 3 + - apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + 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: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/output-to-stdout/.expected/exec.sh b/e2e/testdata/fn-eval/output-to-stdout/.expected/exec.sh index 80be3f347c..5bc41c8811 100755 --- a/e2e/testdata/fn-eval/output-to-stdout/.expected/exec.sh +++ b/e2e/testdata/fn-eval/output-to-stdout/.expected/exec.sh @@ -1,19 +1,19 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn source |\ -kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn source |\ +kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging diff --git a/e2e/testdata/fn-eval/output-to-stdout/.krmignore b/e2e/testdata/fn-eval/output-to-stdout/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/output-to-stdout/.krmignore +++ b/e2e/testdata/fn-eval/output-to-stdout/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/output-to-stdout/resources.yaml b/e2e/testdata/fn-eval/output-to-stdout/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/output-to-stdout/resources.yaml +++ b/e2e/testdata/fn-eval/output-to-stdout/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/preserve-comments/.expected/config.yaml b/e2e/testdata/fn-eval/preserve-comments/.expected/config.yaml index 17fb62c643..4c4c095a60 100644 --- a/e2e/testdata/fn-eval/preserve-comments/.expected/config.yaml +++ b/e2e/testdata/fn-eval/preserve-comments/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/drop-comments:v0.1 +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/drop-comments:v0.1 diff --git a/e2e/testdata/fn-eval/preserve-comments/.krmignore b/e2e/testdata/fn-eval/preserve-comments/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/preserve-comments/.krmignore +++ b/e2e/testdata/fn-eval/preserve-comments/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/preserve-comments/resources.yaml b/e2e/testdata/fn-eval/preserve-comments/resources.yaml index 5e8b5fe157..020331fe40 100644 --- a/e2e/testdata/fn-eval/preserve-comments/resources.yaml +++ b/e2e/testdata/fn-eval/preserve-comments/resources.yaml @@ -1,67 +1,67 @@ -# Copyright 2021 The kpt Authors -# -# 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)$ +# Copyright 2021 The kpt Authors +# +# 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)$ diff --git a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml index 21110ef268..d40d2953bb 100644 --- a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml +++ b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -includeMetaResources: true -exitCode: 1 -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +includeMetaResources: true +exitCode: 1 +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.krmignore b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.krmignore +++ b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/Kptfile b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/Kptfile index 93306a6322..46970550d7 100644 --- a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/Kptfile +++ b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/Kptfile @@ -1,49 +1,49 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: nginx -info: - description: describe this package - site: https://github.com/kptdev/kpt - emails: - - foo@gmail.com - license: license text - keywords: - - tag1 - - tag2 - man: nginx man text -upstream: - type: git - git: - repo: https://github.com/kptdev/kpt - directory: package-examples/nginx - ref: v0.2 - updateStrategy: resource-merge -upstreamLock: - type: git - git: - repo: https://github.com/kptdev/kpt - directory: package-examples/nginx - ref: package-examples/nginx/v0.2 - commit: 4d2aa98b45ddee4b5fa45fbca16f2ff887de9efb -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 - configMap: - namespace: some-space - - image: ghcr.io/kptdev/krm-functions-catalog/apply-setters:latest - configMap: - image: nginx - tag: 1.14.1 - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: ./fn-config.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: path/to/foo-star.yaml -inventory: - namespace: some-space - name: inventory-00933591 - inventoryID: 92c234b7e9267815b0c3e17c9e4d7139a16c104f-1620493522822890000 - labels: - foo: bar - annotations: - abc: def +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: nginx +info: + description: describe this package + site: https://github.com/kptdev/kpt + emails: + - foo@gmail.com + license: license text + keywords: + - tag1 + - tag2 + man: nginx man text +upstream: + type: git + git: + repo: https://github.com/kptdev/kpt + directory: package-examples/nginx + ref: v0.2 + updateStrategy: resource-merge +upstreamLock: + type: git + git: + repo: https://github.com/kptdev/kpt + directory: package-examples/nginx + ref: package-examples/nginx/v0.2 + commit: 4d2aa98b45ddee4b5fa45fbca16f2ff887de9efb +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + configMap: + namespace: some-space + - image: ghcr.io/kptdev/krm-functions-catalog/apply-setters:latest + configMap: + image: nginx + tag: 1.14.1 + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: ./fn-config.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: path/to/foo-star.yaml +inventory: + namespace: some-space + name: inventory-00933591 + inventoryID: 92c234b7e9267815b0c3e17c9e4d7139a16c104f-1620493522822890000 + labels: + foo: bar + annotations: + abc: def diff --git a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/resources.yaml b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/resources.yaml index eedcce0e6e..910325cd6f 100644 --- a/e2e/testdata/fn-eval/preserve-order-include-meta-resources/resources.yaml +++ b/e2e/testdata/fn-eval/preserve-order-include-meta-resources/resources.yaml @@ -1,35 +1,35 @@ -# Copyright 2021 The kpt Authors -# -# 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: - labels: - foo: bar - name: my-nginx -spec: - replicas: 3 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - image: nginx:1.14.2 - name: nginx - ports: - - containerPort: 80 - protocol: TCP +# Copyright 2021 The kpt Authors +# +# 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: + labels: + foo: bar + name: my-nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - image: nginx:1.14.2 + name: nginx + ports: + - containerPort: 80 + protocol: TCP diff --git a/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml b/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml index eb0dfa04f8..7d8c27b301 100644 --- a/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml +++ b/e2e/testdata/fn-eval/preserve-order-null-values/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/preserve-order-null-values/.expected/diff.patch b/e2e/testdata/fn-eval/preserve-order-null-values/.expected/diff.patch index 62ab1e1705..d563ddf672 100644 --- a/e2e/testdata/fn-eval/preserve-order-null-values/.expected/diff.patch +++ b/e2e/testdata/fn-eval/preserve-order-null-values/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index f410b70..13bc056 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -16,6 +16,7 @@ kind: Deployment - metadata: - name: nginx-deployment - createTimestamp: null -+ namespace: staging - spec: - replicas: 3 - --- -@@ -23,5 +24,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f410b70..13bc056 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -16,6 +16,7 @@ kind: Deployment + metadata: + name: nginx-deployment + createTimestamp: null ++ namespace: staging + spec: + replicas: 3 + --- +@@ -23,5 +24,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/preserve-order-null-values/.krmignore b/e2e/testdata/fn-eval/preserve-order-null-values/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/preserve-order-null-values/.krmignore +++ b/e2e/testdata/fn-eval/preserve-order-null-values/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/preserve-order-null-values/resources.yaml b/e2e/testdata/fn-eval/preserve-order-null-values/resources.yaml index f410b70d3a..6b68648d01 100644 --- a/e2e/testdata/fn-eval/preserve-order-null-values/resources.yaml +++ b/e2e/testdata/fn-eval/preserve-order-null-values/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 - createTimestamp: null -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + createTimestamp: null +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/config.yaml b/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/config.yaml index 0ed1a0efc9..ce809ad5d4 100644 --- a/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/config.yaml +++ b/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 diff --git a/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/exec.sh b/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/exec.sh index 12e8de8205..19c2287763 100755 --- a/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/exec.sh +++ b/e2e/testdata/fn-eval/privilege-options/disable-network/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval \ ---image ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest \ --- \ -schema_location='https://kubernetesjsonschema.dev' +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval \ +--image ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest \ +-- \ +schema_location='https://kubernetesjsonschema.dev' diff --git a/e2e/testdata/fn-eval/privilege-options/disable-network/.krmginore b/e2e/testdata/fn-eval/privilege-options/disable-network/.krmginore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/privilege-options/disable-network/.krmginore +++ b/e2e/testdata/fn-eval/privilege-options/disable-network/.krmginore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/privilege-options/disable-network/resources.yaml b/e2e/testdata/fn-eval/privilege-options/disable-network/resources.yaml index a37a24e8cd..383e93464b 100644 --- a/e2e/testdata/fn-eval/privilege-options/disable-network/resources.yaml +++ b/e2e/testdata/fn-eval/privilege-options/disable-network/resources.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: some-secret - namespace: default -data: - less_sensitive_key: less sensitive data goes here - private_key: sensitive data goes here +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: some-secret + namespace: default +data: + less_sensitive_key: less sensitive data goes here + private_key: sensitive data goes here diff --git a/e2e/testdata/fn-eval/privilege-options/enable-network/.expected/exec.sh b/e2e/testdata/fn-eval/privilege-options/enable-network/.expected/exec.sh index 5c56677add..c67069565e 100755 --- a/e2e/testdata/fn-eval/privilege-options/enable-network/.expected/exec.sh +++ b/e2e/testdata/fn-eval/privilege-options/enable-network/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval \ ---image ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest \ ---network \ --- \ -schema_location='https://kubernetesjsonschema.dev' +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval \ +--image ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest \ +--network \ +-- \ +schema_location='https://kubernetesjsonschema.dev' diff --git a/e2e/testdata/fn-eval/privilege-options/enable-network/.krmginore b/e2e/testdata/fn-eval/privilege-options/enable-network/.krmginore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/privilege-options/enable-network/.krmginore +++ b/e2e/testdata/fn-eval/privilege-options/enable-network/.krmginore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/privilege-options/enable-network/resources.yaml b/e2e/testdata/fn-eval/privilege-options/enable-network/resources.yaml index a37a24e8cd..383e93464b 100644 --- a/e2e/testdata/fn-eval/privilege-options/enable-network/resources.yaml +++ b/e2e/testdata/fn-eval/privilege-options/enable-network/resources.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: some-secret - namespace: default -data: - less_sensitive_key: less sensitive data goes here - private_key: sensitive data goes here +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: some-secret + namespace: default +data: + less_sensitive_key: less sensitive data goes here + private_key: sensitive data goes here diff --git a/e2e/testdata/fn-eval/privilege-options/mount/.expected/config.yaml b/e2e/testdata/fn-eval/privilege-options/mount/.expected/config.yaml index c68a282b01..f97f768ed8 100644 --- a/e2e/testdata/fn-eval/privilege-options/mount/.expected/config.yaml +++ b/e2e/testdata/fn-eval/privilege-options/mount/.expected/config.yaml @@ -1,2 +1,2 @@ -runtimes: - - docker +runtimes: + - docker diff --git a/e2e/testdata/fn-eval/privilege-options/mount/.expected/exec.sh b/e2e/testdata/fn-eval/privilege-options/mount/.expected/exec.sh index 079d85a963..da14ce247a 100755 --- a/e2e/testdata/fn-eval/privilege-options/mount/.expected/exec.sh +++ b/e2e/testdata/fn-eval/privilege-options/mount/.expected/exec.sh @@ -1,30 +1,30 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail -# Download schema file -SCHEMA_DIR="schema/master-standalone" -mkdir -p "$SCHEMA_DIR" -curl -sSL 'https://kubernetesjsonschema.dev/master-standalone/configmap-v1.json' -o $SCHEMA_DIR/configmap-v1.json - -kpt fn eval \ ---image ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest \ ---as-current-user \ ---mount type=bind,src=$(pwd)/schema,dst=/schema-dir \ --- \ -schema_location=file:///schema-dir - -# Remove 'schema' to avoid unwanted diff -rm -r schema +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail +# Download schema file +SCHEMA_DIR="schema/master-standalone" +mkdir -p "$SCHEMA_DIR" +curl -sSL 'https://kubernetesjsonschema.dev/master-standalone/configmap-v1.json' -o $SCHEMA_DIR/configmap-v1.json + +kpt fn eval \ +--image ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest \ +--as-current-user \ +--mount type=bind,src=$(pwd)/schema,dst=/schema-dir \ +-- \ +schema_location=file:///schema-dir + +# Remove 'schema' to avoid unwanted diff +rm -r schema diff --git a/e2e/testdata/fn-eval/privilege-options/mount/.krmignore b/e2e/testdata/fn-eval/privilege-options/mount/.krmignore index 5a7b84905f..51a5535eb9 100644 --- a/e2e/testdata/fn-eval/privilege-options/mount/.krmignore +++ b/e2e/testdata/fn-eval/privilege-options/mount/.krmignore @@ -1,2 +1,2 @@ -schema -.expected +schema +.expected diff --git a/e2e/testdata/fn-eval/privilege-options/mount/resources.yaml b/e2e/testdata/fn-eval/privilege-options/mount/resources.yaml index a37a24e8cd..383e93464b 100644 --- a/e2e/testdata/fn-eval/privilege-options/mount/resources.yaml +++ b/e2e/testdata/fn-eval/privilege-options/mount/resources.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: some-secret - namespace: default -data: - less_sensitive_key: less sensitive data goes here - private_key: sensitive data goes here +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: some-secret + namespace: default +data: + less_sensitive_key: less sensitive data goes here + private_key: sensitive data goes here diff --git a/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/config.yaml b/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/config.yaml index 8aef046c6b..c6f7a63c08 100644 --- a/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/config.yaml +++ b/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest -fnConfig: ../../starlark-delete-resource.yaml +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +fnConfig: ../../starlark-delete-resource.yaml diff --git a/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/diff.patch b/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/diff.patch index 4db7c22d7c..1f9afd528a 100644 --- a/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/diff.patch +++ b/e2e/testdata/fn-eval/resource-deletion/pkg/.expected/diff.patch @@ -1,15 +1,15 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..239f0d6 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -17,10 +17,3 @@ metadata: - name: nginx-deployment - spec: - replicas: 3 ----- --apiVersion: custom.io/v1 --kind: Custom --metadata: -- name: custom --spec: -- image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..239f0d6 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -17,10 +17,3 @@ metadata: + name: nginx-deployment + spec: + replicas: 3 +---- +-apiVersion: custom.io/v1 +-kind: Custom +-metadata: +- name: custom +-spec: +- image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/resource-deletion/pkg/.krmignore b/e2e/testdata/fn-eval/resource-deletion/pkg/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/resource-deletion/pkg/.krmignore +++ b/e2e/testdata/fn-eval/resource-deletion/pkg/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/resource-deletion/pkg/resources.yaml b/e2e/testdata/fn-eval/resource-deletion/pkg/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/resource-deletion/pkg/resources.yaml +++ b/e2e/testdata/fn-eval/resource-deletion/pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/resource-deletion/starlark-delete-resource.yaml b/e2e/testdata/fn-eval/resource-deletion/starlark-delete-resource.yaml index 95778bba48..612da4d2c7 100644 --- a/e2e/testdata/fn-eval/resource-deletion/starlark-delete-resource.yaml +++ b/e2e/testdata/fn-eval/resource-deletion/starlark-delete-resource.yaml @@ -1,29 +1,29 @@ -# Copyright 2021 The kpt Authors -# -# 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: delete-resource -source: | - # delete Custom resource - def delete_resource(resource_list): - ret = [] - for i in range(0, len(resource_list)): - res = resource_list[i] - if res["apiVersion"] == "custom.io/v1" and res["kind"] == "Custom": - continue - ret.append(res) - return ret - - ctx.resource_list["items"] = delete_resource(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: delete-resource +source: | + # delete Custom resource + def delete_resource(resource_list): + ret = [] + for i in range(0, len(resource_list)): + res = resource_list[i] + if res["apiVersion"] == "custom.io/v1" and res["kind"] == "Custom": + continue + ret.append(res) + return ret + + ctx.resource_list["items"] = delete_resource(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml index aa27fdc85e..8a9cb68438 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch index fa276bdbb3..0e0f0c7b1f 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch @@ -1,43 +1,43 @@ -diff --git a/sub-pkg/Kptfile b/sub-pkg/Kptfile -index d9e2f05..82455d5 100644 ---- a/sub-pkg/Kptfile -+++ b/sub-pkg/Kptfile -@@ -2,3 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configPath: fn-config.yaml -diff --git a/sub-pkg/fn-config.yaml b/sub-pkg/fn-config.yaml -index 21135f9..1000dd9 100644 ---- a/sub-pkg/fn-config.yaml -+++ b/sub-pkg/fn-config.yaml -@@ -15,5 +15,6 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: fn-config -+ namespace: staging - data: - namespace: staging -diff --git a/sub-pkg/resources.yaml b/sub-pkg/resources.yaml -index eed43d6..81473ca 100644 ---- a/sub-pkg/resources.yaml -+++ b/sub-pkg/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/sub-pkg/Kptfile b/sub-pkg/Kptfile +index d9e2f05..82455d5 100644 +--- a/sub-pkg/Kptfile ++++ b/sub-pkg/Kptfile +@@ -2,3 +2,8 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: staging ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configPath: fn-config.yaml +diff --git a/sub-pkg/fn-config.yaml b/sub-pkg/fn-config.yaml +index 21135f9..1000dd9 100644 +--- a/sub-pkg/fn-config.yaml ++++ b/sub-pkg/fn-config.yaml +@@ -15,5 +15,6 @@ apiVersion: v1 + kind: ConfigMap + metadata: + name: fn-config ++ namespace: staging + data: + namespace: staging +diff --git a/sub-pkg/resources.yaml b/sub-pkg/resources.yaml +index eed43d6..81473ca 100644 +--- a/sub-pkg/resources.yaml ++++ b/sub-pkg/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/exec.sh index e076e0d589..b24c0321e8 100755 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval ./sub-pkg -s -t mutator -i set-namespace:v0.2.0 --fn-config=./sub-pkg/fn-config.yaml +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval ./sub-pkg -s -t mutator -i set-namespace:v0.2.0 --fn-config=./sub-pkg/fn-config.yaml diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.krmignore b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/Kptfile b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/fn-config.yaml b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/fn-config.yaml index 21135f929a..1dfdf25133 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/fn-config.yaml +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/fn-config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: fn-config -data: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: fn-config +data: + namespace: staging diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/resources.yaml b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/sub-pkg/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/save-fn/exec/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/exec/.expected/config.yaml index 4e51d160b1..70b205c2c1 100644 --- a/e2e/testdata/fn-eval/save-fn/exec/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/exec/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "./function.sh" - [PASS] "./function.sh" in 0s - Added "./function.sh" as mutator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "./function.sh" + [PASS] "./function.sh" in 0s + Added "./function.sh" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/exec/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/exec/.expected/diff.patch index ff448eb3f6..8d7daccfd3 100644 --- a/e2e/testdata/fn-eval/save-fn/exec/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/exec/.expected/diff.patch @@ -1,33 +1,33 @@ -diff --git a/Kptfile b/Kptfile -index d9e2f05..daff2a6 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,3 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+pipeline: -+ mutators: -+ - exec: ./function.sh -+ configPath: fn-config.yaml -diff --git a/resources.yaml b/resources.yaml -index 384908c..8514fdb 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,7 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -- namespace: foo -+ namespace: bar - spec: - replicas: 3 - --- -@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -- namespace: foo -+ namespace: bar - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index d9e2f05..daff2a6 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,3 +2,7 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++pipeline: ++ mutators: ++ - exec: ./function.sh ++ configPath: fn-config.yaml +diff --git a/resources.yaml b/resources.yaml +index 384908c..8514fdb 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,7 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment +- namespace: foo ++ namespace: bar + spec: + replicas: 3 + --- +@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom +- namespace: foo ++ namespace: bar + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/exec/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/exec/.expected/exec.sh index 416ebd72e5..a1d8c9a538 100755 --- a/e2e/testdata/fn-eval/save-fn/exec/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/exec/.expected/exec.sh @@ -1,17 +1,17 @@ -#! /bin/bash -# Copyright 2022 The kpt Authors -# -# 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. -set -eo pipefail - -kpt fn eval -s -t mutator --exec ./function.sh --fn-config=fn-config.yaml +#! /bin/bash +# Copyright 2022 The kpt Authors +# +# 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. +set -eo pipefail + +kpt fn eval -s -t mutator --exec ./function.sh --fn-config=fn-config.yaml diff --git a/e2e/testdata/fn-eval/save-fn/exec/.krmignore b/e2e/testdata/fn-eval/save-fn/exec/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/exec/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/exec/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/exec/Kptfile b/e2e/testdata/fn-eval/save-fn/exec/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-eval/save-fn/exec/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/exec/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-eval/save-fn/exec/fn-config.yaml b/e2e/testdata/fn-eval/save-fn/exec/fn-config.yaml index acbb1ca50f..36aeb3d84c 100644 --- a/e2e/testdata/fn-eval/save-fn/exec/fn-config.yaml +++ b/e2e/testdata/fn-eval/save-fn/exec/fn-config.yaml @@ -1,21 +1,21 @@ -# Copyright 2022 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: save-fn - annotations: - config.kubernetes.io/local-config: "true" -data: - name: test +# Copyright 2022 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: save-fn + annotations: + config.kubernetes.io/local-config: "true" +data: + name: test diff --git a/e2e/testdata/fn-eval/save-fn/exec/function.sh b/e2e/testdata/fn-eval/save-fn/exec/function.sh index 0e7c653fab..877439c607 100755 --- a/e2e/testdata/fn-eval/save-fn/exec/function.sh +++ b/e2e/testdata/fn-eval/save-fn/exec/function.sh @@ -1,16 +1,16 @@ -#! /usr/bin/env bash -# Copyright 2022 The kpt Authors -# -# 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. - -sed -e 's/foo/bar/' +#! /usr/bin/env bash +# Copyright 2022 The kpt Authors +# +# 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. + +sed -e 's/foo/bar/' diff --git a/e2e/testdata/fn-eval/save-fn/exec/resources.yaml b/e2e/testdata/fn-eval/save-fn/exec/resources.yaml index 384908cdfe..01b183fa39 100644 --- a/e2e/testdata/fn-eval/save-fn/exec/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/exec/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2022 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2022 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml index aa27fdc85e..8a9cb68438 100644 --- a/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/image/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/image/.expected/diff.patch index 8f2c7bb572..1e7de5b32a 100644 --- a/e2e/testdata/fn-eval/save-fn/image/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/image/.expected/diff.patch @@ -1,33 +1,33 @@ -diff --git a/Kptfile b/Kptfile -index d9e2f05..d0d3425 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,3 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: staging -diff --git a/resources.yaml b/resources.yaml -index eed43d6..81473ca 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index d9e2f05..d0d3425 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,3 +2,9 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: staging ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: staging +diff --git a/resources.yaml b/resources.yaml +index eed43d6..81473ca 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/image/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/image/.expected/exec.sh index d67e3aa2ff..73eff1d3c9 100755 --- a/e2e/testdata/fn-eval/save-fn/image/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/image/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging diff --git a/e2e/testdata/fn-eval/save-fn/image/.krmignore b/e2e/testdata/fn-eval/save-fn/image/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/image/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/image/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/image/Kptfile b/e2e/testdata/fn-eval/save-fn/image/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-eval/save-fn/image/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/image/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-eval/save-fn/image/resources.yaml b/e2e/testdata/fn-eval/save-fn/image/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-eval/save-fn/image/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/image/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml index 3950ae0213..73d6dec496 100644 --- a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/config.yaml @@ -1,22 +1,22 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/diff.patch index 01e1f078e1..e660e11451 100644 --- a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/diff.patch @@ -1,27 +1,27 @@ -diff --git a/Kptfile b/Kptfile -index d9e2f05..3456414 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,3 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: staging -+ selectors: -+ - kind: Deployment -diff --git a/resources.yaml b/resources.yaml -index f2eec52..f169ab0 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- +diff --git a/Kptfile b/Kptfile +index d9e2f05..3456414 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,3 +2,10 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: staging ++ selectors: ++ - kind: Deployment +diff --git a/resources.yaml b/resources.yaml +index f2eec52..f169ab0 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/exec.sh index 04520ed246..f35f14dcce 100755 --- a/e2e/testdata/fn-eval/save-fn/match-selector/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/match-selector/.expected/exec.sh @@ -1,19 +1,19 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn eval -s -t mutator -i set-namespace:v0.2.0 --match-kind Deployment -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn eval -s -t mutator -i set-namespace:v0.2.0 --match-kind Deployment -- namespace=staging diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/.krmignore b/e2e/testdata/fn-eval/save-fn/match-selector/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/match-selector/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/match-selector/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/Kptfile b/e2e/testdata/fn-eval/save-fn/match-selector/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-eval/save-fn/match-selector/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/match-selector/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-eval/save-fn/match-selector/resources.yaml b/e2e/testdata/fn-eval/save-fn/match-selector/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/save-fn/match-selector/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/match-selector/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml index c0e3f581fa..5674b5fbbf 100644 --- a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - function not added: Kptfile not exists +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + function not added: Kptfile not exists diff --git a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/diff.patch index 6da51ab9fa..d24d0785ea 100644 --- a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index eed43d6..81473ca 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index eed43d6..81473ca 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/exec.sh index d67e3aa2ff..73eff1d3c9 100755 --- a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging diff --git a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.krmignore b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/resources.yaml b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-eval/save-fn/no-save-when-fail/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/no-save-when-fail/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml index c4344df5ea..fc49c80bdc 100644 --- a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - Updated "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Updated "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/diff.patch index 266585847c..fd8dc067cf 100644 --- a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/diff.patch @@ -1,37 +1,37 @@ -diff --git a/Kptfile b/Kptfile -index c093436..6dd6980 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,9 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: newNs - pipeline: - mutators: -- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- configMap: -- namespace: oldNs -- name: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: newNs -diff --git a/resources.yaml b/resources.yaml -index eed43d6..0b0d2ce 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: newNs - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: newNs - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index c093436..6dd6980 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,9 +2,9 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: newNs + pipeline: + mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +- configMap: +- namespace: oldNs +- name: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: newNs +diff --git a/resources.yaml b/resources.yaml +index eed43d6..0b0d2ce 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: newNs + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: newNs + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/exec.sh index a8cb475cf3..d11ad7e565 100755 --- a/e2e/testdata/fn-eval/save-fn/override-fn/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/override-fn/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=newNs +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=newNs diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/.krmignore b/e2e/testdata/fn-eval/save-fn/override-fn/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/override-fn/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/override-fn/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/Kptfile b/e2e/testdata/fn-eval/save-fn/override-fn/Kptfile index c093436508..4787dabfd7 100644 --- a/e2e/testdata/fn-eval/save-fn/override-fn/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/override-fn/Kptfile @@ -1,10 +1,10 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 - configMap: - namespace: oldNs - name: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 + configMap: + namespace: oldNs + name: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 diff --git a/e2e/testdata/fn-eval/save-fn/override-fn/resources.yaml b/e2e/testdata/fn-eval/save-fn/override-fn/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-eval/save-fn/override-fn/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/override-fn/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml index aa27fdc85e..8a9cb68438 100644 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as mutator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/diff.patch index 1815663355..056698f6e4 100644 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/diff.patch @@ -1,33 +1,33 @@ -diff --git a/Kptfile b/Kptfile -index 08afd4c..941eb7f 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -4,3 +4,9 @@ kind: Kptfile # comment 1 - metadata: - # comment 2 - name: app # comment 3 -+ namespace: staging -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: staging -diff --git a/resources.yaml b/resources.yaml -index eed43d6..81473ca 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: +diff --git a/Kptfile b/Kptfile +index 08afd4c..941eb7f 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -4,3 +4,9 @@ kind: Kptfile # comment 1 + metadata: + # comment 2 + name: app # comment 3 ++ namespace: staging ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: staging +diff --git a/resources.yaml b/resources.yaml +index eed43d6..81473ca 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: image: nginx:1.2.3 \ No newline at end of file diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/exec.sh index d67e3aa2ff..73eff1d3c9 100755 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.krmignore b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/Kptfile b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/Kptfile index 08afd4ce87..ae8d15dec4 100644 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/Kptfile @@ -1,6 +1,6 @@ -# header comment -apiVersion: kpt.dev/v1 -kind: Kptfile # comment 1 -metadata: - # comment 2 - name: app # comment 3 +# header comment +apiVersion: kpt.dev/v1 +kind: Kptfile # comment 1 +metadata: + # comment 2 + name: app # comment 3 diff --git a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/resources.yaml b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/preserve-kptfile-comments/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml index af337678c4..970d681cb9 100644 --- a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml +++ b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as validator in the Kptfile. +# Copyright 2022 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + Added "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" as validator in the Kptfile. diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/diff.patch index 7090ca7d02..b649454e77 100644 --- a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/diff.patch +++ b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/diff.patch @@ -1,33 +1,33 @@ -diff --git a/Kptfile b/Kptfile -index d9e2f05..72c9469 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,3 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging -+pipeline: -+ validators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: staging -diff --git a/resources.yaml b/resources.yaml -index eed43d6..81473ca 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index d9e2f05..72c9469 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,3 +2,9 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: staging ++pipeline: ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: staging +diff --git a/resources.yaml b/resources.yaml +index eed43d6..81473ca 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/exec.sh b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/exec.sh index f069f40635..0d962003b2 100755 --- a/e2e/testdata/fn-eval/save-fn/validator-type/.expected/exec.sh +++ b/e2e/testdata/fn-eval/save-fn/validator-type/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -s -t validator -i set-namespace:v0.2.0 -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -s -t validator -i set-namespace:v0.2.0 -- namespace=staging diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/.krmignore b/e2e/testdata/fn-eval/save-fn/validator-type/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/save-fn/validator-type/.krmignore +++ b/e2e/testdata/fn-eval/save-fn/validator-type/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/Kptfile b/e2e/testdata/fn-eval/save-fn/validator-type/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-eval/save-fn/validator-type/Kptfile +++ b/e2e/testdata/fn-eval/save-fn/validator-type/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-eval/save-fn/validator-type/resources.yaml b/e2e/testdata/fn-eval/save-fn/validator-type/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-eval/save-fn/validator-type/resources.yaml +++ b/e2e/testdata/fn-eval/save-fn/validator-type/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml index c77db4e32f..b821527b7c 100644 --- a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/diff.patch b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/diff.patch index ac9da91b90..5439fbc372 100644 --- a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/diff.patch +++ b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/diff.patch @@ -1,12 +1,12 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..f169ab0 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- +diff --git a/resources.yaml b/resources.yaml +index f2eec52..f169ab0 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- diff --git a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/exec.sh b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/exec.sh index 503b594d41..8892a80743 100755 --- a/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/exec.sh +++ b/e2e/testdata/fn-eval/selectors/basicpipeline/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -i set-namespace:v0.2.0 --match-name nginx-deployment --match-kind Deployment -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -i set-namespace:v0.2.0 --match-name nginx-deployment --match-kind Deployment -- namespace=staging diff --git a/e2e/testdata/fn-eval/selectors/basicpipeline/.krmignore b/e2e/testdata/fn-eval/selectors/basicpipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/selectors/basicpipeline/.krmignore +++ b/e2e/testdata/fn-eval/selectors/basicpipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/selectors/basicpipeline/resources.yaml b/e2e/testdata/fn-eval/selectors/basicpipeline/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/selectors/basicpipeline/resources.yaml +++ b/e2e/testdata/fn-eval/selectors/basicpipeline/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml index c77db4e32f..b821527b7c 100644 --- a/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/exclude/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/selectors/exclude/.expected/diff.patch b/e2e/testdata/fn-eval/selectors/exclude/.expected/diff.patch index ac9da91b90..5439fbc372 100644 --- a/e2e/testdata/fn-eval/selectors/exclude/.expected/diff.patch +++ b/e2e/testdata/fn-eval/selectors/exclude/.expected/diff.patch @@ -1,12 +1,12 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..f169ab0 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- +diff --git a/resources.yaml b/resources.yaml +index f2eec52..f169ab0 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- diff --git a/e2e/testdata/fn-eval/selectors/exclude/.expected/exec.sh b/e2e/testdata/fn-eval/selectors/exclude/.expected/exec.sh index b38e333c8d..a9086b0c21 100755 --- a/e2e/testdata/fn-eval/selectors/exclude/.expected/exec.sh +++ b/e2e/testdata/fn-eval/selectors/exclude/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -i set-namespace:v0.2.0 --exclude-kind Custom -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -i set-namespace:v0.2.0 --exclude-kind Custom -- namespace=staging diff --git a/e2e/testdata/fn-eval/selectors/exclude/.krmignore b/e2e/testdata/fn-eval/selectors/exclude/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/selectors/exclude/.krmignore +++ b/e2e/testdata/fn-eval/selectors/exclude/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/selectors/exclude/resources.yaml b/e2e/testdata/fn-eval/selectors/exclude/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/selectors/exclude/resources.yaml +++ b/e2e/testdata/fn-eval/selectors/exclude/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml index 3f9b4db1c7..ee38b361c4 100644 --- a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml @@ -1,55 +1,55 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s - [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"} - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - -stdOut: | - apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment - namespace: staging - labels: - tier: backend - spec: - replicas: 3 - selector: - matchLabels: - tier: backend - template: - metadata: - labels: - tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - annotations: - foo: bar - labels: - tier: backend - spec: - image: nginx:1.2.3 +# Copyright 2021,2026 The kpt Authors +# +# 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. + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s + [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"} + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + +stdOut: | + apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment + namespace: staging + labels: + tier: backend + spec: + replicas: 3 + selector: + matchLabels: + tier: backend + template: + metadata: + labels: + tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + annotations: + foo: bar + labels: + tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/exec.sh b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/exec.sh index 9cfdf3cc4e..db2bc3aea4 100755 --- a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/exec.sh +++ b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn source \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 --match-kind Deployment -o stdout -- namespace=staging \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest --match-name custom -- foo=bar \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -o unwrap -- tier=backend +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn source \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 --match-kind Deployment -o stdout -- namespace=staging \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest --match-name custom -- foo=bar \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -o unwrap -- tier=backend diff --git a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.krmignore b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.krmignore +++ b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/resources.yaml b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/resources.yaml +++ b/e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml index c77db4e32f..b821527b7c 100644 --- a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml +++ b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/diff.patch b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/diff.patch index 6dd4532d55..322bc073a4 100644 --- a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/diff.patch +++ b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/diff.patch @@ -1,12 +1,12 @@ -diff --git a/resources.yaml b/resources.yaml -index 90bc5cf..6d24ecb 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -27,6 +27,7 @@ metadata: - labels: - foo: bar - foo-1: bar -+ namespace: staging - --- - apiVersion: custom.io/v1 - kind: Custom +diff --git a/resources.yaml b/resources.yaml +index 90bc5cf..6d24ecb 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -27,6 +27,7 @@ metadata: + labels: + foo: bar + foo-1: bar ++ namespace: staging + --- + apiVersion: custom.io/v1 + kind: Custom diff --git a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/exec.sh b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/exec.sh index 51f413851b..129fe2d6ad 100755 --- a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/exec.sh +++ b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.expected/exec.sh @@ -1,18 +1,18 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -kpt fn eval -i set-namespace:v0.2.0 --match-labels foo=bar --match-labels foo-1=bar --exclude-annotations foo=bar -- namespace=staging +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +kpt fn eval -i set-namespace:v0.2.0 --match-labels foo=bar --match-labels foo-1=bar --exclude-annotations foo=bar -- namespace=staging diff --git a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.krmignore b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.krmignore +++ b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/resources.yaml b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/resources.yaml index 90bc5cf9cf..03ecf385ba 100644 --- a/e2e/testdata/fn-eval/selectors/selectors-with-exclude/resources.yaml +++ b/e2e/testdata/fn-eval/selectors/selectors-with-exclude/resources.yaml @@ -1,41 +1,41 @@ -# Copyright 2021 The kpt Authors -# -# 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 - labels: - foo: bar -spec: - replicas: 3 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: nginx-deployment - labels: - foo: bar - foo-1: bar ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - annotations: - foo: bar - labels: - foo: bar - foo-1: bar -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + labels: + foo: bar +spec: + replicas: 3 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-deployment + labels: + foo: bar + foo-1: bar +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + annotations: + foo: bar + labels: + foo: bar + foo-1: bar +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml b/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml index 8cf6e1787d..c23424eb63 100644 --- a/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml +++ b/e2e/testdata/fn-eval/short-image-path/.expected/config.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -testType: eval - -image: set-namespace:latest - -args: - namespace: staging - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s +# Copyright 2021 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +testType: eval + +image: set-namespace:latest + +args: + namespace: staging + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-eval/short-image-path/.expected/diff.patch b/e2e/testdata/fn-eval/short-image-path/.expected/diff.patch index 551c6bfb48..8af6c0ffea 100644 --- a/e2e/testdata/fn-eval/short-image-path/.expected/diff.patch +++ b/e2e/testdata/fn-eval/short-image-path/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml b/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml index d20fbc5b56..ef75e11488 100755 --- a/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml +++ b/e2e/testdata/fn-eval/short-image-path/.expected/results.yaml @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: FunctionResultList -metadata: - name: fnresults -exitCode: 0 -items: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - exitCode: 0 +apiVersion: kpt.dev/v1 +kind: FunctionResultList +metadata: + name: fnresults +exitCode: 0 +items: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + exitCode: 0 diff --git a/e2e/testdata/fn-eval/short-image-path/.krmignore b/e2e/testdata/fn-eval/short-image-path/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/short-image-path/.krmignore +++ b/e2e/testdata/fn-eval/short-image-path/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/short-image-path/resources.yaml b/e2e/testdata/fn-eval/short-image-path/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/short-image-path/resources.yaml +++ b/e2e/testdata/fn-eval/short-image-path/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml b/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml index 50cb6a8da9..b859ae6a1f 100644 --- a/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml +++ b/e2e/testdata/fn-eval/simple-function-symlink/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: |- - [WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: |- + [WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" diff --git a/e2e/testdata/fn-eval/simple-function-symlink/.expected/diff.patch b/e2e/testdata/fn-eval/simple-function-symlink/.expected/diff.patch index 551c6bfb48..8af6c0ffea 100644 --- a/e2e/testdata/fn-eval/simple-function-symlink/.expected/diff.patch +++ b/e2e/testdata/fn-eval/simple-function-symlink/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/simple-function-symlink/.expected/exec.sh b/e2e/testdata/fn-eval/simple-function-symlink/.expected/exec.sh index e4eddd31eb..c98f118a0a 100755 --- a/e2e/testdata/fn-eval/simple-function-symlink/.expected/exec.sh +++ b/e2e/testdata/fn-eval/simple-function-symlink/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -ln -s ./ new-link - -kpt fn eval new-link --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging - +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +ln -s ./ new-link + +kpt fn eval new-link --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -- namespace=staging + rm -rf new-link \ No newline at end of file diff --git a/e2e/testdata/fn-eval/simple-function-symlink/.krmignore b/e2e/testdata/fn-eval/simple-function-symlink/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/simple-function-symlink/.krmignore +++ b/e2e/testdata/fn-eval/simple-function-symlink/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/simple-function-symlink/resources.yaml b/e2e/testdata/fn-eval/simple-function-symlink/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/simple-function-symlink/resources.yaml +++ b/e2e/testdata/fn-eval/simple-function-symlink/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/simple-function-with-tag/.expected/config.yaml b/e2e/testdata/fn-eval/simple-function-with-tag/.expected/config.yaml index 6d42874490..605f37d747 100644 --- a/e2e/testdata/fn-eval/simple-function-with-tag/.expected/config.yaml +++ b/e2e/testdata/fn-eval/simple-function-with-tag/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2026 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace -tag: "~0.4" -args: - namespace: staging +# Copyright 2026 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace +tag: "~0.4" +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/simple-function-with-tag/.expected/diff.patch b/e2e/testdata/fn-eval/simple-function-with-tag/.expected/diff.patch index 5371dee2ab..2c516b3540 100644 --- a/e2e/testdata/fn-eval/simple-function-with-tag/.expected/diff.patch +++ b/e2e/testdata/fn-eval/simple-function-with-tag/.expected/diff.patch @@ -1,12 +1,12 @@ -diff --git a/resources.yaml b/resources.yaml -index 1f15150..5966859 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 +diff --git a/resources.yaml b/resources.yaml +index 1f15150..5966859 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 --- \ No newline at end of file diff --git a/e2e/testdata/fn-eval/simple-function-with-tag/.krmignore b/e2e/testdata/fn-eval/simple-function-with-tag/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/simple-function-with-tag/.krmignore +++ b/e2e/testdata/fn-eval/simple-function-with-tag/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/simple-function-with-tag/resources.yaml b/e2e/testdata/fn-eval/simple-function-with-tag/resources.yaml index 1f15150409..ffbb3d7ba8 100644 --- a/e2e/testdata/fn-eval/simple-function-with-tag/resources.yaml +++ b/e2e/testdata/fn-eval/simple-function-with-tag/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2026 The kpt Authors -# -# 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 +# Copyright 2026 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/simple-function/.expected/config.yaml b/e2e/testdata/fn-eval/simple-function/.expected/config.yaml index eb0dfa04f8..7d8c27b301 100644 --- a/e2e/testdata/fn-eval/simple-function/.expected/config.yaml +++ b/e2e/testdata/fn-eval/simple-function/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/simple-function/.expected/diff.patch b/e2e/testdata/fn-eval/simple-function/.expected/diff.patch index 551c6bfb48..8af6c0ffea 100644 --- a/e2e/testdata/fn-eval/simple-function/.expected/diff.patch +++ b/e2e/testdata/fn-eval/simple-function/.expected/diff.patch @@ -1,19 +1,19 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/simple-function/.krmignore b/e2e/testdata/fn-eval/simple-function/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/simple-function/.krmignore +++ b/e2e/testdata/fn-eval/simple-function/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/simple-function/resources.yaml b/e2e/testdata/fn-eval/simple-function/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/simple-function/resources.yaml +++ b/e2e/testdata/fn-eval/simple-function/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/config.yaml b/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/config.yaml index 2952283bd9..0a83cef237 100644 --- a/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/config.yaml @@ -1,23 +1,23 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# This test case tests the structured output of the `eval` command. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest -fnConfig: ../search-replace-conf.yaml -# Non-error messages should be printed to stderr -stdErr: "[info]" +# Copyright 2021 The kpt Authors +# +# 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. + +# This test case tests the structured output of the `eval` command. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +testType: eval +image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest +fnConfig: ../search-replace-conf.yaml +# Non-error messages should be printed to stderr +stdErr: "[info]" diff --git a/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/diff.patch b/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/diff.patch index 685cb16e8d..610771972e 100644 --- a/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/diff.patch +++ b/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/diff.patch @@ -1,13 +1,13 @@ -diff --git a/resources.yaml b/resources.yaml -index f2eec52..114819d 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -16,7 +16,7 @@ kind: Deployment - metadata: - name: nginx-deployment - spec: -- replicas: 3 -+ replicas: 4 - --- - apiVersion: custom.io/v1 - kind: Custom +diff --git a/resources.yaml b/resources.yaml +index f2eec52..114819d 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -16,7 +16,7 @@ kind: Deployment + metadata: + name: nginx-deployment + spec: +- replicas: 3 ++ replicas: 4 + --- + apiVersion: custom.io/v1 + kind: Custom diff --git a/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/results.yaml b/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/results.yaml index 4b8202d414..cd3c0753cc 100755 --- a/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/results.yaml +++ b/e2e/testdata/fn-eval/structured-results-in-stdout/.expected/results.yaml @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: FunctionResultList -metadata: - name: fnresults -exitCode: 0 -items: - - image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest - exitCode: 0 - results: - - message: Mutated field value to "4" - field: - path: spec.replicas - file: - path: resources.yaml +apiVersion: kpt.dev/v1 +kind: FunctionResultList +metadata: + name: fnresults +exitCode: 0 +items: + - image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest + exitCode: 0 + results: + - message: Mutated field value to "4" + field: + path: spec.replicas + file: + path: resources.yaml diff --git a/e2e/testdata/fn-eval/structured-results-in-stdout/.krmignore b/e2e/testdata/fn-eval/structured-results-in-stdout/.krmignore index d3ede13e0a..4a34c957ba 100644 --- a/e2e/testdata/fn-eval/structured-results-in-stdout/.krmignore +++ b/e2e/testdata/fn-eval/structured-results-in-stdout/.krmignore @@ -1,2 +1,2 @@ -.expected -search-replace-conf.yaml +.expected +search-replace-conf.yaml diff --git a/e2e/testdata/fn-eval/structured-results-in-stdout/resources.yaml b/e2e/testdata/fn-eval/structured-results-in-stdout/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/structured-results-in-stdout/resources.yaml +++ b/e2e/testdata/fn-eval/structured-results-in-stdout/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/structured-results-in-stdout/search-replace-conf.yaml b/e2e/testdata/fn-eval/structured-results-in-stdout/search-replace-conf.yaml index 1048b0b416..77dcb6ae82 100644 --- a/e2e/testdata/fn-eval/structured-results-in-stdout/search-replace-conf.yaml +++ b/e2e/testdata/fn-eval/structured-results-in-stdout/search-replace-conf.yaml @@ -1,22 +1,22 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: search-replace-fn-config -data: - by-path: spec.replicas - by-value: 3 - put-value: 4 +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: search-replace-fn-config +data: + by-path: spec.replicas + by-value: 3 + put-value: 4 diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml index eb0dfa04f8..7d8c27b301 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/diff.patch b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/diff.patch index cc32d23128..90d991f58d 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/diff.patch +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.expected/diff.patch @@ -1,76 +1,76 @@ -diff --git a/Kptfile b/Kptfile -index 92a643d..ede2393 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -diff --git a/db/Kptfile b/db/Kptfile -index 093e789..a085eed 100644 ---- a/db/Kptfile -+++ b/db/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -diff --git a/db/labelconfig.yaml b/db/labelconfig.yaml -index 6db7671..0de2122 100644 ---- a/db/labelconfig.yaml -+++ b/db/labelconfig.yaml -@@ -17,5 +17,6 @@ metadata: - name: db-label-config - metadata: - config.kubernetes.io/local-config: "true" -+ namespace: staging - data: - namespace: db -diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..b44084a 100644 ---- a/db/resources.yaml -+++ b/db/resources.yaml -@@ -15,5 +15,6 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db -+ namespace: staging - spec: - replicas: 3 -diff --git a/labelconfig.yaml b/labelconfig.yaml -index 9c360e2..420c97c 100644 ---- a/labelconfig.yaml -+++ b/labelconfig.yaml -@@ -17,5 +17,6 @@ metadata: - name: label-config - annotations: - config.kubernetes.io/local-config: "true" -+ namespace: staging - data: - tier: app -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index 92a643d..ede2393 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: staging + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +diff --git a/db/Kptfile b/db/Kptfile +index 093e789..a085eed 100644 +--- a/db/Kptfile ++++ b/db/Kptfile +@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: db ++ namespace: staging + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +diff --git a/db/labelconfig.yaml b/db/labelconfig.yaml +index 6db7671..0de2122 100644 +--- a/db/labelconfig.yaml ++++ b/db/labelconfig.yaml +@@ -17,5 +17,6 @@ metadata: + name: db-label-config + metadata: + config.kubernetes.io/local-config: "true" ++ namespace: staging + data: + namespace: db +diff --git a/db/resources.yaml b/db/resources.yaml +index dabe43c..b44084a 100644 +--- a/db/resources.yaml ++++ b/db/resources.yaml +@@ -15,5 +15,6 @@ apiVersion: apps/v1 + kind: StatefulSet + metadata: + name: db ++ namespace: staging + spec: + replicas: 3 +diff --git a/labelconfig.yaml b/labelconfig.yaml +index 9c360e2..420c97c 100644 +--- a/labelconfig.yaml ++++ b/labelconfig.yaml +@@ -17,5 +17,6 @@ metadata: + name: label-config + annotations: + config.kubernetes.io/local-config: "true" ++ namespace: staging + data: + tier: app +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.krmignore b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.krmignore +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/Kptfile b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/Kptfile index 92a643d65f..10a45e6946 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/Kptfile +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/Kptfile b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/Kptfile index 093e7896d6..2a59abbe70 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/Kptfile +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/labelconfig.yaml b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/labelconfig.yaml index 6db767164b..55a7b82178 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/labelconfig.yaml +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/labelconfig.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: db-label-config - metadata: - config.kubernetes.io/local-config: "true" -data: - namespace: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: db-label-config + metadata: + config.kubernetes.io/local-config: "true" +data: + namespace: db diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/resources.yaml b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/resources.yaml +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/labelconfig.yaml b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/labelconfig.yaml index 9c360e2497..69373113b1 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/labelconfig.yaml +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/labelconfig.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config - annotations: - config.kubernetes.io/local-config: "true" -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config + annotations: + config.kubernetes.io/local-config: "true" +data: + tier: app diff --git a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/resources.yaml b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/resources.yaml +++ b/e2e/testdata/fn-eval/subpkg-exclude-fn-config-by-default/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml index 72644e4089..b109b29c5c 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: dev +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: dev diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/diff.patch b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/diff.patch index 1ddfb0beae..1a53f0951e 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/diff.patch +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.expected/diff.patch @@ -1,41 +1,41 @@ -diff --git a/Kptfile b/Kptfile -index 701e0a1..f9b5995 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,5 +2,6 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: root-pkg -+ namespace: dev - info: - description: sample description -diff --git a/pkg-a/Kptfile b/pkg-a/Kptfile -index 1c0e1cc..e278c20 100644 ---- a/pkg-a/Kptfile -+++ b/pkg-a/Kptfile -@@ -2,5 +2,6 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: pkg-a -+ namespace: dev - info: - description: sample description -diff --git a/pkg-a/pkg-a/resources.yaml b/pkg-a/pkg-a/resources.yaml -index f2eec52..c4e4abb 100644 ---- a/pkg-a/pkg-a/resources.yaml -+++ b/pkg-a/pkg-a/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: dev - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: dev - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index 701e0a1..f9b5995 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,5 +2,6 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: root-pkg ++ namespace: dev + info: + description: sample description +diff --git a/pkg-a/Kptfile b/pkg-a/Kptfile +index 1c0e1cc..e278c20 100644 +--- a/pkg-a/Kptfile ++++ b/pkg-a/Kptfile +@@ -2,5 +2,6 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: pkg-a ++ namespace: dev + info: + description: sample description +diff --git a/pkg-a/pkg-a/resources.yaml b/pkg-a/pkg-a/resources.yaml +index f2eec52..c4e4abb 100644 +--- a/pkg-a/pkg-a/resources.yaml ++++ b/pkg-a/pkg-a/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: dev + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: dev + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.krmignore b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.krmignore +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/Kptfile b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/Kptfile index 701e0a1b0e..76dd24afa0 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/Kptfile +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/Kptfile @@ -1,6 +1,6 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: root-pkg -info: - description: sample description +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: root-pkg +info: + description: sample description diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/Kptfile b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/Kptfile index 1c0e1ccba2..505ca39426 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/Kptfile +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/Kptfile @@ -1,6 +1,6 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: pkg-a -info: - description: sample description +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: pkg-a +info: + description: sample description diff --git a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml +++ b/e2e/testdata/fn-eval/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml b/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml index 63e976d46b..525a047f43 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/.expected/config.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -runCount: 2 -testType: eval -image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -includeMetaResources: true -exitCode: 1 -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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. + +runCount: 2 +testType: eval +image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +includeMetaResources: true +exitCode: 1 +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/.krmignore b/e2e/testdata/fn-eval/subpkg-include-meta-resources/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/.krmignore +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/Kptfile b/e2e/testdata/fn-eval/subpkg-include-meta-resources/Kptfile index 92a643d65f..10a45e6946 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/Kptfile +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/Kptfile b/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/Kptfile index 093e7896d6..2a59abbe70 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/Kptfile +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/labelconfig.yaml b/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/labelconfig.yaml index b859692cdb..57beddeb52 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/labelconfig.yaml +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: db-label-config -data: - namespace: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: db-label-config +data: + namespace: db diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/resources.yaml b/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/resources.yaml +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/labelconfig.yaml b/e2e/testdata/fn-eval/subpkg-include-meta-resources/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/labelconfig.yaml +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-eval/subpkg-include-meta-resources/resources.yaml b/e2e/testdata/fn-eval/subpkg-include-meta-resources/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/subpkg-include-meta-resources/resources.yaml +++ b/e2e/testdata/fn-eval/subpkg-include-meta-resources/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml index eb0dfa04f8..7d8c27b301 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/diff.patch b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/diff.patch index cdcc3bc03c..1227441002 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/diff.patch +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.expected/diff.patch @@ -1,30 +1,30 @@ -diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..b44084a 100644 ---- a/db/resources.yaml -+++ b/db/resources.yaml -@@ -15,5 +15,6 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db -+ namespace: staging - spec: - replicas: 3 -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/db/resources.yaml b/db/resources.yaml +index dabe43c..b44084a 100644 +--- a/db/resources.yaml ++++ b/db/resources.yaml +@@ -15,5 +15,6 @@ apiVersion: apps/v1 + kind: StatefulSet + metadata: + name: db ++ namespace: staging + spec: + replicas: 3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.krmignore b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.krmignore index ce69193538..8a1f6789a7 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/.krmignore +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/.krmignore @@ -1,2 +1,2 @@ -.expected -non-krm.yaml +.expected +non-krm.yaml diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/non-krm.yaml b/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/non-krm.yaml index 63a8c95e55..75c9fa06df 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/non-krm.yaml +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/non-krm.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. -- op: replace - path: /spec - value: - group: kubeflow.org +# Copyright 2021 The kpt Authors +# +# 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. +- op: replace + path: /spec + value: + group: kubeflow.org diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/resources.yaml b/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/resources.yaml +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-eval/subpkgs-with-krmignore/resources.yaml b/e2e/testdata/fn-eval/subpkgs-with-krmignore/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/subpkgs-with-krmignore/resources.yaml +++ b/e2e/testdata/fn-eval/subpkgs-with-krmignore/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml b/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml index eb0dfa04f8..7d8c27b301 100644 --- a/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml +++ b/e2e/testdata/fn-eval/subpkgs/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -args: - namespace: staging +# Copyright 2021 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +args: + namespace: staging diff --git a/e2e/testdata/fn-eval/subpkgs/.expected/diff.patch b/e2e/testdata/fn-eval/subpkgs/.expected/diff.patch index cdcc3bc03c..1227441002 100644 --- a/e2e/testdata/fn-eval/subpkgs/.expected/diff.patch +++ b/e2e/testdata/fn-eval/subpkgs/.expected/diff.patch @@ -1,30 +1,30 @@ -diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..b44084a 100644 ---- a/db/resources.yaml -+++ b/db/resources.yaml -@@ -15,5 +15,6 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db -+ namespace: staging - spec: - replicas: 3 -diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging - spec: - image: nginx:1.2.3 +diff --git a/db/resources.yaml b/db/resources.yaml +index dabe43c..b44084a 100644 +--- a/db/resources.yaml ++++ b/db/resources.yaml +@@ -15,5 +15,6 @@ apiVersion: apps/v1 + kind: StatefulSet + metadata: + name: db ++ namespace: staging + spec: + replicas: 3 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..b66c419 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,6 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 + --- +@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-eval/subpkgs/.krmignore b/e2e/testdata/fn-eval/subpkgs/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/subpkgs/.krmignore +++ b/e2e/testdata/fn-eval/subpkgs/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/subpkgs/db/resources.yaml b/e2e/testdata/fn-eval/subpkgs/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-eval/subpkgs/db/resources.yaml +++ b/e2e/testdata/fn-eval/subpkgs/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-eval/subpkgs/resources.yaml b/e2e/testdata/fn-eval/subpkgs/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-eval/subpkgs/resources.yaml +++ b/e2e/testdata/fn-eval/subpkgs/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml b/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml index 15907fa66c..7a858b5d9b 100644 --- a/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml +++ b/e2e/testdata/fn-eval/wasm-function/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2022 The kpt Authors -# -# 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: ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest -image: gcr.io/kpt-fn-demo/set-namespace:latest -args: - namespace: staging -allowWasm: true +# Copyright 2022 The kpt Authors +# +# 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: ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest +image: gcr.io/kpt-fn-demo/set-namespace:latest +args: + namespace: staging +allowWasm: true diff --git a/e2e/testdata/fn-eval/wasm-function/.expected/diff.patch b/e2e/testdata/fn-eval/wasm-function/.expected/diff.patch index fd8c99c2cd..0f7640c009 100644 --- a/e2e/testdata/fn-eval/wasm-function/.expected/diff.patch +++ b/e2e/testdata/fn-eval/wasm-function/.expected/diff.patch @@ -1,11 +1,11 @@ -diff --git a/resources.yaml b/resources.yaml -index 903c6a5..98b8a68 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,5 +15,6 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 +diff --git a/resources.yaml b/resources.yaml +index 903c6a5..98b8a68 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,5 +15,6 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging + spec: + replicas: 3 diff --git a/e2e/testdata/fn-eval/wasm-function/.krmignore b/e2e/testdata/fn-eval/wasm-function/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-eval/wasm-function/.krmignore +++ b/e2e/testdata/fn-eval/wasm-function/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-eval/wasm-function/resources.yaml b/e2e/testdata/fn-eval/wasm-function/resources.yaml index 903c6a5711..0b5257ff95 100644 --- a/e2e/testdata/fn-eval/wasm-function/resources.yaml +++ b/e2e/testdata/fn-eval/wasm-function/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/all-resource-deletion/.expected/diff.patch b/e2e/testdata/fn-render/all-resource-deletion/.expected/diff.patch index f8121fb91e..043f03d456 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/.expected/diff.patch +++ b/e2e/testdata/fn-render/all-resource-deletion/.expected/diff.patch @@ -1,83 +1,141 @@ diff --git a/Kptfile b/Kptfile -index 3c93e9e..6fa7b45 100644 +index 20fac6a..7f10467 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: delete-all.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: delete-all.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/delete-all.yaml b/delete-all.yaml -index 3c86d8b..6754b0a 100644 +index 9ddbbe2..bea1693 100755 --- a/delete-all.yaml +++ b/delete-all.yaml -@@ -17,6 +17,9 @@ metadata: - name: delete-all - annotations: - config.kubernetes.io/local-config: "true" -+ namespace: staging +@@ -1,22 +1,24 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: delete-all +- annotations: +- config.kubernetes.io/local-config: "true" +-source: |- +- # delete all resources +- ctx.resource_list["items"] = [x for x in ctx.resource_list["items"] if x["kind"] in ["Kptfile", "StarlarkRun"]] ++# Copyright 2021 The kpt Authors ++# ++# 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: delete-all ++ annotations: ++ config.kubernetes.io/local-config: "true" + labels: + tier: backend - source: |- - # delete all resources - ctx.resource_list["items"] = [x for x in ctx.resource_list["items"] if x["kind"] in ["Kptfile", "StarlarkRun"]] ++source: |- ++ # delete all resources ++ ctx.resource_list["items"] = [x for x in ctx.resource_list["items"] if x["kind"] in ["Kptfile", "StarlarkRun"]] diff --git a/deployment.yaml b/deployment.yaml -deleted file mode 100644 -index 990ca9b..0000000 +deleted file mode 100755 +index 73d3f5e..0000000 --- a/deployment.yaml +++ /dev/null @@ -1,24 +0,0 @@ --# Copyright 2021 The kpt Authors --# --# 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: httpbin --spec: -- replicas: 4 -- template: -- spec: -- containers: -- - name: httpbin -- image: kennethreitz/httpbin +-# Copyright 2021 The kpt Authors +-# +-# 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: httpbin +-spec: +- replicas: 4 +- template: +- spec: +- containers: +- - name: httpbin +- image: kennethreitz/httpbin diff --git a/resources.yaml b/resources.yaml -deleted file mode 100644 -index 239f0d6..0000000 +deleted file mode 100755 +index 027731c..0000000 --- a/resources.yaml +++ /dev/null @@ -1,19 +0,0 @@ --# Copyright 2021 The kpt Authors --# --# 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: +-# Copyright 2021 The kpt Authors +-# +-# 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 diff --git a/e2e/testdata/fn-render/all-resource-deletion/.krmignore b/e2e/testdata/fn-render/all-resource-deletion/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/.krmignore +++ b/e2e/testdata/fn-render/all-resource-deletion/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/all-resource-deletion/Kptfile b/e2e/testdata/fn-render/all-resource-deletion/Kptfile index faf208d647..20fac6ad71 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/Kptfile +++ b/e2e/testdata/fn-render/all-resource-deletion/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: delete-all.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: delete-all.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/all-resource-deletion/delete-all.yaml b/e2e/testdata/fn-render/all-resource-deletion/delete-all.yaml index 3c86d8b2e7..9ddbbe2c83 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/delete-all.yaml +++ b/e2e/testdata/fn-render/all-resource-deletion/delete-all.yaml @@ -1,22 +1,22 @@ -# Copyright 2021 The kpt Authors -# -# 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: delete-all - annotations: - config.kubernetes.io/local-config: "true" -source: |- - # delete all resources - ctx.resource_list["items"] = [x for x in ctx.resource_list["items"] if x["kind"] in ["Kptfile", "StarlarkRun"]] +# Copyright 2021 The kpt Authors +# +# 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: delete-all + annotations: + config.kubernetes.io/local-config: "true" +source: |- + # delete all resources + ctx.resource_list["items"] = [x for x in ctx.resource_list["items"] if x["kind"] in ["Kptfile", "StarlarkRun"]] diff --git a/e2e/testdata/fn-render/all-resource-deletion/deployment.yaml b/e2e/testdata/fn-render/all-resource-deletion/deployment.yaml index 990ca9b682..73d3f5e08d 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/deployment.yaml +++ b/e2e/testdata/fn-render/all-resource-deletion/deployment.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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: httpbin -spec: - replicas: 4 - template: - spec: - containers: - - name: httpbin - image: kennethreitz/httpbin +# Copyright 2021 The kpt Authors +# +# 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: httpbin +spec: + replicas: 4 + template: + spec: + containers: + - name: httpbin + image: kennethreitz/httpbin diff --git a/e2e/testdata/fn-render/all-resource-deletion/resources.yaml b/e2e/testdata/fn-render/all-resource-deletion/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/all-resource-deletion/resources.yaml +++ b/e2e/testdata/fn-render/all-resource-deletion/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/diff.patch b/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/diff.patch index 634b642a68..eb0c7231a5 100644 --- a/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/diff.patch +++ b/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/diff.patch @@ -1,66 +1,66 @@ -diff --git a/out/Kptfile b/out/Kptfile -new file mode 100644 -index 0000000..3a2c718 ---- /dev/null -+++ b/out/Kptfile -@@ -0,0 +1,15 @@ -+apiVersion: kpt.dev/v1 -+kind: Kptfile -+metadata: -+ name: app -+ namespace: staging -+ labels: -+ tier: backend -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: staging -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -+ configMap: -+ tier: backend -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..84cfb26 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,39 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+ labels: -+ tier: backend -+spec: -+ replicas: 3 -+ selector: -+ matchLabels: -+ tier: backend -+ template: -+ metadata: -+ labels: -+ tier: backend -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+ namespace: staging -+ labels: -+ tier: backend -+spec: -+ image: nginx:1.2.3 +diff --git a/out/Kptfile b/out/Kptfile +new file mode 100644 +index 0000000..3a2c718 +--- /dev/null ++++ b/out/Kptfile +@@ -0,0 +1,15 @@ ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++ namespace: staging ++ labels: ++ tier: backend ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..84cfb26 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,39 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++ labels: ++ tier: backend ++spec: ++ replicas: 3 ++ selector: ++ matchLabels: ++ tier: backend ++ template: ++ metadata: ++ labels: ++ tier: backend ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ namespace: staging ++ labels: ++ tier: backend ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/exec.sh b/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/exec.sh index 8597ffcf9e..184bd1bf2a 100755 --- a/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/exec.sh +++ b/e2e/testdata/fn-render/basicpipeline-out-of-place/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -rm -rf out - -kpt fn render -o out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +rm -rf out + +kpt fn render -o out diff --git a/e2e/testdata/fn-render/basicpipeline-out-of-place/.krmignore b/e2e/testdata/fn-render/basicpipeline-out-of-place/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-render/basicpipeline-out-of-place/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline-out-of-place/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile b/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-out-of-place/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/basicpipeline-out-of-place/resources.yaml b/e2e/testdata/fn-render/basicpipeline-out-of-place/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/basicpipeline-out-of-place/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline-out-of-place/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline-semver/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline-semver/.expected/config.yaml index 002f6dbdd7..e146b7d46d 100644 --- a/e2e/testdata/fn-render/basicpipeline-semver/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline-semver/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2026 The kpt Authors -# -# 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. - +# Copyright 2026 The kpt Authors +# +# 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. + allowNetwork: true \ No newline at end of file diff --git a/e2e/testdata/fn-render/basicpipeline-semver/.expected/diff.patch b/e2e/testdata/fn-render/basicpipeline-semver/.expected/diff.patch index 754306a2b7..1e008ae8a0 100644 --- a/e2e/testdata/fn-render/basicpipeline-semver/.expected/diff.patch +++ b/e2e/testdata/fn-render/basicpipeline-semver/.expected/diff.patch @@ -1,38 +1,100 @@ diff --git a/Kptfile b/Kptfile -index 2336da4..85f42f5 100644 +index 68ea4fc..85f42f5 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace +- tag: "0.4.1 - 0.4.3" +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels +- tag: "~0.2" +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace ++ tag: "0.4.1 - 0.4.3" ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels ++ tag: "~0.2" ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index 1f15150..936d957 100644 +index ffbb3d7..936d957 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,20 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,34 @@ +-# Copyright 2026 The kpt Authors +-# +-# 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 ++# Copyright 2026 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/basicpipeline-semver/.krmignore b/e2e/testdata/fn-render/basicpipeline-semver/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/basicpipeline-semver/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline-semver/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/basicpipeline-semver/Kptfile b/e2e/testdata/fn-render/basicpipeline-semver/Kptfile index 2336da4869..68ea4fcf60 100644 --- a/e2e/testdata/fn-render/basicpipeline-semver/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-semver/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace - tag: "0.4.1 - 0.4.3" - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels - tag: "~0.2" - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace + tag: "0.4.1 - 0.4.3" + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels + tag: "~0.2" + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/basicpipeline-semver/resources.yaml b/e2e/testdata/fn-render/basicpipeline-semver/resources.yaml index 1f15150409..ffbb3d7ba8 100644 --- a/e2e/testdata/fn-render/basicpipeline-semver/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline-semver/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2026 The kpt Authors -# -# 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 +# Copyright 2026 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml index 7662b2c61e..3b73bd9e50 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: |- - [WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored - Package: "basicpipeline-symlink" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - Successfully executed 2 function(s) in 1 package(s). +# Copyright 2021,2026 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: |- + [WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored + Package: "basicpipeline-symlink" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/diff.patch b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/diff.patch index a21c38b30e..2e02429e85 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/diff.patch +++ b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/diff.patch @@ -1,44 +1,44 @@ -diff --git a/Kptfile b/Kptfile -index 1307fb5..3a2c718 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging -+ labels: -+ tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -diff --git a/resources.yaml b/resources.yaml -index f2eec52..84cfb26 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging -+ labels: -+ tier: backend - spec: - replicas: 3 -+ selector: -+ matchLabels: -+ tier: backend -+ template: -+ metadata: -+ labels: -+ tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging -+ labels: -+ tier: backend - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index 1307fb5..3a2c718 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: staging ++ labels: ++ tier: backend + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..84cfb26 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,12 +15,25 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging ++ labels: ++ tier: backend + spec: + replicas: 3 ++ selector: ++ matchLabels: ++ tier: backend ++ template: ++ metadata: ++ labels: ++ tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging ++ labels: ++ tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/exec.sh b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/exec.sh index cd47f896e0..81aff32c21 100755 --- a/e2e/testdata/fn-render/basicpipeline-symlink/.expected/exec.sh +++ b/e2e/testdata/fn-render/basicpipeline-symlink/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -ln -s ./ new-link - -kpt fn render new-link - +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +ln -s ./ new-link + +kpt fn render new-link + rm -rf new-link \ No newline at end of file diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/.krmignore b/e2e/testdata/fn-render/basicpipeline-symlink/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline-symlink/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile b/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-symlink/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/basicpipeline-symlink/resources.yaml b/e2e/testdata/fn-render/basicpipeline-symlink/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/basicpipeline-symlink/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline-symlink/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha1/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline-v1alpha1/.expected/config.yaml index 003dc21aba..ced354dc5d 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha1/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha1/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. -exitCode: 1 -stdErr: 'has an old version ("v1alpha1") of the Kptfile schema' +# Copyright 2021 The kpt Authors +# +# 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. +exitCode: 1 +stdErr: 'has an old version ("v1alpha1") of the Kptfile schema' diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha1/.krmignore b/e2e/testdata/fn-render/basicpipeline-v1alpha1/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha1/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha1/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha1/Kptfile b/e2e/testdata/fn-render/basicpipeline-v1alpha1/Kptfile index f5d3715446..0365122bbb 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha1/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha1/Kptfile @@ -1,101 +1,101 @@ -apiVersion: kpt.dev/v1alpha1 -kind: Kptfile -metadata: - name: nginx -dependencies: - - name: hello-world - updateStrategy: fast-forward - stdin: - filenamePattern: foo* - original: bar - autoSet: false - ensureNotExists: false - functions: - - image: ghcr.io/kptdev/krm-functions-catalog/my-func:latest - config: - apiVersion: v1 - kind: ConfigMap - metadata: - name: function-config - data: - param1: value1 - git: - directory: /package-examples/helloworld-set - ref: master - repo: https://github.com/kptdev/kpt -functions: - autoRunStarlark: true - starlarkFunctions: - - name: foo-star - path: path/to/foo-star.yaml -inventory: - name: inventory-00933591 - namespace: some-space - labels: - foo: bar - annotations: - abc: def - inventoryID: 92c234b7e9267815b0c3e17c9e4d7139a16c104f-1620493522822890000 -openAPI: - definitions: - io.k8s.cli.setters.image: - x-k8s-cli: - setter: - name: image - value: nginx - io.k8s.cli.setters.list: - type: array - x-k8s-cli: - setter: - name: list - value: "" - listValues: - - dev - - stage - io.k8s.cli.setters.namespace: - type: string - maxLength: 10 - x-k8s-cli: - setter: - name: namespace - value: some-space - io.k8s.cli.setters.tag: - x-k8s-cli: - setter: - name: tag - value: 1.14.1 - io.k8s.cli.substitutions.fullimage: - x-k8s-cli: - substitution: - name: fullimage - pattern: ${image}:${tag} - values: - - marker: ${image} - ref: '#/definitions/io.k8s.cli.setters.image' - - marker: ${tag} - ref: '#/definitions/io.k8s.cli.setters.tag' - io.k8s.cli.substitutions.imageidentifier: - x-k8s-cli: - substitution: - name: imageidentifier - pattern: deployment-${fullimage} - values: - - marker: ${fullimage} - ref: '#/definitions/io.k8s.cli.substitutions.fullimage' -packageMetadata: - email: foo@gmail.com - license: license text - man: nginx man text - shortDescription: describe this package - tags: - - tag1 - - tag2 - url: https://github.com/kptdev/kpt - version: v0.1 -upstream: - type: git - git: - commit: 4d2aa98b45ddee4b5fa45fbca16f2ff887de9efb - directory: package-examples/nginx - ref: v0.2 - repo: https://github.com/kptdev/kpt +apiVersion: kpt.dev/v1alpha1 +kind: Kptfile +metadata: + name: nginx +dependencies: + - name: hello-world + updateStrategy: fast-forward + stdin: + filenamePattern: foo* + original: bar + autoSet: false + ensureNotExists: false + functions: + - image: ghcr.io/kptdev/krm-functions-catalog/my-func:latest + config: + apiVersion: v1 + kind: ConfigMap + metadata: + name: function-config + data: + param1: value1 + git: + directory: /package-examples/helloworld-set + ref: master + repo: https://github.com/kptdev/kpt +functions: + autoRunStarlark: true + starlarkFunctions: + - name: foo-star + path: path/to/foo-star.yaml +inventory: + name: inventory-00933591 + namespace: some-space + labels: + foo: bar + annotations: + abc: def + inventoryID: 92c234b7e9267815b0c3e17c9e4d7139a16c104f-1620493522822890000 +openAPI: + definitions: + io.k8s.cli.setters.image: + x-k8s-cli: + setter: + name: image + value: nginx + io.k8s.cli.setters.list: + type: array + x-k8s-cli: + setter: + name: list + value: "" + listValues: + - dev + - stage + io.k8s.cli.setters.namespace: + type: string + maxLength: 10 + x-k8s-cli: + setter: + name: namespace + value: some-space + io.k8s.cli.setters.tag: + x-k8s-cli: + setter: + name: tag + value: 1.14.1 + io.k8s.cli.substitutions.fullimage: + x-k8s-cli: + substitution: + name: fullimage + pattern: ${image}:${tag} + values: + - marker: ${image} + ref: '#/definitions/io.k8s.cli.setters.image' + - marker: ${tag} + ref: '#/definitions/io.k8s.cli.setters.tag' + io.k8s.cli.substitutions.imageidentifier: + x-k8s-cli: + substitution: + name: imageidentifier + pattern: deployment-${fullimage} + values: + - marker: ${fullimage} + ref: '#/definitions/io.k8s.cli.substitutions.fullimage' +packageMetadata: + email: foo@gmail.com + license: license text + man: nginx man text + shortDescription: describe this package + tags: + - tag1 + - tag2 + url: https://github.com/kptdev/kpt + version: v0.1 +upstream: + type: git + git: + commit: 4d2aa98b45ddee4b5fa45fbca16f2ff887de9efb + directory: package-examples/nginx + ref: v0.2 + repo: https://github.com/kptdev/kpt diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha1/labelconfig.yaml b/e2e/testdata/fn-render/basicpipeline-v1alpha1/labelconfig.yaml index bb25a6558b..bd8c438acc 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha1/labelconfig.yaml +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha1/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: app +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: app diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha1/resources.yaml b/e2e/testdata/fn-render/basicpipeline-v1alpha1/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha1/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha1/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha2/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline-v1alpha2/.expected/config.yaml index f38393b113..195141647a 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha2/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha2/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. -exitCode: 1 -stdErr: 'has an old version ("v1alpha2") of the Kptfile schema' +# Copyright 2021 The kpt Authors +# +# 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. +exitCode: 1 +stdErr: 'has an old version ("v1alpha2") of the Kptfile schema' diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha2/.krmignore b/e2e/testdata/fn-render/basicpipeline-v1alpha2/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha2/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha2/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile b/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile index 1648ad9067..1ffaa6dd4b 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha2/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1alpha2 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1alpha2 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/basicpipeline-v1alpha2/resources.yaml b/e2e/testdata/fn-render/basicpipeline-v1alpha2/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/basicpipeline-v1alpha2/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline-v1alpha2/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/config.yaml index c496ddff01..02c4d6f313 100644 --- a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2022 The kpt Authors -# -# 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. - -sequential: true -allowWasm: true +# Copyright 2022 The kpt Authors +# +# 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. + +sequential: true +allowWasm: true diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/diff.patch b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/diff.patch index 373cc33df7..90c8ed2696 100644 --- a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/diff.patch +++ b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/diff.patch @@ -1,29 +1,29 @@ -diff --git a/resources.yaml b/resources.yaml -index eed43d6..e76b00d 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,12 +15,24 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging -+ labels: -+ tier: backend - spec: - replicas: 3 -+ selector: -+ matchLabels: -+ tier: backend -+ template: -+ metadata: -+ labels: -+ tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ labels: -+ tier: backend - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index eed43d6..e76b00d 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,12 +15,24 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging ++ labels: ++ tier: backend + spec: + replicas: 3 ++ selector: ++ matchLabels: ++ tier: backend ++ template: ++ metadata: ++ labels: ++ tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ labels: ++ tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/setup.sh b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/setup.sh index 115e1ca96f..13fc24f108 100755 --- a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/setup.sh +++ b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/setup.sh @@ -1,16 +1,16 @@ -#! /usr/bin/env bash -# Copyright 2022 The kpt Authors -# -# 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. - -export KPT_FN_WASM_RUNTIME=wasmtime +#! /usr/bin/env bash +# Copyright 2022 The kpt Authors +# +# 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. + +export KPT_FN_WASM_RUNTIME=wasmtime diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/teardown.sh b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/teardown.sh index 595dfa4d80..2cb52d6cbb 100755 --- a/e2e/testdata/fn-render/basicpipeline-wasm/.expected/teardown.sh +++ b/e2e/testdata/fn-render/basicpipeline-wasm/.expected/teardown.sh @@ -1,16 +1,16 @@ -#! /usr/bin/env bash -# Copyright 2022 The kpt Authors -# -# 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. - -unset KPT_FN_WASM_RUNTIME +#! /usr/bin/env bash +# Copyright 2022 The kpt Authors +# +# 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. + +unset KPT_FN_WASM_RUNTIME diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/.krmignore b/e2e/testdata/fn-render/basicpipeline-wasm/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/basicpipeline-wasm/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline-wasm/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile b/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile index 12457eadf0..21a9349348 100644 --- a/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline-wasm/Kptfile @@ -1,17 +1,17 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app - labels: - tier: backend -pipeline: - mutators: - # The following 2 images are built from https://github.com/kptdev/krm-functions-catalog/pull/898. - - image: gcr.io/kpt-fn-demo/set-namespace:latest - # ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest - configMap: - namespace: staging - - image: gcr.io/kpt-fn-demo/set-labels:v0.2.0 - # ghcr.io/kptdev/krm-functions-catalog/wasm/set-labels:v0.2.0 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app + labels: + tier: backend +pipeline: + mutators: + # The following 2 images are built from https://github.com/kptdev/krm-functions-catalog/pull/898. + - image: gcr.io/kpt-fn-demo/set-namespace:latest + # ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest + configMap: + namespace: staging + - image: gcr.io/kpt-fn-demo/set-labels:v0.2.0 + # ghcr.io/kptdev/krm-functions-catalog/wasm/set-labels:v0.2.0 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/basicpipeline-wasm/resources.yaml b/e2e/testdata/fn-render/basicpipeline-wasm/resources.yaml index eed43d6a06..3570f87e9b 100644 --- a/e2e/testdata/fn-render/basicpipeline-wasm/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline-wasm/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2022 The kpt Authors -# -# 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 +# Copyright 2022 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/basicpipeline/.expected/config.yaml b/e2e/testdata/fn-render/basicpipeline/.expected/config.yaml index 325550be81..c1af4d3b5c 100644 --- a/e2e/testdata/fn-render/basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-render/basicpipeline/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2023 The kpt Authors -# -# 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. - +# Copyright 2023 The kpt Authors +# +# 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. + allowNetwork: true \ No newline at end of file diff --git a/e2e/testdata/fn-render/basicpipeline/.expected/diff.patch b/e2e/testdata/fn-render/basicpipeline/.expected/diff.patch index a21c38b30e..c93758d413 100644 --- a/e2e/testdata/fn-render/basicpipeline/.expected/diff.patch +++ b/e2e/testdata/fn-render/basicpipeline/.expected/diff.patch @@ -1,30 +1,87 @@ diff --git a/Kptfile b/Kptfile -index 1307fb5..3a2c718 100644 +index c3817f3..9caee20 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index f2eec52..84cfb26 100644 +index 9d1f786..6b5d443 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -32,13 +89,12 @@ index f2eec52..84cfb26 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/basicpipeline/.krmignore b/e2e/testdata/fn-render/basicpipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/basicpipeline/.krmignore +++ b/e2e/testdata/fn-render/basicpipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/basicpipeline/Kptfile b/e2e/testdata/fn-render/basicpipeline/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/basicpipeline/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/basicpipeline/resources.yaml b/e2e/testdata/fn-render/basicpipeline/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/basicpipeline/resources.yaml +++ b/e2e/testdata/fn-render/basicpipeline/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/default-runtime/.expected/diff.patch b/e2e/testdata/fn-render/default-runtime/.expected/diff.patch index a21c38b30e..2e02429e85 100644 --- a/e2e/testdata/fn-render/default-runtime/.expected/diff.patch +++ b/e2e/testdata/fn-render/default-runtime/.expected/diff.patch @@ -1,44 +1,44 @@ -diff --git a/Kptfile b/Kptfile -index 1307fb5..3a2c718 100644 ---- a/Kptfile -+++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging -+ labels: -+ tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -diff --git a/resources.yaml b/resources.yaml -index f2eec52..84cfb26 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging -+ labels: -+ tier: backend - spec: - replicas: 3 -+ selector: -+ matchLabels: -+ tier: backend -+ template: -+ metadata: -+ labels: -+ tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging -+ labels: -+ tier: backend - spec: - image: nginx:1.2.3 +diff --git a/Kptfile b/Kptfile +index 1307fb5..3a2c718 100644 +--- a/Kptfile ++++ b/Kptfile +@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app ++ namespace: staging ++ labels: ++ tier: backend + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +diff --git a/resources.yaml b/resources.yaml +index f2eec52..84cfb26 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,12 +15,25 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment ++ namespace: staging ++ labels: ++ tier: backend + spec: + replicas: 3 ++ selector: ++ matchLabels: ++ tier: backend ++ template: ++ metadata: ++ labels: ++ tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom ++ namespace: staging ++ labels: ++ tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/default-runtime/.expected/exec.sh b/e2e/testdata/fn-render/default-runtime/.expected/exec.sh index b7bb8ad589..8458f8029a 100755 --- a/e2e/testdata/fn-render/default-runtime/.expected/exec.sh +++ b/e2e/testdata/fn-render/default-runtime/.expected/exec.sh @@ -1,25 +1,25 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -# clear environment variable KRM_FN_RUNTIME if it matches the default -if [ "${KRM_FN_RUNTIME}" = "docker" ]; then - unset KRM_FN_RUNTIME -fi - -echo "KRM_FN_RUNTIME is ${KRM_FN_RUNTIME}" -# run render with KRM_FN_RUNTIME unset. -kpt fn render +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +# clear environment variable KRM_FN_RUNTIME if it matches the default +if [ "${KRM_FN_RUNTIME}" = "docker" ]; then + unset KRM_FN_RUNTIME +fi + +echo "KRM_FN_RUNTIME is ${KRM_FN_RUNTIME}" +# run render with KRM_FN_RUNTIME unset. +kpt fn render diff --git a/e2e/testdata/fn-render/default-runtime/.krmignore b/e2e/testdata/fn-render/default-runtime/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/default-runtime/.krmignore +++ b/e2e/testdata/fn-render/default-runtime/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/default-runtime/Kptfile b/e2e/testdata/fn-render/default-runtime/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/default-runtime/Kptfile +++ b/e2e/testdata/fn-render/default-runtime/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/default-runtime/resources.yaml b/e2e/testdata/fn-render/default-runtime/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/default-runtime/resources.yaml +++ b/e2e/testdata/fn-render/default-runtime/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/empty-pipeline/.krmignore b/e2e/testdata/fn-render/empty-pipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/empty-pipeline/.krmignore +++ b/e2e/testdata/fn-render/empty-pipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/empty-pipeline/Kptfile b/e2e/testdata/fn-render/empty-pipeline/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-render/empty-pipeline/Kptfile +++ b/e2e/testdata/fn-render/empty-pipeline/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-render/empty-pipeline/resources.yaml b/e2e/testdata/fn-render/empty-pipeline/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/empty-pipeline/resources.yaml +++ b/e2e/testdata/fn-render/empty-pipeline/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/exec-function-stderr/.expected/config.yaml b/e2e/testdata/fn-render/exec-function-stderr/.expected/config.yaml index d45b91017d..68699dcd26 100644 --- a/e2e/testdata/fn-render/exec-function-stderr/.expected/config.yaml +++ b/e2e/testdata/fn-render/exec-function-stderr/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -allowExec: true -stdErr: | - Package: "exec-function-stderr" - [RUNNING] "./testdata/fn-render/exec-function-stderr/function.sh" - [PASS] "./testdata/fn-render/exec-function-stderr/function.sh" in 0s - Stderr: Hello world 0!, Hello world 1!, Hello world 2!, Hello world 3!, Hello world 4!, Hello world 5!, Hello world 6!, Hello world 7!, Hello world 8!, Hello world 9!, Hello world 10!, Hello world 11!, Hello world 12!, Hello world 13!, Hello world 14!, Hello world 15!, Hello world 16!, Hello world 17!, Hello world 18!, Hello world 19!, Hello world 20!, Successfully executed 1 function(s) in 1 package(s). +# Copyright 2021,2026 The kpt Authors +# +# 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. + +allowExec: true +stdErr: | + Package: "exec-function-stderr" + [RUNNING] "./testdata/fn-render/exec-function-stderr/function.sh" + [PASS] "./testdata/fn-render/exec-function-stderr/function.sh" in 0s + Stderr: Hello world 0!, Hello world 1!, Hello world 2!, Hello world 3!, Hello world 4!, Hello world 5!, Hello world 6!, Hello world 7!, Hello world 8!, Hello world 9!, Hello world 10!, Hello world 11!, Hello world 12!, Hello world 13!, Hello world 14!, Hello world 15!, Hello world 16!, Hello world 17!, Hello world 18!, Hello world 19!, Hello world 20!, Successfully executed 1 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/exec-function-stderr/.expected/diff.patch b/e2e/testdata/fn-render/exec-function-stderr/.expected/diff.patch index c35d542fb0..e23467f595 100644 --- a/e2e/testdata/fn-render/exec-function-stderr/.expected/diff.patch +++ b/e2e/testdata/fn-render/exec-function-stderr/.expected/diff.patch @@ -1,21 +1,21 @@ -diff --git a/resources.yaml b/resources.yaml -index 0f69886..ff4bde7 100644 ---- a/resources.yaml -+++ b/resources.yaml -@@ -15,7 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -- namespace: foo -+ namespace: bar - spec: - replicas: 3 - --- -@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -- namespace: foo -+ namespace: bar - spec: - image: nginx:1.2.3 +diff --git a/resources.yaml b/resources.yaml +index 0f69886..ff4bde7 100644 +--- a/resources.yaml ++++ b/resources.yaml +@@ -15,7 +15,7 @@ apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment +- namespace: foo ++ namespace: bar + spec: + replicas: 3 + --- +@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom +- namespace: foo ++ namespace: bar + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/exec-function-stderr/.krmignore b/e2e/testdata/fn-render/exec-function-stderr/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/exec-function-stderr/.krmignore +++ b/e2e/testdata/fn-render/exec-function-stderr/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/exec-function-stderr/Kptfile b/e2e/testdata/fn-render/exec-function-stderr/Kptfile index 6f2fe1122f..9248a1ea72 100644 --- a/e2e/testdata/fn-render/exec-function-stderr/Kptfile +++ b/e2e/testdata/fn-render/exec-function-stderr/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - exec: "./testdata/fn-render/exec-function-stderr/function.sh" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - exec: "./testdata/fn-render/exec-function-stderr/function.sh" diff --git a/e2e/testdata/fn-render/exec-function-stderr/function.sh b/e2e/testdata/fn-render/exec-function-stderr/function.sh index 66bf707286..307507f8ff 100755 --- a/e2e/testdata/fn-render/exec-function-stderr/function.sh +++ b/e2e/testdata/fn-render/exec-function-stderr/function.sh @@ -1,21 +1,21 @@ -#! /usr/bin/env bash -# Copyright 2021 The kpt Authors -# -# 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. - -sed -e 's/foo/bar/' - -for i in {0..20} -do - >&2 echo "Hello world $i!" -done +#! /usr/bin/env bash +# Copyright 2021 The kpt Authors +# +# 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. + +sed -e 's/foo/bar/' + +for i in {0..20} +do + >&2 echo "Hello world $i!" +done diff --git a/e2e/testdata/fn-render/exec-function-stderr/resources.yaml b/e2e/testdata/fn-render/exec-function-stderr/resources.yaml index 0f69886ef5..159de16b1f 100644 --- a/e2e/testdata/fn-render/exec-function-stderr/resources.yaml +++ b/e2e/testdata/fn-render/exec-function-stderr/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/exec-function-with-args/.expected/config.yaml b/e2e/testdata/fn-render/exec-function-with-args/.expected/config.yaml index 48065bf499..2cfb56c078 100644 --- a/e2e/testdata/fn-render/exec-function-with-args/.expected/config.yaml +++ b/e2e/testdata/fn-render/exec-function-with-args/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -allowExec: true +# Copyright 2021 The kpt Authors +# +# 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. + +allowExec: true diff --git a/e2e/testdata/fn-render/exec-function-with-args/.expected/diff.patch b/e2e/testdata/fn-render/exec-function-with-args/.expected/diff.patch index c58020a874..58e0fee7aa 100644 --- a/e2e/testdata/fn-render/exec-function-with-args/.expected/diff.patch +++ b/e2e/testdata/fn-render/exec-function-with-args/.expected/diff.patch @@ -1,31 +1,80 @@ diff --git a/Kptfile b/Kptfile -index 0d98dbb..23bd061 100644 +index 5628a13..23bd061 100755 --- a/Kptfile +++ b/Kptfile -@@ -4,4 +4,4 @@ metadata: - name: app - pipeline: - mutators: -- - exec: "sed -e 's/foo/bar/'" +@@ -1,7 +1,7 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - exec: "sed -e 's/foo/bar/'" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: + - exec: "sed -e 's/bar/bar/'" diff --git a/resources.yaml b/resources.yaml -index 0f69886..ff4bde7 100644 +index 159de16..ff4bde7 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,7 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -- namespace: foo +@@ -1,28 +1,28 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +- namespace: foo +-spec: +- replicas: 3 +---- +-apiVersion: custom.io/v1 +-kind: Custom +-metadata: +- name: custom +- namespace: foo +-spec: +- image: nginx:1.2.3 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: bar - spec: - replicas: 3 - --- -@@ -23,6 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -- namespace: foo ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + namespace: bar - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/exec-function-with-args/.krmignore b/e2e/testdata/fn-render/exec-function-with-args/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/exec-function-with-args/.krmignore +++ b/e2e/testdata/fn-render/exec-function-with-args/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/exec-function-with-args/Kptfile b/e2e/testdata/fn-render/exec-function-with-args/Kptfile index 0d98dbb169..5628a13def 100644 --- a/e2e/testdata/fn-render/exec-function-with-args/Kptfile +++ b/e2e/testdata/fn-render/exec-function-with-args/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - exec: "sed -e 's/foo/bar/'" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - exec: "sed -e 's/foo/bar/'" diff --git a/e2e/testdata/fn-render/exec-function-with-args/resources.yaml b/e2e/testdata/fn-render/exec-function-with-args/resources.yaml index 0f69886ef5..159de16b1f 100644 --- a/e2e/testdata/fn-render/exec-function-with-args/resources.yaml +++ b/e2e/testdata/fn-render/exec-function-with-args/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/exec-without-permissions/.expected/config.yaml b/e2e/testdata/fn-render/exec-without-permissions/.expected/config.yaml index 62dbc6ef19..448c8ca372 100644 --- a/e2e/testdata/fn-render/exec-without-permissions/.expected/config.yaml +++ b/e2e/testdata/fn-render/exec-without-permissions/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: 'Error: must run with `--allow-exec` option to allow running function binaries' \ No newline at end of file diff --git a/e2e/testdata/fn-render/exec-without-permissions/.krmignore b/e2e/testdata/fn-render/exec-without-permissions/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/exec-without-permissions/.krmignore +++ b/e2e/testdata/fn-render/exec-without-permissions/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/exec-without-permissions/Kptfile b/e2e/testdata/fn-render/exec-without-permissions/Kptfile index 0d98dbb169..5628a13def 100644 --- a/e2e/testdata/fn-render/exec-without-permissions/Kptfile +++ b/e2e/testdata/fn-render/exec-without-permissions/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - exec: "sed -e 's/foo/bar/'" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - exec: "sed -e 's/foo/bar/'" diff --git a/e2e/testdata/fn-render/exec-without-permissions/resources.yaml b/e2e/testdata/fn-render/exec-without-permissions/resources.yaml index 0f69886ef5..159de16b1f 100644 --- a/e2e/testdata/fn-render/exec-without-permissions/resources.yaml +++ b/e2e/testdata/fn-render/exec-without-permissions/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: foo -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: foo -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: foo +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: foo +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fn-failure-output-no-truncate/.expected/config.yaml b/e2e/testdata/fn-render/fn-failure-output-no-truncate/.expected/config.yaml index 6a1b44ca7a..060018b213 100644 --- a/e2e/testdata/fn-render/fn-failure-output-no-truncate/.expected/config.yaml +++ b/e2e/testdata/fn-render/fn-failure-output-no-truncate/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 -disableOutputTruncate: true -stdErr: '[error] apps/v1/Deployment/nginx-deployment spec.replicas: got string, want null or integer' +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 +disableOutputTruncate: true +stdErr: '[error] apps/v1/Deployment/nginx-deployment spec.replicas: got string, want null or integer' diff --git a/e2e/testdata/fn-render/fn-failure-output-no-truncate/.krmignore b/e2e/testdata/fn-render/fn-failure-output-no-truncate/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fn-failure-output-no-truncate/.krmignore +++ b/e2e/testdata/fn-render/fn-failure-output-no-truncate/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fn-failure-output-no-truncate/Kptfile b/e2e/testdata/fn-render/fn-failure-output-no-truncate/Kptfile index 0586af999b..ce3de86f8b 100644 --- a/e2e/testdata/fn-render/fn-failure-output-no-truncate/Kptfile +++ b/e2e/testdata/fn-render/fn-failure-output-no-truncate/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest - configMap: - strict: "true" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest + configMap: + strict: "true" diff --git a/e2e/testdata/fn-render/fn-failure-output-no-truncate/resources.yaml b/e2e/testdata/fn-render/fn-failure-output-no-truncate/resources.yaml index 81bd9975d7..afc54ce286 100644 --- a/e2e/testdata/fn-render/fn-failure-output-no-truncate/resources.yaml +++ b/e2e/testdata/fn-render/fn-failure-output-no-truncate/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: invalid ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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: invalid +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fn-failure/.expected/config.yaml b/e2e/testdata/fn-render/fn-failure/.expected/config.yaml index 0b36990bfa..7a1b2b6428 100644 --- a/e2e/testdata/fn-render/fn-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/fn-failure/.expected/config.yaml @@ -1,24 +1,24 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 -stdErr: | - Package: "fn-failure" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" - [FAIL] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" in 0s - [Results]: [error]: httpbin-gen:3:73: got newline, want primary expression - Stderr: failed to evaluate function: error: function failure Exit code: 1 - +# Copyright 2021,2026 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 +stdErr: | + Package: "fn-failure" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" + [FAIL] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" in 0s + [Results]: [error]: httpbin-gen:3:73: got newline, want primary expression + Stderr: failed to evaluate function: error: function failure Exit code: 1 + diff --git a/e2e/testdata/fn-render/fn-failure/.krmignore b/e2e/testdata/fn-render/fn-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fn-failure/.krmignore +++ b/e2e/testdata/fn-render/fn-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fn-failure/Kptfile b/e2e/testdata/fn-render/fn-failure/Kptfile index ad0c67219a..9e5cb7acf9 100644 --- a/e2e/testdata/fn-render/fn-failure/Kptfile +++ b/e2e/testdata/fn-render/fn-failure/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: -# invalid starlark input results in failure of first fn - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-failure-fn.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: +# invalid starlark input results in failure of first fn + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-failure-fn.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/fn-failure/deployment_httpbin.yaml b/e2e/testdata/fn-render/fn-failure/deployment_httpbin.yaml index b3b3361dea..3d1c7de618 100644 --- a/e2e/testdata/fn-render/fn-failure/deployment_httpbin.yaml +++ b/e2e/testdata/fn-render/fn-failure/deployment_httpbin.yaml @@ -1,37 +1,37 @@ -# Copyright 2021 The kpt Authors -# -# 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: - labels: - app: backend - tier: db - name: httpbin - namespace: staging -spec: - replicas: 4 - selector: - matchLabels: - app: backend - tier: db - template: - metadata: - labels: - app: backend - tier: db - spec: - containers: - - image: kennethreitz/httpbin - name: httpbin +# Copyright 2021 The kpt Authors +# +# 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: + labels: + app: backend + tier: db + name: httpbin + namespace: staging +spec: + replicas: 4 + selector: + matchLabels: + app: backend + tier: db + template: + metadata: + labels: + app: backend + tier: db + spec: + containers: + - image: kennethreitz/httpbin + name: httpbin diff --git a/e2e/testdata/fn-render/fn-failure/resources.yaml b/e2e/testdata/fn-render/fn-failure/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fn-failure/resources.yaml +++ b/e2e/testdata/fn-render/fn-failure/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fn-failure/starlark-failure-fn.yaml b/e2e/testdata/fn-render/fn-failure/starlark-failure-fn.yaml index bb3b184776..9965dbcddb 100644 --- a/e2e/testdata/fn-render/fn-failure/starlark-failure-fn.yaml +++ b/e2e/testdata/fn-render/fn-failure/starlark-failure-fn.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: | - # AND conditional has syntax error forcing fn to fail - def isHTTPBin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and - r["metadata"]["name"] == "httpbin" - - # filter out the httpbin deployment - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] +# Copyright 2021 The kpt Authors +# +# 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: | + # AND conditional has syntax error forcing fn to fail + def isHTTPBin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and + r["metadata"]["name"] == "httpbin" + + # filter out the httpbin deployment + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] diff --git a/e2e/testdata/fn-render/fn-success-with-stderr/.expected/diff.patch b/e2e/testdata/fn-render/fn-success-with-stderr/.expected/diff.patch new file mode 100644 index 0000000000..da4f264a7d --- /dev/null +++ b/e2e/testdata/fn-render/fn-success-with-stderr/.expected/diff.patch @@ -0,0 +1,123 @@ +diff --git a/Kptfile b/Kptfile +index ff38bf9..f591880 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark.yaml +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 +diff --git a/starlark.yaml b/starlark.yaml +index c636402..9f8a888 100755 +--- a/starlark.yaml ++++ b/starlark.yaml +@@ -1,20 +1,20 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: | +- print("function succeeded, reporting it on stderr") ++# Copyright 2021 The kpt Authors ++# ++# 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: | ++ print("function succeeded, reporting it on stderr") diff --git a/e2e/testdata/fn-render/fn-success-with-stderr/.krmignore b/e2e/testdata/fn-render/fn-success-with-stderr/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fn-success-with-stderr/.krmignore +++ b/e2e/testdata/fn-render/fn-success-with-stderr/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fn-success-with-stderr/Kptfile b/e2e/testdata/fn-render/fn-success-with-stderr/Kptfile index f591880388..ff38bf9ff0 100644 --- a/e2e/testdata/fn-render/fn-success-with-stderr/Kptfile +++ b/e2e/testdata/fn-render/fn-success-with-stderr/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark.yaml diff --git a/e2e/testdata/fn-render/fn-success-with-stderr/resources.yaml b/e2e/testdata/fn-render/fn-success-with-stderr/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fn-success-with-stderr/resources.yaml +++ b/e2e/testdata/fn-render/fn-success-with-stderr/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fn-success-with-stderr/starlark.yaml b/e2e/testdata/fn-render/fn-success-with-stderr/starlark.yaml index 9f8a88859e..c636402555 100644 --- a/e2e/testdata/fn-render/fn-success-with-stderr/starlark.yaml +++ b/e2e/testdata/fn-render/fn-success-with-stderr/starlark.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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: | - print("function succeeded, reporting it on stderr") +# Copyright 2021 The kpt Authors +# +# 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: | + print("function succeeded, reporting it on stderr") diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.expected/diff.patch b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.expected/diff.patch index 0201b51e87..3bcfeec163 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.expected/diff.patch +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.expected/diff.patch @@ -1,55 +1,141 @@ diff --git a/Kptfile b/Kptfile -index dbab15c..a37d10e 100644 +index d4b3127..8d8916e 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +@@ -1,9 +1,9 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging diff --git a/db/Kptfile b/db/Kptfile -index 093e789..dfe7f20 100644 +index 2a59abb..5bddc41 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db +@@ -1,8 +1,10 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configPath: labelconfig.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + tier: db -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: labelconfig.yaml diff --git a/db/labelconfig.yaml b/db/labelconfig.yaml -index 22d2de2..f4d597f 100644 +index 84d2149..f4d597f 100755 --- a/db/labelconfig.yaml +++ b/db/labelconfig.yaml -@@ -15,5 +15,8 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: label-config +@@ -1,19 +1,22 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: v1 +-kind: ConfigMap +-metadata: +- name: label-config +-data: +- tier: db ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: label-config + labels: + tier: db + namespace: staging - data: - tier: db ++data: ++ tier: db diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..7ced034 100644 +index c9c269b..7ced034 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,5 +15,15 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db +@@ -1,19 +1,29 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db + labels: + tier: db + namespace: staging - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -58,21 +144,60 @@ index dabe43c..7ced034 100644 + labels: + tier: db diff --git a/resources.yaml b/resources.yaml -index f2eec52..b66c419 100644 +index 9d1f786..f169ab0 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: staging - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom +@@ -1,26 +1,27 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging - spec: - image: nginx:1.2.3 ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.krmignore b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile index 8d8916eff3..d4b312741b 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/Kptfile b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/Kptfile index 093e7896d6..2a59abbe70 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/resources.yaml b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/resources.yaml b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-ancestorfn-not-mutate-subpkg-config/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.expected/config.yaml b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.expected/config.yaml index d10d9e6a80..d0ea358fd7 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | - Kptfile is invalid: - Field: `pipeline.mutators[0].configPath` - Value: "db/labelconfig.yaml" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | + Kptfile is invalid: + Field: `pipeline.mutators[0].configPath` + Value: "db/labelconfig.yaml" Reason: functionConfig must exist in the current package \ No newline at end of file diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.krmignore b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/Kptfile b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/Kptfile index 0bfdbb0548..30c50b1de7 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: db/labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: db/labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/Kptfile b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/Kptfile index 79b7a5a39e..db5e84a9d1 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/resources.yaml b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/resources.yaml index 945c004d88..b380542215 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/db/resources.yaml @@ -1,29 +1,29 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db - namespace: staging - labels: - tier: db -spec: - replicas: 3 - selector: - matchLabels: - tier: db - template: - metadata: - labels: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db + namespace: staging + labels: + tier: db +spec: + replicas: 3 + selector: + matchLabels: + tier: db + template: + metadata: + labels: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/resources.yaml b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/resources.yaml index 8b2113ddfa..e2121f909c 100644 --- a/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-cannot-refer-subpkgs/resources.yaml @@ -1,39 +1,39 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: staging - labels: - tier: db -spec: - replicas: 3 - selector: - matchLabels: - tier: db - template: - metadata: - labels: - tier: db ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: staging - labels: - tier: db -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: staging + labels: + tier: db +spec: + replicas: 3 + selector: + matchLabels: + tier: db + template: + metadata: + labels: + tier: db +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: staging + labels: + tier: db +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/config.yaml b/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/config.yaml index 70d9081a83..8927a18d88 100644 --- a/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/config.yaml @@ -1,14 +1,14 @@ -# Copyright 2021 The kpt Authors -# -# 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. -# +# Copyright 2021 The kpt Authors +# +# 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. +# diff --git a/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/diff.patch b/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/diff.patch index e81f73f1cc..5e07a0e90a 100644 --- a/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/diff.patch +++ b/e2e/testdata/fn-render/fnconfig-in-subdir/.expected/diff.patch @@ -1,40 +1,123 @@ diff --git a/Kptfile b/Kptfile -index 0bfdbb0..69acc11 100644 +index 30c50b1..69acc11 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db +@@ -1,8 +1,10 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configPath: db/labelconfig.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db + labels: + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: db/labelconfig.yaml diff --git a/db/labelconfig.yaml b/db/labelconfig.yaml -index 22d2de2..19e0746 100644 +index 84d2149..19e0746 100755 --- a/db/labelconfig.yaml +++ b/db/labelconfig.yaml -@@ -15,5 +15,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: label-config +@@ -1,19 +1,21 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: v1 +-kind: ConfigMap +-metadata: +- name: label-config +-data: +- tier: db ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: label-config + labels: + tier: db - data: - tier: db ++data: ++ tier: db diff --git a/resources.yaml b/resources.yaml -index f2eec52..022e175 100644 +index 9d1f786..022e175 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,23 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,37 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + labels: + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -42,12 +125,12 @@ index f2eec52..022e175 100644 + metadata: + labels: + tier: db - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: db - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fnconfig-in-subdir/.krmignore b/e2e/testdata/fn-render/fnconfig-in-subdir/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-in-subdir/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-in-subdir/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-in-subdir/Kptfile b/e2e/testdata/fn-render/fnconfig-in-subdir/Kptfile index 0bfdbb0548..30c50b1de7 100644 --- a/e2e/testdata/fn-render/fnconfig-in-subdir/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-in-subdir/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: db/labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: db/labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-in-subdir/db/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-in-subdir/db/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig-in-subdir/db/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-in-subdir/db/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-in-subdir/resources.yaml b/e2e/testdata/fn-render/fnconfig-in-subdir/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-in-subdir/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-in-subdir/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-missing-name/.expected/config.yaml b/e2e/testdata/fn-render/fnconfig-missing-name/.expected/config.yaml index c491ada18b..6c1708def2 100644 --- a/e2e/testdata/fn-render/fnconfig-missing-name/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnconfig-missing-name/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "resource must have `metadata.name`" \ No newline at end of file diff --git a/e2e/testdata/fn-render/fnconfig-missing-name/.krmignore b/e2e/testdata/fn-render/fnconfig-missing-name/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-missing-name/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-missing-name/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile b/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile index e93b78ae8f..6579bee199 100644 --- a/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-missing-name/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-missing-name/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-missing-name/labelconfig.yaml index 48cffe1424..775f52f135 100644 --- a/e2e/testdata/fn-render/fnconfig-missing-name/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-missing-name/labelconfig.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-missing-name/resources.yaml b/e2e/testdata/fn-render/fnconfig-missing-name/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-missing-name/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-missing-name/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/.expected/config.yaml b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/.expected/config.yaml index ac4432eef1..768f81e621 100644 --- a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. -exitCode: 1 -stdErr: "functionConfig \"labelconfig.yaml\" must not contain more than one config, got 2" +# Copyright 2021 The kpt Authors +# +# 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. +exitCode: 1 +stdErr: "functionConfig \"labelconfig.yaml\" must not contain more than one config, got 2" diff --git a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/Kptfile b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/Kptfile index be1368f8d4..e3115f7905 100644 --- a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/labelconfig.yaml index 31d816f2c3..712820c920 100644 --- a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/labelconfig.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/resources.yaml b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-multiple-config-one-file/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-not-relative/.expected/config.yaml b/e2e/testdata/fn-render/fnconfig-not-relative/.expected/config.yaml index f427672339..68fd821028 100644 --- a/e2e/testdata/fn-render/fnconfig-not-relative/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnconfig-not-relative/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | - Kptfile is invalid: - Field: `pipeline.mutators[0].configPath` - Value: "/some/root/labelconfig.yaml" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | + Kptfile is invalid: + Field: `pipeline.mutators[0].configPath` + Value: "/some/root/labelconfig.yaml" Reason: path must be relative \ No newline at end of file diff --git a/e2e/testdata/fn-render/fnconfig-not-relative/.krmignore b/e2e/testdata/fn-render/fnconfig-not-relative/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-not-relative/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-not-relative/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-not-relative/Kptfile b/e2e/testdata/fn-render/fnconfig-not-relative/Kptfile index fc1df4a780..52a87489f9 100644 --- a/e2e/testdata/fn-render/fnconfig-not-relative/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-not-relative/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: /some/root/labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: /some/root/labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-not-relative/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-not-relative/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig-not-relative/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-not-relative/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-not-relative/resources.yaml b/e2e/testdata/fn-render/fnconfig-not-relative/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-not-relative/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-not-relative/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-outside-package/.expected/config.yaml b/e2e/testdata/fn-render/fnconfig-outside-package/.expected/config.yaml index a465446780..a51e588bbd 100644 --- a/e2e/testdata/fn-render/fnconfig-outside-package/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnconfig-outside-package/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | - Kptfile is invalid: - Field: `pipeline.mutators[1].configPath` - Value: "some/../../home/.kube/config" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | + Kptfile is invalid: + Field: `pipeline.mutators[1].configPath` + Value: "some/../../home/.kube/config" Reason: path must not be outside the package \ No newline at end of file diff --git a/e2e/testdata/fn-render/fnconfig-outside-package/.krmignore b/e2e/testdata/fn-render/fnconfig-outside-package/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-outside-package/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-outside-package/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-outside-package/Kptfile b/e2e/testdata/fn-render/fnconfig-outside-package/Kptfile index 8de925f1a7..155d9d5533 100644 --- a/e2e/testdata/fn-render/fnconfig-outside-package/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-outside-package/Kptfile @@ -1,10 +1,10 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: some/../../home/.kube/config # config pointing outside the package +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: some/../../home/.kube/config # config pointing outside the package diff --git a/e2e/testdata/fn-render/fnconfig-outside-package/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-outside-package/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig-outside-package/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-outside-package/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-outside-package/resources.yaml b/e2e/testdata/fn-render/fnconfig-outside-package/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-outside-package/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-outside-package/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.expected/diff.patch b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.expected/diff.patch index acfd29847a..b2f8f79449 100644 --- a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.expected/diff.patch +++ b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.expected/diff.patch @@ -1,40 +1,123 @@ diff --git a/Kptfile b/Kptfile -index c2cf3ba..81422f3 100644 +index 332c26e..81422f3 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db +@@ -1,8 +1,10 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configPath: confs/labelconfig.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db + labels: + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: confs/labelconfig.yaml diff --git a/confs/labelconfig.yaml b/confs/labelconfig.yaml -index 22d2de2..19e0746 100644 +index 84d2149..19e0746 100755 --- a/confs/labelconfig.yaml +++ b/confs/labelconfig.yaml -@@ -15,5 +15,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: label-config +@@ -1,19 +1,21 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: v1 +-kind: ConfigMap +-metadata: +- name: label-config +-data: +- tier: db ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: label-config + labels: + tier: db - data: - tier: db ++data: ++ tier: db diff --git a/resources.yaml b/resources.yaml -index f2eec52..022e175 100644 +index 9d1f786..022e175 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,23 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,37 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + labels: + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -42,12 +125,12 @@ index f2eec52..022e175 100644 + metadata: + labels: + tier: db - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: db - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.krmignore b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/Kptfile b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/Kptfile index c2cf3ba71f..332c26e6bc 100644 --- a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: confs/labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: confs/labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/confs/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/confs/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/confs/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/confs/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/resources.yaml b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig-pkgfn-refers-subdir/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/.expected/diff.patch b/e2e/testdata/fn-render/fnconfig-updated-in-render/.expected/diff.patch index e7c0130835..6802d6f841 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/.expected/diff.patch +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/.expected/diff.patch @@ -1,91 +1,200 @@ diff --git a/Kptfile b/Kptfile -index 950565f..7bd678e 100644 +index 28cebe8..c9a3a24 100755 --- a/Kptfile +++ b/Kptfile -@@ -3,7 +3,7 @@ kind: Kptfile - metadata: - name: frontend - labels: -- app.kubernetes.io/app: example +@@ -1,18 +1,18 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: frontend +- labels: +- app.kubernetes.io/app: example +- annotations: +- config.kubernetes.io/local-config: "true" +-info: +- description: sample description +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configPath: package-context.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/apply-replacements:latest +- configPath: update-labels.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configPath: label-input.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: frontend ++ labels: + app.kubernetes.io/app: frontend - annotations: - config.kubernetes.io/local-config: "true" - info: ++ annotations: ++ config.kubernetes.io/local-config: "true" ++info: ++ description: sample description ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configPath: package-context.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/apply-replacements:latest ++ configPath: update-labels.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: label-input.yaml diff --git a/app.yaml b/app.yaml -index 3361e5b..33f2627 100644 +index 5261ea2..33f2627 100755 --- a/app.yaml +++ b/app.yaml -@@ -2,9 +2,9 @@ apiVersion: apps/v1 - kind: Deployment - metadata: # kpt-merge: example/deployment - name: deployment -- namespace: example +@@ -1,22 +1,22 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: # kpt-merge: example/deployment +- name: deployment +- namespace: example +- labels: +- app.kubernetes.io/app: example +-spec: +- replicas: 3 +- template: +- spec: +- containers: +- - name: nginx +- image: nginx:1.14.2 +- ports: +- - containerPort: 80 +- metadata: +- labels: +- app.kubernetes.io/app: example +- selector: +- matchLabels: +- app.kubernetes.io/app: example ++apiVersion: apps/v1 ++kind: Deployment ++metadata: # kpt-merge: example/deployment ++ name: deployment + namespace: frontend - labels: -- app.kubernetes.io/app: example ++ labels: + app.kubernetes.io/app: frontend - spec: - replicas: 3 - template: -@@ -16,7 +16,7 @@ spec: - - containerPort: 80 - metadata: - labels: -- app.kubernetes.io/app: example ++spec: ++ replicas: 3 ++ template: ++ spec: ++ containers: ++ - name: nginx ++ image: nginx:1.14.2 ++ ports: ++ - containerPort: 80 ++ metadata: ++ labels: + app.kubernetes.io/app: frontend - selector: - matchLabels: -- app.kubernetes.io/app: example ++ selector: ++ matchLabels: + app.kubernetes.io/app: frontend diff --git a/label-input.yaml b/label-input.yaml -index 26dab6c..cdff6e0 100644 +index 9d87001..cdff6e0 100755 --- a/label-input.yaml +++ b/label-input.yaml -@@ -5,6 +5,6 @@ metadata: # kpt-merge: /label-input - annotations: - config.kubernetes.io/local-config: "true" - labels: -- app.kubernetes.io/app: example +@@ -1,10 +1,10 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: # kpt-merge: /label-input +- name: label-input +- annotations: +- config.kubernetes.io/local-config: "true" +- labels: +- app.kubernetes.io/app: example +-data: +- app.kubernetes.io/app: example ++apiVersion: v1 ++kind: ConfigMap ++metadata: # kpt-merge: /label-input ++ name: label-input ++ annotations: ++ config.kubernetes.io/local-config: "true" ++ labels: + app.kubernetes.io/app: frontend - data: -- app.kubernetes.io/app: example ++data: + app.kubernetes.io/app: frontend diff --git a/namespace.yaml b/namespace.yaml -index 9db1da3..e112378 100644 +index cdcee64..e112378 100755 --- a/namespace.yaml +++ b/namespace.yaml @@ -1,7 +1,7 @@ - apiVersion: v1 - kind: Namespace - metadata: # kpt-merge: /example -- name: example +-apiVersion: v1 +-kind: Namespace +-metadata: # kpt-merge: /example +- name: example +- labels: +- app.kubernetes.io/app: example +-spec: {} ++apiVersion: v1 ++kind: Namespace ++metadata: # kpt-merge: /example + name: frontend - labels: -- app.kubernetes.io/app: example ++ labels: + app.kubernetes.io/app: frontend - spec: {} ++spec: {} diff --git a/package-context.yaml b/package-context.yaml -index 2340959..bbf7167 100644 +index 46a2557..bbf7167 100755 --- a/package-context.yaml +++ b/package-context.yaml -@@ -4,5 +4,7 @@ metadata: - name: kptfile.kpt.dev - annotations: - config.kubernetes.io/local-config: "true" +@@ -1,8 +1,10 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: kptfile.kpt.dev +- annotations: +- config.kubernetes.io/local-config: "true" +-data: +- name: frontend ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: kptfile.kpt.dev ++ annotations: ++ config.kubernetes.io/local-config: "true" + labels: + app.kubernetes.io/app: frontend - data: - name: frontend ++data: ++ name: frontend diff --git a/update-labels.yaml b/update-labels.yaml -index 7aae6c7..cabf787 100644 +index 7b659b4..cabf787 100755 --- a/update-labels.yaml +++ b/update-labels.yaml -@@ -5,7 +5,7 @@ metadata: # kpt-merge: /update-labels - annotations: - config.kubernetes.io/local-config: "true" - labels: -- app.kubernetes.io/app: example +@@ -1,19 +1,19 @@ +-apiVersion: fn.kpt.dev/v1alpha1 +-kind: ApplyReplacements +-metadata: # kpt-merge: /update-labels +- name: update-labels +- annotations: +- config.kubernetes.io/local-config: "true" +- labels: +- app.kubernetes.io/app: example +-replacements: +-- source: +- kind: ConfigMap +- name: kptfile.kpt.dev +- fieldPath: data.name +- targets: +- - select: +- kind: ConfigMap +- name: label-input +- fieldPaths: +- - data.[app.kubernetes.io/app] ++apiVersion: fn.kpt.dev/v1alpha1 ++kind: ApplyReplacements ++metadata: # kpt-merge: /update-labels ++ name: update-labels ++ annotations: ++ config.kubernetes.io/local-config: "true" ++ labels: + app.kubernetes.io/app: frontend - replacements: - - source: - kind: ConfigMap ++replacements: ++- source: ++ kind: ConfigMap ++ name: kptfile.kpt.dev ++ fieldPath: data.name ++ targets: ++ - select: ++ kind: ConfigMap ++ name: label-input ++ fieldPaths: ++ - data.[app.kubernetes.io/app] diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/.krmignore b/e2e/testdata/fn-render/fnconfig-updated-in-render/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/.krmignore +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile b/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile index abfc9c12e6..28cebe8480 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/Kptfile @@ -1,18 +1,18 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: frontend - labels: - app.kubernetes.io/app: example - annotations: - config.kubernetes.io/local-config: "true" -info: - description: sample description -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configPath: package-context.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/apply-replacements:latest - configPath: update-labels.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: label-input.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: frontend + labels: + app.kubernetes.io/app: example + annotations: + config.kubernetes.io/local-config: "true" +info: + description: sample description +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configPath: package-context.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/apply-replacements:latest + configPath: update-labels.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: label-input.yaml diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/app.yaml b/e2e/testdata/fn-render/fnconfig-updated-in-render/app.yaml index 3361e5b31f..5261ea2209 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/app.yaml +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/app.yaml @@ -1,22 +1,22 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: # kpt-merge: example/deployment - name: deployment - namespace: example - labels: - app.kubernetes.io/app: example -spec: - replicas: 3 - template: - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: - - containerPort: 80 - metadata: - labels: - app.kubernetes.io/app: example - selector: - matchLabels: - app.kubernetes.io/app: example +apiVersion: apps/v1 +kind: Deployment +metadata: # kpt-merge: example/deployment + name: deployment + namespace: example + labels: + app.kubernetes.io/app: example +spec: + replicas: 3 + template: + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 + metadata: + labels: + app.kubernetes.io/app: example + selector: + matchLabels: + app.kubernetes.io/app: example diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/label-input.yaml b/e2e/testdata/fn-render/fnconfig-updated-in-render/label-input.yaml index 26dab6c2b8..9d870011d4 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/label-input.yaml +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/label-input.yaml @@ -1,10 +1,10 @@ -apiVersion: v1 -kind: ConfigMap -metadata: # kpt-merge: /label-input - name: label-input - annotations: - config.kubernetes.io/local-config: "true" - labels: - app.kubernetes.io/app: example -data: - app.kubernetes.io/app: example +apiVersion: v1 +kind: ConfigMap +metadata: # kpt-merge: /label-input + name: label-input + annotations: + config.kubernetes.io/local-config: "true" + labels: + app.kubernetes.io/app: example +data: + app.kubernetes.io/app: example diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/namespace.yaml b/e2e/testdata/fn-render/fnconfig-updated-in-render/namespace.yaml index 9db1da3d4d..cdcee64a35 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/namespace.yaml +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/namespace.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Namespace -metadata: # kpt-merge: /example - name: example - labels: - app.kubernetes.io/app: example -spec: {} +apiVersion: v1 +kind: Namespace +metadata: # kpt-merge: /example + name: example + labels: + app.kubernetes.io/app: example +spec: {} diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/package-context.yaml b/e2e/testdata/fn-render/fnconfig-updated-in-render/package-context.yaml index 2340959f69..46a2557ab7 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/package-context.yaml +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/package-context.yaml @@ -1,8 +1,8 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: kptfile.kpt.dev - annotations: - config.kubernetes.io/local-config: "true" -data: - name: frontend +apiVersion: v1 +kind: ConfigMap +metadata: + name: kptfile.kpt.dev + annotations: + config.kubernetes.io/local-config: "true" +data: + name: frontend diff --git a/e2e/testdata/fn-render/fnconfig-updated-in-render/update-labels.yaml b/e2e/testdata/fn-render/fnconfig-updated-in-render/update-labels.yaml index 7aae6c7381..7b659b4ba3 100644 --- a/e2e/testdata/fn-render/fnconfig-updated-in-render/update-labels.yaml +++ b/e2e/testdata/fn-render/fnconfig-updated-in-render/update-labels.yaml @@ -1,19 +1,19 @@ -apiVersion: fn.kpt.dev/v1alpha1 -kind: ApplyReplacements -metadata: # kpt-merge: /update-labels - name: update-labels - annotations: - config.kubernetes.io/local-config: "true" - labels: - app.kubernetes.io/app: example -replacements: -- source: - kind: ConfigMap - name: kptfile.kpt.dev - fieldPath: data.name - targets: - - select: - kind: ConfigMap - name: label-input - fieldPaths: - - data.[app.kubernetes.io/app] +apiVersion: fn.kpt.dev/v1alpha1 +kind: ApplyReplacements +metadata: # kpt-merge: /update-labels + name: update-labels + annotations: + config.kubernetes.io/local-config: "true" + labels: + app.kubernetes.io/app: example +replacements: +- source: + kind: ConfigMap + name: kptfile.kpt.dev + fieldPath: data.name + targets: + - select: + kind: ConfigMap + name: label-input + fieldPaths: + - data.[app.kubernetes.io/app] diff --git a/e2e/testdata/fn-render/fnconfig/.expected/diff.patch b/e2e/testdata/fn-render/fnconfig/.expected/diff.patch index c5cb4870a0..f3d7bd0c67 100644 --- a/e2e/testdata/fn-render/fnconfig/.expected/diff.patch +++ b/e2e/testdata/fn-render/fnconfig/.expected/diff.patch @@ -1,46 +1,111 @@ diff --git a/Kptfile b/Kptfile -index 043dcac..0ee2ac8 100644 +index 6579bee..9e51473 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db -+ namespace: staging +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configPath: labelconfig.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db + labels: + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configPath: labelconfig.yaml diff --git a/db/Kptfile b/db/Kptfile -index 264dd2e..8dd7c37 100644 +index 03f1b81..bf7230a 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging +@@ -1,12 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- app: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + app: backend + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ app: backend diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..e9be40c 100644 +index c9c269b..e9be40c 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,5 +15,18 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db +@@ -1,19 +1,32 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db + namespace: staging + labels: + app: backend + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + app: backend @@ -51,31 +116,104 @@ index dabe43c..e9be40c 100644 + app: backend + tier: db diff --git a/labelconfig.yaml b/labelconfig.yaml -index 22d2de2..8712cbf 100644 +index 84d2149..8712cbf 100755 --- a/labelconfig.yaml +++ b/labelconfig.yaml -@@ -15,5 +15,8 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: label-config +@@ -1,19 +1,22 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: v1 +-kind: ConfigMap +-metadata: +- name: label-config +-data: +- tier: db ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: label-config + namespace: staging + labels: + tier: db - data: - tier: db ++data: ++ tier: db diff --git a/resources.yaml b/resources.yaml -index f2eec52..8b2113d 100644 +index 9d1f786..b212081 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -83,13 +221,12 @@ index f2eec52..8b2113d 100644 + metadata: + labels: + tier: db - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: db - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fnconfig/.krmignore b/e2e/testdata/fn-render/fnconfig/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnconfig/.krmignore +++ b/e2e/testdata/fn-render/fnconfig/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnconfig/Kptfile b/e2e/testdata/fn-render/fnconfig/Kptfile index e93b78ae8f..6579bee199 100644 --- a/e2e/testdata/fn-render/fnconfig/Kptfile +++ b/e2e/testdata/fn-render/fnconfig/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig.yaml diff --git a/e2e/testdata/fn-render/fnconfig/db/Kptfile b/e2e/testdata/fn-render/fnconfig/db/Kptfile index 0c2b57a9b6..03f1b81ac9 100644 --- a/e2e/testdata/fn-render/fnconfig/db/Kptfile +++ b/e2e/testdata/fn-render/fnconfig/db/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/fnconfig/db/resources.yaml b/e2e/testdata/fn-render/fnconfig/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/fnconfig/db/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/fnconfig/labelconfig.yaml b/e2e/testdata/fn-render/fnconfig/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/fnconfig/labelconfig.yaml +++ b/e2e/testdata/fn-render/fnconfig/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/fnconfig/resources.yaml b/e2e/testdata/fn-render/fnconfig/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnconfig/resources.yaml +++ b/e2e/testdata/fn-render/fnconfig/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnresult-fn-failure/.expected/config.yaml b/e2e/testdata/fn-render/fnresult-fn-failure/.expected/config.yaml index 48e14bec9d..3ea0f398c7 100644 --- a/e2e/testdata/fn-render/fnresult-fn-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnresult-fn-failure/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 -stdErr: '[error] apps/v1/Deployment/nginx-deployment spec.replicas: got string, want null or integer' +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 +stdErr: '[error] apps/v1/Deployment/nginx-deployment spec.replicas: got string, want null or integer' diff --git a/e2e/testdata/fn-render/fnresult-fn-failure/.krmignore b/e2e/testdata/fn-render/fnresult-fn-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnresult-fn-failure/.krmignore +++ b/e2e/testdata/fn-render/fnresult-fn-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnresult-fn-failure/Kptfile b/e2e/testdata/fn-render/fnresult-fn-failure/Kptfile index 0586af999b..ce3de86f8b 100644 --- a/e2e/testdata/fn-render/fnresult-fn-failure/Kptfile +++ b/e2e/testdata/fn-render/fnresult-fn-failure/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest - configMap: - strict: "true" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest + configMap: + strict: "true" diff --git a/e2e/testdata/fn-render/fnresult-fn-failure/resources.yaml b/e2e/testdata/fn-render/fnresult-fn-failure/resources.yaml index 81bd9975d7..afc54ce286 100644 --- a/e2e/testdata/fn-render/fnresult-fn-failure/resources.yaml +++ b/e2e/testdata/fn-render/fnresult-fn-failure/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: invalid ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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: invalid +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/fnresult-fn-success/.expected/config.yaml b/e2e/testdata/fn-render/fnresult-fn-success/.expected/config.yaml index 8618a74890..74d2c1e51c 100644 --- a/e2e/testdata/fn-render/fnresult-fn-success/.expected/config.yaml +++ b/e2e/testdata/fn-render/fnresult-fn-success/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 0 -stdErr: | +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 0 +stdErr: | [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/search-replace:latest" \ No newline at end of file diff --git a/e2e/testdata/fn-render/fnresult-fn-success/.expected/diff.patch b/e2e/testdata/fn-render/fnresult-fn-success/.expected/diff.patch index 685cb16e8d..19eb536ec8 100644 --- a/e2e/testdata/fn-render/fnresult-fn-success/.expected/diff.patch +++ b/e2e/testdata/fn-render/fnresult-fn-success/.expected/diff.patch @@ -1,13 +1,125 @@ +diff --git a/Kptfile b/Kptfile +index cb38e78..3c63ab9 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest +- configPath: search-replace-conf.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest ++ configPath: search-replace-conf.yaml diff --git a/resources.yaml b/resources.yaml -index f2eec52..114819d 100644 +index 9d1f786..114819d 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -16,7 +16,7 @@ kind: Deployment - metadata: - name: nginx-deployment - spec: -- replicas: 3 +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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: 4 - --- - apiVersion: custom.io/v1 - kind: Custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++spec: ++ image: nginx:1.2.3 +diff --git a/search-replace-conf.yaml b/search-replace-conf.yaml +index bb4ed4a..a3c4ee1 100755 +--- a/search-replace-conf.yaml ++++ b/search-replace-conf.yaml +@@ -1,21 +1,21 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: v1 +-kind: ConfigMap +-metadata: +- name: search-replace-fn-config +-data: +- by-path: spec.replicas +- by-value: "3" +- put-value: "4" ++# Copyright 2021 The kpt Authors ++# ++# 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: v1 ++kind: ConfigMap ++metadata: ++ name: search-replace-fn-config ++data: ++ by-path: spec.replicas ++ by-value: "3" ++ put-value: "4" diff --git a/e2e/testdata/fn-render/fnresult-fn-success/.krmignore b/e2e/testdata/fn-render/fnresult-fn-success/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/fnresult-fn-success/.krmignore +++ b/e2e/testdata/fn-render/fnresult-fn-success/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/fnresult-fn-success/Kptfile b/e2e/testdata/fn-render/fnresult-fn-success/Kptfile index 3c63ab9eaf..cb38e78f20 100644 --- a/e2e/testdata/fn-render/fnresult-fn-success/Kptfile +++ b/e2e/testdata/fn-render/fnresult-fn-success/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest - configPath: search-replace-conf.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/search-replace:latest + configPath: search-replace-conf.yaml diff --git a/e2e/testdata/fn-render/fnresult-fn-success/resources.yaml b/e2e/testdata/fn-render/fnresult-fn-success/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/fnresult-fn-success/resources.yaml +++ b/e2e/testdata/fn-render/fnresult-fn-success/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/fnresult-fn-success/search-replace-conf.yaml b/e2e/testdata/fn-render/fnresult-fn-success/search-replace-conf.yaml index a3c4ee1681..bb4ed4a215 100644 --- a/e2e/testdata/fn-render/fnresult-fn-success/search-replace-conf.yaml +++ b/e2e/testdata/fn-render/fnresult-fn-success/search-replace-conf.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: search-replace-fn-config -data: - by-path: spec.replicas - by-value: "3" - put-value: "4" +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: search-replace-fn-config +data: + by-path: spec.replicas + by-value: "3" + put-value: "4" diff --git a/e2e/testdata/fn-render/format-on-success/.expected/diff.patch b/e2e/testdata/fn-render/format-on-success/.expected/diff.patch index aedf8745b7..fa9e75771d 100644 --- a/e2e/testdata/fn-render/format-on-success/.expected/diff.patch +++ b/e2e/testdata/fn-render/format-on-success/.expected/diff.patch @@ -1,47 +1,160 @@ diff --git a/Kptfile b/Kptfile -index dbab15c..a37d10e 100644 +index d4b3127..8d8916e 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +@@ -1,9 +1,9 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging diff --git a/db/Kptfile b/db/Kptfile -index 92bb0fc..31aafaa 100644 +index aee9666..5953cfa 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 +@@ -1,9 +1,9 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..b44084a 100644 +index c9c269b..b44084a 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,5 +15,6 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db +@@ -1,19 +1,20 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db + namespace: staging - spec: - replicas: 3 ++spec: ++ replicas: 3 diff --git a/resources.yaml b/resources.yaml -index f32ed5c..9260c99 100644 +index 5716ad3..9260c99 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,32 +1,33 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +- selector: +- matchLabels: +- app: nginx +- template: +- metadata: +- labels: +- app: nginx +- spec: +- containers: +- - name: nginx +- image: nginx:1.14.2 +- ports: +- - containerPort: 80 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging - spec: - replicas: 3 - selector: ++spec: ++ replicas: 3 ++ selector: ++ matchLabels: ++ app: nginx ++ template: ++ metadata: ++ labels: ++ app: nginx ++ spec: ++ containers: ++ - name: nginx ++ image: nginx:1.14.2 ++ ports: ++ - containerPort: 80 diff --git a/e2e/testdata/fn-render/format-on-success/.krmignore b/e2e/testdata/fn-render/format-on-success/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/format-on-success/.krmignore +++ b/e2e/testdata/fn-render/format-on-success/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/format-on-success/Kptfile b/e2e/testdata/fn-render/format-on-success/Kptfile index 8d8916eff3..d4b312741b 100644 --- a/e2e/testdata/fn-render/format-on-success/Kptfile +++ b/e2e/testdata/fn-render/format-on-success/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/format-on-success/db/Kptfile b/e2e/testdata/fn-render/format-on-success/db/Kptfile index 5953cfadf1..aee9666d6c 100644 --- a/e2e/testdata/fn-render/format-on-success/db/Kptfile +++ b/e2e/testdata/fn-render/format-on-success/db/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db diff --git a/e2e/testdata/fn-render/format-on-success/db/resources.yaml b/e2e/testdata/fn-render/format-on-success/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/format-on-success/db/resources.yaml +++ b/e2e/testdata/fn-render/format-on-success/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/format-on-success/resources.yaml b/e2e/testdata/fn-render/format-on-success/resources.yaml index f32ed5ce8b..5716ad3040 100644 --- a/e2e/testdata/fn-render/format-on-success/resources.yaml +++ b/e2e/testdata/fn-render/format-on-success/resources.yaml @@ -1,32 +1,32 @@ -# Copyright 2021 The kpt Authors -# -# 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 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: - - containerPort: 80 +# Copyright 2021 The kpt Authors +# +# 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 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 diff --git a/e2e/testdata/fn-render/generator-absolute-path/.expected/diff.patch b/e2e/testdata/fn-render/generator-absolute-path/.expected/diff.patch index 1c94a808e6..c7178bdb5c 100644 --- a/e2e/testdata/fn-render/generator-absolute-path/.expected/diff.patch +++ b/e2e/testdata/fn-render/generator-absolute-path/.expected/diff.patch @@ -1,3 +1,24 @@ +diff --git a/Kptfile b/Kptfile +index ab9d7ec..714d078 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin.yaml diff --git a/another/file/out.yaml b/another/file/out.yaml new file mode 100644 index 0000000..f36c98e @@ -17,3 +38,171 @@ index 0000000..f36c98e + name: httpbin + ports: + - containerPort: 9876 +diff --git a/resources.yaml b/resources.yaml +index c9c269b..dabe43c 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,19 +1,19 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db ++spec: ++ replicas: 3 +diff --git a/starlark-httpbin.yaml b/starlark-httpbin.yaml +index 3fdc99b..a7b393f 100755 +--- a/starlark-httpbin.yaml ++++ b/starlark-httpbin.yaml +@@ -1,60 +1,60 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- "annotations": { +- "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 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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: |- ++ httpbin_deployment = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ "annotations": { ++ "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 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment) ++ ++ ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/generator-absolute-path/.krmignore b/e2e/testdata/fn-render/generator-absolute-path/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/generator-absolute-path/.krmignore +++ b/e2e/testdata/fn-render/generator-absolute-path/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/generator-absolute-path/Kptfile b/e2e/testdata/fn-render/generator-absolute-path/Kptfile index 714d078787..ab9d7ec858 100644 --- a/e2e/testdata/fn-render/generator-absolute-path/Kptfile +++ b/e2e/testdata/fn-render/generator-absolute-path/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml diff --git a/e2e/testdata/fn-render/generator-absolute-path/resources.yaml b/e2e/testdata/fn-render/generator-absolute-path/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/generator-absolute-path/resources.yaml +++ b/e2e/testdata/fn-render/generator-absolute-path/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/generator-absolute-path/starlark-httpbin.yaml b/e2e/testdata/fn-render/generator-absolute-path/starlark-httpbin.yaml index a7b393f3bc..3fdc99b33e 100644 --- a/e2e/testdata/fn-render/generator-absolute-path/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/generator-absolute-path/starlark-httpbin.yaml @@ -1,60 +1,60 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - "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 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + "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 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/generator-subpkgs/.krmignore b/e2e/testdata/fn-render/generator-subpkgs/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/.krmignore +++ b/e2e/testdata/fn-render/generator-subpkgs/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/generator-subpkgs/Kptfile b/e2e/testdata/fn-render/generator-subpkgs/Kptfile index 46ab689079..61a087d8ce 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/Kptfile +++ b/e2e/testdata/fn-render/generator-subpkgs/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/upsert-resource:latest - configPath: fn-config.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/upsert-resource:latest + configPath: fn-config.yaml diff --git a/e2e/testdata/fn-render/generator-subpkgs/db/Kptfile b/e2e/testdata/fn-render/generator-subpkgs/db/Kptfile index 8de052f5b5..4e81f9b7bb 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/db/Kptfile +++ b/e2e/testdata/fn-render/generator-subpkgs/db/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/upsert-resource:latest - configPath: fn-config.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/upsert-resource:latest + configPath: fn-config.yaml diff --git a/e2e/testdata/fn-render/generator-subpkgs/db/fn-config.yaml b/e2e/testdata/fn-render/generator-subpkgs/db/fn-config.yaml index 7a0f3af097..c510fc4418 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/db/fn-config.yaml +++ b/e2e/testdata/fn-render/generator-subpkgs/db/fn-config.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: db-map -data: - db-key: db-value +apiVersion: v1 +kind: ConfigMap +metadata: + name: db-map +data: + db-key: db-value diff --git a/e2e/testdata/fn-render/generator-subpkgs/db/resources.yaml b/e2e/testdata/fn-render/generator-subpkgs/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/db/resources.yaml +++ b/e2e/testdata/fn-render/generator-subpkgs/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/generator-subpkgs/fn-config.yaml b/e2e/testdata/fn-render/generator-subpkgs/fn-config.yaml index fd1e17d77a..d9db4a92a0 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/fn-config.yaml +++ b/e2e/testdata/fn-render/generator-subpkgs/fn-config.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: parent-map - namespace: def -data: - parent-key: parent-value +apiVersion: v1 +kind: ConfigMap +metadata: + name: parent-map + namespace: def +data: + parent-key: parent-value diff --git a/e2e/testdata/fn-render/generator-subpkgs/resources.yaml b/e2e/testdata/fn-render/generator-subpkgs/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/generator-subpkgs/resources.yaml +++ b/e2e/testdata/fn-render/generator-subpkgs/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/generator/.expected/diff.patch b/e2e/testdata/fn-render/generator/.expected/diff.patch index 1151fe3a2d..98191bcfef 100644 --- a/e2e/testdata/fn-render/generator/.expected/diff.patch +++ b/e2e/testdata/fn-render/generator/.expected/diff.patch @@ -1,32 +1,70 @@ diff --git a/Kptfile b/Kptfile -index 8050168..cb7293f 100644 +index 8d8550f..f683388 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-generator -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-generator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: db ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-generator + labels: + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: db diff --git a/db/Kptfile b/db/Kptfile -index 3091f75..b290407 100644 +index 9a98864..21da9a4 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging +@@ -1,14 +1,17 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- app: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + app: backend + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ app: backend diff --git a/db/deployment_httpbin.yaml b/db/deployment_httpbin.yaml new file mode 100644 index 0000000..ffdf484 @@ -59,19 +97,52 @@ index 0000000..ffdf484 + app: backend + tier: db diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..e9be40c 100644 +index c9c269b..e9be40c 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,5 +15,18 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db +@@ -1,19 +1,32 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db + namespace: staging + labels: + app: backend + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + app: backend @@ -82,33 +153,176 @@ index dabe43c..e9be40c 100644 + app: backend + tier: db diff --git a/db/starlark-httpbin.yaml b/db/starlark-httpbin.yaml -index e52e48f..d21601e 100644 +index 07a7784..7aad15e 100755 --- a/db/starlark-httpbin.yaml +++ b/db/starlark-httpbin.yaml -@@ -15,6 +15,10 @@ apiVersion: fn.kpt.dev/v1alpha1 - kind: StarlarkRun - metadata: - name: httpbin-gen -+ namespace: staging +@@ -1,55 +1,58 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- }, +- "spec": { +- "replicas": 4, +- "template": { +- "spec": { +- "containers": [ +- { +- "name": "httpbin", +- "image": "kennethreitz/httpbin", +- "ports": [ +- { +- "containerPort": 9876 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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 + labels: + app: backend + tier: db - source: |- - httpbin_deployment = { - "apiVersion": "apps/v1", ++source: |- ++ httpbin_deployment = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ }, ++ "spec": { ++ "replicas": 4, ++ "template": { ++ "spec": { ++ "containers": [ ++ { ++ "name": "httpbin", ++ "image": "kennethreitz/httpbin", ++ "ports": [ ++ { ++ "containerPort": 9876 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment) ++ ++ ensure_httpbin(ctx.resource_list["items"]) diff --git a/resources.yaml b/resources.yaml -index f2eec52..8b2113d 100644 +index 9d1f786..b212081 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -116,13 +330,12 @@ index f2eec52..8b2113d 100644 + metadata: + labels: + tier: db - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: db - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/generator/.krmignore b/e2e/testdata/fn-render/generator/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/generator/.krmignore +++ b/e2e/testdata/fn-render/generator/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/generator/Kptfile b/e2e/testdata/fn-render/generator/Kptfile index bf73fbddf4..8d8550f50c 100644 --- a/e2e/testdata/fn-render/generator/Kptfile +++ b/e2e/testdata/fn-render/generator/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: db diff --git a/e2e/testdata/fn-render/generator/db/Kptfile b/e2e/testdata/fn-render/generator/db/Kptfile index d589972c67..9a9886458d 100644 --- a/e2e/testdata/fn-render/generator/db/Kptfile +++ b/e2e/testdata/fn-render/generator/db/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/generator/db/resources.yaml b/e2e/testdata/fn-render/generator/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/generator/db/resources.yaml +++ b/e2e/testdata/fn-render/generator/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/generator/db/starlark-httpbin.yaml b/e2e/testdata/fn-render/generator/db/starlark-httpbin.yaml index e52e48f94d..07a7784900 100644 --- a/e2e/testdata/fn-render/generator/db/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/generator/db/starlark-httpbin.yaml @@ -1,55 +1,55 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/generator/resources.yaml b/e2e/testdata/fn-render/generator/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/generator/resources.yaml +++ b/e2e/testdata/fn-render/generator/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/image-pull-policy-always/.expected/config.yaml b/e2e/testdata/fn-render/image-pull-policy-always/.expected/config.yaml index c5d14b88db..2c7b32d56c 100644 --- a/e2e/testdata/fn-render/image-pull-policy-always/.expected/config.yaml +++ b/e2e/testdata/fn-render/image-pull-policy-always/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -imagePullPolicy: Always -sequential: true -exitCode: 1 -stdErr: foo +# Copyright 2021 The kpt Authors +# +# 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. + +imagePullPolicy: Always +sequential: true +exitCode: 1 +stdErr: foo diff --git a/e2e/testdata/fn-render/image-pull-policy-always/.expected/setup.sh b/e2e/testdata/fn-render/image-pull-policy-always/.expected/setup.sh index 4d3f77f4f6..9c11e1b2a3 100755 --- a/e2e/testdata/fn-render/image-pull-policy-always/.expected/setup.sh +++ b/e2e/testdata/fn-render/image-pull-policy-always/.expected/setup.sh @@ -1,25 +1,25 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" - -# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and -# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. -# We intentionally tag a wrong image as ghcr.io/kptdev/krm-functions-catalog/foo:v0.1, since we -# expect the correct image to be pulled and override the wrong image. -${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 -${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" + +# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and +# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. +# We intentionally tag a wrong image as ghcr.io/kptdev/krm-functions-catalog/foo:v0.1, since we +# expect the correct image to be pulled and override the wrong image. +${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 diff --git a/e2e/testdata/fn-render/image-pull-policy-always/.krmignore b/e2e/testdata/fn-render/image-pull-policy-always/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/image-pull-policy-always/.krmignore +++ b/e2e/testdata/fn-render/image-pull-policy-always/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/image-pull-policy-always/Kptfile b/e2e/testdata/fn-render/image-pull-policy-always/Kptfile index 3f7b3371ad..577f0aa392 100644 --- a/e2e/testdata/fn-render/image-pull-policy-always/Kptfile +++ b/e2e/testdata/fn-render/image-pull-policy-always/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 diff --git a/e2e/testdata/fn-render/image-pull-policy-always/resources.yaml b/e2e/testdata/fn-render/image-pull-policy-always/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/image-pull-policy-always/resources.yaml +++ b/e2e/testdata/fn-render/image-pull-policy-always/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/config.yaml b/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/config.yaml index b24a5b7f60..46fd0c103b 100644 --- a/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/config.yaml +++ b/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -imagePullPolicy: IfNotPresent -sequential: true -exitCode: 1 -stdErr: foo +# Copyright 2021 The kpt Authors +# +# 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. + +imagePullPolicy: IfNotPresent +sequential: true +exitCode: 1 +stdErr: foo diff --git a/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/setup.sh b/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/setup.sh index c1aeb03f12..7e65f24a80 100755 --- a/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/setup.sh +++ b/e2e/testdata/fn-render/image-pull-policy-if-not-present/.expected/setup.sh @@ -1,24 +1,24 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" - -# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and -# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. -# We intentionally tag a wrong image as pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 -${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 -${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +KRM_FN_RUNTIME="${KRM_FN_RUNTIME:=docker}" + +# Function ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 prints "foo" to stderr and +# function ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 prints "bar" to stderr. +# We intentionally tag a wrong image as pull ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 +${KRM_FN_RUNTIME} pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +${KRM_FN_RUNTIME} tag ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 ghcr.io/kptdev/krm-functions-catalog/bar:v0.1 diff --git a/e2e/testdata/fn-render/image-pull-policy-if-not-present/.krmignore b/e2e/testdata/fn-render/image-pull-policy-if-not-present/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/image-pull-policy-if-not-present/.krmignore +++ b/e2e/testdata/fn-render/image-pull-policy-if-not-present/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/image-pull-policy-if-not-present/Kptfile b/e2e/testdata/fn-render/image-pull-policy-if-not-present/Kptfile index 3f7b3371ad..577f0aa392 100644 --- a/e2e/testdata/fn-render/image-pull-policy-if-not-present/Kptfile +++ b/e2e/testdata/fn-render/image-pull-policy-if-not-present/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: pull ghcr.io/kptdev/krm-functions-catalog/foo:v0.1 diff --git a/e2e/testdata/fn-render/image-pull-policy-if-not-present/resources.yaml b/e2e/testdata/fn-render/image-pull-policy-if-not-present/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/image-pull-policy-if-not-present/resources.yaml +++ b/e2e/testdata/fn-render/image-pull-policy-if-not-present/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/image-pull-policy-never/.expected/config.yaml b/e2e/testdata/fn-render/image-pull-policy-never/.expected/config.yaml index 7c5b5cc8d5..9eb4b59a18 100644 --- a/e2e/testdata/fn-render/image-pull-policy-never/.expected/config.yaml +++ b/e2e/testdata/fn-render/image-pull-policy-never/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -imagePullPolicy: Never -exitCode: 1 -# The output in stderr is different depending on the runtime. -# "No such image" is from docker and "image not known" is from podman. -stdErrRegEx: No such image|image not known +# Copyright 2021 The kpt Authors +# +# 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. + +imagePullPolicy: Never +exitCode: 1 +# The output in stderr is different depending on the runtime. +# "No such image" is from docker and "image not known" is from podman. +stdErrRegEx: No such image|image not known diff --git a/e2e/testdata/fn-render/image-pull-policy-never/.krmignore b/e2e/testdata/fn-render/image-pull-policy-never/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/image-pull-policy-never/.krmignore +++ b/e2e/testdata/fn-render/image-pull-policy-never/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/image-pull-policy-never/Kptfile b/e2e/testdata/fn-render/image-pull-policy-never/Kptfile index 5b7fc74f56..2f5bd1b1c8 100644 --- a/e2e/testdata/fn-render/image-pull-policy-never/Kptfile +++ b/e2e/testdata/fn-render/image-pull-policy-never/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/not-exist:latest +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/not-exist:latest diff --git a/e2e/testdata/fn-render/image-pull-policy-never/resources.yaml b/e2e/testdata/fn-render/image-pull-policy-never/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/image-pull-policy-never/resources.yaml +++ b/e2e/testdata/fn-render/image-pull-policy-never/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/invalid-configmap-fnconfig/.expected/config.yaml b/e2e/testdata/fn-render/invalid-configmap-fnconfig/.expected/config.yaml index beba97e939..b0b58ee591 100644 --- a/e2e/testdata/fn-render/invalid-configmap-fnconfig/.expected/config.yaml +++ b/e2e/testdata/fn-render/invalid-configmap-fnconfig/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "line 14: cannot unmarshal !!seq into string" \ No newline at end of file diff --git a/e2e/testdata/fn-render/invalid-configmap-fnconfig/.krmignore b/e2e/testdata/fn-render/invalid-configmap-fnconfig/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/invalid-configmap-fnconfig/.krmignore +++ b/e2e/testdata/fn-render/invalid-configmap-fnconfig/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile b/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile index 64a434f0a7..22a27686db 100644 --- a/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/invalid-configmap-fnconfig/Kptfile @@ -1,16 +1,16 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: # invalid config - tier: backend - envs: # lists are not allowed in configmap - - dev - - staging - - production +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: # invalid config + tier: backend + envs: # lists are not allowed in configmap + - dev + - staging + - production diff --git a/e2e/testdata/fn-render/invalid-configmap-fnconfig/resources.yaml b/e2e/testdata/fn-render/invalid-configmap-fnconfig/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/invalid-configmap-fnconfig/resources.yaml +++ b/e2e/testdata/fn-render/invalid-configmap-fnconfig/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile b/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile index 84c025e495..d85447f909 100644 --- a/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/invalid-inline-fnconfig/Kptfile @@ -1,16 +1,16 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - config: # invalid inline config, missing apiVersion/kind - envs: - - dev - - staging - - production - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + config: # invalid inline config, missing apiVersion/kind + envs: + - dev + - staging + - production + tier: backend diff --git a/e2e/testdata/fn-render/invalid-kptfile/.expected/config.yaml b/e2e/testdata/fn-render/invalid-kptfile/.expected/config.yaml index 080e88af05..91d35aebe2 100644 --- a/e2e/testdata/fn-render/invalid-kptfile/.expected/config.yaml +++ b/e2e/testdata/fn-render/invalid-kptfile/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "can't be read.\n\nDetails:\nyaml: line 3: could not find expected ':'" \ No newline at end of file diff --git a/e2e/testdata/fn-render/invalid-kptfile/.krmignore b/e2e/testdata/fn-render/invalid-kptfile/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/invalid-kptfile/.krmignore +++ b/e2e/testdata/fn-render/invalid-kptfile/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/invalid-kptfile/Kptfile b/e2e/testdata/fn-render/invalid-kptfile/Kptfile index c8a8f89975..9299b3ed9a 100644 --- a/e2e/testdata/fn-render/invalid-kptfile/Kptfile +++ b/e2e/testdata/fn-render/invalid-kptfile/Kptfile @@ -1,4 +1,4 @@ -# Invalid Kptfile -apiVersion: kpt.dev/v1 -kslsls -;s;s;s +# Invalid Kptfile +apiVersion: kpt.dev/v1 +kslsls +;s;s;s diff --git a/e2e/testdata/fn-render/invalid-kptfile/resources.yaml b/e2e/testdata/fn-render/invalid-kptfile/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/invalid-kptfile/resources.yaml +++ b/e2e/testdata/fn-render/invalid-kptfile/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/kptfile-unknown-fields/.expected/config.yaml b/e2e/testdata/fn-render/kptfile-unknown-fields/.expected/config.yaml index 7f7b1d86f9..0066f7f872 100644 --- a/e2e/testdata/fn-render/kptfile-unknown-fields/.expected/config.yaml +++ b/e2e/testdata/fn-render/kptfile-unknown-fields/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 -stdErr: | - yaml: unmarshal errors: +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 +stdErr: | + yaml: unmarshal errors: line 13: field targetResources not found in type v1.Function \ No newline at end of file diff --git a/e2e/testdata/fn-render/kptfile-unknown-fields/.krmignore b/e2e/testdata/fn-render/kptfile-unknown-fields/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/kptfile-unknown-fields/.krmignore +++ b/e2e/testdata/fn-render/kptfile-unknown-fields/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile b/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile index b9113a16e9..75441e031f 100644 --- a/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile +++ b/e2e/testdata/fn-render/kptfile-unknown-fields/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend - targetResources: # unknown field - - kind: Deployment +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend + targetResources: # unknown field + - kind: Deployment diff --git a/e2e/testdata/fn-render/kptfile-unknown-fields/resources.yaml b/e2e/testdata/fn-render/kptfile-unknown-fields/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/kptfile-unknown-fields/resources.yaml +++ b/e2e/testdata/fn-render/kptfile-unknown-fields/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/krm-check-exclude-kustomize/.expected/diff.patch b/e2e/testdata/fn-render/krm-check-exclude-kustomize/.expected/diff.patch index d851cb49cd..f5bd56503f 100644 --- a/e2e/testdata/fn-render/krm-check-exclude-kustomize/.expected/diff.patch +++ b/e2e/testdata/fn-render/krm-check-exclude-kustomize/.expected/diff.patch @@ -1,43 +1,121 @@ diff --git a/Kptfile b/Kptfile -index 2985a1a..3dfdcf6 100644 +index a75ee2b..3dfdcf6 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app +@@ -1,9 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/kustomization.yaml b/kustomization.yaml -index f3f0207..6c517af 100644 +index f4af88c..6c517af 100755 --- a/kustomization.yaml +++ b/kustomization.yaml -@@ -11,7 +11,9 @@ - # 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. -- - # kustomization.yaml contents - resources: - - resources.yaml +@@ -1,17 +1,19 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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. +- +-# kustomization.yaml contents +-resources: +-- resources.yaml ++# Copyright 2021 The kpt Authors ++# ++# 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. ++# kustomization.yaml contents ++resources: ++- resources.yaml +metadata: + labels: + tier: backend diff --git a/resources.yaml b/resources.yaml -index 40a033d..eb585ba 100644 +index cc403eb..eb585ba 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,23 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,37 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 # kpt-set: {something} ++# Copyright 2021 The kpt Authors ++# ++# 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 + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -45,12 +123,12 @@ index 40a033d..eb585ba 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 # kpt-set: {something} ++spec: ++ image: nginx:1.2.3 # kpt-set: {something} diff --git a/e2e/testdata/fn-render/krm-check-exclude-kustomize/Kptfile b/e2e/testdata/fn-render/krm-check-exclude-kustomize/Kptfile index 2985a1af95..a75ee2b0d9 100644 --- a/e2e/testdata/fn-render/krm-check-exclude-kustomize/Kptfile +++ b/e2e/testdata/fn-render/krm-check-exclude-kustomize/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/krm-check-exclude-kustomize/kustomization.yaml b/e2e/testdata/fn-render/krm-check-exclude-kustomize/kustomization.yaml index f3f0207b7c..f4af88c33a 100644 --- a/e2e/testdata/fn-render/krm-check-exclude-kustomize/kustomization.yaml +++ b/e2e/testdata/fn-render/krm-check-exclude-kustomize/kustomization.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# kustomization.yaml contents -resources: -- resources.yaml +# Copyright 2021 The kpt Authors +# +# 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. + +# kustomization.yaml contents +resources: +- resources.yaml diff --git a/e2e/testdata/fn-render/krm-check-exclude-kustomize/resources.yaml b/e2e/testdata/fn-render/krm-check-exclude-kustomize/resources.yaml index 40a033d97a..cc403eb351 100644 --- a/e2e/testdata/fn-render/krm-check-exclude-kustomize/resources.yaml +++ b/e2e/testdata/fn-render/krm-check-exclude-kustomize/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 # kpt-set: {something} +# Copyright 2021 The kpt Authors +# +# 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 # kpt-set: {something} diff --git a/e2e/testdata/fn-render/krmignore/.krmignore b/e2e/testdata/fn-render/krmignore/.krmignore index c9ef99edd1..dac7f0e301 100644 --- a/e2e/testdata/fn-render/krmignore/.krmignore +++ b/e2e/testdata/fn-render/krmignore/.krmignore @@ -1,2 +1,2 @@ -resources.yaml -.expected +resources.yaml +.expected diff --git a/e2e/testdata/fn-render/krmignore/Kptfile b/e2e/testdata/fn-render/krmignore/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/krmignore/Kptfile +++ b/e2e/testdata/fn-render/krmignore/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/krmignore/resources.yaml b/e2e/testdata/fn-render/krmignore/resources.yaml index c1e00cb252..dde3a069c3 100644 --- a/e2e/testdata/fn-render/krmignore/resources.yaml +++ b/e2e/testdata/fn-render/krmignore/resources.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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 -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/kubeval-failure/.expected/config.yaml b/e2e/testdata/fn-render/kubeval-failure/.expected/config.yaml index 158679c8e9..38a841f34c 100644 --- a/e2e/testdata/fn-render/kubeval-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/kubeval-failure/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 diff --git a/e2e/testdata/fn-render/kubeval-failure/.krmignore b/e2e/testdata/fn-render/kubeval-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/kubeval-failure/.krmignore +++ b/e2e/testdata/fn-render/kubeval-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/kubeval-failure/Kptfile b/e2e/testdata/fn-render/kubeval-failure/Kptfile index 2c6e9657b2..fd327586db 100644 --- a/e2e/testdata/fn-render/kubeval-failure/Kptfile +++ b/e2e/testdata/fn-render/kubeval-failure/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest - configMap: - strict: "true" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest + configMap: + strict: "true" diff --git a/e2e/testdata/fn-render/kubeval-failure/resources.yaml b/e2e/testdata/fn-render/kubeval-failure/resources.yaml index 81bd9975d7..afc54ce286 100644 --- a/e2e/testdata/fn-render/kubeval-failure/resources.yaml +++ b/e2e/testdata/fn-render/kubeval-failure/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: invalid ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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: invalid +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/missing-fn-image/.expected/config.yaml b/e2e/testdata/fn-render/missing-fn-image/.expected/config.yaml index faaa67e0e4..01481e94b2 100644 --- a/e2e/testdata/fn-render/missing-fn-image/.expected/config.yaml +++ b/e2e/testdata/fn-render/missing-fn-image/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/missing-fn-image/.krmignore b/e2e/testdata/fn-render/missing-fn-image/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/missing-fn-image/.krmignore +++ b/e2e/testdata/fn-render/missing-fn-image/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/missing-fn-image/Kptfile b/e2e/testdata/fn-render/missing-fn-image/Kptfile index e60b7a42e2..9f42b072d3 100644 --- a/e2e/testdata/fn-render/missing-fn-image/Kptfile +++ b/e2e/testdata/fn-render/missing-fn-image/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/dne # non-existing image - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/dne # non-existing image + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/missing-fn-image/resources.yaml b/e2e/testdata/fn-render/missing-fn-image/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/missing-fn-image/resources.yaml +++ b/e2e/testdata/fn-render/missing-fn-image/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/missing-fnconfig/.expected/config.yaml b/e2e/testdata/fn-render/missing-fnconfig/.expected/config.yaml index b0147d9a2f..8f5fba78b2 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/.expected/config.yaml +++ b/e2e/testdata/fn-render/missing-fnconfig/.expected/config.yaml @@ -1,20 +1,20 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | - Kptfile is invalid: - Field: `pipeline.mutators[1].configPath` - Value: "labelconfig1.yaml" - Reason: functionConfig must exist in the current package +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | + Kptfile is invalid: + Field: `pipeline.mutators[1].configPath` + Value: "labelconfig1.yaml" + Reason: functionConfig must exist in the current package diff --git a/e2e/testdata/fn-render/missing-fnconfig/.krmignore b/e2e/testdata/fn-render/missing-fnconfig/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/.krmignore +++ b/e2e/testdata/fn-render/missing-fnconfig/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/missing-fnconfig/Kptfile b/e2e/testdata/fn-render/missing-fnconfig/Kptfile index b5d6abecb5..355609bf21 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/missing-fnconfig/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configPath: labelconfig1.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configPath: labelconfig1.yaml diff --git a/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile b/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile index 0c2b57a9b6..03f1b81ac9 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile +++ b/e2e/testdata/fn-render/missing-fnconfig/db/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/missing-fnconfig/db/resources.yaml b/e2e/testdata/fn-render/missing-fnconfig/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/db/resources.yaml +++ b/e2e/testdata/fn-render/missing-fnconfig/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/missing-fnconfig/labelconfig.yaml b/e2e/testdata/fn-render/missing-fnconfig/labelconfig.yaml index 22d2de2faf..84d2149832 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/labelconfig.yaml +++ b/e2e/testdata/fn-render/missing-fnconfig/labelconfig.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: label-config -data: - tier: db +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: label-config +data: + tier: db diff --git a/e2e/testdata/fn-render/missing-fnconfig/resources.yaml b/e2e/testdata/fn-render/missing-fnconfig/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/missing-fnconfig/resources.yaml +++ b/e2e/testdata/fn-render/missing-fnconfig/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/missing-kptfile/.expected/config.yaml b/e2e/testdata/fn-render/missing-kptfile/.expected/config.yaml index 79e03ef201..02e3e9571a 100644 --- a/e2e/testdata/fn-render/missing-kptfile/.expected/config.yaml +++ b/e2e/testdata/fn-render/missing-kptfile/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "No Kptfile found at" \ No newline at end of file diff --git a/e2e/testdata/fn-render/missing-kptfile/.krmignore b/e2e/testdata/fn-render/missing-kptfile/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/missing-kptfile/.krmignore +++ b/e2e/testdata/fn-render/missing-kptfile/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/missing-kptfile/resources.yaml b/e2e/testdata/fn-render/missing-kptfile/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/missing-kptfile/resources.yaml +++ b/e2e/testdata/fn-render/missing-kptfile/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/modify-legacy-path-annotation/.expected/diff.patch b/e2e/testdata/fn-render/modify-legacy-path-annotation/.expected/diff.patch index 6157962658..a3a1da6c8f 100644 --- a/e2e/testdata/fn-render/modify-legacy-path-annotation/.expected/diff.patch +++ b/e2e/testdata/fn-render/modify-legacy-path-annotation/.expected/diff.patch @@ -1,4 +1,118 @@ +diff --git a/Kptfile b/Kptfile +index b83e710..5d377d4 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-fn.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-fn.yaml diff --git a/deployment.yaml b/newfilename.yaml -similarity index 100% +old mode 100755 +new mode 100644 +similarity index 97% rename from deployment.yaml -rename to newfilename.yaml \ No newline at end of file +rename to newfilename.yaml +index 027731c..239f0d6 +--- a/deployment.yaml ++++ b/newfilename.yaml +@@ -1,19 +1,19 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 +diff --git a/starlark-fn.yaml b/starlark-fn.yaml +index cb573e5..6be484f 100755 +--- a/starlark-fn.yaml ++++ b/starlark-fn.yaml +@@ -1,22 +1,22 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: update-path +-source: | +- for r in ctx.resource_list["items"]: +- if r["kind"] == "Deployment": +- r["metadata"]["annotations"]["config.kubernetes.io/path"] = "newfilename.yaml" ++# Copyright 2021 The kpt Authors ++# ++# 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: update-path ++source: | ++ for r in ctx.resource_list["items"]: ++ if r["kind"] == "Deployment": ++ r["metadata"]["annotations"]["config.kubernetes.io/path"] = "newfilename.yaml" diff --git a/e2e/testdata/fn-render/modify-legacy-path-annotation/.krmignore b/e2e/testdata/fn-render/modify-legacy-path-annotation/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/modify-legacy-path-annotation/.krmignore +++ b/e2e/testdata/fn-render/modify-legacy-path-annotation/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/modify-legacy-path-annotation/Kptfile b/e2e/testdata/fn-render/modify-legacy-path-annotation/Kptfile index 5d377d4bf4..b83e710b99 100644 --- a/e2e/testdata/fn-render/modify-legacy-path-annotation/Kptfile +++ b/e2e/testdata/fn-render/modify-legacy-path-annotation/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-fn.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-fn.yaml diff --git a/e2e/testdata/fn-render/modify-legacy-path-annotation/deployment.yaml b/e2e/testdata/fn-render/modify-legacy-path-annotation/deployment.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/modify-legacy-path-annotation/deployment.yaml +++ b/e2e/testdata/fn-render/modify-legacy-path-annotation/deployment.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/modify-legacy-path-annotation/starlark-fn.yaml b/e2e/testdata/fn-render/modify-legacy-path-annotation/starlark-fn.yaml index 6be484f8dd..cb573e5f95 100644 --- a/e2e/testdata/fn-render/modify-legacy-path-annotation/starlark-fn.yaml +++ b/e2e/testdata/fn-render/modify-legacy-path-annotation/starlark-fn.yaml @@ -1,22 +1,22 @@ -# Copyright 2021 The kpt Authors -# -# 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: update-path -source: | - for r in ctx.resource_list["items"]: - if r["kind"] == "Deployment": - r["metadata"]["annotations"]["config.kubernetes.io/path"] = "newfilename.yaml" +# Copyright 2021 The kpt Authors +# +# 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: update-path +source: | + for r in ctx.resource_list["items"]: + if r["kind"] == "Deployment": + r["metadata"]["annotations"]["config.kubernetes.io/path"] = "newfilename.yaml" diff --git a/e2e/testdata/fn-render/modify-path-annotation/.expected/diff.patch b/e2e/testdata/fn-render/modify-path-annotation/.expected/diff.patch index 20ce9c627f..4877bc7ad0 100644 --- a/e2e/testdata/fn-render/modify-path-annotation/.expected/diff.patch +++ b/e2e/testdata/fn-render/modify-path-annotation/.expected/diff.patch @@ -1,16 +1,117 @@ +diff --git a/Kptfile b/Kptfile +index b83e710..5d377d4 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-fn.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-fn.yaml diff --git a/deployment.yaml b/newfilename.yaml -similarity index 100% +old mode 100755 +new mode 100644 +similarity index 97% rename from deployment.yaml rename to newfilename.yaml +index 027731c..239f0d6 +--- a/deployment.yaml ++++ b/newfilename.yaml +@@ -1,19 +1,19 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 diff --git a/starlark-fn.yaml b/starlark-fn.yaml -index 247c2ae..0ef906e 100644 +index c75f967..0ef906e 100755 --- a/starlark-fn.yaml +++ b/starlark-fn.yaml -@@ -11,7 +11,6 @@ - # 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: +@@ -1,22 +1,21 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: update-path +-source: | +- for r in ctx.resource_list["items"]: +- if r["kind"] == "Deployment": +- r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "newfilename.yaml" ++# Copyright 2021 The kpt Authors ++# ++# 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: update-path ++source: | ++ for r in ctx.resource_list["items"]: ++ if r["kind"] == "Deployment": ++ r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "newfilename.yaml" diff --git a/e2e/testdata/fn-render/modify-path-annotation/.krmignore b/e2e/testdata/fn-render/modify-path-annotation/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/modify-path-annotation/.krmignore +++ b/e2e/testdata/fn-render/modify-path-annotation/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/modify-path-annotation/Kptfile b/e2e/testdata/fn-render/modify-path-annotation/Kptfile index 5d377d4bf4..b83e710b99 100644 --- a/e2e/testdata/fn-render/modify-path-annotation/Kptfile +++ b/e2e/testdata/fn-render/modify-path-annotation/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-fn.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-fn.yaml diff --git a/e2e/testdata/fn-render/modify-path-annotation/deployment.yaml b/e2e/testdata/fn-render/modify-path-annotation/deployment.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/modify-path-annotation/deployment.yaml +++ b/e2e/testdata/fn-render/modify-path-annotation/deployment.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/modify-path-annotation/starlark-fn.yaml b/e2e/testdata/fn-render/modify-path-annotation/starlark-fn.yaml index 247c2aee15..c75f9673bd 100644 --- a/e2e/testdata/fn-render/modify-path-annotation/starlark-fn.yaml +++ b/e2e/testdata/fn-render/modify-path-annotation/starlark-fn.yaml @@ -1,22 +1,22 @@ -# Copyright 2021 The kpt Authors -# -# 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: update-path -source: | - for r in ctx.resource_list["items"]: - if r["kind"] == "Deployment": - r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "newfilename.yaml" +# Copyright 2021 The kpt Authors +# +# 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: update-path +source: | + for r in ctx.resource_list["items"]: + if r["kind"] == "Deployment": + r["metadata"]["annotations"]["internal.config.kubernetes.io/path"] = "newfilename.yaml" diff --git a/e2e/testdata/fn-render/multiple-fnconfig/.expected/config.yaml b/e2e/testdata/fn-render/multiple-fnconfig/.expected/config.yaml index 860538b659..49f1a482b6 100644 --- a/e2e/testdata/fn-render/multiple-fnconfig/.expected/config.yaml +++ b/e2e/testdata/fn-render/multiple-fnconfig/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: 'functionConfig must not specify both `configMap` and `configPath` at the same time' +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: 'functionConfig must not specify both `configMap` and `configPath` at the same time' diff --git a/e2e/testdata/fn-render/multiple-fnconfig/.krmignore b/e2e/testdata/fn-render/multiple-fnconfig/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/multiple-fnconfig/.krmignore +++ b/e2e/testdata/fn-render/multiple-fnconfig/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/multiple-fnconfig/Kptfile b/e2e/testdata/fn-render/multiple-fnconfig/Kptfile index 6103bc8b39..eafdf52c97 100644 --- a/e2e/testdata/fn-render/multiple-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/multiple-fnconfig/Kptfile @@ -1,10 +1,10 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - configPath: configmap.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + configPath: configmap.yaml diff --git a/e2e/testdata/fn-render/multiple-fnconfig/configmap.yaml b/e2e/testdata/fn-render/multiple-fnconfig/configmap.yaml index a50e35be37..13efb906ba 100644 --- a/e2e/testdata/fn-render/multiple-fnconfig/configmap.yaml +++ b/e2e/testdata/fn-render/multiple-fnconfig/configmap.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: my-config -data: - "namespace": "example-ns" +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: my-config +data: + "namespace": "example-ns" diff --git a/e2e/testdata/fn-render/multiple-fnconfig/resources.yaml b/e2e/testdata/fn-render/multiple-fnconfig/resources.yaml index 9812c5d66e..c5b5eb5f20 100644 --- a/e2e/testdata/fn-render/multiple-fnconfig/resources.yaml +++ b/e2e/testdata/fn-render/multiple-fnconfig/resources.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: example-ns -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - namespace: example-ns -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: example-ns +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + namespace: example-ns +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/mutate-legacy-path-index/.expected/diff.patch b/e2e/testdata/fn-render/mutate-legacy-path-index/.expected/diff.patch index 2a7336fc06..e321def482 100644 --- a/e2e/testdata/fn-render/mutate-legacy-path-index/.expected/diff.patch +++ b/e2e/testdata/fn-render/mutate-legacy-path-index/.expected/diff.patch @@ -1,11 +1,141 @@ +diff --git a/Kptfile b/Kptfile +index e3ad4cc..894ad57 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-mutate-path-index.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-mutate-path-index.yaml +diff --git a/starlark-mutate-path-index.yaml b/starlark-mutate-path-index.yaml +index 8651900..c2b2a91 100755 +--- a/starlark-mutate-path-index.yaml ++++ b/starlark-mutate-path-index.yaml +@@ -1,38 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +- annotations: +- config.kubernetes.io/local-config: "true" +-source: |- +- def change_path_index(resources): +- for r in resources: +- if r["kind"] in ["Kptfile", "StarlarkRun"]: +- continue +- 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"]) ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ annotations: ++ config.kubernetes.io/local-config: "true" ++source: |- ++ def change_path_index(resources): ++ for r in resources: ++ if r["kind"] in ["Kptfile", "StarlarkRun"]: ++ continue ++ 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"]) diff --git a/x.yaml b/y.yaml -similarity index 100% +old mode 100755 +new mode 100644 +similarity index 96% rename from x.yaml rename to y.yaml -index f2eec52..ae8b12c 100644 +index 9d1f786..ae8b12c --- a/x.yaml +++ b/y.yaml -@@ -1,3 +1,10 @@ +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +apiVersion: custom.io/v1 +kind: Custom +metadata: @@ -13,17 +143,22 @@ index f2eec52..ae8b12c 100644 +spec: + image: nginx:1.2.3 +--- - # Copyright 2021 The kpt Authors - # - # 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 diff --git a/e2e/testdata/fn-render/mutate-legacy-path-index/.krmignore b/e2e/testdata/fn-render/mutate-legacy-path-index/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/mutate-legacy-path-index/.krmignore +++ b/e2e/testdata/fn-render/mutate-legacy-path-index/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/mutate-legacy-path-index/Kptfile b/e2e/testdata/fn-render/mutate-legacy-path-index/Kptfile index 894ad57791..e3ad4cc52e 100644 --- a/e2e/testdata/fn-render/mutate-legacy-path-index/Kptfile +++ b/e2e/testdata/fn-render/mutate-legacy-path-index/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-mutate-path-index.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-mutate-path-index.yaml diff --git a/e2e/testdata/fn-render/mutate-legacy-path-index/starlark-mutate-path-index.yaml b/e2e/testdata/fn-render/mutate-legacy-path-index/starlark-mutate-path-index.yaml index c2b2a9152c..8651900e12 100644 --- a/e2e/testdata/fn-render/mutate-legacy-path-index/starlark-mutate-path-index.yaml +++ b/e2e/testdata/fn-render/mutate-legacy-path-index/starlark-mutate-path-index.yaml @@ -1,38 +1,38 @@ -# Copyright 2021 The kpt Authors -# -# 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 - annotations: - config.kubernetes.io/local-config: "true" -source: |- - def change_path_index(resources): - for r in resources: - if r["kind"] in ["Kptfile", "StarlarkRun"]: - continue - 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"]) +# Copyright 2021 The kpt Authors +# +# 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 + annotations: + config.kubernetes.io/local-config: "true" +source: |- + def change_path_index(resources): + for r in resources: + if r["kind"] in ["Kptfile", "StarlarkRun"]: + continue + 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"]) diff --git a/e2e/testdata/fn-render/mutate-legacy-path-index/x.yaml b/e2e/testdata/fn-render/mutate-legacy-path-index/x.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/mutate-legacy-path-index/x.yaml +++ b/e2e/testdata/fn-render/mutate-legacy-path-index/x.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/mutate-path-index/.expected/diff.patch b/e2e/testdata/fn-render/mutate-path-index/.expected/diff.patch index 2a7336fc06..5184e32987 100644 --- a/e2e/testdata/fn-render/mutate-path-index/.expected/diff.patch +++ b/e2e/testdata/fn-render/mutate-path-index/.expected/diff.patch @@ -1,11 +1,141 @@ +diff --git a/Kptfile b/Kptfile +index e3ad4cc..894ad57 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-mutate-path-index.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-mutate-path-index.yaml +diff --git a/starlark-mutate-path-index.yaml b/starlark-mutate-path-index.yaml +index f9c64f8..23e372b 100755 +--- a/starlark-mutate-path-index.yaml ++++ b/starlark-mutate-path-index.yaml +@@ -1,38 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +- annotations: +- config.kubernetes.io/local-config: "true" +-source: |- +- def change_path_index(resources): +- for r in resources: +- if r["kind"] in ["Kptfile", "StarlarkRun"]: +- continue +- 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"]) ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ annotations: ++ config.kubernetes.io/local-config: "true" ++source: |- ++ def change_path_index(resources): ++ for r in resources: ++ if r["kind"] in ["Kptfile", "StarlarkRun"]: ++ continue ++ 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"]) diff --git a/x.yaml b/y.yaml -similarity index 100% +old mode 100755 +new mode 100644 +similarity index 96% rename from x.yaml rename to y.yaml -index f2eec52..ae8b12c 100644 +index 9d1f786..ae8b12c --- a/x.yaml +++ b/y.yaml -@@ -1,3 +1,10 @@ +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +apiVersion: custom.io/v1 +kind: Custom +metadata: @@ -13,17 +143,22 @@ index f2eec52..ae8b12c 100644 +spec: + image: nginx:1.2.3 +--- - # Copyright 2021 The kpt Authors - # - # 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 diff --git a/e2e/testdata/fn-render/mutate-path-index/.krmignore b/e2e/testdata/fn-render/mutate-path-index/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/mutate-path-index/.krmignore +++ b/e2e/testdata/fn-render/mutate-path-index/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/mutate-path-index/Kptfile b/e2e/testdata/fn-render/mutate-path-index/Kptfile index 894ad57791..e3ad4cc52e 100644 --- a/e2e/testdata/fn-render/mutate-path-index/Kptfile +++ b/e2e/testdata/fn-render/mutate-path-index/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-mutate-path-index.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-mutate-path-index.yaml diff --git a/e2e/testdata/fn-render/mutate-path-index/starlark-mutate-path-index.yaml b/e2e/testdata/fn-render/mutate-path-index/starlark-mutate-path-index.yaml index 23e372bfb0..f9c64f8f38 100644 --- a/e2e/testdata/fn-render/mutate-path-index/starlark-mutate-path-index.yaml +++ b/e2e/testdata/fn-render/mutate-path-index/starlark-mutate-path-index.yaml @@ -1,38 +1,38 @@ -# Copyright 2021 The kpt Authors -# -# 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 - annotations: - config.kubernetes.io/local-config: "true" -source: |- - def change_path_index(resources): - for r in resources: - if r["kind"] in ["Kptfile", "StarlarkRun"]: - continue - 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"]) +# Copyright 2021 The kpt Authors +# +# 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 + annotations: + config.kubernetes.io/local-config: "true" +source: |- + def change_path_index(resources): + for r in resources: + if r["kind"] in ["Kptfile", "StarlarkRun"]: + continue + 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"]) diff --git a/e2e/testdata/fn-render/mutate-path-index/x.yaml b/e2e/testdata/fn-render/mutate-path-index/x.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/mutate-path-index/x.yaml +++ b/e2e/testdata/fn-render/mutate-path-index/x.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/no-fnconfig/.expected/config.yaml b/e2e/testdata/fn-render/no-fnconfig/.expected/config.yaml index 08019ed331..34fc0cf7bb 100644 --- a/e2e/testdata/fn-render/no-fnconfig/.expected/config.yaml +++ b/e2e/testdata/fn-render/no-fnconfig/.expected/config.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -exitCode: 1 - -stdErr: "[error]: failed to configure function: `functionConfig` must be either a `ConfigMap` or `SetLabels`" +# Copyright 2021 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +exitCode: 1 + +stdErr: "[error]: failed to configure function: `functionConfig` must be either a `ConfigMap` or `SetLabels`" diff --git a/e2e/testdata/fn-render/no-fnconfig/.krmignore b/e2e/testdata/fn-render/no-fnconfig/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/no-fnconfig/.krmignore +++ b/e2e/testdata/fn-render/no-fnconfig/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/no-fnconfig/Kptfile b/e2e/testdata/fn-render/no-fnconfig/Kptfile index 4e59b34039..6b84e51cca 100644 --- a/e2e/testdata/fn-render/no-fnconfig/Kptfile +++ b/e2e/testdata/fn-render/no-fnconfig/Kptfile @@ -1,10 +1,10 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 diff --git a/e2e/testdata/fn-render/no-fnconfig/resources.yaml b/e2e/testdata/fn-render/no-fnconfig/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/no-fnconfig/resources.yaml +++ b/e2e/testdata/fn-render/no-fnconfig/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/no-format-on-failure/.expected/config.yaml b/e2e/testdata/fn-render/no-format-on-failure/.expected/config.yaml index c8bb7376dc..9382bf0814 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/no-format-on-failure/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: "can't be read.\n\nDetails:\nyaml: unmarshal errors:\n line 10: cannot unmarshal !!map into string" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: "can't be read.\n\nDetails:\nyaml: unmarshal errors:\n line 10: cannot unmarshal !!map into string" diff --git a/e2e/testdata/fn-render/no-format-on-failure/.krmignore b/e2e/testdata/fn-render/no-format-on-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/.krmignore +++ b/e2e/testdata/fn-render/no-format-on-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/no-format-on-failure/Kptfile b/e2e/testdata/fn-render/no-format-on-failure/Kptfile index 972feaeda4..547e23cc20 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/Kptfile +++ b/e2e/testdata/fn-render/no-format-on-failure/Kptfile @@ -1,10 +1,10 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: - hello: world +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: + hello: world diff --git a/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile b/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile index 5953cfadf1..aee9666d6c 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile +++ b/e2e/testdata/fn-render/no-format-on-failure/db/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db diff --git a/e2e/testdata/fn-render/no-format-on-failure/db/resources.yaml b/e2e/testdata/fn-render/no-format-on-failure/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/db/resources.yaml +++ b/e2e/testdata/fn-render/no-format-on-failure/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/no-format-on-failure/resources.yaml b/e2e/testdata/fn-render/no-format-on-failure/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/no-format-on-failure/resources.yaml +++ b/e2e/testdata/fn-render/no-format-on-failure/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/no-op/.expected/config.yaml b/e2e/testdata/fn-render/no-op/.expected/config.yaml index 0693e6cdf5..b6265a07e8 100644 --- a/e2e/testdata/fn-render/no-op/.expected/config.yaml +++ b/e2e/testdata/fn-render/no-op/.expected/config.yaml @@ -1,14 +1,14 @@ -# Copyright 2021 The kpt Authors -# -# 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. - +# Copyright 2021 The kpt Authors +# +# 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. + diff --git a/e2e/testdata/fn-render/no-op/.expected/diff.patch b/e2e/testdata/fn-render/no-op/.expected/diff.patch new file mode 100644 index 0000000000..638857fc7a --- /dev/null +++ b/e2e/testdata/fn-render/no-op/.expected/diff.patch @@ -0,0 +1,188 @@ +diff --git a/Kptfile b/Kptfile +index 1e0e356..a7a2d0b 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,7 +1,7 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/no-op ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/no-op +diff --git a/resources.yaml b/resources.yaml +index c0974f0..60f96f2 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,82 +1,82 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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/e2e/testdata/fn-render/no-op/.krmignore b/e2e/testdata/fn-render/no-op/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/no-op/.krmignore +++ b/e2e/testdata/fn-render/no-op/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/no-op/Kptfile b/e2e/testdata/fn-render/no-op/Kptfile index a7a2d0bdf2..1e0e356d8c 100644 --- a/e2e/testdata/fn-render/no-op/Kptfile +++ b/e2e/testdata/fn-render/no-op/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/no-op +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/no-op diff --git a/e2e/testdata/fn-render/no-op/resources.yaml b/e2e/testdata/fn-render/no-op/resources.yaml index 60f96f2d25..c0974f0944 100644 --- a/e2e/testdata/fn-render/no-op/resources.yaml +++ b/e2e/testdata/fn-render/no-op/resources.yaml @@ -1,82 +1,82 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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/e2e/testdata/fn-render/no-pipeline-in-subpackage/.expected/diff.patch b/e2e/testdata/fn-render/no-pipeline-in-subpackage/.expected/diff.patch index 21b66e32b1..ed06157b63 100644 --- a/e2e/testdata/fn-render/no-pipeline-in-subpackage/.expected/diff.patch +++ b/e2e/testdata/fn-render/no-pipeline-in-subpackage/.expected/diff.patch @@ -1,41 +1,102 @@ diff --git a/Kptfile b/Kptfile -index 1307fb5..3a2c718 100644 +index c3817f3..9caee20 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/db/Kptfile b/db/Kptfile -index 79b7a5a..15f086b 100644 +index db5e84a..c1f496c 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,3 +2,6 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging +@@ -1,4 +1,6 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + tier: backend diff --git a/db/resources.yaml b/db/resources.yaml -index f2eec52..84cfb26 100644 +index 9d1f786..6b5d443 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -43,13 +104,12 @@ index f2eec52..84cfb26 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/no-pipeline-in-subpackage/.krmignore b/e2e/testdata/fn-render/no-pipeline-in-subpackage/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/no-pipeline-in-subpackage/.krmignore +++ b/e2e/testdata/fn-render/no-pipeline-in-subpackage/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile b/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile +++ b/e2e/testdata/fn-render/no-pipeline-in-subpackage/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/Kptfile b/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/Kptfile index 79b7a5a39e..db5e84a9d1 100644 --- a/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/Kptfile +++ b/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db diff --git a/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/resources.yaml b/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/resources.yaml +++ b/e2e/testdata/fn-render/no-pipeline-in-subpackage/db/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/no-pipeline/.krmignore b/e2e/testdata/fn-render/no-pipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/no-pipeline/.krmignore +++ b/e2e/testdata/fn-render/no-pipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/no-pipeline/Kptfile b/e2e/testdata/fn-render/no-pipeline/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-render/no-pipeline/Kptfile +++ b/e2e/testdata/fn-render/no-pipeline/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-render/no-pipeline/resources.yaml b/e2e/testdata/fn-render/no-pipeline/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/no-pipeline/resources.yaml +++ b/e2e/testdata/fn-render/no-pipeline/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/no-resources/.expected/diff.patch b/e2e/testdata/fn-render/no-resources/.expected/diff.patch index 1bec9c43de..e2d4331ef8 100644 --- a/e2e/testdata/fn-render/no-resources/.expected/diff.patch +++ b/e2e/testdata/fn-render/no-resources/.expected/diff.patch @@ -1,3 +1,24 @@ +diff --git a/Kptfile b/Kptfile +index ab9d7ec..714d078 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin.yaml diff --git a/another/file/out.yaml b/another/file/out.yaml new file mode 100644 index 0000000..fe3c0c6 @@ -31,3 +52,190 @@ index 0000000..fe3c0c6 + name: httpbin + ports: + - containerPort: 9876 +diff --git a/starlark-httpbin.yaml b/starlark-httpbin.yaml +index 782fa3b..40dc660 100755 +--- a/starlark-httpbin.yaml ++++ b/starlark-httpbin.yaml +@@ -1,91 +1,91 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment_internal = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- "annotations": { +- "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" +- } +- }, +- "spec": { +- "replicas": 4, +- "template": { +- "spec": { +- "containers": [ +- { +- "name": "httpbin", +- "image": "kennethreitz/httpbin", +- "ports": [ +- { +- "containerPort": 9876 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment_internal) +- resources.append(httpbin_deployment_legacy) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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: |- ++ httpbin_deployment_internal = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ "annotations": { ++ "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" ++ } ++ }, ++ "spec": { ++ "replicas": 4, ++ "template": { ++ "spec": { ++ "containers": [ ++ { ++ "name": "httpbin", ++ "image": "kennethreitz/httpbin", ++ "ports": [ ++ { ++ "containerPort": 9876 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment_internal) ++ resources.append(httpbin_deployment_legacy) ++ ++ ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/no-resources/.krmignore b/e2e/testdata/fn-render/no-resources/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/no-resources/.krmignore +++ b/e2e/testdata/fn-render/no-resources/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/no-resources/Kptfile b/e2e/testdata/fn-render/no-resources/Kptfile index 714d078787..ab9d7ec858 100644 --- a/e2e/testdata/fn-render/no-resources/Kptfile +++ b/e2e/testdata/fn-render/no-resources/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml diff --git a/e2e/testdata/fn-render/no-resources/starlark-httpbin.yaml b/e2e/testdata/fn-render/no-resources/starlark-httpbin.yaml index 40dc660107..782fa3b494 100644 --- a/e2e/testdata/fn-render/no-resources/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/no-resources/starlark-httpbin.yaml @@ -1,91 +1,91 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment_internal = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - "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" - } - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment_internal) - resources.append(httpbin_deployment_legacy) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment_internal = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + "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" + } + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment_internal) + resources.append(httpbin_deployment_legacy) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.expected/config.yaml b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.expected/config.yaml index 25f612255e..cd11d750a3 100644 --- a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.expected/config.yaml +++ b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "Error: input resource list must contain only KRM resources: non-krm.yaml: resource must have `apiVersion`" \ No newline at end of file diff --git a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.krmignore b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.krmignore +++ b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/Kptfile b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/Kptfile index d9e2f05c07..1e96a3a189 100644 --- a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/Kptfile +++ b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app diff --git a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/non-krm.yaml b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/non-krm.yaml index 81b7d5c618..d3a5f65e1b 100644 --- a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/non-krm.yaml +++ b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/non-krm.yaml @@ -1,14 +1,14 @@ -# Copyright 2021 The kpt Authors -# -# 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. +# Copyright 2021 The kpt Authors +# +# 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. Non-krm-resource: true \ No newline at end of file diff --git a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/resources.yaml b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/non-krm-resource-no-pipeline/resources.yaml +++ b/e2e/testdata/fn-render/non-krm-resource-no-pipeline/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/non-krm-resource/.expected/config.yaml b/e2e/testdata/fn-render/non-krm-resource/.expected/config.yaml index 25f612255e..cd11d750a3 100644 --- a/e2e/testdata/fn-render/non-krm-resource/.expected/config.yaml +++ b/e2e/testdata/fn-render/non-krm-resource/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "Error: input resource list must contain only KRM resources: non-krm.yaml: resource must have `apiVersion`" \ No newline at end of file diff --git a/e2e/testdata/fn-render/non-krm-resource/.krmignore b/e2e/testdata/fn-render/non-krm-resource/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/non-krm-resource/.krmignore +++ b/e2e/testdata/fn-render/non-krm-resource/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/non-krm-resource/Kptfile b/e2e/testdata/fn-render/non-krm-resource/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/non-krm-resource/Kptfile +++ b/e2e/testdata/fn-render/non-krm-resource/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/non-krm-resource/non-krm.yaml b/e2e/testdata/fn-render/non-krm-resource/non-krm.yaml index 81b7d5c618..d3a5f65e1b 100644 --- a/e2e/testdata/fn-render/non-krm-resource/non-krm.yaml +++ b/e2e/testdata/fn-render/non-krm-resource/non-krm.yaml @@ -1,14 +1,14 @@ -# Copyright 2021 The kpt Authors -# -# 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. +# Copyright 2021 The kpt Authors +# +# 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. Non-krm-resource: true \ No newline at end of file diff --git a/e2e/testdata/fn-render/non-krm-resource/resources.yaml b/e2e/testdata/fn-render/non-krm-resource/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/non-krm-resource/resources.yaml +++ b/e2e/testdata/fn-render/non-krm-resource/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/config.yaml index 83c61c0af1..856281d55b 100644 --- a/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | directory "out" already exists, please delete the directory and retry \ No newline at end of file diff --git a/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/exec.sh index a9c376d948..8923b2921d 100755 --- a/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-dir-exists-error/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -rm -rf out; mkdir out - -kpt fn render -o out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +rm -rf out; mkdir out + +kpt fn render -o out diff --git a/e2e/testdata/fn-render/out-of-place-dir-exists-error/.krmignore b/e2e/testdata/fn-render/out-of-place-dir-exists-error/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-render/out-of-place-dir-exists-error/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-dir-exists-error/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile b/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-dir-exists-error/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-dir-exists-error/resources.yaml b/e2e/testdata/fn-render/out-of-place-dir-exists-error/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-dir-exists-error/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-dir-exists-error/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml index fed31a7989..2681b480cb 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-dir/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s \ No newline at end of file diff --git a/e2e/testdata/fn-render/out-of-place-dir/.expected/diff.patch b/e2e/testdata/fn-render/out-of-place-dir/.expected/diff.patch index 02cf7dab0c..d4f71ff203 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/.expected/diff.patch +++ b/e2e/testdata/fn-render/out-of-place-dir/.expected/diff.patch @@ -1,50 +1,50 @@ -diff --git a/out/Kptfile b/out/Kptfile -new file mode 100644 -index 0000000..d0d3425 ---- /dev/null -+++ b/out/Kptfile -@@ -0,0 +1,10 @@ -+apiVersion: kpt.dev/v1 -+kind: Kptfile -+metadata: -+ name: app -+ namespace: staging -+pipeline: -+ mutators: -+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 -+ configMap: -+ namespace: staging -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..b66c419 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,28 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+spec: -+ replicas: 3 -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+ namespace: staging -+spec: -+ image: nginx:1.2.3 +diff --git a/out/Kptfile b/out/Kptfile +new file mode 100644 +index 0000000..d0d3425 +--- /dev/null ++++ b/out/Kptfile +@@ -0,0 +1,10 @@ ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++ namespace: staging ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ configMap: ++ namespace: staging +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..b66c419 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,28 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ namespace: staging ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/out-of-place-dir/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-dir/.expected/exec.sh index 8597ffcf9e..184bd1bf2a 100755 --- a/e2e/testdata/fn-render/out-of-place-dir/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-dir/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -rm -rf out - -kpt fn render -o out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +rm -rf out + +kpt fn render -o out diff --git a/e2e/testdata/fn-render/out-of-place-dir/.krmignore b/e2e/testdata/fn-render/out-of-place-dir/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-dir/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-render/out-of-place-dir/Kptfile b/e2e/testdata/fn-render/out-of-place-dir/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-dir/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-dir/resources.yaml b/e2e/testdata/fn-render/out-of-place-dir/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-dir/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-dir/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml index a3e1bafdd3..ee2c34fb50 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/config.yaml @@ -1,84 +1,84 @@ -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app - annotations: - config.kubernetes.io/index: "0" - config.kubernetes.io/path: Kptfile - internal.config.kubernetes.io/index: "0" - internal.config.kubernetes.io/path: Kptfile - internal.config.kubernetes.io/seqindent: wide - foo: bar - namespace: staging - labels: - tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - # Copyright 2021 The kpt Authors - # - # 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 - 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 - labels: - tier: backend - spec: - replicas: 3 - template: - metadata: - annotations: - foo: bar - labels: - tier: backend - selector: - matchLabels: - tier: backend - - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - 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 - labels: - tier: backend - spec: - image: nginx:1.2.3 -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app + annotations: + config.kubernetes.io/index: "0" + config.kubernetes.io/path: Kptfile + internal.config.kubernetes.io/index: "0" + internal.config.kubernetes.io/path: Kptfile + internal.config.kubernetes.io/seqindent: wide + foo: bar + namespace: staging + labels: + tier: backend + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + # Copyright 2021 The kpt Authors + # + # 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 + 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 + labels: + tier: backend + spec: + replicas: 3 + template: + metadata: + annotations: + foo: bar + labels: + tier: backend + selector: + matchLabels: + tier: backend + - apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + 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 + labels: + tier: backend + spec: + image: nginx:1.2.3 +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/exec.sh index a72f60e44b..22d72454e7 100755 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.expected/exec.sh @@ -1,27 +1,27 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -# create a temporary directory for results -results=$(mktemp -d) - -kpt fn render -o stdout --results-dir $results \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest --results-dir $results -- foo=bar \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 --results-dir $results -- tier=backend - -# remove temporary directory +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +# create a temporary directory for results +results=$(mktemp -d) + +kpt fn render -o stdout --results-dir $results \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest --results-dir $results -- foo=bar \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 --results-dir $results -- tier=backend + +# remove temporary directory rm -r $results \ No newline at end of file diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.krmignore b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/resources.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout-results/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml index 8fe48132be..67b90820ff 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml @@ -1,91 +1,91 @@ -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - Package: "out-of-place-fnchain-stdout" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s - [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app - annotations: - config.kubernetes.io/index: "0" - config.kubernetes.io/path: Kptfile - internal.config.kubernetes.io/index: "0" - internal.config.kubernetes.io/path: Kptfile - internal.config.kubernetes.io/seqindent: wide - foo: bar - namespace: staging - labels: - tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - # Copyright 2021 The kpt Authors - # - # 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 - 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 - labels: - tier: backend - spec: - replicas: 3 - template: - metadata: - annotations: - foo: bar - labels: - tier: backend - selector: - matchLabels: - tier: backend - - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - 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 - labels: - tier: backend - spec: - image: nginx:1.2.3 +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + Package: "out-of-place-fnchain-stdout" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s + [Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"} + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app + annotations: + config.kubernetes.io/index: "0" + config.kubernetes.io/path: Kptfile + internal.config.kubernetes.io/index: "0" + internal.config.kubernetes.io/path: Kptfile + internal.config.kubernetes.io/seqindent: wide + foo: bar + namespace: staging + labels: + tier: backend + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + # Copyright 2021 The kpt Authors + # + # 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 + 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 + labels: + tier: backend + spec: + replicas: 3 + template: + metadata: + annotations: + foo: bar + labels: + tier: backend + selector: + matchLabels: + tier: backend + - apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + 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 + labels: + tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/exec.sh index 26d16af6c0..f78561b9df 100755 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn render -o stdout \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -- tier=backend +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn render -o stdout \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -- tier=backend diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.krmignore b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/resources.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-stdout/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-stdout/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/config.yaml index 168fd286ca..330c948bc7 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/config.yaml @@ -1,60 +1,60 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdOut: | - # Copyright 2021 The kpt Authors - # - # 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 - annotations: - foo: bar - namespace: staging - labels: - tier: backend - spec: - replicas: 3 - template: - metadata: - annotations: - foo: bar - labels: - tier: backend - selector: - matchLabels: - tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - annotations: - foo: bar - namespace: staging - labels: - tier: backend - spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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. + +stdOut: | + # Copyright 2021 The kpt Authors + # + # 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 + annotations: + foo: bar + namespace: staging + labels: + tier: backend + spec: + replicas: 3 + template: + metadata: + annotations: + foo: bar + labels: + tier: backend + selector: + matchLabels: + tier: backend + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + annotations: + foo: bar + namespace: staging + labels: + tier: backend + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/exec.sh index 27e478a335..5ef8069559 100755 --- a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn render -o stdout \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -o unwrap -- tier=backend +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn render -o stdout \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest -- foo=bar \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 -o unwrap -- tier=backend diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.krmignore b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/resources.yaml b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-fnchain-unwrap/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml index c96712620c..a3391196df 100644 --- a/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-stdout/.expected/config.yaml @@ -1,67 +1,67 @@ -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app - annotations: - config.kubernetes.io/index: "0" - config.kubernetes.io/path: Kptfile - internal.config.kubernetes.io/index: "0" - internal.config.kubernetes.io/path: Kptfile - internal.config.kubernetes.io/seqindent: wide - namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - # Copyright 2021 The kpt Authors - # - # 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 - 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: - replicas: 3 - - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - 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: - image: nginx:1.2.3 +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - apiVersion: kpt.dev/v1 + kind: Kptfile + metadata: + name: app + annotations: + config.kubernetes.io/index: "0" + config.kubernetes.io/path: Kptfile + internal.config.kubernetes.io/index: "0" + internal.config.kubernetes.io/path: Kptfile + internal.config.kubernetes.io/seqindent: wide + namespace: staging + pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + # Copyright 2021 The kpt Authors + # + # 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 + 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: + replicas: 3 + - apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + 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: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/out-of-place-stdout/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-stdout/.expected/exec.sh index 289c03ba6e..b06b3346bc 100755 --- a/e2e/testdata/fn-render/out-of-place-stdout/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-stdout/.expected/exec.sh @@ -1,19 +1,19 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn render -o stdout +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn render -o stdout diff --git a/e2e/testdata/fn-render/out-of-place-stdout/.krmignore b/e2e/testdata/fn-render/out-of-place-stdout/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/out-of-place-stdout/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-stdout/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/out-of-place-stdout/Kptfile b/e2e/testdata/fn-render/out-of-place-stdout/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-stdout/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-stdout/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-stdout/resources.yaml b/e2e/testdata/fn-render/out-of-place-stdout/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-stdout/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-stdout/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml b/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml index 381a5d2d3a..8277b93b50 100644 --- a/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml +++ b/e2e/testdata/fn-render/out-of-place-unwrap/.expected/config.yaml @@ -1,34 +1,34 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - -stdOut: | - apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment - namespace: staging - spec: - replicas: 3 - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - namespace: staging - spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + +stdOut: | + apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment + namespace: staging + spec: + replicas: 3 + --- + apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + namespace: staging + spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/.expected/exec.sh b/e2e/testdata/fn-render/out-of-place-unwrap/.expected/exec.sh index 2c0e5b9ca8..3f14f04d01 100755 --- a/e2e/testdata/fn-render/out-of-place-unwrap/.expected/exec.sh +++ b/e2e/testdata/fn-render/out-of-place-unwrap/.expected/exec.sh @@ -1,19 +1,19 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn render -o unwrap +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn render -o unwrap diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/.krmignore b/e2e/testdata/fn-render/out-of-place-unwrap/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/out-of-place-unwrap/.krmignore +++ b/e2e/testdata/fn-render/out-of-place-unwrap/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile b/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile index 710f44a846..1d66c8aa6c 100644 --- a/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile +++ b/e2e/testdata/fn-render/out-of-place-unwrap/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging diff --git a/e2e/testdata/fn-render/out-of-place-unwrap/resources.yaml b/e2e/testdata/fn-render/out-of-place-unwrap/resources.yaml index 9ebec8f972..791e9d511c 100644 --- a/e2e/testdata/fn-render/out-of-place-unwrap/resources.yaml +++ b/e2e/testdata/fn-render/out-of-place-unwrap/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/path-index-ancestor/.expected/config.yaml b/e2e/testdata/fn-render/path-index-ancestor/.expected/config.yaml index 08cb900ac3..138d9a0c67 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/.expected/config.yaml +++ b/e2e/testdata/fn-render/path-index-ancestor/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "Error: function must not modify resources outside of package: resource has path ../deployment_httpbin.yaml" \ No newline at end of file diff --git a/e2e/testdata/fn-render/path-index-ancestor/.krmignore b/e2e/testdata/fn-render/path-index-ancestor/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/.krmignore +++ b/e2e/testdata/fn-render/path-index-ancestor/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/path-index-ancestor/Kptfile b/e2e/testdata/fn-render/path-index-ancestor/Kptfile index ac710dc029..10c69851c0 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/Kptfile +++ b/e2e/testdata/fn-render/path-index-ancestor/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator diff --git a/e2e/testdata/fn-render/path-index-ancestor/db/Kptfile b/e2e/testdata/fn-render/path-index-ancestor/db/Kptfile index fad4836c7c..506b5e357b 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/db/Kptfile +++ b/e2e/testdata/fn-render/path-index-ancestor/db/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin-gen.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin-gen.yaml diff --git a/e2e/testdata/fn-render/path-index-ancestor/db/resources.yaml b/e2e/testdata/fn-render/path-index-ancestor/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/db/resources.yaml +++ b/e2e/testdata/fn-render/path-index-ancestor/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/path-index-ancestor/db/starlark-httpbin-gen.yaml b/e2e/testdata/fn-render/path-index-ancestor/db/starlark-httpbin-gen.yaml index 195d9d58a8..27a51e2bb8 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/db/starlark-httpbin-gen.yaml +++ b/e2e/testdata/fn-render/path-index-ancestor/db/starlark-httpbin-gen.yaml @@ -1,59 +1,59 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - "internal.config.kubernetes.io/index": 0, - # generates resource in parent directory - "internal.config.kubernetes.io/path": "../deployment_httpbin.yaml" - } - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + "internal.config.kubernetes.io/index": 0, + # generates resource in parent directory + "internal.config.kubernetes.io/path": "../deployment_httpbin.yaml" + } + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/path-index-ancestor/resources.yaml b/e2e/testdata/fn-render/path-index-ancestor/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/path-index-ancestor/resources.yaml +++ b/e2e/testdata/fn-render/path-index-ancestor/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/path-index-current/.expected/diff.patch b/e2e/testdata/fn-render/path-index-current/.expected/diff.patch index 1ae748f1e4..6ccb5183c5 100644 --- a/e2e/testdata/fn-render/path-index-current/.expected/diff.patch +++ b/e2e/testdata/fn-render/path-index-current/.expected/diff.patch @@ -1,3 +1,24 @@ +diff --git a/Kptfile b/Kptfile +index 9033153..0f5d7db 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-generator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin-gen.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-generator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin-gen.yaml diff --git a/deployment_httpbin.yaml b/deployment_httpbin.yaml new file mode 100644 index 0000000..f36c98e @@ -17,3 +38,185 @@ index 0000000..f36c98e + name: httpbin + ports: + - containerPort: 9876 +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 +diff --git a/starlark-httpbin-gen.yaml b/starlark-httpbin-gen.yaml +index 910aa53..3a44610 100755 +--- a/starlark-httpbin-gen.yaml ++++ b/starlark-httpbin-gen.yaml +@@ -1,60 +1,60 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- "annotations": { +- "internal.config.kubernetes.io/index": 0, +- # generates resource in current directory +- "internal.config.kubernetes.io/path": "./deployment_httpbin.yaml" +- } +- }, +- "spec": { +- "replicas": 4, +- "template": { +- "spec": { +- "containers": [ +- { +- "name": "httpbin", +- "image": "kennethreitz/httpbin", +- "ports": [ +- { +- "containerPort": 9876 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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: |- ++ httpbin_deployment = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ "annotations": { ++ "internal.config.kubernetes.io/index": 0, ++ # generates resource in current directory ++ "internal.config.kubernetes.io/path": "./deployment_httpbin.yaml" ++ } ++ }, ++ "spec": { ++ "replicas": 4, ++ "template": { ++ "spec": { ++ "containers": [ ++ { ++ "name": "httpbin", ++ "image": "kennethreitz/httpbin", ++ "ports": [ ++ { ++ "containerPort": 9876 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment) ++ ++ ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/path-index-current/.krmignore b/e2e/testdata/fn-render/path-index-current/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/path-index-current/.krmignore +++ b/e2e/testdata/fn-render/path-index-current/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/path-index-current/Kptfile b/e2e/testdata/fn-render/path-index-current/Kptfile index 0f5d7db133..9033153717 100644 --- a/e2e/testdata/fn-render/path-index-current/Kptfile +++ b/e2e/testdata/fn-render/path-index-current/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin-gen.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin-gen.yaml diff --git a/e2e/testdata/fn-render/path-index-current/resources.yaml b/e2e/testdata/fn-render/path-index-current/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/path-index-current/resources.yaml +++ b/e2e/testdata/fn-render/path-index-current/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/path-index-current/starlark-httpbin-gen.yaml b/e2e/testdata/fn-render/path-index-current/starlark-httpbin-gen.yaml index 3a44610a7f..910aa536ea 100644 --- a/e2e/testdata/fn-render/path-index-current/starlark-httpbin-gen.yaml +++ b/e2e/testdata/fn-render/path-index-current/starlark-httpbin-gen.yaml @@ -1,60 +1,60 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - "internal.config.kubernetes.io/index": 0, - # generates resource in current directory - "internal.config.kubernetes.io/path": "./deployment_httpbin.yaml" - } - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + "internal.config.kubernetes.io/index": 0, + # generates resource in current directory + "internal.config.kubernetes.io/path": "./deployment_httpbin.yaml" + } + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/path-index-descendent/.expected/diff.patch b/e2e/testdata/fn-render/path-index-descendent/.expected/diff.patch index a8e328e54e..9d92267a08 100644 --- a/e2e/testdata/fn-render/path-index-descendent/.expected/diff.patch +++ b/e2e/testdata/fn-render/path-index-descendent/.expected/diff.patch @@ -1,3 +1,37 @@ +diff --git a/Kptfile b/Kptfile +index 9033153..0f5d7db 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,8 +1,8 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-generator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin-gen.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-generator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin-gen.yaml +diff --git a/db/Kptfile b/db/Kptfile +index db5e84a..79b7a5a 100755 +--- a/db/Kptfile ++++ b/db/Kptfile +@@ -1,4 +1,4 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db diff --git a/db/deployment_httpbin.yaml b/db/deployment_httpbin.yaml new file mode 100644 index 0000000..f36c98e @@ -17,3 +51,228 @@ index 0000000..f36c98e + name: httpbin + ports: + - containerPort: 9876 +diff --git a/db/resources.yaml b/db/resources.yaml +index c9c269b..dabe43c 100755 +--- a/db/resources.yaml ++++ b/db/resources.yaml +@@ -1,19 +1,19 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db ++spec: ++ replicas: 3 +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 +diff --git a/starlark-httpbin-gen.yaml b/starlark-httpbin-gen.yaml +index 106be2d..285547d 100755 +--- a/starlark-httpbin-gen.yaml ++++ b/starlark-httpbin-gen.yaml +@@ -1,60 +1,60 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- "annotations": { +- "internal.config.kubernetes.io/index": 0, +- # generates resource in child directory +- "internal.config.kubernetes.io/path": "./db/deployment_httpbin.yaml" +- } +- }, +- "spec": { +- "replicas": 4, +- "template": { +- "spec": { +- "containers": [ +- { +- "name": "httpbin", +- "image": "kennethreitz/httpbin", +- "ports": [ +- { +- "containerPort": 9876 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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: |- ++ httpbin_deployment = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ "annotations": { ++ "internal.config.kubernetes.io/index": 0, ++ # generates resource in child directory ++ "internal.config.kubernetes.io/path": "./db/deployment_httpbin.yaml" ++ } ++ }, ++ "spec": { ++ "replicas": 4, ++ "template": { ++ "spec": { ++ "containers": [ ++ { ++ "name": "httpbin", ++ "image": "kennethreitz/httpbin", ++ "ports": [ ++ { ++ "containerPort": 9876 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment) ++ ++ ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/path-index-descendent/.krmignore b/e2e/testdata/fn-render/path-index-descendent/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/path-index-descendent/.krmignore +++ b/e2e/testdata/fn-render/path-index-descendent/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/path-index-descendent/Kptfile b/e2e/testdata/fn-render/path-index-descendent/Kptfile index 0f5d7db133..9033153717 100644 --- a/e2e/testdata/fn-render/path-index-descendent/Kptfile +++ b/e2e/testdata/fn-render/path-index-descendent/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin-gen.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin-gen.yaml diff --git a/e2e/testdata/fn-render/path-index-descendent/db/Kptfile b/e2e/testdata/fn-render/path-index-descendent/db/Kptfile index 79b7a5a39e..db5e84a9d1 100644 --- a/e2e/testdata/fn-render/path-index-descendent/db/Kptfile +++ b/e2e/testdata/fn-render/path-index-descendent/db/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db diff --git a/e2e/testdata/fn-render/path-index-descendent/db/resources.yaml b/e2e/testdata/fn-render/path-index-descendent/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/path-index-descendent/db/resources.yaml +++ b/e2e/testdata/fn-render/path-index-descendent/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/path-index-descendent/resources.yaml b/e2e/testdata/fn-render/path-index-descendent/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/path-index-descendent/resources.yaml +++ b/e2e/testdata/fn-render/path-index-descendent/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/path-index-descendent/starlark-httpbin-gen.yaml b/e2e/testdata/fn-render/path-index-descendent/starlark-httpbin-gen.yaml index 285547dfa2..106be2de50 100644 --- a/e2e/testdata/fn-render/path-index-descendent/starlark-httpbin-gen.yaml +++ b/e2e/testdata/fn-render/path-index-descendent/starlark-httpbin-gen.yaml @@ -1,60 +1,60 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - "internal.config.kubernetes.io/index": 0, - # generates resource in child directory - "internal.config.kubernetes.io/path": "./db/deployment_httpbin.yaml" - } - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + "internal.config.kubernetes.io/index": 0, + # generates resource in child directory + "internal.config.kubernetes.io/path": "./db/deployment_httpbin.yaml" + } + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/path-index-duplicate/.expected/config.yaml b/e2e/testdata/fn-render/path-index-duplicate/.expected/config.yaml index 9282a933b5..9f69fc816a 100644 --- a/e2e/testdata/fn-render/path-index-duplicate/.expected/config.yaml +++ b/e2e/testdata/fn-render/path-index-duplicate/.expected/config.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 -stdErr: 'resource at path "resources.yaml" and index "0" already exists' +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 +stdErr: 'resource at path "resources.yaml" and index "0" already exists' diff --git a/e2e/testdata/fn-render/path-index-duplicate/.krmignore b/e2e/testdata/fn-render/path-index-duplicate/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/path-index-duplicate/.krmignore +++ b/e2e/testdata/fn-render/path-index-duplicate/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/path-index-duplicate/Kptfile b/e2e/testdata/fn-render/path-index-duplicate/Kptfile index ef99dadc7c..25dd680e66 100644 --- a/e2e/testdata/fn-render/path-index-duplicate/Kptfile +++ b/e2e/testdata/fn-render/path-index-duplicate/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-gen-duplicate-path.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-gen-duplicate-path.yaml diff --git a/e2e/testdata/fn-render/path-index-duplicate/resources.yaml b/e2e/testdata/fn-render/path-index-duplicate/resources.yaml index 42b1adddcd..c7e5cd9b13 100644 --- a/e2e/testdata/fn-render/path-index-duplicate/resources.yaml +++ b/e2e/testdata/fn-render/path-index-duplicate/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors - -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors + +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/path-index-duplicate/starlark-gen-duplicate-path.yaml b/e2e/testdata/fn-render/path-index-duplicate/starlark-gen-duplicate-path.yaml index 90d3962a50..926b54e2a1 100644 --- a/e2e/testdata/fn-render/path-index-duplicate/starlark-gen-duplicate-path.yaml +++ b/e2e/testdata/fn-render/path-index-duplicate/starlark-gen-duplicate-path.yaml @@ -1,60 +1,60 @@ -# Copyright 2021 The kpt Authors -# -# 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: duplicate-path-generator -source: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - # generates resource with duplicate path and index - "internal.config.kubernetes.io/index": 0, - "internal.config.kubernetes.io/path": "./resources.yaml" - } - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: duplicate-path-generator +source: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + # generates resource with duplicate path and index + "internal.config.kubernetes.io/index": 0, + "internal.config.kubernetes.io/path": "./resources.yaml" + } + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/path-index-outofpackage/.expected/config.yaml b/e2e/testdata/fn-render/path-index-outofpackage/.expected/config.yaml index cbd7ac9729..94b549bad8 100644 --- a/e2e/testdata/fn-render/path-index-outofpackage/.expected/config.yaml +++ b/e2e/testdata/fn-render/path-index-outofpackage/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "Error: function must not modify resources outside of package: resource has path ../notpkg/deployment_httpbin.yaml" \ No newline at end of file diff --git a/e2e/testdata/fn-render/path-index-outofpackage/.krmignore b/e2e/testdata/fn-render/path-index-outofpackage/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/path-index-outofpackage/.krmignore +++ b/e2e/testdata/fn-render/path-index-outofpackage/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/path-index-outofpackage/Kptfile b/e2e/testdata/fn-render/path-index-outofpackage/Kptfile index ac710dc029..10c69851c0 100644 --- a/e2e/testdata/fn-render/path-index-outofpackage/Kptfile +++ b/e2e/testdata/fn-render/path-index-outofpackage/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator diff --git a/e2e/testdata/fn-render/path-index-outofpackage/db/Kptfile b/e2e/testdata/fn-render/path-index-outofpackage/db/Kptfile index fad4836c7c..506b5e357b 100644 --- a/e2e/testdata/fn-render/path-index-outofpackage/db/Kptfile +++ b/e2e/testdata/fn-render/path-index-outofpackage/db/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin-gen.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin-gen.yaml diff --git a/e2e/testdata/fn-render/path-index-outofpackage/db/resources.yaml b/e2e/testdata/fn-render/path-index-outofpackage/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/path-index-outofpackage/db/resources.yaml +++ b/e2e/testdata/fn-render/path-index-outofpackage/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/path-index-outofpackage/db/starlark-httpbin-gen.yaml b/e2e/testdata/fn-render/path-index-outofpackage/db/starlark-httpbin-gen.yaml index af509d101e..07f54269fb 100644 --- a/e2e/testdata/fn-render/path-index-outofpackage/db/starlark-httpbin-gen.yaml +++ b/e2e/testdata/fn-render/path-index-outofpackage/db/starlark-httpbin-gen.yaml @@ -1,59 +1,59 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - "annotations": { - "internal.config.kubernetes.io/index": 0, - # generates resource in directory that is not a package - "internal.config.kubernetes.io/path": "../notpkg/deployment_httpbin.yaml" - } - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + "annotations": { + "internal.config.kubernetes.io/index": 0, + # generates resource in directory that is not a package + "internal.config.kubernetes.io/path": "../notpkg/deployment_httpbin.yaml" + } + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/preserve-comments/.expected/config.yaml b/e2e/testdata/fn-render/preserve-comments/.expected/config.yaml index 0693e6cdf5..b6265a07e8 100644 --- a/e2e/testdata/fn-render/preserve-comments/.expected/config.yaml +++ b/e2e/testdata/fn-render/preserve-comments/.expected/config.yaml @@ -1,14 +1,14 @@ -# Copyright 2021 The kpt Authors -# -# 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. - +# Copyright 2021 The kpt Authors +# +# 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. + diff --git a/e2e/testdata/fn-render/preserve-comments/.expected/diff.patch b/e2e/testdata/fn-render/preserve-comments/.expected/diff.patch new file mode 100644 index 0000000000..9edb305f5d --- /dev/null +++ b/e2e/testdata/fn-render/preserve-comments/.expected/diff.patch @@ -0,0 +1,158 @@ +diff --git a/Kptfile b/Kptfile +index 7b85c09..828d292 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,7 +1,7 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/drop-comments:v0.1 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/drop-comments:v0.1 +diff --git a/resources.yaml b/resources.yaml +index 020331f..5e8b5fe 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,67 +1,67 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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)$ ++# Copyright 2021 The kpt Authors ++# ++# 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)$ diff --git a/e2e/testdata/fn-render/preserve-comments/.krmignore b/e2e/testdata/fn-render/preserve-comments/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/preserve-comments/.krmignore +++ b/e2e/testdata/fn-render/preserve-comments/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/preserve-comments/Kptfile b/e2e/testdata/fn-render/preserve-comments/Kptfile index 828d292724..7b85c09cee 100644 --- a/e2e/testdata/fn-render/preserve-comments/Kptfile +++ b/e2e/testdata/fn-render/preserve-comments/Kptfile @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/drop-comments:v0.1 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/drop-comments:v0.1 diff --git a/e2e/testdata/fn-render/preserve-comments/resources.yaml b/e2e/testdata/fn-render/preserve-comments/resources.yaml index 5e8b5fe157..020331fe40 100644 --- a/e2e/testdata/fn-render/preserve-comments/resources.yaml +++ b/e2e/testdata/fn-render/preserve-comments/resources.yaml @@ -1,67 +1,67 @@ -# Copyright 2021 The kpt Authors -# -# 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)$ +# Copyright 2021 The kpt Authors +# +# 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)$ diff --git a/e2e/testdata/fn-render/preserve-order-null-values/.expected/diff.patch b/e2e/testdata/fn-render/preserve-order-null-values/.expected/diff.patch index 0e758a50d7..fa029dc1ef 100644 --- a/e2e/testdata/fn-render/preserve-order-null-values/.expected/diff.patch +++ b/e2e/testdata/fn-render/preserve-order-null-values/.expected/diff.patch @@ -1,30 +1,89 @@ diff --git a/Kptfile b/Kptfile -index 1307fb5..3a2c718 100644 +index c3817f3..9caee20 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index f410b70..b58c04c 100644 +index 6b68648..6a0f28f 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -16,12 +16,25 @@ kind: Deployment - metadata: - name: nginx-deployment - createTimestamp: null +@@ -1,27 +1,39 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +- createTimestamp: null +-spec: +- replicas: 3 +---- +-apiVersion: custom.io/v1 +-kind: Custom +-metadata: +- name: custom +-spec: +- image: nginx:1.2.3 ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ createTimestamp: null + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -32,13 +91,12 @@ index f410b70..b58c04c 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/preserve-order-null-values/.krmignore b/e2e/testdata/fn-render/preserve-order-null-values/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/preserve-order-null-values/.krmignore +++ b/e2e/testdata/fn-render/preserve-order-null-values/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/preserve-order-null-values/Kptfile b/e2e/testdata/fn-render/preserve-order-null-values/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/preserve-order-null-values/Kptfile +++ b/e2e/testdata/fn-render/preserve-order-null-values/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/preserve-order-null-values/resources.yaml b/e2e/testdata/fn-render/preserve-order-null-values/resources.yaml index f410b70d3a..6b68648d01 100644 --- a/e2e/testdata/fn-render/preserve-order-null-values/resources.yaml +++ b/e2e/testdata/fn-render/preserve-order-null-values/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 - createTimestamp: null -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + createTimestamp: null +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/resource-deletion/.expected/diff.patch b/e2e/testdata/fn-render/resource-deletion/.expected/diff.patch index 61eda0ce31..2d1f7b9075 100644 --- a/e2e/testdata/fn-render/resource-deletion/.expected/diff.patch +++ b/e2e/testdata/fn-render/resource-deletion/.expected/diff.patch @@ -1,72 +1,133 @@ diff --git a/Kptfile b/Kptfile -index 364e274..75cfedb 100644 +index 1e4b14a..8d6e225 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/deployment_httpbin.yaml b/deployment_httpbin.yaml -deleted file mode 100644 -index 49d4f6e..0000000 +deleted file mode 100755 +index b4028f8..0000000 --- a/deployment_httpbin.yaml +++ /dev/null @@ -1,36 +0,0 @@ --# Copyright 2021 The kpt Authors --# --# 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: httpbin -- namespace: staging -- labels: -- app: backend -- tier: db --spec: -- replicas: 4 -- selector: -- matchLabels: -- app: backend -- tier: db -- template: -- metadata: -- labels: -- app: backend -- tier: db -- spec: -- containers: -- - name: httpbin -- image: kennethreitz/httpbin +-# Copyright 2021 The kpt Authors +-# +-# 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: httpbin +- namespace: staging +- labels: +- app: backend +- tier: db +-spec: +- replicas: 4 +- selector: +- matchLabels: +- app: backend +- tier: db +- template: +- metadata: +- labels: +- app: backend +- tier: db +- spec: +- containers: +- - name: httpbin +- image: kennethreitz/httpbin diff --git a/resources.yaml b/resources.yaml -index f2eec52..84cfb26 100644 +index 9d1f786..6b5d443 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -74,27 +135,67 @@ index f2eec52..84cfb26 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/starlark-httpbin.yaml b/starlark-httpbin.yaml -index fd90109..e437ba7 100644 +index b668683..f9174fb 100755 --- a/starlark-httpbin.yaml +++ b/starlark-httpbin.yaml -@@ -15,6 +15,9 @@ apiVersion: fn.kpt.dev/v1alpha1 - kind: StarlarkRun - metadata: - name: httpbin-gen -+ namespace: staging +@@ -1,24 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: | +- # filter to return if resource is HTTPBin resource +- def isHTTPBin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- # filter out the httpbin deployment +- ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] ++# Copyright 2021 The kpt Authors ++# ++# 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 + labels: + tier: backend - source: | - # filter to return if resource is HTTPBin resource - def isHTTPBin(r): ++source: | ++ # filter to return if resource is HTTPBin resource ++ def isHTTPBin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ # filter out the httpbin deployment ++ ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] diff --git a/e2e/testdata/fn-render/resource-deletion/.krmignore b/e2e/testdata/fn-render/resource-deletion/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/resource-deletion/.krmignore +++ b/e2e/testdata/fn-render/resource-deletion/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/resource-deletion/Kptfile b/e2e/testdata/fn-render/resource-deletion/Kptfile index 7316bb0b1a..1e4b14aea6 100644 --- a/e2e/testdata/fn-render/resource-deletion/Kptfile +++ b/e2e/testdata/fn-render/resource-deletion/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/resource-deletion/deployment_httpbin.yaml b/e2e/testdata/fn-render/resource-deletion/deployment_httpbin.yaml index 49d4f6e3dd..b4028f8592 100644 --- a/e2e/testdata/fn-render/resource-deletion/deployment_httpbin.yaml +++ b/e2e/testdata/fn-render/resource-deletion/deployment_httpbin.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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: httpbin - namespace: staging - labels: - app: backend - tier: db -spec: - replicas: 4 - selector: - matchLabels: - app: backend - tier: db - template: - metadata: - labels: - app: backend - tier: db - spec: - containers: - - name: httpbin - image: kennethreitz/httpbin +# Copyright 2021 The kpt Authors +# +# 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: httpbin + namespace: staging + labels: + app: backend + tier: db +spec: + replicas: 4 + selector: + matchLabels: + app: backend + tier: db + template: + metadata: + labels: + app: backend + tier: db + spec: + containers: + - name: httpbin + image: kennethreitz/httpbin diff --git a/e2e/testdata/fn-render/resource-deletion/resources.yaml b/e2e/testdata/fn-render/resource-deletion/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/resource-deletion/resources.yaml +++ b/e2e/testdata/fn-render/resource-deletion/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/resource-deletion/starlark-httpbin.yaml b/e2e/testdata/fn-render/resource-deletion/starlark-httpbin.yaml index fd9010919c..b668683784 100644 --- a/e2e/testdata/fn-render/resource-deletion/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/resource-deletion/starlark-httpbin.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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: | - # filter to return if resource is HTTPBin resource - def isHTTPBin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - # filter out the httpbin deployment - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] +# Copyright 2021 The kpt Authors +# +# 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: | + # filter to return if resource is HTTPBin resource + def isHTTPBin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + # filter out the httpbin deployment + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] diff --git a/e2e/testdata/fn-render/resource-has-pkgname-prefix/.expected/diff.patch b/e2e/testdata/fn-render/resource-has-pkgname-prefix/.expected/diff.patch index 0149749d0f..0b86fa1f99 100644 --- a/e2e/testdata/fn-render/resource-has-pkgname-prefix/.expected/diff.patch +++ b/e2e/testdata/fn-render/resource-has-pkgname-prefix/.expected/diff.patch @@ -1,105 +1,399 @@ diff --git a/Kptfile b/Kptfile -index 21d9773..66b7fc9 100644 +index e2f4e83..66b7fc9 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: wordpress +@@ -1,9 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: wordpress +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest +- configMap: +- abc: def ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: wordpress + annotations: + abc: def - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest ++ configMap: ++ abc: def diff --git a/mysql/Kptfile b/mysql/Kptfile -index 3d51a77..965bc63 100644 +index 7e407bc..965bc63 100755 --- a/mysql/Kptfile +++ b/mysql/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: mysql +@@ -1,9 +1,12 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: mysql +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest +- configMap: +- foo: bar ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: mysql + annotations: + foo: bar + abc: def - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest ++ configMap: ++ foo: bar diff --git a/mysql/mysql-deployment.yaml b/mysql/mysql-deployment.yaml -index 1b0fbd4..349681e 100644 +index faf76a1..349681e 100755 --- a/mysql/mysql-deployment.yaml +++ b/mysql/mysql-deployment.yaml -@@ -18,6 +18,8 @@ metadata: - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} +@@ -1,81 +1,90 @@ +-# Copyright 2019 The kpt Authors +-# +-# 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: v1 +-kind: Service +-metadata: +- name: wordpress-mysql +- annotations: +- projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} +- teamname: 'YOURTEAM' # kpt-set: ${teamname} +-spec: +- selector: +- app: wordpress +- tier: mysql +- ports: +- - port: 3306 +- clusterIP: None +---- +-apiVersion: v1 +-kind: PersistentVolumeClaim +-metadata: +- name: mysql-pv-claim +- annotations: +- projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} +- teamname: 'YOURTEAM' # kpt-set: ${teamname} +-spec: +- resources: +- requests: +- storage: 20Gi +- accessModes: +- - ReadWriteOnce +---- +-apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 +-kind: Deployment +-metadata: +- name: wordpress-mysql +- annotations: +- projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} +- teamname: 'YOURTEAM' # kpt-set: ${teamname} +-spec: +- selector: +- matchLabels: +- app: wordpress +- tier: mysql +- template: +- metadata: +- labels: +- app: wordpress +- tier: mysql +- spec: +- containers: +- - name: mysql +- image: mysql:5.6 # kpt-set: ${ms-image}:${ms-tag} +- ports: +- - name: mysql +- containerPort: 3306 +- env: +- - name: MYSQL_ROOT_PASSWORD +- valueFrom: +- secretKeyRef: +- name: mysql-pass +- key: password +- volumeMounts: +- - name: mysql-persistent-storage +- mountPath: /var/lib/mysql +- volumes: +- - name: mysql-persistent-storage +- persistentVolumeClaim: +- claimName: mysql-pv-claim +- strategy: +- type: Recreate ++# Copyright 2019 The kpt Authors ++# ++# 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: v1 ++kind: Service ++metadata: ++ name: wordpress-mysql ++ annotations: ++ projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} ++ teamname: 'YOURTEAM' # kpt-set: ${teamname} + foo: bar + abc: def - spec: - selector: - app: wordpress -@@ -33,6 +35,8 @@ metadata: - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} ++spec: ++ selector: ++ app: wordpress ++ tier: mysql ++ ports: ++ - port: 3306 ++ clusterIP: None ++--- ++apiVersion: v1 ++kind: PersistentVolumeClaim ++metadata: ++ name: mysql-pv-claim ++ annotations: ++ projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} ++ teamname: 'YOURTEAM' # kpt-set: ${teamname} + foo: bar + abc: def - spec: - resources: - requests: -@@ -47,6 +51,8 @@ metadata: - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} ++spec: ++ resources: ++ requests: ++ storage: 20Gi ++ accessModes: ++ - ReadWriteOnce ++--- ++apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 ++kind: Deployment ++metadata: ++ name: wordpress-mysql ++ annotations: ++ projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} ++ teamname: 'YOURTEAM' # kpt-set: ${teamname} + foo: bar + abc: def - spec: - selector: - matchLabels: -@@ -57,6 +63,9 @@ spec: - labels: - app: wordpress - tier: mysql ++spec: ++ selector: ++ matchLabels: ++ app: wordpress ++ tier: mysql ++ template: ++ metadata: ++ labels: ++ app: wordpress ++ tier: mysql + annotations: + foo: bar + abc: def - spec: - containers: - - name: mysql ++ spec: ++ containers: ++ - name: mysql ++ image: mysql:5.6 # kpt-set: ${ms-image}:${ms-tag} ++ ports: ++ - name: mysql ++ containerPort: 3306 ++ env: ++ - name: MYSQL_ROOT_PASSWORD ++ valueFrom: ++ secretKeyRef: ++ name: mysql-pass ++ key: password ++ volumeMounts: ++ - name: mysql-persistent-storage ++ mountPath: /var/lib/mysql ++ volumes: ++ - name: mysql-persistent-storage ++ persistentVolumeClaim: ++ claimName: mysql-pv-claim ++ strategy: ++ type: Recreate diff --git a/wordpress-deployment.yaml b/wordpress-deployment.yaml -index d018dfa..af25a1f 100644 +index 0d53f68..af25a1f 100755 --- a/wordpress-deployment.yaml +++ b/wordpress-deployment.yaml -@@ -16,6 +16,7 @@ metadata: - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} +@@ -1,81 +1,86 @@ +-# Copyright 2019 The kpt Authors +-# +-# 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: v1 +-kind: Service +-metadata: +- name: wordpress +- annotations: +- projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} +- teamname: 'YOURTEAM' # kpt-set: ${teamname} +-spec: +- type: LoadBalancer +- selector: +- app: wordpress +- tier: frontend +- ports: +- - port: 80 +---- +-apiVersion: v1 +-kind: PersistentVolumeClaim +-metadata: +- name: wp-pv-claim +- annotations: +- projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} +- teamname: 'YOURTEAM' # kpt-set: ${teamname} +-spec: +- resources: +- requests: +- storage: 20Gi +- accessModes: +- - ReadWriteOnce +---- +-apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 +-kind: Deployment +-metadata: +- name: wordpress +- annotations: +- projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} +- teamname: 'YOURTEAM' # kpt-set: ${teamname} +-spec: +- selector: +- matchLabels: +- app: wordpress +- tier: frontend +- template: +- metadata: +- labels: +- app: wordpress +- tier: frontend +- spec: +- containers: +- - name: wordpress +- image: wordpress:4.8-apache # kpt-set: ${wp-image}:${wp-tag} +- ports: +- - name: wordpress +- containerPort: 80 +- env: +- - name: WORDPRESS_DB_HOST +- value: wordpress-mysql +- - name: WORDPRESS_DB_PASSWORD +- valueFrom: +- secretKeyRef: +- name: mysql-pass +- key: password +- volumeMounts: +- - name: wordpress-persistent-storage +- mountPath: /var/www/html +- volumes: +- - name: wordpress-persistent-storage +- persistentVolumeClaim: +- claimName: wp-pv-claim +- strategy: +- type: Recreate ++# Copyright 2019 The kpt Authors ++# ++# 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: v1 ++kind: Service ++metadata: ++ name: wordpress ++ annotations: ++ projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} ++ teamname: 'YOURTEAM' # kpt-set: ${teamname} + abc: def - spec: - type: LoadBalancer - selector: -@@ -31,6 +32,7 @@ metadata: - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} ++spec: ++ type: LoadBalancer ++ selector: ++ app: wordpress ++ tier: frontend ++ ports: ++ - port: 80 ++--- ++apiVersion: v1 ++kind: PersistentVolumeClaim ++metadata: ++ name: wp-pv-claim ++ annotations: ++ projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} ++ teamname: 'YOURTEAM' # kpt-set: ${teamname} + abc: def - spec: - resources: - requests: -@@ -45,6 +47,7 @@ metadata: - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} ++spec: ++ resources: ++ requests: ++ storage: 20Gi ++ accessModes: ++ - ReadWriteOnce ++--- ++apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 ++kind: Deployment ++metadata: ++ name: wordpress ++ annotations: ++ projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} ++ teamname: 'YOURTEAM' # kpt-set: ${teamname} + abc: def - spec: - selector: - matchLabels: -@@ -55,6 +58,8 @@ spec: - labels: - app: wordpress - tier: frontend ++spec: ++ selector: ++ matchLabels: ++ app: wordpress ++ tier: frontend ++ template: ++ metadata: ++ labels: ++ app: wordpress ++ tier: frontend + annotations: + abc: def - spec: - containers: - - name: wordpress ++ spec: ++ containers: ++ - name: wordpress ++ image: wordpress:4.8-apache # kpt-set: ${wp-image}:${wp-tag} ++ ports: ++ - name: wordpress ++ containerPort: 80 ++ env: ++ - name: WORDPRESS_DB_HOST ++ value: wordpress-mysql ++ - name: WORDPRESS_DB_PASSWORD ++ valueFrom: ++ secretKeyRef: ++ name: mysql-pass ++ key: password ++ volumeMounts: ++ - name: wordpress-persistent-storage ++ mountPath: /var/www/html ++ volumes: ++ - name: wordpress-persistent-storage ++ persistentVolumeClaim: ++ claimName: wp-pv-claim ++ strategy: ++ type: Recreate diff --git a/e2e/testdata/fn-render/resource-has-pkgname-prefix/.krmignore b/e2e/testdata/fn-render/resource-has-pkgname-prefix/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/resource-has-pkgname-prefix/.krmignore +++ b/e2e/testdata/fn-render/resource-has-pkgname-prefix/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/resource-has-pkgname-prefix/Kptfile b/e2e/testdata/fn-render/resource-has-pkgname-prefix/Kptfile index 21d9773604..e2f4e83991 100644 --- a/e2e/testdata/fn-render/resource-has-pkgname-prefix/Kptfile +++ b/e2e/testdata/fn-render/resource-has-pkgname-prefix/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: wordpress -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest - configMap: - abc: def +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: wordpress +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest + configMap: + abc: def diff --git a/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/Kptfile b/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/Kptfile index 3d51a77d38..7e407bcfc4 100644 --- a/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/Kptfile +++ b/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: mysql -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest - configMap: - foo: bar +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: mysql +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest + configMap: + foo: bar diff --git a/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/mysql-deployment.yaml b/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/mysql-deployment.yaml index 1b0fbd4e40..faf76a1592 100644 --- a/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/mysql-deployment.yaml +++ b/e2e/testdata/fn-render/resource-has-pkgname-prefix/mysql/mysql-deployment.yaml @@ -1,81 +1,81 @@ -# Copyright 2019 The kpt Authors -# -# 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: v1 -kind: Service -metadata: - name: wordpress-mysql - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} -spec: - selector: - app: wordpress - tier: mysql - ports: - - port: 3306 - clusterIP: None ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: mysql-pv-claim - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} -spec: - resources: - requests: - storage: 20Gi - accessModes: - - ReadWriteOnce ---- -apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 -kind: Deployment -metadata: - name: wordpress-mysql - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} -spec: - selector: - matchLabels: - app: wordpress - tier: mysql - template: - metadata: - labels: - app: wordpress - tier: mysql - spec: - containers: - - name: mysql - image: mysql:5.6 # kpt-set: ${ms-image}:${ms-tag} - ports: - - name: mysql - containerPort: 3306 - env: - - name: MYSQL_ROOT_PASSWORD - valueFrom: - secretKeyRef: - name: mysql-pass - key: password - volumeMounts: - - name: mysql-persistent-storage - mountPath: /var/lib/mysql - volumes: - - name: mysql-persistent-storage - persistentVolumeClaim: - claimName: mysql-pv-claim - strategy: - type: Recreate +# Copyright 2019 The kpt Authors +# +# 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: v1 +kind: Service +metadata: + name: wordpress-mysql + annotations: + projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} + teamname: 'YOURTEAM' # kpt-set: ${teamname} +spec: + selector: + app: wordpress + tier: mysql + ports: + - port: 3306 + clusterIP: None +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-pv-claim + annotations: + projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} + teamname: 'YOURTEAM' # kpt-set: ${teamname} +spec: + resources: + requests: + storage: 20Gi + accessModes: + - ReadWriteOnce +--- +apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 +kind: Deployment +metadata: + name: wordpress-mysql + annotations: + projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} + teamname: 'YOURTEAM' # kpt-set: ${teamname} +spec: + selector: + matchLabels: + app: wordpress + tier: mysql + template: + metadata: + labels: + app: wordpress + tier: mysql + spec: + containers: + - name: mysql + image: mysql:5.6 # kpt-set: ${ms-image}:${ms-tag} + ports: + - name: mysql + containerPort: 3306 + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-pass + key: password + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: mysql-pv-claim + strategy: + type: Recreate diff --git a/e2e/testdata/fn-render/resource-has-pkgname-prefix/wordpress-deployment.yaml b/e2e/testdata/fn-render/resource-has-pkgname-prefix/wordpress-deployment.yaml index d018dfaf35..0d53f68d47 100644 --- a/e2e/testdata/fn-render/resource-has-pkgname-prefix/wordpress-deployment.yaml +++ b/e2e/testdata/fn-render/resource-has-pkgname-prefix/wordpress-deployment.yaml @@ -1,81 +1,81 @@ -# Copyright 2019 The kpt Authors -# -# 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: v1 -kind: Service -metadata: - name: wordpress - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} -spec: - type: LoadBalancer - selector: - app: wordpress - tier: frontend - ports: - - port: 80 ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: wp-pv-claim - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} -spec: - resources: - requests: - storage: 20Gi - accessModes: - - ReadWriteOnce ---- -apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 -kind: Deployment -metadata: - name: wordpress - annotations: - projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} - teamname: 'YOURTEAM' # kpt-set: ${teamname} -spec: - selector: - matchLabels: - app: wordpress - tier: frontend - template: - metadata: - labels: - app: wordpress - tier: frontend - spec: - containers: - - name: wordpress - image: wordpress:4.8-apache # kpt-set: ${wp-image}:${wp-tag} - ports: - - name: wordpress - containerPort: 80 - env: - - name: WORDPRESS_DB_HOST - value: wordpress-mysql - - name: WORDPRESS_DB_PASSWORD - valueFrom: - secretKeyRef: - name: mysql-pass - key: password - volumeMounts: - - name: wordpress-persistent-storage - mountPath: /var/www/html - volumes: - - name: wordpress-persistent-storage - persistentVolumeClaim: - claimName: wp-pv-claim - strategy: - type: Recreate +# Copyright 2019 The kpt Authors +# +# 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: v1 +kind: Service +metadata: + name: wordpress + annotations: + projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} + teamname: 'YOURTEAM' # kpt-set: ${teamname} +spec: + type: LoadBalancer + selector: + app: wordpress + tier: frontend + ports: + - port: 80 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: wp-pv-claim + annotations: + projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} + teamname: 'YOURTEAM' # kpt-set: ${teamname} +spec: + resources: + requests: + storage: 20Gi + accessModes: + - ReadWriteOnce +--- +apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 +kind: Deployment +metadata: + name: wordpress + annotations: + projectId: 'PROJECT_ID' # kpt-set: ${gcloud.core.project} + teamname: 'YOURTEAM' # kpt-set: ${teamname} +spec: + selector: + matchLabels: + app: wordpress + tier: frontend + template: + metadata: + labels: + app: wordpress + tier: frontend + spec: + containers: + - name: wordpress + image: wordpress:4.8-apache # kpt-set: ${wp-image}:${wp-tag} + ports: + - name: wordpress + containerPort: 80 + env: + - name: WORDPRESS_DB_HOST + value: wordpress-mysql + - name: WORDPRESS_DB_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-pass + key: password + volumeMounts: + - name: wordpress-persistent-storage + mountPath: /var/www/html + volumes: + - name: wordpress-persistent-storage + persistentVolumeClaim: + claimName: wp-pv-claim + strategy: + type: Recreate diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/diff.patch index b0b6b3e100..c39c5aca8e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.expected/diff.patch @@ -1,30 +1,65 @@ diff --git a/Kptfile b/Kptfile -index ec2c042..d795f4f 100644 +index 03e022b..0676899 100755 --- a/Kptfile +++ b/Kptfile -@@ -4,7 +4,9 @@ metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" +@@ -1,18 +1,19 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: save-on-render-failure +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 +- configMap: +- app: myapp +- - image: invalid-image:v0.0.0 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" + app: myapp - name: save-on-render-failure -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ name: save-on-render-failure ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 ++ configMap: ++ app: myapp ++ - image: invalid-image:v0.0.0 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index 0848ba0..7eece9b 100644 +index 65cd534..7eece9b 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -2,5 +2,12 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,6 +1,13 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: nginx-deployment +-spec: +- replicas: 3 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: nginx-deployment + annotations: + app: myapp + namespace: staging - spec: - replicas: 3 ++spec: ++ replicas: 3 + template: + metadata: + annotations: diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile index 223faf01af..03e022b0ba 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/Kptfile @@ -1,18 +1,18 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: save-on-render-failure -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 - configMap: - app: myapp - - image: invalid-image:v0.0.0 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: save-on-render-failure +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 + configMap: + app: myapp + - image: invalid-image:v0.0.0 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/resources.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/resources.yaml index 0848ba0e21..65cd5343a9 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/resources.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-basicpipeline/resources.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment -spec: - replicas: 3 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/diff.patch index 3efb8adbb5..38708e516a 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.expected/diff.patch @@ -1,85 +1,154 @@ diff --git a/Kptfile b/Kptfile -index dbd6541..bc4fd2d 100644 +index 1e9f852..bc4fd2d 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,10 +5,12 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-deep-nested-middle-fails +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-deep-nested-middle-fails +-info: +- description: BFS - Deep nested, middle level fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- level: "root" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-deep-nested-middle-fails + labels: + level: root - info: - description: BFS - Deep nested, middle level fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- level: "root" ++info: ++ description: BFS - Deep nested, middle level fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + level: root diff --git a/configmap.yaml b/configmap.yaml -index 59bb817..19a7ead 100644 +index d6381d9..19a7ead 100755 --- a/configmap.yaml +++ b/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: root-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- level: root ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config + labels: + level: root - data: - level: root ++data: ++ level: root diff --git a/level1/Kptfile b/level1/Kptfile -index b5960dd..b42f153 100644 +index 141c89b..b42f153 100755 --- a/level1/Kptfile +++ b/level1/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: level1 +@@ -1,13 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: level1 +-info: +- description: Level1 with failing validator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- level: level1 +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: level1 + labels: + level: level1 - info: - description: Level1 with failing validator - pipeline: ++info: ++ description: Level1 with failing validator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ level: level1 ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/level1/configmap.yaml b/level1/configmap.yaml -index 57d3b69..10a2e13 100644 +index 3d47190..10a2e13 100755 --- a/level1/configmap.yaml +++ b/level1/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: level1-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: level1-config +-data: +- level: level1 ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: level1-config + labels: + level: level1 - data: - level: level1 ++data: ++ level: level1 diff --git a/level1/level2/Kptfile b/level1/level2/Kptfile -index 314d402..29e69db 100644 +index 378b725..29e69db 100755 --- a/level1/level2/Kptfile +++ b/level1/level2/Kptfile -@@ -2,10 +2,12 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: level2 +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: level2 +-info: +- description: Level2 that succeeds +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- level: "level2" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: level2 + labels: + level: level1 - info: - description: Level2 that succeeds - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- level: "level2" ++info: ++ description: Level2 that succeeds ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + level: level2 diff --git a/level1/level2/configmap.yaml b/level1/level2/configmap.yaml -index ab7d3fa..1eeeaed 100644 +index b9bc0d1..1eeeaed 100755 --- a/level1/level2/configmap.yaml +++ b/level1/level2/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: level2-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: level2-config +-data: +- level: level2 ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: level2-config + labels: + level: level1 - data: - level: level2 ++data: ++ level: level2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/Kptfile index dbd6541cc7..1e9f852fed 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-deep-nested-middle-fails -info: - description: BFS - Deep nested, middle level fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - level: "root" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-deep-nested-middle-fails +info: + description: BFS - Deep nested, middle level fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + level: "root" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/configmap.yaml index 59bb817db7..d6381d95df 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - level: root +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + level: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/Kptfile index b5960dd7a7..141c89bf34 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: level1 -info: - description: Level1 with failing validator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - level: level1 - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: level1 +info: + description: Level1 with failing validator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + level: level1 + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/configmap.yaml index 57d3b69a93..3d47190987 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: level1-config -data: - level: level1 +apiVersion: v1 +kind: ConfigMap +metadata: + name: level1-config +data: + level: level1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/Kptfile index 314d40223e..378b725307 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: level2 -info: - description: Level2 that succeeds -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - level: "level2" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: level2 +info: + description: Level2 that succeeds +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + level: "level2" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/configmap.yaml index ab7d3fa161..b9bc0d16c0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-deep-nested-middle-fails/level1/level2/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: level2-config -data: - level: level2 +apiVersion: v1 +kind: ConfigMap +metadata: + name: level2-config +data: + level: level2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/diff.patch index 8a582dcd77..bbee61e0fb 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.expected/diff.patch @@ -1,56 +1,105 @@ diff --git a/Kptfile b/Kptfile -index e9fad85..1b08a62 100644 +index 88ee27c..1b08a62 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,6 +5,8 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-multiple-subpkgs-one-fails +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-multiple-subpkgs-one-fails +-info: +- description: BFS - Multiple subpackages, sub2 fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: root ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-multiple-subpkgs-one-fails + labels: + pkg: root - info: - description: BFS - Multiple subpackages, sub2 fails - pipeline: ++info: ++ description: BFS - Multiple subpackages, sub2 fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: root diff --git a/service.yaml b/service.yaml -index 9148b9b..2e551c8 100644 +index dada970..2e551c8 100755 --- a/service.yaml +++ b/service.yaml -@@ -2,6 +2,10 @@ apiVersion: v1 - kind: Service - metadata: - name: root-service +@@ -1,7 +1,11 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: root-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: root-service + labels: + pkg: root - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + pkg: root diff --git a/sub1/Kptfile b/sub1/Kptfile -index 2d62077..0f03268 100644 +index b3d9bcf..0f03268 100755 --- a/sub1/Kptfile +++ b/sub1/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: sub1 +@@ -1,9 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: sub1 +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: sub1 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: sub1 + labels: + pkg: sub1 - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: sub1 diff --git a/sub1/deployment.yaml b/sub1/deployment.yaml -index 2f649ba..c2245a9 100644 +index 16fcb85..c2245a9 100755 --- a/sub1/deployment.yaml +++ b/sub1/deployment.yaml -@@ -2,5 +2,14 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub1-deployment +@@ -1,6 +1,15 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub1-deployment +-spec: +- replicas: 1 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub1-deployment + labels: + pkg: sub1 - spec: - replicas: 1 ++spec: ++ replicas: 1 + selector: + matchLabels: + pkg: sub1 @@ -59,30 +108,53 @@ index 2f649ba..c2245a9 100644 + labels: + pkg: sub1 diff --git a/sub2/Kptfile b/sub2/Kptfile -index 792277c..6412843 100644 +index 8a4836b..6412843 100755 --- a/sub2/Kptfile +++ b/sub2/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: sub2 +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: sub2 +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: sub2 +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: sub2 + labels: + pkg: sub2 - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: sub2 ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/sub2/deployment.yaml b/sub2/deployment.yaml -index 20375ea..7290360 100644 +index 16bb7f0..7290360 100755 --- a/sub2/deployment.yaml +++ b/sub2/deployment.yaml -@@ -2,5 +2,14 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub2-deployment +@@ -1,6 +1,15 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub2-deployment +-spec: +- replicas: 2 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub2-deployment + labels: + pkg: sub2 - spec: - replicas: 2 ++spec: ++ replicas: 2 + selector: + matchLabels: + pkg: sub2 @@ -91,30 +163,49 @@ index 20375ea..7290360 100644 + labels: + pkg: sub2 diff --git a/sub3/Kptfile b/sub3/Kptfile -index ff35b98..958a351 100644 +index fad2e95..958a351 100755 --- a/sub3/Kptfile +++ b/sub3/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: sub3 +@@ -1,9 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: sub3 +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: sub3 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: sub3 + labels: + pkg: root - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: sub3 diff --git a/sub3/deployment.yaml b/sub3/deployment.yaml -index dc257b3..3a13d11 100644 +index eb51b87..3a13d11 100755 --- a/sub3/deployment.yaml +++ b/sub3/deployment.yaml -@@ -2,5 +2,14 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub3-deployment +@@ -1,6 +1,15 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub3-deployment +-spec: +- replicas: 3 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub3-deployment + labels: + pkg: root - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + pkg: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/Kptfile index e9fad85916..88ee27cf00 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-multiple-subpkgs-one-fails -info: - description: BFS - Multiple subpackages, sub2 fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: root +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-multiple-subpkgs-one-fails +info: + description: BFS - Multiple subpackages, sub2 fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/service.yaml index 9148b9b3ae..dada970279 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: root-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: root-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/Kptfile index 2d62077ee1..b3d9bcfb42 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: sub1 -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: sub1 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: sub1 +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: sub1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/deployment.yaml index 2f649ba024..16fcb85a25 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub1/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub1-deployment -spec: - replicas: 1 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub1-deployment +spec: + replicas: 1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/Kptfile index 792277c2b0..8a4836b89c 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: sub2 -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: sub2 - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: sub2 +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: sub2 + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/deployment.yaml index 20375eac1e..16bb7f09a8 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub2/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub2-deployment -spec: - replicas: 2 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub2-deployment +spec: + replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/Kptfile index ff35b980cf..fad2e95675 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: sub3 -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: sub3 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: sub3 +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: sub3 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/deployment.yaml index dc257b32ae..eb51b87309 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-multiple-subpkgs-one-fails/sub3/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub3-deployment -spec: - replicas: 3 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub3-deployment +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/diff.patch index 6154172d4a..f45addf426 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.expected/diff.patch @@ -1,53 +1,114 @@ diff --git a/Kptfile b/Kptfile -index cbe756f..a5fa6c0 100644 +index 3694310..a5fa6c0 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,6 +5,8 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-parent-and-subpkg-both-fail +@@ -1,16 +1,18 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-parent-and-subpkg-both-fail +-info: +- description: BFS - Both parent and subpackage fail +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: root +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-parent-and-subpkg-both-fail + labels: + pkg: root - info: - description: BFS - Both parent and subpackage fail - pipeline: ++info: ++ description: BFS - Both parent and subpackage fail ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: root ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/configmap.yaml b/configmap.yaml -index 8594873..a591ceb 100644 +index e8017db..a591ceb 100755 --- a/configmap.yaml +++ b/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: root-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- pkg: root ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config + labels: + pkg: root - data: - pkg: root ++data: ++ pkg: root diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index a332cf5..2a3f05c 100644 +index 0b62901..2a3f05c 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg +@@ -1,13 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage that also fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: subpkg +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + pkg: root - info: - description: Subpackage that also fails - pipeline: ++info: ++ description: Subpackage that also fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: subpkg ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/subpkg/service.yaml b/subpkg/service.yaml -index 276bf9e..d6424da 100644 +index cd6bc70..d6424da 100755 --- a/subpkg/service.yaml +++ b/subpkg/service.yaml -@@ -2,6 +2,10 @@ apiVersion: v1 - kind: Service - metadata: - name: sub-service +@@ -1,7 +1,11 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: sub-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: sub-service + labels: + pkg: root - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + pkg: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/Kptfile index cbe756f987..3694310fa1 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/Kptfile @@ -1,16 +1,16 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-parent-and-subpkg-both-fail -info: - description: BFS - Both parent and subpackage fail -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: root - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-parent-and-subpkg-both-fail +info: + description: BFS - Both parent and subpackage fail +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: root + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/configmap.yaml index 8594873c1f..e8017db0a9 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - pkg: root +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + pkg: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/Kptfile index a332cf57ab..0b62901254 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage that also fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: subpkg - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage that also fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: subpkg + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/service.yaml index 276bf9e88d..cd6bc70c5f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-and-subpkg-both-fail/subpkg/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: sub-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: sub-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/diff.patch index d7619bd383..146507e88d 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.expected/diff.patch @@ -1,59 +1,108 @@ diff --git a/Kptfile b/Kptfile -index c80b904..6954e67 100644 +index 7e481a5..6954e67 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,11 +5,13 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-parent-mutator-fails +@@ -1,15 +1,17 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-parent-mutator-fails +-info: +- description: BFS - Parent mutator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "parent-mutator-fail" +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-parent-mutator-fails + labels: + test: parent-mutator-fail - info: - description: BFS - Parent mutator fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- test: "parent-mutator-fail" ++info: ++ description: BFS - Parent mutator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + test: parent-mutator-fail - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/configmap.yaml b/configmap.yaml -index 20a54f6..a46a12b 100644 +index 4f9a1b3..a46a12b 100755 --- a/configmap.yaml +++ b/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: root-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- key: value ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config + labels: + test: parent-mutator-fail - data: - key: value ++data: ++ key: value diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index e940ae8..e6e678c 100644 +index 24faac6..ed7a995 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage that succeeds +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + test: parent-mutator-fail - info: - description: Subpackage that succeeds - pipeline: ++info: ++ description: Subpackage that succeeds ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns diff --git a/subpkg/service.yaml b/subpkg/service.yaml -index 276bf9e..acfae7a 100644 +index cd6bc70..acfae7a 100755 --- a/subpkg/service.yaml +++ b/subpkg/service.yaml -@@ -2,6 +2,10 @@ apiVersion: v1 - kind: Service - metadata: - name: sub-service +@@ -1,7 +1,11 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: sub-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: sub-service + labels: + test: parent-mutator-fail - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + test: parent-mutator-fail diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/Kptfile index c80b904236..7e481a52c3 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-parent-mutator-fails -info: - description: BFS - Parent mutator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "parent-mutator-fail" - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-parent-mutator-fails +info: + description: BFS - Parent mutator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "parent-mutator-fail" + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/configmap.yaml index 20a54f6725..4f9a1b3de2 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - key: value +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + key: value diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile index fd277c8250..24faac65db 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage that succeeds -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage that succeeds +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/service.yaml index 276bf9e88d..cd6bc70c5f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-mutator-fails/subpkg/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: sub-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: sub-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/diff.patch index 1d8bba0c89..d5e95d462f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.expected/diff.patch @@ -1,60 +1,110 @@ diff --git a/Kptfile b/Kptfile -index 491b12e..8c66fe7 100644 +index d72dbf4..8c66fe7 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,12 +5,14 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-parent-validator-fails +@@ -1,16 +1,18 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-parent-validator-fails +-info: +- description: BFS - Parent validator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "parent-fail" +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-parent-validator-fails + labels: + test: parent-fail - info: - description: BFS - Parent validator fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- test: "parent-fail" ++info: ++ description: BFS - Parent validator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + test: parent-fail - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/configmap.yaml b/configmap.yaml -index 20a54f6..ad595de 100644 +index 4f9a1b3..ad595de 100755 --- a/configmap.yaml +++ b/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: root-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- key: value ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config + labels: + test: parent-fail - data: - key: value ++data: ++ key: value diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index e940ae8..88a8d4e 100644 +index 24faac6..ecbfb69 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage that succeeds +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + test: parent-fail - info: - description: Subpackage that succeeds - pipeline: ++info: ++ description: Subpackage that succeeds ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns diff --git a/subpkg/service.yaml b/subpkg/service.yaml -index 276bf9e..fe08496 100644 +index cd6bc70..fe08496 100755 --- a/subpkg/service.yaml +++ b/subpkg/service.yaml -@@ -2,6 +2,10 @@ apiVersion: v1 - kind: Service - metadata: - name: sub-service +@@ -1,7 +1,11 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: sub-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: sub-service + labels: + test: parent-fail - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + test: parent-fail diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/Kptfile index 491b12e732..d72dbf44f5 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/Kptfile @@ -1,16 +1,16 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-parent-validator-fails -info: - description: BFS - Parent validator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "parent-fail" - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-parent-validator-fails +info: + description: BFS - Parent validator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "parent-fail" + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/configmap.yaml index 20a54f6725..4f9a1b3de2 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - key: value +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + key: value diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile index fd277c8250..24faac65db 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage that succeeds -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage that succeeds +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/service.yaml index 276bf9e88d..cd6bc70c5f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-parent-validator-fails/subpkg/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: sub-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: sub-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/diff.patch index 5c771fd77f..b547a9962a 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.expected/diff.patch @@ -1,33 +1,57 @@ diff --git a/Kptfile b/Kptfile -index 84b93a6..877725d 100644 +index f764615..877725d 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,10 +5,12 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-subpkg-mutator-fails +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-subpkg-mutator-fails +-info: +- description: BFS - Subpackage mutator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "mutator-fail" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-subpkg-mutator-fails + labels: + test: mutator-fail - info: - description: BFS - Subpackage mutator fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- test: "mutator-fail" ++info: ++ description: BFS - Subpackage mutator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + test: mutator-fail diff --git a/deployment.yaml b/deployment.yaml -index cc866f6..6ed4201 100644 +index d4db082..6ed4201 100755 --- a/deployment.yaml +++ b/deployment.yaml -@@ -2,5 +2,14 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: root-deployment +@@ -1,6 +1,15 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: root-deployment +-spec: +- replicas: 1 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: root-deployment + labels: + test: mutator-fail - spec: - replicas: 1 ++spec: ++ replicas: 1 + selector: + matchLabels: + test: mutator-fail @@ -36,32 +60,56 @@ index cc866f6..6ed4201 100644 + labels: + test: mutator-fail diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index ec4ce38..82fcf74 100644 +index ae05dfe..19e913c 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage with failing mutator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + test: mutator-fail -+ namespace: subpkg-ns - info: - description: Subpackage with failing mutator - pipeline: ++info: ++ description: Subpackage with failing mutator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/subpkg/deployment.yaml b/subpkg/deployment.yaml -index 302322e..546fe5c 100644 +index 1c4bc07..546fe5c 100755 --- a/subpkg/deployment.yaml +++ b/subpkg/deployment.yaml -@@ -2,5 +2,15 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub-deployment +@@ -1,6 +1,16 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub-deployment +-spec: +- replicas: 2 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub-deployment + labels: + test: mutator-fail + namespace: subpkg-ns - spec: - replicas: 2 ++spec: ++ replicas: 2 + selector: + matchLabels: + test: mutator-fail diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/Kptfile index 84b93a6de8..f764615a4b 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-subpkg-mutator-fails -info: - description: BFS - Subpackage mutator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "mutator-fail" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-subpkg-mutator-fails +info: + description: BFS - Subpackage mutator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "mutator-fail" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/deployment.yaml index cc866f632d..d4db082c02 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: root-deployment -spec: - replicas: 1 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: root-deployment +spec: + replicas: 1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile index 65639042a0..ae05dfe102 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage with failing mutator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage with failing mutator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/deployment.yaml index 302322e59d..1c4bc07520 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-mutator-fails/subpkg/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub-deployment -spec: - replicas: 2 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub-deployment +spec: + replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/diff.patch index c18f86ccf4..01c847c77d 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.expected/diff.patch @@ -1,37 +1,63 @@ diff --git a/Kptfile b/Kptfile -index 86dbe13..c5c38b8 100644 +index 4464df0..c5c38b8 100755 --- a/Kptfile +++ b/Kptfile -@@ -5,11 +5,14 @@ metadata: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-subpkg-validator-fails +@@ -1,15 +1,18 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/bfs-rendering: "true" +- kpt.dev/save-on-render-failure: "true" +- name: bfs-subpkg-validator-fails +-info: +- description: BFS - Subpackage validator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "subpkg-fail" +- level: "root" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/bfs-rendering: "true" ++ kpt.dev/save-on-render-failure: "true" ++ name: bfs-subpkg-validator-fails + labels: + level: root + test: subpkg-fail - info: - description: BFS - Subpackage validator fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- test: "subpkg-fail" -- level: "root" ++info: ++ description: BFS - Subpackage validator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + test: subpkg-fail + level: root diff --git a/deployment.yaml b/deployment.yaml -index 7123634..4db6211 100644 +index 8ae7b44..4db6211 100755 --- a/deployment.yaml +++ b/deployment.yaml -@@ -3,5 +3,17 @@ kind: Deployment - metadata: - name: root-deployment - namespace: default +@@ -1,7 +1,19 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: root-deployment +- namespace: default +-spec: +- replicas: 1 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: root-deployment ++ namespace: default + labels: + level: root + test: subpkg-fail - spec: - replicas: 1 ++spec: ++ replicas: 1 + selector: + matchLabels: + level: root @@ -42,34 +68,60 @@ index 7123634..4db6211 100644 + level: root + test: subpkg-fail diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index f147d84..15fd450 100644 +index ea45393..edd5b30 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg +@@ -1,13 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage with failing validator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + level: root + test: subpkg-fail -+ namespace: subpkg-ns - info: - description: Subpackage with failing validator - pipeline: ++info: ++ description: Subpackage with failing validator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/subpkg/deployment.yaml b/subpkg/deployment.yaml -index 302322e..dfe3056 100644 +index 1c4bc07..dfe3056 100755 --- a/subpkg/deployment.yaml +++ b/subpkg/deployment.yaml -@@ -2,5 +2,18 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub-deployment +@@ -1,6 +1,19 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub-deployment +-spec: +- replicas: 2 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub-deployment + labels: + level: root + test: subpkg-fail + namespace: subpkg-ns - spec: - replicas: 2 ++spec: ++ replicas: 2 + selector: + matchLabels: + level: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/Kptfile index 86dbe130e7..4464df08f8 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/bfs-rendering: "true" - kpt.dev/save-on-render-failure: "true" - name: bfs-subpkg-validator-fails -info: - description: BFS - Subpackage validator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "subpkg-fail" - level: "root" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/bfs-rendering: "true" + kpt.dev/save-on-render-failure: "true" + name: bfs-subpkg-validator-fails +info: + description: BFS - Subpackage validator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "subpkg-fail" + level: "root" diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/deployment.yaml index 7123634a2f..8ae7b445a6 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/deployment.yaml @@ -1,7 +1,7 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: root-deployment - namespace: default -spec: - replicas: 1 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: root-deployment + namespace: default +spec: + replicas: 1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile index 7dd3a25143..ea453931d0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage with failing validator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage with failing validator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/deployment.yaml index 302322e59d..1c4bc07520 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/bfs-subpkg-validator-fails/subpkg/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub-deployment -spec: - replicas: 2 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub-deployment +spec: + replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/diff.patch index 92754c2fd1..4a14656a63 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.expected/diff.patch @@ -1,30 +1,63 @@ diff --git a/Kptfile b/Kptfile -index c6fc0c5..1631bfb 100644 +index c14bf3d..666665a 100755 --- a/Kptfile +++ b/Kptfile -@@ -3,7 +3,9 @@ kind: Kptfile - metadata: - annotations: - kpt.dev/save-on-render-failure: "true" +@@ -1,17 +1,18 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: save-on-render-failure +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 +- configMap: +- app: myapp +- - image: invalid-image:v0.0.0 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" + app: myapp - name: save-on-render-failure -+ namespace: staging - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++ name: save-on-render-failure ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 ++ configMap: ++ app: myapp ++ - image: invalid-image:v0.0.0 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index 0848ba0..7eece9b 100644 +index 65cd534..7eece9b 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -2,5 +2,12 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,6 +1,13 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: nginx-deployment +-spec: +- replicas: 3 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: nginx-deployment + annotations: + app: myapp + namespace: staging - spec: - replicas: 3 ++spec: ++ replicas: 3 + template: + metadata: + annotations: diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile index 2dafd970cb..c14bf3dd07 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/Kptfile @@ -1,17 +1,17 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: save-on-render-failure -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 - configMap: - app: myapp - - image: invalid-image:v0.0.0 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: save-on-render-failure +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 + configMap: + app: myapp + - image: invalid-image:v0.0.0 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/resources.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/resources.yaml index 0848ba0e21..65cd5343a9 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/resources.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-basicpipeline/resources.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment -spec: - replicas: 3 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/diff.patch index a4012da01e..fc75ced941 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.expected/diff.patch @@ -1,55 +1,148 @@ +diff --git a/Kptfile b/Kptfile +index 9f5d352..4047d27 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,13 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-deep-nested-middle-fails +-info: +- description: DFS - Deep nested, middle level fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- level: "root" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-deep-nested-middle-fails ++info: ++ description: DFS - Deep nested, middle level fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ level: "root" +diff --git a/configmap.yaml b/configmap.yaml +index d6381d9..59bb817 100755 +--- a/configmap.yaml ++++ b/configmap.yaml +@@ -1,6 +1,6 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- level: root ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config ++data: ++ level: root diff --git a/level1/Kptfile b/level1/Kptfile -index b5960dd..b42f153 100644 +index 141c89b..b42f153 100755 --- a/level1/Kptfile +++ b/level1/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: level1 +@@ -1,13 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: level1 +-info: +- description: Level1 with failing validator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- level: level1 +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: level1 + labels: + level: level1 - info: - description: Level1 with failing validator - pipeline: ++info: ++ description: Level1 with failing validator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ level: level1 ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/level1/configmap.yaml b/level1/configmap.yaml -index 57d3b69..10a2e13 100644 +index 3d47190..10a2e13 100755 --- a/level1/configmap.yaml +++ b/level1/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: level1-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: level1-config +-data: +- level: level1 ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: level1-config + labels: + level: level1 - data: - level: level1 ++data: ++ level: level1 diff --git a/level1/level2/Kptfile b/level1/level2/Kptfile -index 314d402..29e69db 100644 +index 378b725..29e69db 100755 --- a/level1/level2/Kptfile +++ b/level1/level2/Kptfile -@@ -2,10 +2,12 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: level2 +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: level2 +-info: +- description: Level2 that succeeds +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- level: "level2" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: level2 + labels: + level: level1 - info: - description: Level2 that succeeds - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- level: "level2" ++info: ++ description: Level2 that succeeds ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + level: level2 diff --git a/level1/level2/configmap.yaml b/level1/level2/configmap.yaml -index ab7d3fa..1eeeaed 100644 +index b9bc0d1..1eeeaed 100755 --- a/level1/level2/configmap.yaml +++ b/level1/level2/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: level2-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: level2-config +-data: +- level: level2 ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: level2-config + labels: + level: level1 - data: - level: level2 ++data: ++ level: level2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/Kptfile index 4047d2778b..9f5d352998 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-deep-nested-middle-fails -info: - description: DFS - Deep nested, middle level fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - level: "root" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-deep-nested-middle-fails +info: + description: DFS - Deep nested, middle level fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + level: "root" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/configmap.yaml index 59bb817db7..d6381d95df 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - level: root +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + level: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/Kptfile index b5960dd7a7..141c89bf34 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: level1 -info: - description: Level1 with failing validator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - level: level1 - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: level1 +info: + description: Level1 with failing validator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + level: level1 + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/configmap.yaml index 57d3b69a93..3d47190987 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: level1-config -data: - level: level1 +apiVersion: v1 +kind: ConfigMap +metadata: + name: level1-config +data: + level: level1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/Kptfile index 314d40223e..378b725307 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: level2 -info: - description: Level2 that succeeds -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - level: "level2" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: level2 +info: + description: Level2 that succeeds +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + level: "level2" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/configmap.yaml index ab7d3fa161..b9bc0d16c0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-deep-nested-middle-fails/level1/level2/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: level2-config -data: - level: level2 +apiVersion: v1 +kind: ConfigMap +metadata: + name: level2-config +data: + level: level2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/diff.patch index 70def2baa5..6e3d489bb7 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.expected/diff.patch @@ -1,28 +1,97 @@ +diff --git a/Kptfile b/Kptfile +index 291b91b..c47c90d 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,13 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-multiple-subpkgs-one-fails +-info: +- description: DFS - Multiple subpackages, sub2 fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: root ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-multiple-subpkgs-one-fails ++info: ++ description: DFS - Multiple subpackages, sub2 fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: root +diff --git a/service.yaml b/service.yaml +index dada970..9148b9b 100755 +--- a/service.yaml ++++ b/service.yaml +@@ -1,7 +1,7 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: root-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: root-service ++spec: ++ ports: ++ - port: 80 diff --git a/sub1/Kptfile b/sub1/Kptfile -index 2d62077..0f03268 100644 +index b3d9bcf..0f03268 100755 --- a/sub1/Kptfile +++ b/sub1/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: sub1 +@@ -1,9 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: sub1 +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: sub1 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: sub1 + labels: + pkg: sub1 - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: sub1 diff --git a/sub1/deployment.yaml b/sub1/deployment.yaml -index 2f649ba..c2245a9 100644 +index 16fcb85..c2245a9 100755 --- a/sub1/deployment.yaml +++ b/sub1/deployment.yaml -@@ -2,5 +2,14 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub1-deployment +@@ -1,6 +1,15 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub1-deployment +-spec: +- replicas: 1 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub1-deployment + labels: + pkg: sub1 - spec: - replicas: 1 ++spec: ++ replicas: 1 + selector: + matchLabels: + pkg: sub1 @@ -31,30 +100,53 @@ index 2f649ba..c2245a9 100644 + labels: + pkg: sub1 diff --git a/sub2/Kptfile b/sub2/Kptfile -index 792277c..6412843 100644 +index 8a4836b..6412843 100755 --- a/sub2/Kptfile +++ b/sub2/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: sub2 +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: sub2 +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: sub2 +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: sub2 + labels: + pkg: sub2 - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: sub2 ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/sub2/deployment.yaml b/sub2/deployment.yaml -index 20375ea..7290360 100644 +index 16bb7f0..7290360 100755 --- a/sub2/deployment.yaml +++ b/sub2/deployment.yaml -@@ -2,5 +2,14 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub2-deployment +@@ -1,6 +1,15 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub2-deployment +-spec: +- replicas: 2 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub2-deployment + labels: + pkg: sub2 - spec: - replicas: 2 ++spec: ++ replicas: 2 + selector: + matchLabels: + pkg: sub2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/Kptfile index c47c90d51f..291b91b394 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-multiple-subpkgs-one-fails -info: - description: DFS - Multiple subpackages, sub2 fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: root +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-multiple-subpkgs-one-fails +info: + description: DFS - Multiple subpackages, sub2 fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/service.yaml index 9148b9b3ae..dada970279 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: root-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: root-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/Kptfile index 2d62077ee1..b3d9bcfb42 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: sub1 -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: sub1 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: sub1 +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: sub1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/deployment.yaml index 2f649ba024..16fcb85a25 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub1/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub1-deployment -spec: - replicas: 1 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub1-deployment +spec: + replicas: 1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/Kptfile index 792277c2b0..8a4836b89c 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: sub2 -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: sub2 - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: sub2 +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: sub2 + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/deployment.yaml index 20375eac1e..16bb7f09a8 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub2/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub2-deployment -spec: - replicas: 2 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub2-deployment +spec: + replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/Kptfile index ff35b980cf..fad2e95675 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: sub3 -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: sub3 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: sub3 +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: sub3 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/deployment.yaml index dc257b32ae..eb51b87309 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-multiple-subpkgs-one-fails/sub3/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub3-deployment -spec: - replicas: 3 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub3-deployment +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/diff.patch index e2923d8d42..66f69399b0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.expected/diff.patch @@ -1,28 +1,108 @@ +diff --git a/Kptfile b/Kptfile +index cebfd3e..e4d630d 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,15 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-parent-and-subpkg-both-fail +-info: +- description: DFS - Both parent and subpackage fail +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: root +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-parent-and-subpkg-both-fail ++info: ++ description: DFS - Both parent and subpackage fail ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: root ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +diff --git a/configmap.yaml b/configmap.yaml +index e8017db..8594873 100755 +--- a/configmap.yaml ++++ b/configmap.yaml +@@ -1,6 +1,6 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- pkg: root ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config ++data: ++ pkg: root diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index a332cf5..cb45834 100644 +index 0b62901..cb45834 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg +@@ -1,13 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage that also fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- pkg: subpkg +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + pkg: subpkg - info: - description: Subpackage that also fails - pipeline: ++info: ++ description: Subpackage that also fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ pkg: subpkg ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/subpkg/service.yaml b/subpkg/service.yaml -index 276bf9e..7b26a8d 100644 +index cd6bc70..7b26a8d 100755 --- a/subpkg/service.yaml +++ b/subpkg/service.yaml -@@ -2,6 +2,10 @@ apiVersion: v1 - kind: Service - metadata: - name: sub-service +@@ -1,7 +1,11 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: sub-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: sub-service + labels: + pkg: subpkg - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + pkg: subpkg diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/Kptfile index e4d630ddc7..cebfd3e305 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-parent-and-subpkg-both-fail -info: - description: DFS - Both parent and subpackage fail -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: root - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-parent-and-subpkg-both-fail +info: + description: DFS - Both parent and subpackage fail +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: root + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/configmap.yaml index 8594873c1f..e8017db0a9 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - pkg: root +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + pkg: root diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/Kptfile index a332cf57ab..0b62901254 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage that also fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - pkg: subpkg - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage that also fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + pkg: subpkg + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/service.yaml index 276bf9e88d..cd6bc70c5f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-and-subpkg-both-fail/subpkg/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: sub-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: sub-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/diff.patch index 0c15742529..bfa8fc7d9e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.expected/diff.patch @@ -1,61 +1,107 @@ diff --git a/Kptfile b/Kptfile -index c134b37..32d759a 100644 +index 22b3c38..32d759a 100755 --- a/Kptfile +++ b/Kptfile -@@ -4,11 +4,13 @@ metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-parent-mutator-fails +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-parent-mutator-fails +-info: +- description: DFS - Parent mutator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "parent-mutator-fail" +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-parent-mutator-fails + labels: + test: parent-mutator-fail - info: - description: DFS - Parent mutator fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- test: "parent-mutator-fail" ++info: ++ description: DFS - Parent mutator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + test: parent-mutator-fail - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/configmap.yaml b/configmap.yaml -index 20a54f6..a46a12b 100644 +index 4f9a1b3..a46a12b 100755 --- a/configmap.yaml +++ b/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: root-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- key: value ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config + labels: + test: parent-mutator-fail - data: - key: value ++data: ++ key: value diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index e940ae8..9b73f07 100644 +index 24faac6..ed7a995 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg -+ namespace: subpkg-ns +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage that succeeds +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + test: parent-mutator-fail - info: - description: Subpackage that succeeds - pipeline: ++info: ++ description: Subpackage that succeeds ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns diff --git a/subpkg/service.yaml b/subpkg/service.yaml -index 276bf9e..571e684 100644 +index cd6bc70..571e684 100755 --- a/subpkg/service.yaml +++ b/subpkg/service.yaml -@@ -2,6 +2,11 @@ apiVersion: v1 - kind: Service - metadata: - name: sub-service +@@ -1,7 +1,12 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: sub-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: sub-service + namespace: subpkg-ns + labels: + test: parent-mutator-fail - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + test: parent-mutator-fail diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/Kptfile index c134b37717..22b3c389ea 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-parent-mutator-fails -info: - description: DFS - Parent mutator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "parent-mutator-fail" - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-parent-mutator-fails +info: + description: DFS - Parent mutator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "parent-mutator-fail" + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/configmap.yaml index 20a54f6725..4f9a1b3de2 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - key: value +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + key: value diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile index fd277c8250..24faac65db 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage that succeeds -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage that succeeds +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/service.yaml index 276bf9e88d..cd6bc70c5f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-mutator-fails/subpkg/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: sub-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: sub-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/diff.patch index cfdb9a036b..3c80f5d88b 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.expected/diff.patch @@ -1,62 +1,109 @@ diff --git a/Kptfile b/Kptfile -index 94a7a73..8581173 100644 +index 49f89a8..8581173 100755 --- a/Kptfile +++ b/Kptfile -@@ -4,12 +4,14 @@ metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-parent-validator-fails +@@ -1,15 +1,17 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-parent-validator-fails +-info: +- description: DFS - Parent validator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "parent-fail" +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-parent-validator-fails + labels: + test: parent-fail - info: - description: DFS - Parent validator fails - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: -- test: "parent-fail" ++info: ++ description: DFS - Parent validator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: + test: parent-fail - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/configmap.yaml b/configmap.yaml -index 20a54f6..ad595de 100644 +index 4f9a1b3..ad595de 100755 --- a/configmap.yaml +++ b/configmap.yaml -@@ -2,5 +2,7 @@ apiVersion: v1 - kind: ConfigMap - metadata: - name: root-config +@@ -1,6 +1,8 @@ +-apiVersion: v1 +-kind: ConfigMap +-metadata: +- name: root-config +-data: +- key: value ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: root-config + labels: + test: parent-fail - data: - key: value ++data: ++ key: value diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index e940ae8..a2fe9c5 100644 +index 24faac6..ecbfb69 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg -+ namespace: subpkg-ns +@@ -1,11 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage that succeeds +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg + labels: + test: parent-fail - info: - description: Subpackage that succeeds - pipeline: ++info: ++ description: Subpackage that succeeds ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns diff --git a/subpkg/service.yaml b/subpkg/service.yaml -index 276bf9e..3ba5cae 100644 +index cd6bc70..3ba5cae 100755 --- a/subpkg/service.yaml +++ b/subpkg/service.yaml -@@ -2,6 +2,11 @@ apiVersion: v1 - kind: Service - metadata: - name: sub-service +@@ -1,7 +1,12 @@ +-apiVersion: v1 +-kind: Service +-metadata: +- name: sub-service +-spec: +- ports: +- - port: 80 ++apiVersion: v1 ++kind: Service ++metadata: ++ name: sub-service + namespace: subpkg-ns + labels: + test: parent-fail - spec: - ports: - - port: 80 ++spec: ++ ports: ++ - port: 80 + selector: + test: parent-fail diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/Kptfile index 94a7a73ca7..49f89a89b4 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-parent-validator-fails -info: - description: DFS - Parent validator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "parent-fail" - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-parent-validator-fails +info: + description: DFS - Parent validator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "parent-fail" + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/configmap.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/configmap.yaml index 20a54f6725..4f9a1b3de2 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/configmap.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/configmap.yaml @@ -1,6 +1,6 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-config -data: - key: value +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-config +data: + key: value diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile index fd277c8250..24faac65db 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage that succeeds -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage that succeeds +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/service.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/service.yaml index 276bf9e88d..cd6bc70c5f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/service.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-parent-validator-fails/subpkg/service.yaml @@ -1,7 +1,7 @@ -apiVersion: v1 -kind: Service -metadata: - name: sub-service -spec: - ports: - - port: 80 +apiVersion: v1 +kind: Service +metadata: + name: sub-service +spec: + ports: + - port: 80 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/diff.patch index 24433c71d9..60fe53745d 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.expected/diff.patch @@ -1,23 +1,95 @@ +diff --git a/Kptfile b/Kptfile +index 368e39e..80aa788 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,13 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-subpkg-mutator-fails +-info: +- description: DFS - Subpackage mutator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "mutator-fail" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-subpkg-mutator-fails ++info: ++ description: DFS - Subpackage mutator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ test: "mutator-fail" +diff --git a/deployment.yaml b/deployment.yaml +index d4db082..cc866f6 100755 +--- a/deployment.yaml ++++ b/deployment.yaml +@@ -1,6 +1,6 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: root-deployment +-spec: +- replicas: 1 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: root-deployment ++spec: ++ replicas: 1 diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index ec4ce38..d7ac408 100644 +index ae05dfe..6563904 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg -+ namespace: subpkg-ns - info: - description: Subpackage with failing mutator - pipeline: +@@ -1,12 +1,12 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage with failing mutator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg ++info: ++ description: Subpackage with failing mutator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/subpkg/deployment.yaml b/subpkg/deployment.yaml -index 302322e..98ff830 100644 +index 1c4bc07..98ff830 100755 --- a/subpkg/deployment.yaml +++ b/subpkg/deployment.yaml -@@ -2,5 +2,6 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub-deployment +@@ -1,6 +1,7 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub-deployment +-spec: +- replicas: 2 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub-deployment + namespace: subpkg-ns - spec: - replicas: 2 ++spec: ++ replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/Kptfile index 80aa788235..368e39ea6a 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-subpkg-mutator-fails -info: - description: DFS - Subpackage mutator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "mutator-fail" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-subpkg-mutator-fails +info: + description: DFS - Subpackage mutator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "mutator-fail" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/deployment.yaml index cc866f632d..d4db082c02 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: root-deployment -spec: - replicas: 1 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: root-deployment +spec: + replicas: 1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile index 65639042a0..ae05dfe102 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage with failing mutator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage with failing mutator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/deployment.yaml index 302322e59d..1c4bc07520 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-mutator-fails/subpkg/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub-deployment -spec: - replicas: 2 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub-deployment +spec: + replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/config.yaml index 2eba311bad..a5425c3d09 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/config.yaml @@ -1,2 +1,2 @@ -exitCode: 1 -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/diff.patch b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/diff.patch index 0fdd10dee3..74112c94db 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/diff.patch +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.expected/diff.patch @@ -1,23 +1,101 @@ +diff --git a/Kptfile b/Kptfile +index e08a4a0..7c3b09a 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,14 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- annotations: +- kpt.dev/save-on-render-failure: "true" +- name: dfs-subpkg-validator-fails +-info: +- description: DFS - Subpackage validator fails +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- test: "subpkg-fail" +- level: "root" ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ annotations: ++ kpt.dev/save-on-render-failure: "true" ++ name: dfs-subpkg-validator-fails ++info: ++ description: DFS - Subpackage validator fails ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ test: "subpkg-fail" ++ level: "root" +diff --git a/deployment.yaml b/deployment.yaml +index 8ae7b44..7123634 100755 +--- a/deployment.yaml ++++ b/deployment.yaml +@@ -1,7 +1,7 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: root-deployment +- namespace: default +-spec: +- replicas: 1 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: root-deployment ++ namespace: default ++spec: ++ replicas: 1 diff --git a/subpkg/Kptfile b/subpkg/Kptfile -index f147d84..b3c532e 100644 +index ea45393..7dd3a25 100755 --- a/subpkg/Kptfile +++ b/subpkg/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: subpkg -+ namespace: subpkg-ns - info: - description: Subpackage with failing validator - pipeline: +@@ -1,13 +1,13 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: subpkg +-info: +- description: Subpackage with failing validator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: subpkg-ns +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: subpkg ++info: ++ description: Subpackage with failing validator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: subpkg-ns ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/subpkg/deployment.yaml b/subpkg/deployment.yaml -index 302322e..98ff830 100644 +index 1c4bc07..98ff830 100755 --- a/subpkg/deployment.yaml +++ b/subpkg/deployment.yaml -@@ -2,5 +2,6 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: sub-deployment +@@ -1,6 +1,7 @@ +-apiVersion: apps/v1 +-kind: Deployment +-metadata: +- name: sub-deployment +-spec: +- replicas: 2 ++apiVersion: apps/v1 ++kind: Deployment ++metadata: ++ name: sub-deployment + namespace: subpkg-ns - spec: - replicas: 2 ++spec: ++ replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/Kptfile index 7c3b09a202..e08a4a04c9 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - annotations: - kpt.dev/save-on-render-failure: "true" - name: dfs-subpkg-validator-fails -info: - description: DFS - Subpackage validator fails -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - test: "subpkg-fail" - level: "root" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + annotations: + kpt.dev/save-on-render-failure: "true" + name: dfs-subpkg-validator-fails +info: + description: DFS - Subpackage validator fails +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + test: "subpkg-fail" + level: "root" diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/deployment.yaml index 7123634a2f..8ae7b445a6 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/deployment.yaml @@ -1,7 +1,7 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: root-deployment - namespace: default -spec: - replicas: 1 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: root-deployment + namespace: default +spec: + replicas: 1 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile index 7dd3a25143..ea453931d0 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/Kptfile @@ -1,13 +1,13 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: subpkg -info: - description: Subpackage with failing validator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: subpkg-ns - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: subpkg +info: + description: Subpackage with failing validator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: subpkg-ns + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/invalid-image:v0.0.0 diff --git a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/deployment.yaml b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/deployment.yaml index 302322e59d..1c4bc07520 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/deployment.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/dfs-subpkg-validator-fails/subpkg/deployment.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sub-deployment -spec: - replicas: 2 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sub-deployment +spec: + replicas: 2 diff --git a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.expected/config.yaml b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.expected/config.yaml index 66f4b9726b..ecb575d001 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.expected/config.yaml @@ -1,3 +1,3 @@ -exitCode: 1 -allowNetwork: true -StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" +exitCode: 1 +allowNetwork: true +StdErrRegEx: "(docker: Error response from daemon: Head.*denied|Error.*initializing source docker)" diff --git a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.krmignore b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.krmignore +++ b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile index 0cb6c3e75a..814117f45f 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile +++ b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: no-save-on-render-failure -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 - configMap: - app: myapp - - image: invalid-image:v0.0.0 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: no-save-on-render-failure +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 + configMap: + app: myapp + - image: invalid-image:v0.0.0 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/resources.yaml b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/resources.yaml index 0848ba0e21..65cd5343a9 100644 --- a/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/resources.yaml +++ b/e2e/testdata/fn-render/save-on-render-failure/no-save-on-render-failure/resources.yaml @@ -1,6 +1,6 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment -spec: - replicas: 3 +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml b/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml index 609c132e4a..8001643d38 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/basicpipeline/.expected/config.yaml @@ -1,29 +1,29 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - Package: "basicpipeline" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - Successfully executed 2 function(s) in 1 package(s). - +# Copyright 2021,2026 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + Package: "basicpipeline" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + Successfully executed 2 function(s) in 1 package(s). + diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/.expected/diff.patch b/e2e/testdata/fn-render/selectors/basicpipeline/.expected/diff.patch index b29c072d71..c684843965 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/.expected/diff.patch +++ b/e2e/testdata/fn-render/selectors/basicpipeline/.expected/diff.patch @@ -1,29 +1,93 @@ diff --git a/Kptfile b/Kptfile -index abc7b97..1120263 100644 +index a6932b3..e322be3 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app +@@ -1,15 +1,17 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- selectors: +- - name: nginx-deployment +- kind: Deployment +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ selectors: ++ - name: nginx-deployment ++ kind: Deployment ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index f2eec52..6b5d443 100644 +index 9d1f786..6b5d443 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,24 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -31,12 +95,12 @@ index f2eec52..6b5d443 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/.krmignore b/e2e/testdata/fn-render/selectors/basicpipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/.krmignore +++ b/e2e/testdata/fn-render/selectors/basicpipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile b/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile index 351f2feb05..a6932b3cd7 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile +++ b/e2e/testdata/fn-render/selectors/basicpipeline/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - selectors: - - name: nginx-deployment - kind: Deployment - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + selectors: + - name: nginx-deployment + kind: Deployment + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/selectors/basicpipeline/resources.yaml b/e2e/testdata/fn-render/selectors/basicpipeline/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/selectors/basicpipeline/resources.yaml +++ b/e2e/testdata/fn-render/selectors/basicpipeline/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml b/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml index a606d03525..465269a6c0 100644 --- a/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/exclude/.expected/config.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - Package: "exclude" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 2 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - Successfully executed 2 function(s) in 1 package(s). +# Copyright 2021 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + Package: "exclude" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 2 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/selectors/exclude/.expected/diff.patch b/e2e/testdata/fn-render/selectors/exclude/.expected/diff.patch index 207f384e99..d80f5d0ce6 100644 --- a/e2e/testdata/fn-render/selectors/exclude/.expected/diff.patch +++ b/e2e/testdata/fn-render/selectors/exclude/.expected/diff.patch @@ -1,16 +1,95 @@ +diff --git a/Kptfile b/Kptfile +index 44f6e29..6632e9c 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,17 +1,17 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- selectors: +- - name: nginx-deployment +- kind: Deployment +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend +- exclude: +- - kind: Kptfile ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ selectors: ++ - name: nginx-deployment ++ kind: Deployment ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend ++ exclude: ++ - kind: Kptfile diff --git a/resources.yaml b/resources.yaml -index f2eec52..6b5d443 100644 +index 9d1f786..6b5d443 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,24 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -18,12 +97,12 @@ index f2eec52..6b5d443 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/selectors/exclude/.krmignore b/e2e/testdata/fn-render/selectors/exclude/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/selectors/exclude/.krmignore +++ b/e2e/testdata/fn-render/selectors/exclude/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/selectors/exclude/Kptfile b/e2e/testdata/fn-render/selectors/exclude/Kptfile index 6632e9cd74..44f6e29524 100644 --- a/e2e/testdata/fn-render/selectors/exclude/Kptfile +++ b/e2e/testdata/fn-render/selectors/exclude/Kptfile @@ -1,17 +1,17 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - selectors: - - name: nginx-deployment - kind: Deployment - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend - exclude: - - kind: Kptfile +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + selectors: + - name: nginx-deployment + kind: Deployment + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend + exclude: + - kind: Kptfile diff --git a/e2e/testdata/fn-render/selectors/exclude/resources.yaml b/e2e/testdata/fn-render/selectors/exclude/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/selectors/exclude/resources.yaml +++ b/e2e/testdata/fn-render/selectors/exclude/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml b/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml index 10e7c3733f..2d3a22e5c9 100644 --- a/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/generator/.expected/config.yaml @@ -1,35 +1,35 @@ -# Copyright 2021,2026 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - Package: "generator/db" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - Package: "generator" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - Successfully executed 5 function(s) in 2 package(s). +# Copyright 2021,2026 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + Package: "generator/db" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + Package: "generator" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + Successfully executed 5 function(s) in 2 package(s). diff --git a/e2e/testdata/fn-render/selectors/generator/.expected/diff.patch b/e2e/testdata/fn-render/selectors/generator/.expected/diff.patch index dd1d2c47f0..40bdb6c4e8 100644 --- a/e2e/testdata/fn-render/selectors/generator/.expected/diff.patch +++ b/e2e/testdata/fn-render/selectors/generator/.expected/diff.patch @@ -1,3 +1,81 @@ +diff --git a/Kptfile b/Kptfile +index 8b11afc..15df83b 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,16 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-generator +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- selectors: +- - name: httpbin +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: db +- selectors: +- - name: httpbin ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-generator ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ selectors: ++ - name: httpbin ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: db ++ selectors: ++ - name: httpbin +diff --git a/db/Kptfile b/db/Kptfile +index 61d51d2..913523f 100755 +--- a/db/Kptfile ++++ b/db/Kptfile +@@ -1,18 +1,18 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db +- selectors: +- - name: httpbin +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- app: backend +- selectors: +- - name: httpbin ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db ++ selectors: ++ - name: httpbin ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ app: backend ++ selectors: ++ - name: httpbin diff --git a/db/deployment_httpbin.yaml b/db/deployment_httpbin.yaml new file mode 100644 index 0000000..ffdf484 @@ -29,3 +107,218 @@ index 0000000..ffdf484 + matchLabels: + app: backend + tier: db +diff --git a/db/resources.yaml b/db/resources.yaml +index c9c269b..dabe43c 100755 +--- a/db/resources.yaml ++++ b/db/resources.yaml +@@ -1,19 +1,19 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db ++spec: ++ replicas: 3 +diff --git a/db/starlark-httpbin.yaml b/db/starlark-httpbin.yaml +index 07a7784..e52e48f 100755 +--- a/db/starlark-httpbin.yaml ++++ b/db/starlark-httpbin.yaml +@@ -1,55 +1,55 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- }, +- "spec": { +- "replicas": 4, +- "template": { +- "spec": { +- "containers": [ +- { +- "name": "httpbin", +- "image": "kennethreitz/httpbin", +- "ports": [ +- { +- "containerPort": 9876 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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: |- ++ httpbin_deployment = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ }, ++ "spec": { ++ "replicas": 4, ++ "template": { ++ "spec": { ++ "containers": [ ++ { ++ "name": "httpbin", ++ "image": "kennethreitz/httpbin", ++ "ports": [ ++ { ++ "containerPort": 9876 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment) ++ ++ ensure_httpbin(ctx.resource_list["items"]) +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 diff --git a/e2e/testdata/fn-render/selectors/generator/.krmignore b/e2e/testdata/fn-render/selectors/generator/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/selectors/generator/.krmignore +++ b/e2e/testdata/fn-render/selectors/generator/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/selectors/generator/Kptfile b/e2e/testdata/fn-render/selectors/generator/Kptfile index 15df83b26a..8b11afc2e0 100644 --- a/e2e/testdata/fn-render/selectors/generator/Kptfile +++ b/e2e/testdata/fn-render/selectors/generator/Kptfile @@ -1,16 +1,16 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-generator -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - selectors: - - name: httpbin - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: db - selectors: - - name: httpbin +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-generator +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + selectors: + - name: httpbin + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: db + selectors: + - name: httpbin diff --git a/e2e/testdata/fn-render/selectors/generator/db/Kptfile b/e2e/testdata/fn-render/selectors/generator/db/Kptfile index 913523f0d3..61d51d2ffb 100644 --- a/e2e/testdata/fn-render/selectors/generator/db/Kptfile +++ b/e2e/testdata/fn-render/selectors/generator/db/Kptfile @@ -1,18 +1,18 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - selectors: - - name: httpbin - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend - selectors: - - name: httpbin +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + selectors: + - name: httpbin + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend + selectors: + - name: httpbin diff --git a/e2e/testdata/fn-render/selectors/generator/db/resources.yaml b/e2e/testdata/fn-render/selectors/generator/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/selectors/generator/db/resources.yaml +++ b/e2e/testdata/fn-render/selectors/generator/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/selectors/generator/db/starlark-httpbin.yaml b/e2e/testdata/fn-render/selectors/generator/db/starlark-httpbin.yaml index e52e48f94d..07a7784900 100644 --- a/e2e/testdata/fn-render/selectors/generator/db/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/selectors/generator/db/starlark-httpbin.yaml @@ -1,55 +1,55 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/selectors/generator/resources.yaml b/e2e/testdata/fn-render/selectors/generator/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/selectors/generator/resources.yaml +++ b/e2e/testdata/fn-render/selectors/generator/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml index aff411b9db..49d42fd0cf 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/config.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -stdErr: | - Package: "selectors-with-exclude" - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - Successfully executed 2 function(s) in 1 package(s). +# Copyright 2021 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +stdErr: | + Package: "selectors-with-exclude" + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" on 1 resource(s) + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + Successfully executed 2 function(s) in 1 package(s). diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/diff.patch b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/diff.patch index 45e8d1aff3..31da6c805f 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/diff.patch +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.expected/diff.patch @@ -1,28 +1,102 @@ diff --git a/Kptfile b/Kptfile -index c16cdca..ef430cd 100644 +index bb96972..d8897bb 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app +@@ -1,17 +1,19 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- selectors: +- - labels: +- foo: bar +- exclude: +- - kind: Custom +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ selectors: ++ - labels: ++ foo: bar ++ exclude: ++ - kind: Custom ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index d3ed04c..f66e542 100644 +index 002bf32..f66e542 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -17,8 +17,17 @@ metadata: - name: nginx-deployment - labels: - foo: bar +@@ -1,30 +1,40 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 +- labels: +- foo: bar +-spec: +- replicas: 3 +---- +-apiVersion: custom.io/v1 +-kind: Custom +-metadata: +- name: custom +- labels: +- foo: bar +-spec: +- image: nginx:1.2.3 ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ labels: ++ foo: bar + tier: backend + namespace: staging - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -30,13 +104,13 @@ index d3ed04c..f66e542 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom -@@ -26,5 +35,6 @@ metadata: - name: custom - labels: - foo: bar ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++ labels: ++ foo: bar + tier: backend - spec: - image: nginx:1.2.3 \ No newline at end of file ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.krmignore b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/.krmignore +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile b/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile index bc106717b4..bb96972a60 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/Kptfile @@ -1,17 +1,17 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - selectors: - - labels: - foo: bar - exclude: - - kind: Custom - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + selectors: + - labels: + foo: bar + exclude: + - kind: Custom + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/selectors/selectors-with-exclude/resources.yaml b/e2e/testdata/fn-render/selectors/selectors-with-exclude/resources.yaml index d3ed04cbdb..002bf32abe 100644 --- a/e2e/testdata/fn-render/selectors/selectors-with-exclude/resources.yaml +++ b/e2e/testdata/fn-render/selectors/selectors-with-exclude/resources.yaml @@ -1,30 +1,30 @@ -# Copyright 2021 The kpt Authors -# -# 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 - labels: - foo: bar -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom - labels: - foo: bar -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + labels: + foo: bar +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom + labels: + foo: bar +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/selectors/validate-subset/.krmignore b/e2e/testdata/fn-render/selectors/validate-subset/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/selectors/validate-subset/.krmignore +++ b/e2e/testdata/fn-render/selectors/validate-subset/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/selectors/validate-subset/Kptfile b/e2e/testdata/fn-render/selectors/validate-subset/Kptfile index f9e90a23e3..d9233f9dc3 100644 --- a/e2e/testdata/fn-render/selectors/validate-subset/Kptfile +++ b/e2e/testdata/fn-render/selectors/validate-subset/Kptfile @@ -1,10 +1,10 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest # validates httpbin deployment exists - configPath: starlark-httpbin-val.yaml - selectors: - - kind: Deployment +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest # validates httpbin deployment exists + configPath: starlark-httpbin-val.yaml + selectors: + - kind: Deployment diff --git a/e2e/testdata/fn-render/selectors/validate-subset/resources.yaml b/e2e/testdata/fn-render/selectors/validate-subset/resources.yaml index f169ab020d..a32192a835 100644 --- a/e2e/testdata/fn-render/selectors/validate-subset/resources.yaml +++ b/e2e/testdata/fn-render/selectors/validate-subset/resources.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: staging -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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 + namespace: staging +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/selectors/validate-subset/starlark-httpbin-val.yaml b/e2e/testdata/fn-render/selectors/validate-subset/starlark-httpbin-val.yaml index 6a2dafda73..6a4cb621e1 100644 --- a/e2e/testdata/fn-render/selectors/validate-subset/starlark-httpbin-val.yaml +++ b/e2e/testdata/fn-render/selectors/validate-subset/starlark-httpbin-val.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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-val -source: |- - def contains_httpbin_resource(resource_list): - for r in resource_list["items"]: - if r["metadata"]["namespace"] != "staging": - fail("resource has different namespace") - return - contains_httpbin_resource(ctx.resource_list) +# Copyright 2021 The kpt Authors +# +# 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-val +source: |- + def contains_httpbin_resource(resource_list): + for r in resource_list["items"]: + if r["metadata"]["namespace"] != "staging": + fail("resource has different namespace") + return + contains_httpbin_resource(ctx.resource_list) diff --git a/e2e/testdata/fn-render/short-image-path/.expected/config.yaml b/e2e/testdata/fn-render/short-image-path/.expected/config.yaml index 359f4574b0..5525347368 100644 --- a/e2e/testdata/fn-render/short-image-path/.expected/config.yaml +++ b/e2e/testdata/fn-render/short-image-path/.expected/config.yaml @@ -1,28 +1,28 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -actualStripLines: - - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" - [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s - -stdErrStripLines: - - " Stderr:" - - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" - -disableOutputTruncate: true +# Copyright 2021 The kpt Authors +# +# 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. + +actualStripLines: + - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" + [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s + +stdErrStripLines: + - " Stderr:" + - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" + +disableOutputTruncate: true diff --git a/e2e/testdata/fn-render/short-image-path/.expected/diff.patch b/e2e/testdata/fn-render/short-image-path/.expected/diff.patch index af84880849..113a3274bf 100644 --- a/e2e/testdata/fn-render/short-image-path/.expected/diff.patch +++ b/e2e/testdata/fn-render/short-image-path/.expected/diff.patch @@ -1,30 +1,87 @@ diff --git a/Kptfile b/Kptfile -index d4e5935..06cb2ef 100644 +index 8076576..37954f5 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: set-namespace:latest +- configMap: +- namespace: staging +- - image: set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index f2eec52..84cfb26 100644 +index 9d1f786..6b5d443 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -32,13 +89,12 @@ index f2eec52..84cfb26 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/short-image-path/.expected/results.yaml b/e2e/testdata/fn-render/short-image-path/.expected/results.yaml index 2e5fc6b753..6b0ddb6503 100755 --- a/e2e/testdata/fn-render/short-image-path/.expected/results.yaml +++ b/e2e/testdata/fn-render/short-image-path/.expected/results.yaml @@ -6,6 +6,10 @@ exitCode: 0 items: - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest exitCode: 0 + results: + - message: namespace [default] updated to "staging", 1 value(s) changed + severity: info + - message: all `depends-on` annotations are up-to-date. no `namespace` changed + severity: info - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 exitCode: 0 - diff --git a/e2e/testdata/fn-render/short-image-path/.krmignore b/e2e/testdata/fn-render/short-image-path/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/short-image-path/.krmignore +++ b/e2e/testdata/fn-render/short-image-path/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/short-image-path/Kptfile b/e2e/testdata/fn-render/short-image-path/Kptfile index 5e29eb2fa8..8076576ef2 100644 --- a/e2e/testdata/fn-render/short-image-path/Kptfile +++ b/e2e/testdata/fn-render/short-image-path/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: set-namespace:latest - configMap: - namespace: staging - - image: set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: set-namespace:latest + configMap: + namespace: staging + - image: set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/short-image-path/resources.yaml b/e2e/testdata/fn-render/short-image-path/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/short-image-path/resources.yaml +++ b/e2e/testdata/fn-render/short-image-path/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.expected/config.yaml b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.expected/config.yaml index 158679c8e9..38a841f34c 100644 --- a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.expected/config.yaml +++ b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -# One of the functions in the pipeline fails resulting in -# non-zero exit code and no changes in the resources. -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +# One of the functions in the pipeline fails resulting in +# non-zero exit code and no changes in the resources. +exitCode: 1 diff --git a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.krmignore b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.krmignore +++ b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/Kptfile b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/Kptfile index 91828a8a25..f24e451e2e 100644 --- a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/Kptfile +++ b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/gatekeeper:latest - - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest - configMap: - ignore_missing_schemas: "true" - strict: "true" +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/gatekeeper:latest + - image: ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest + configMap: + ignore_missing_schemas: "true" + strict: "true" diff --git a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/resources.yaml b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/resources.yaml index 09239cf8fd..70c40b87ac 100644 --- a/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/resources.yaml +++ b/e2e/testdata/fn-render/structured-results-from-muiltiple-fns/resources.yaml @@ -1,89 +1,89 @@ -# Copyright 2021 The kpt Authors -# -# 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: invalid ---- -apiVersion: templates.gatekeeper.sh/v1beta1 -kind: ConstraintTemplate -metadata: - name: k8sconfigmapkeysrulesv1 -spec: - crd: - spec: - names: - kind: K8sConfigMapKeysRulesV1 - validation: - openAPIV3Schema: - properties: - keys: - type: array - items: - type: string - targets: - - rego: |- - package ban_keys - - violation[{"msg": sprintf("%v", [val])}] { - keys = {key | input.review.object.data[key]} - banned = {key | input.parameters.keys[_] = key} - overlap = keys & banned - count(overlap) > 0 - val := sprintf("The following banned keys are being used in the ConfigMap: %v", [overlap]) - } - target: admission.k8s.gatekeeper.sh ---- -apiVersion: constraints.gatekeeper.sh/v1beta1 -kind: K8sConfigMapKeysRulesV1 -metadata: - name: no-secrets-in-configmap -spec: - enforcementAction: warn # create warning instead of errors - match: - kinds: - - apiGroups: - - '' - kinds: - - ConfigMap - parameters: - keys: - - private_key ---- -apiVersion: constraints.gatekeeper.sh/v1beta1 -kind: K8sConfigMapKeysRulesV1 -metadata: - name: no-sensitive-data-in-configmap -spec: - enforcementAction: dryrun # create info instead of errors - match: - kinds: - - apiGroups: - - '' - kinds: - - ConfigMap - parameters: - keys: - - less_sensitive_key ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: some-secret - namespace: default -data: - less_sensitive_key: less sensitive data goes here - private_key: sensitive data goes here +# Copyright 2021 The kpt Authors +# +# 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: invalid +--- +apiVersion: templates.gatekeeper.sh/v1beta1 +kind: ConstraintTemplate +metadata: + name: k8sconfigmapkeysrulesv1 +spec: + crd: + spec: + names: + kind: K8sConfigMapKeysRulesV1 + validation: + openAPIV3Schema: + properties: + keys: + type: array + items: + type: string + targets: + - rego: |- + package ban_keys + + violation[{"msg": sprintf("%v", [val])}] { + keys = {key | input.review.object.data[key]} + banned = {key | input.parameters.keys[_] = key} + overlap = keys & banned + count(overlap) > 0 + val := sprintf("The following banned keys are being used in the ConfigMap: %v", [overlap]) + } + target: admission.k8s.gatekeeper.sh +--- +apiVersion: constraints.gatekeeper.sh/v1beta1 +kind: K8sConfigMapKeysRulesV1 +metadata: + name: no-secrets-in-configmap +spec: + enforcementAction: warn # create warning instead of errors + match: + kinds: + - apiGroups: + - '' + kinds: + - ConfigMap + parameters: + keys: + - private_key +--- +apiVersion: constraints.gatekeeper.sh/v1beta1 +kind: K8sConfigMapKeysRulesV1 +metadata: + name: no-sensitive-data-in-configmap +spec: + enforcementAction: dryrun # create info instead of errors + match: + kinds: + - apiGroups: + - '' + kinds: + - ConfigMap + parameters: + keys: + - less_sensitive_key +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: some-secret + namespace: default +data: + less_sensitive_key: less sensitive data goes here + private_key: sensitive data goes here diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/.expected/config.yaml b/e2e/testdata/fn-render/subpkg-fn-failure/.expected/config.yaml index 92dc7be93d..361743b05e 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/subpkg-fn-failure/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: "statefulset-filter:4:42: got newline, want primary expression" +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: "statefulset-filter:4:42: got newline, want primary expression" diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/.krmignore b/e2e/testdata/fn-render/subpkg-fn-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/.krmignore +++ b/e2e/testdata/fn-render/subpkg-fn-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile b/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile index 7316bb0b1a..1e4b14aea6 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile +++ b/e2e/testdata/fn-render/subpkg-fn-failure/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile b/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile index 9295ee3a83..e8a364cde2 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile +++ b/e2e/testdata/fn-render/subpkg-fn-failure/db/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: statefulset-filter.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: statefulset-filter.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/db/resources.yaml b/e2e/testdata/fn-render/subpkg-fn-failure/db/resources.yaml index f9835978b2..2905805efe 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/db/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-fn-failure/db/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/db/statefulset-filter.yaml b/e2e/testdata/fn-render/subpkg-fn-failure/db/statefulset-filter.yaml index b46cbba4a5..0d1b591788 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/db/statefulset-filter.yaml +++ b/e2e/testdata/fn-render/subpkg-fn-failure/db/statefulset-filter.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: statefulset-filter -source: | - # filter to return if resource is statefulset kind - # AND conditional has syntax error forcing function to fail - def isStatefulSet(r): - return r["apiVersion"] == "apps/v1" and - r["kind"] == "StatefulSet" - - # filter out statefulsets - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] +# Copyright 2021 The kpt Authors +# +# 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: statefulset-filter +source: | + # filter to return if resource is statefulset kind + # AND conditional has syntax error forcing function to fail + def isStatefulSet(r): + return r["apiVersion"] == "apps/v1" and + r["kind"] == "StatefulSet" + + # filter out statefulsets + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/deployment_httpbin.yaml b/e2e/testdata/fn-render/subpkg-fn-failure/deployment_httpbin.yaml index 49d4f6e3dd..b4028f8592 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/deployment_httpbin.yaml +++ b/e2e/testdata/fn-render/subpkg-fn-failure/deployment_httpbin.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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: httpbin - namespace: staging - labels: - app: backend - tier: db -spec: - replicas: 4 - selector: - matchLabels: - app: backend - tier: db - template: - metadata: - labels: - app: backend - tier: db - spec: - containers: - - name: httpbin - image: kennethreitz/httpbin +# Copyright 2021 The kpt Authors +# +# 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: httpbin + namespace: staging + labels: + app: backend + tier: db +spec: + replicas: 4 + selector: + matchLabels: + app: backend + tier: db + template: + metadata: + labels: + app: backend + tier: db + spec: + containers: + - name: httpbin + image: kennethreitz/httpbin diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/resources.yaml b/e2e/testdata/fn-render/subpkg-fn-failure/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-fn-failure/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/subpkg-fn-failure/starlark-httpbin.yaml b/e2e/testdata/fn-render/subpkg-fn-failure/starlark-httpbin.yaml index 1a1cb5e35f..d9b020a7ef 100644 --- a/e2e/testdata/fn-render/subpkg-fn-failure/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/subpkg-fn-failure/starlark-httpbin.yaml @@ -1,25 +1,25 @@ -# Copyright 2021 The kpt Authors -# -# 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: | - # filter to return if resource is HTTPBin resource - def isHTTPBin(r): - return r["apiVersion"] == "apps/v1" and - r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - # filter out the httpbin deployment - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] +# Copyright 2021 The kpt Authors +# +# 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: | + # filter to return if resource is HTTPBin resource + def isHTTPBin(r): + return r["apiVersion"] == "apps/v1" and + r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + # filter out the httpbin deployment + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.expected/config.yaml b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.expected/config.yaml index 240f345bb2..6d667155f4 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.expected/config.yaml +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.expected/config.yaml @@ -1,16 +1,16 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 stdErr: "can't be read.\n\nDetails:\nyaml: line 10: mapping values are not allowed in this context" \ No newline at end of file diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.krmignore b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.krmignore +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile index ea39e22f9f..aea52223bb 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/Kptfile @@ -1,15 +1,15 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - # malformed Kptfile - configPath: statefulset-filter.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + # malformed Kptfile + configPath: statefulset-filter.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/resources.yaml b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/resources.yaml index f9835978b2..2905805efe 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/statefulset-filter.yaml b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/statefulset-filter.yaml index e873c776dc..1069c4afc2 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/statefulset-filter.yaml +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/db/statefulset-filter.yaml @@ -1,25 +1,25 @@ -# Copyright 2021 The kpt Authors -# -# 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: statefulset-filter -source: | - # filter to return if resource is statefulset kind - def isStatefulSet(r): - return r["apiVersion"] == "apps/v1" and - r["kind"] == "StatefulSet" - - # filter out statefulsets - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] +# Copyright 2021 The kpt Authors +# +# 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: statefulset-filter +source: | + # filter to return if resource is statefulset kind + def isStatefulSet(r): + return r["apiVersion"] == "apps/v1" and + r["kind"] == "StatefulSet" + + # filter out statefulsets + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] diff --git a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/resources.yaml b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-has-invalid-kptfile/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/.krmignore b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/.krmignore +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/Kptfile b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/Kptfile index 701e0a1b0e..76dd24afa0 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/Kptfile @@ -1,6 +1,6 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: root-pkg -info: - description: sample description +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: root-pkg +info: + description: sample description diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/Kptfile b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/Kptfile index 1c0e1ccba2..505ca39426 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/Kptfile @@ -1,6 +1,6 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: pkg-a -info: - description: sample description +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: pkg-a +info: + description: sample description diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/pkg-a/resources.yaml b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/pkg-a/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/pkg-a/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir-empty-pipeline/pkg-a/pkg-a/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir/.expected/diff.patch b/e2e/testdata/fn-render/subpkg-has-samename-subdir/.expected/diff.patch index 3ed1b478ec..3ee22b6907 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir/.expected/diff.patch +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir/.expected/diff.patch @@ -1,31 +1,102 @@ +diff --git a/Kptfile b/Kptfile +index 76dd24a..701e0a1 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,6 +1,6 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: root-pkg +-info: +- description: sample description ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: root-pkg ++info: ++ description: sample description diff --git a/pkg-a/Kptfile b/pkg-a/Kptfile -index 088bc03..c42f368 100644 +index 49f605e..4a4ab87 100755 --- a/pkg-a/Kptfile +++ b/pkg-a/Kptfile -@@ -2,6 +2,7 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: pkg-a -+ namespace: dev - info: - description: sample description - pipeline: +@@ -1,11 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: pkg-a +-info: +- description: sample description +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: dev ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: pkg-a ++info: ++ description: sample description ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: dev diff --git a/pkg-a/pkg-a/resources.yaml b/pkg-a/pkg-a/resources.yaml -index f2eec52..c4e4abb 100644 +index 9d1f786..1934a8f 100755 --- a/pkg-a/pkg-a/resources.yaml +++ b/pkg-a/pkg-a/resources.yaml -@@ -15,6 +15,7 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment -+ namespace: dev - spec: - replicas: 3 - --- -@@ -22,5 +23,6 @@ apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom +@@ -1,26 +1,27 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: dev - spec: - image: nginx:1.2.3 ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir/.krmignore b/e2e/testdata/fn-render/subpkg-has-samename-subdir/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir/.krmignore +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir/Kptfile b/e2e/testdata/fn-render/subpkg-has-samename-subdir/Kptfile index 701e0a1b0e..76dd24afa0 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir/Kptfile @@ -1,6 +1,6 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: root-pkg -info: - description: sample description +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: root-pkg +info: + description: sample description diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile b/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile index 4a4ab87785..49f605e203 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: pkg-a -info: - description: sample description -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: dev +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: pkg-a +info: + description: sample description +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: dev diff --git a/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml b/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-has-samename-subdir/pkg-a/pkg-a/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/.expected/diff.patch b/e2e/testdata/fn-render/subpkg-resource-deletion/.expected/diff.patch index a92d37160d..d1bc139d14 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/.expected/diff.patch +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/.expected/diff.patch @@ -1,137 +1,258 @@ diff --git a/Kptfile b/Kptfile -index 364e274..75cfedb 100644 +index 1e4b14a..8d6e225 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,14 +1,16 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/db/Kptfile b/db/Kptfile -index 6c7674c..11fe9cc 100644 +index e8a364c..cd33860 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging +@@ -1,14 +1,17 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: statefulset-filter.yaml +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- app: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + app: backend + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: statefulset-filter.yaml ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ app: backend diff --git a/db/resources.yaml b/db/resources.yaml -index f983597..9dabb18 100644 +index 2905805..e21782c 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -1,26 +1,10 @@ --# Copyright 2021 The kpt Authors --# --# 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: StatefulSet --metadata: -- name: db --spec: -- replicas: 3 ----- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging +@@ -1,26 +1,9 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 +---- +-apiVersion: custom.io/v1 +-kind: Custom +-metadata: +- name: custom +-spec: +- image: nginx:1.2.3 ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + app: backend + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/db/statefulset-filter.yaml b/db/statefulset-filter.yaml -index e1f7b67..ac69c02 100644 +index f47fa4e..8ab4033 100755 --- a/db/statefulset-filter.yaml +++ b/db/statefulset-filter.yaml -@@ -15,6 +15,10 @@ apiVersion: fn.kpt.dev/v1alpha1 - kind: StarlarkRun - metadata: - name: statefulset-filter -+ namespace: staging +@@ -1,24 +1,27 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: statefulset-filter +-source: | +- # filter to return if resource is statefulset kind +- def isStatefulSet(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "StatefulSet" +- +- # filter out statefulsets +- ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] ++# Copyright 2021 The kpt Authors ++# ++# 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: statefulset-filter + labels: + app: backend + tier: backend - source: | - # filter to return if resource is statefulset kind - def isStatefulSet(r): ++source: | ++ # filter to return if resource is statefulset kind ++ def isStatefulSet(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "StatefulSet" ++ ++ # filter out statefulsets ++ ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] diff --git a/deployment_httpbin.yaml b/deployment_httpbin.yaml -deleted file mode 100644 -index 49d4f6e..0000000 +deleted file mode 100755 +index b4028f8..0000000 --- a/deployment_httpbin.yaml +++ /dev/null @@ -1,36 +0,0 @@ --# Copyright 2021 The kpt Authors --# --# 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: httpbin -- namespace: staging -- labels: -- app: backend -- tier: db --spec: -- replicas: 4 -- selector: -- matchLabels: -- app: backend -- tier: db -- template: -- metadata: -- labels: -- app: backend -- tier: db -- spec: -- containers: -- - name: httpbin -- image: kennethreitz/httpbin +-# Copyright 2021 The kpt Authors +-# +-# 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: httpbin +- namespace: staging +- labels: +- app: backend +- tier: db +-spec: +- replicas: 4 +- selector: +- matchLabels: +- app: backend +- tier: db +- template: +- metadata: +- labels: +- app: backend +- tier: db +- spec: +- containers: +- - name: httpbin +- image: kennethreitz/httpbin diff --git a/resources.yaml b/resources.yaml -index 239f0d6..9ca3271 100644 +index 027731c..9ca3271 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,5 +15,15 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,19 +1,29 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -140,16 +261,57 @@ index 239f0d6..9ca3271 100644 + labels: + tier: backend diff --git a/starlark-httpbin.yaml b/starlark-httpbin.yaml -index fd90109..e437ba7 100644 +index b668683..f9174fb 100755 --- a/starlark-httpbin.yaml +++ b/starlark-httpbin.yaml -@@ -15,6 +15,9 @@ apiVersion: fn.kpt.dev/v1alpha1 - kind: StarlarkRun - metadata: - name: httpbin-gen -+ namespace: staging +@@ -1,24 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: | +- # filter to return if resource is HTTPBin resource +- def isHTTPBin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- # filter out the httpbin deployment +- ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] ++# Copyright 2021 The kpt Authors ++# ++# 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 + labels: + tier: backend - source: | - # filter to return if resource is HTTPBin resource - def isHTTPBin(r): ++source: | ++ # filter to return if resource is HTTPBin resource ++ def isHTTPBin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ # filter out the httpbin deployment ++ ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/.krmignore b/e2e/testdata/fn-render/subpkg-resource-deletion/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/.krmignore +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile b/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile index 7316bb0b1a..1e4b14aea6 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile b/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile index 9295ee3a83..e8a364cde2 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/db/Kptfile @@ -1,14 +1,14 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: statefulset-filter.yaml - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: statefulset-filter.yaml + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/db/resources.yaml b/e2e/testdata/fn-render/subpkg-resource-deletion/db/resources.yaml index f9835978b2..2905805efe 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/db/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/db/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 ---- -apiVersion: custom.io/v1 -kind: Custom -metadata: - name: custom -spec: - image: nginx:1.2.3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 +--- +apiVersion: custom.io/v1 +kind: Custom +metadata: + name: custom +spec: + image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/db/statefulset-filter.yaml b/e2e/testdata/fn-render/subpkg-resource-deletion/db/statefulset-filter.yaml index e1f7b672c2..f47fa4e49e 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/db/statefulset-filter.yaml +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/db/statefulset-filter.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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: statefulset-filter -source: | - # filter to return if resource is statefulset kind - def isStatefulSet(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "StatefulSet" - - # filter out statefulsets - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] +# Copyright 2021 The kpt Authors +# +# 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: statefulset-filter +source: | + # filter to return if resource is statefulset kind + def isStatefulSet(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "StatefulSet" + + # filter out statefulsets + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isStatefulSet(r)] diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/deployment_httpbin.yaml b/e2e/testdata/fn-render/subpkg-resource-deletion/deployment_httpbin.yaml index 49d4f6e3dd..b4028f8592 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/deployment_httpbin.yaml +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/deployment_httpbin.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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: httpbin - namespace: staging - labels: - app: backend - tier: db -spec: - replicas: 4 - selector: - matchLabels: - app: backend - tier: db - template: - metadata: - labels: - app: backend - tier: db - spec: - containers: - - name: httpbin - image: kennethreitz/httpbin +# Copyright 2021 The kpt Authors +# +# 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: httpbin + namespace: staging + labels: + app: backend + tier: db +spec: + replicas: 4 + selector: + matchLabels: + app: backend + tier: db + template: + metadata: + labels: + app: backend + tier: db + spec: + containers: + - name: httpbin + image: kennethreitz/httpbin diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/resources.yaml b/e2e/testdata/fn-render/subpkg-resource-deletion/resources.yaml index 239f0d6b46..027731c3e5 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/resources.yaml +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/subpkg-resource-deletion/starlark-httpbin.yaml b/e2e/testdata/fn-render/subpkg-resource-deletion/starlark-httpbin.yaml index fd9010919c..b668683784 100644 --- a/e2e/testdata/fn-render/subpkg-resource-deletion/starlark-httpbin.yaml +++ b/e2e/testdata/fn-render/subpkg-resource-deletion/starlark-httpbin.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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: | - # filter to return if resource is HTTPBin resource - def isHTTPBin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - # filter out the httpbin deployment - ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] +# Copyright 2021 The kpt Authors +# +# 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: | + # filter to return if resource is HTTPBin resource + def isHTTPBin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + # filter out the httpbin deployment + ctx.resource_list["items"] = [r for r in ctx.resource_list["items"] if not isHTTPBin(r)] diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/.expected/diff.patch b/e2e/testdata/fn-render/subpkgs-with-krmignore/.expected/diff.patch index efb950203b..091bbee1b8 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/.expected/diff.patch +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/.expected/diff.patch @@ -1,46 +1,113 @@ diff --git a/Kptfile b/Kptfile -index 82686a8..c24d77e 100644 +index 87161b6..4215c05 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: db ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db + labels: + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: db diff --git a/db/Kptfile b/db/Kptfile -index 264dd2e..8dd7c37 100644 +index 03f1b81..bf7230a 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging +@@ -1,12 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- app: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + app: backend + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ app: backend diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..e9be40c 100644 +index c9c269b..e9be40c 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,5 +15,18 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db +@@ -1,19 +1,32 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db + namespace: staging + labels: + app: backend + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + app: backend @@ -51,18 +118,58 @@ index dabe43c..e9be40c 100644 + app: backend + tier: db diff --git a/resources.yaml b/resources.yaml -index f2eec52..8b2113d 100644 +index 9d1f786..b212081 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -70,13 +177,12 @@ index f2eec52..8b2113d 100644 + metadata: + labels: + tier: db - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: db - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/.krmignore b/e2e/testdata/fn-render/subpkgs-with-krmignore/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/.krmignore +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile b/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile index f97e8a4746..87161b6841 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: db diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile index 0c2b57a9b6..03f1b81ac9 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/non-krm.yaml b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/non-krm.yaml index 63a8c95e55..75c9fa06df 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/non-krm.yaml +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/non-krm.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. -- op: replace - path: /spec - value: - group: kubeflow.org +# Copyright 2021 The kpt Authors +# +# 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. +- op: replace + path: /spec + value: + group: kubeflow.org diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/resources.yaml b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/db/resources.yaml +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/subpkgs-with-krmignore/resources.yaml b/e2e/testdata/fn-render/subpkgs-with-krmignore/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/subpkgs-with-krmignore/resources.yaml +++ b/e2e/testdata/fn-render/subpkgs-with-krmignore/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/subpkgs/.expected/diff.patch b/e2e/testdata/fn-render/subpkgs/.expected/diff.patch index efb950203b..091bbee1b8 100644 --- a/e2e/testdata/fn-render/subpkgs/.expected/diff.patch +++ b/e2e/testdata/fn-render/subpkgs/.expected/diff.patch @@ -1,46 +1,113 @@ diff --git a/Kptfile b/Kptfile -index 82686a8..c24d77e 100644 +index 87161b6..4215c05 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app-with-db -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app-with-db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: db ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app-with-db + labels: + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: db diff --git a/db/Kptfile b/db/Kptfile -index 264dd2e..8dd7c37 100644 +index 03f1b81..bf7230a 100755 --- a/db/Kptfile +++ b/db/Kptfile -@@ -2,6 +2,10 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: db -+ namespace: staging +@@ -1,12 +1,15 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: db +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- app: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db + labels: + app: backend + tier: db - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: db ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ app: backend diff --git a/db/resources.yaml b/db/resources.yaml -index dabe43c..e9be40c 100644 +index c9c269b..e9be40c 100755 --- a/db/resources.yaml +++ b/db/resources.yaml -@@ -15,5 +15,18 @@ apiVersion: apps/v1 - kind: StatefulSet - metadata: - name: db +@@ -1,19 +1,32 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: StatefulSet +-metadata: +- name: db +-spec: +- replicas: 3 ++# Copyright 2021 The kpt Authors ++# ++# 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: StatefulSet ++metadata: ++ name: db + namespace: staging + labels: + app: backend + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + app: backend @@ -51,18 +118,58 @@ index dabe43c..e9be40c 100644 + app: backend + tier: db diff --git a/resources.yaml b/resources.yaml -index f2eec52..8b2113d 100644 +index 9d1f786..b212081 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: db - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: db @@ -70,13 +177,12 @@ index f2eec52..8b2113d 100644 + metadata: + labels: + tier: db - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: db - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/subpkgs/.krmignore b/e2e/testdata/fn-render/subpkgs/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/subpkgs/.krmignore +++ b/e2e/testdata/fn-render/subpkgs/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/subpkgs/Kptfile b/e2e/testdata/fn-render/subpkgs/Kptfile index f97e8a4746..87161b6841 100644 --- a/e2e/testdata/fn-render/subpkgs/Kptfile +++ b/e2e/testdata/fn-render/subpkgs/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: db diff --git a/e2e/testdata/fn-render/subpkgs/db/Kptfile b/e2e/testdata/fn-render/subpkgs/db/Kptfile index 0c2b57a9b6..03f1b81ac9 100644 --- a/e2e/testdata/fn-render/subpkgs/db/Kptfile +++ b/e2e/testdata/fn-render/subpkgs/db/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + app: backend diff --git a/e2e/testdata/fn-render/subpkgs/db/resources.yaml b/e2e/testdata/fn-render/subpkgs/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-render/subpkgs/db/resources.yaml +++ b/e2e/testdata/fn-render/subpkgs/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-render/subpkgs/resources.yaml b/e2e/testdata/fn-render/subpkgs/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/subpkgs/resources.yaml +++ b/e2e/testdata/fn-render/subpkgs/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/success-stdout/.expected/config.yaml b/e2e/testdata/fn-render/success-stdout/.expected/config.yaml index 4c5a7d838c..f1156f6810 100644 --- a/e2e/testdata/fn-render/success-stdout/.expected/config.yaml +++ b/e2e/testdata/fn-render/success-stdout/.expected/config.yaml @@ -1,15 +1,15 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: "Successfully executed 2 function(s) in 1 package(s)" +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: "Successfully executed 2 function(s) in 1 package(s)" diff --git a/e2e/testdata/fn-render/success-stdout/.expected/diff.patch b/e2e/testdata/fn-render/success-stdout/.expected/diff.patch index a21c38b30e..c93758d413 100644 --- a/e2e/testdata/fn-render/success-stdout/.expected/diff.patch +++ b/e2e/testdata/fn-render/success-stdout/.expected/diff.patch @@ -1,30 +1,87 @@ diff --git a/Kptfile b/Kptfile -index 1307fb5..3a2c718 100644 +index c3817f3..9caee20 100755 --- a/Kptfile +++ b/Kptfile -@@ -2,6 +2,9 @@ apiVersion: kpt.dev/v1 - kind: Kptfile - metadata: - name: app -+ namespace: staging +@@ -1,12 +1,14 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: app +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest +- configMap: +- namespace: staging +- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 +- configMap: +- tier: backend ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: app + labels: + tier: backend - pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0 ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest ++ configMap: ++ namespace: staging ++ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 ++ configMap: ++ tier: backend diff --git a/resources.yaml b/resources.yaml -index f2eec52..84cfb26 100644 +index 9d1f786..6b5d443 100755 --- a/resources.yaml +++ b/resources.yaml -@@ -15,12 +15,25 @@ apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment +@@ -1,26 +1,38 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 + namespace: staging + labels: + tier: backend - spec: - replicas: 3 ++spec: ++ replicas: 3 + selector: + matchLabels: + tier: backend @@ -32,13 +89,12 @@ index f2eec52..84cfb26 100644 + metadata: + labels: + tier: backend - --- - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom -+ namespace: staging ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom + labels: + tier: backend - spec: - image: nginx:1.2.3 ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-render/success-stdout/.krmignore b/e2e/testdata/fn-render/success-stdout/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/success-stdout/.krmignore +++ b/e2e/testdata/fn-render/success-stdout/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/success-stdout/Kptfile b/e2e/testdata/fn-render/success-stdout/Kptfile index 93ae454de7..c3817f3f67 100644 --- a/e2e/testdata/fn-render/success-stdout/Kptfile +++ b/e2e/testdata/fn-render/success-stdout/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/success-stdout/resources.yaml b/e2e/testdata/fn-render/success-stdout/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/success-stdout/resources.yaml +++ b/e2e/testdata/fn-render/success-stdout/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/validate-generated-resource/.expected/diff.patch b/e2e/testdata/fn-render/validate-generated-resource/.expected/diff.patch index 1ae748f1e4..ab021eab85 100644 --- a/e2e/testdata/fn-render/validate-generated-resource/.expected/diff.patch +++ b/e2e/testdata/fn-render/validate-generated-resource/.expected/diff.patch @@ -1,3 +1,30 @@ +diff --git a/Kptfile b/Kptfile +index 5c1d9fa..b2432a4 100755 +--- a/Kptfile ++++ b/Kptfile +@@ -1,11 +1,11 @@ +-apiVersion: kpt.dev/v1 +-kind: Kptfile +-metadata: +- name: db +-pipeline: +- mutators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin-gen.yaml +- validators: +- - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest +- configPath: starlark-httpbin-val.yaml ++apiVersion: kpt.dev/v1 ++kind: Kptfile ++metadata: ++ name: db ++pipeline: ++ mutators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin-gen.yaml ++ validators: ++ - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest ++ configPath: starlark-httpbin-val.yaml diff --git a/deployment_httpbin.yaml b/deployment_httpbin.yaml new file mode 100644 index 0000000..f36c98e @@ -17,3 +44,228 @@ index 0000000..f36c98e + name: httpbin + ports: + - containerPort: 9876 +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 +diff --git a/starlark-httpbin-gen.yaml b/starlark-httpbin-gen.yaml +index 07a7784..e52e48f 100755 +--- a/starlark-httpbin-gen.yaml ++++ b/starlark-httpbin-gen.yaml +@@ -1,55 +1,55 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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: |- +- httpbin_deployment = { +- "apiVersion": "apps/v1", +- "kind": "Deployment", +- "metadata": { +- "name": "httpbin", +- }, +- "spec": { +- "replicas": 4, +- "template": { +- "spec": { +- "containers": [ +- { +- "name": "httpbin", +- "image": "kennethreitz/httpbin", +- "ports": [ +- { +- "containerPort": 9876 +- } +- ] +- } +- ] +- } +- } +- } +- } +- # filter to return if resource is HTTPBin resource +- def is_httpbin(r): +- return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" +- +- def ensure_httpbin(resources): +- for r in resources: +- if is_httpbin(r): +- return +- +- resources.append(httpbin_deployment) +- +- ensure_httpbin(ctx.resource_list["items"]) ++# Copyright 2021 The kpt Authors ++# ++# 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: |- ++ httpbin_deployment = { ++ "apiVersion": "apps/v1", ++ "kind": "Deployment", ++ "metadata": { ++ "name": "httpbin", ++ }, ++ "spec": { ++ "replicas": 4, ++ "template": { ++ "spec": { ++ "containers": [ ++ { ++ "name": "httpbin", ++ "image": "kennethreitz/httpbin", ++ "ports": [ ++ { ++ "containerPort": 9876 ++ } ++ ] ++ } ++ ] ++ } ++ } ++ } ++ } ++ # filter to return if resource is HTTPBin resource ++ def is_httpbin(r): ++ return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" ++ ++ def ensure_httpbin(resources): ++ for r in resources: ++ if is_httpbin(r): ++ return ++ ++ resources.append(httpbin_deployment) ++ ++ ensure_httpbin(ctx.resource_list["items"]) +diff --git a/starlark-httpbin-val.yaml b/starlark-httpbin-val.yaml +index 386aa6f..81973cf 100755 +--- a/starlark-httpbin-val.yaml ++++ b/starlark-httpbin-val.yaml +@@ -1,24 +1,24 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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-val +-source: |- +- def contains_httpbin_resource(resource_list): +- for r in resource_list["items"]: +- if r["metadata"]["name"] == "httpbin" and r["kind"] == "Deployment": +- return +- fail("could not find httpbin deployment") +- contains_httpbin_resource(ctx.resource_list) ++# Copyright 2021 The kpt Authors ++# ++# 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-val ++source: |- ++ def contains_httpbin_resource(resource_list): ++ for r in resource_list["items"]: ++ if r["metadata"]["name"] == "httpbin" and r["kind"] == "Deployment": ++ return ++ fail("could not find httpbin deployment") ++ contains_httpbin_resource(ctx.resource_list) diff --git a/e2e/testdata/fn-render/validate-generated-resource/.krmignore b/e2e/testdata/fn-render/validate-generated-resource/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/validate-generated-resource/.krmignore +++ b/e2e/testdata/fn-render/validate-generated-resource/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/validate-generated-resource/Kptfile b/e2e/testdata/fn-render/validate-generated-resource/Kptfile index b2432a4870..5c1d9fadf4 100644 --- a/e2e/testdata/fn-render/validate-generated-resource/Kptfile +++ b/e2e/testdata/fn-render/validate-generated-resource/Kptfile @@ -1,11 +1,11 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin-gen.yaml - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest - configPath: starlark-httpbin-val.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin-gen.yaml + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest + configPath: starlark-httpbin-val.yaml diff --git a/e2e/testdata/fn-render/validate-generated-resource/resources.yaml b/e2e/testdata/fn-render/validate-generated-resource/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/validate-generated-resource/resources.yaml +++ b/e2e/testdata/fn-render/validate-generated-resource/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-gen.yaml b/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-gen.yaml index e52e48f94d..07a7784900 100644 --- a/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-gen.yaml +++ b/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-gen.yaml @@ -1,55 +1,55 @@ -# Copyright 2021 The kpt Authors -# -# 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: |- - httpbin_deployment = { - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": { - "name": "httpbin", - }, - "spec": { - "replicas": 4, - "template": { - "spec": { - "containers": [ - { - "name": "httpbin", - "image": "kennethreitz/httpbin", - "ports": [ - { - "containerPort": 9876 - } - ] - } - ] - } - } - } - } - # filter to return if resource is HTTPBin resource - def is_httpbin(r): - return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" - - def ensure_httpbin(resources): - for r in resources: - if is_httpbin(r): - return - - resources.append(httpbin_deployment) - - ensure_httpbin(ctx.resource_list["items"]) +# Copyright 2021 The kpt Authors +# +# 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: |- + httpbin_deployment = { + "apiVersion": "apps/v1", + "kind": "Deployment", + "metadata": { + "name": "httpbin", + }, + "spec": { + "replicas": 4, + "template": { + "spec": { + "containers": [ + { + "name": "httpbin", + "image": "kennethreitz/httpbin", + "ports": [ + { + "containerPort": 9876 + } + ] + } + ] + } + } + } + } + # filter to return if resource is HTTPBin resource + def is_httpbin(r): + return r["apiVersion"] == "apps/v1" and r["kind"] == "Deployment" and r["metadata"]["name"] == "httpbin" + + def ensure_httpbin(resources): + for r in resources: + if is_httpbin(r): + return + + resources.append(httpbin_deployment) + + ensure_httpbin(ctx.resource_list["items"]) diff --git a/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-val.yaml b/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-val.yaml index 81973cff90..386aa6f892 100644 --- a/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-val.yaml +++ b/e2e/testdata/fn-render/validate-generated-resource/starlark-httpbin-val.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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-val -source: |- - def contains_httpbin_resource(resource_list): - for r in resource_list["items"]: - if r["metadata"]["name"] == "httpbin" and r["kind"] == "Deployment": - return - fail("could not find httpbin deployment") - contains_httpbin_resource(ctx.resource_list) +# Copyright 2021 The kpt Authors +# +# 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-val +source: |- + def contains_httpbin_resource(resource_list): + for r in resource_list["items"]: + if r["metadata"]["name"] == "httpbin" and r["kind"] == "Deployment": + return + fail("could not find httpbin deployment") + contains_httpbin_resource(ctx.resource_list) diff --git a/e2e/testdata/fn-render/validate-resource-failure/.expected/config.yaml b/e2e/testdata/fn-render/validate-resource-failure/.expected/config.yaml index 0c55d6d76e..17dc3efd71 100644 --- a/e2e/testdata/fn-render/validate-resource-failure/.expected/config.yaml +++ b/e2e/testdata/fn-render/validate-resource-failure/.expected/config.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -actualStripLines: - - " WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested" - -exitCode: 1 -stdErr: "fail: could not find httpbin deployment" +# Copyright 2021 The kpt Authors +# +# 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. + +actualStripLines: + - " WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested" + +exitCode: 1 +stdErr: "fail: could not find httpbin deployment" diff --git a/e2e/testdata/fn-render/validate-resource-failure/.krmignore b/e2e/testdata/fn-render/validate-resource-failure/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/validate-resource-failure/.krmignore +++ b/e2e/testdata/fn-render/validate-resource-failure/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/validate-resource-failure/Kptfile b/e2e/testdata/fn-render/validate-resource-failure/Kptfile index 8c3173a239..b32bf80338 100644 --- a/e2e/testdata/fn-render/validate-resource-failure/Kptfile +++ b/e2e/testdata/fn-render/validate-resource-failure/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest # validates httpbin deployment exists - configPath: starlark-httpbin-val.yaml +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest # validates httpbin deployment exists + configPath: starlark-httpbin-val.yaml diff --git a/e2e/testdata/fn-render/validate-resource-failure/resources.yaml b/e2e/testdata/fn-render/validate-resource-failure/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/validate-resource-failure/resources.yaml +++ b/e2e/testdata/fn-render/validate-resource-failure/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-render/validate-resource-failure/starlark-httpbin-val.yaml b/e2e/testdata/fn-render/validate-resource-failure/starlark-httpbin-val.yaml index 81973cff90..386aa6f892 100644 --- a/e2e/testdata/fn-render/validate-resource-failure/starlark-httpbin-val.yaml +++ b/e2e/testdata/fn-render/validate-resource-failure/starlark-httpbin-val.yaml @@ -1,24 +1,24 @@ -# Copyright 2021 The kpt Authors -# -# 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-val -source: |- - def contains_httpbin_resource(resource_list): - for r in resource_list["items"]: - if r["metadata"]["name"] == "httpbin" and r["kind"] == "Deployment": - return - fail("could not find httpbin deployment") - contains_httpbin_resource(ctx.resource_list) +# Copyright 2021 The kpt Authors +# +# 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-val +source: |- + def contains_httpbin_resource(resource_list): + for r in resource_list["items"]: + if r["metadata"]["name"] == "httpbin" and r["kind"] == "Deployment": + return + fail("could not find httpbin deployment") + contains_httpbin_resource(ctx.resource_list) diff --git a/e2e/testdata/fn-render/validator-mutates-resources/.krmignore b/e2e/testdata/fn-render/validator-mutates-resources/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-render/validator-mutates-resources/.krmignore +++ b/e2e/testdata/fn-render/validator-mutates-resources/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-render/validator-mutates-resources/Kptfile b/e2e/testdata/fn-render/validator-mutates-resources/Kptfile index 2324206a72..d25a2d92df 100644 --- a/e2e/testdata/fn-render/validator-mutates-resources/Kptfile +++ b/e2e/testdata/fn-render/validator-mutates-resources/Kptfile @@ -1,9 +1,9 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app -pipeline: - validators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 - configMap: - tier: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app +pipeline: + validators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5 + configMap: + tier: backend diff --git a/e2e/testdata/fn-render/validator-mutates-resources/resources.yaml b/e2e/testdata/fn-render/validator-mutates-resources/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-render/validator-mutates-resources/resources.yaml +++ b/e2e/testdata/fn-render/validator-mutates-resources/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/config.yaml b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/config.yaml index 83c61c0af1..856281d55b 100644 --- a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/config.yaml +++ b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -exitCode: 1 -stdErr: | +# Copyright 2021 The kpt Authors +# +# 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. + +exitCode: 1 +stdErr: | directory "out" already exists, please delete the directory and retry \ No newline at end of file diff --git a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/exec.sh b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/exec.sh index f5596cc42c..22137e22d5 100755 --- a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/exec.sh +++ b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.expected/exec.sh @@ -1,21 +1,21 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out; mkdir out - -kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -o stdout -- namespace=staging \ -| kpt fn sink out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out; mkdir out + +kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -o stdout -- namespace=staging \ +| kpt fn sink out diff --git a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.krmignore b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.krmignore +++ b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/resources.yaml b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/resources.yaml +++ b/e2e/testdata/fn-sink/out-of-place-dir-exists-error-sink/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/config.yaml b/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/config.yaml index aed0b15065..57fb9de024 100644 --- a/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/config.yaml +++ b/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/config.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -stdErr: | - [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" +# Copyright 2021 The kpt Authors +# +# 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. + +stdErr: | + [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" \ No newline at end of file diff --git a/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/diff.patch b/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/diff.patch index faf8c2aa97..d84130ff98 100644 --- a/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/diff.patch +++ b/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/diff.patch @@ -1,33 +1,33 @@ -diff --git a/out/resources.yaml b/out/resources.yaml -new file mode 100644 -index 0000000..f169ab0 ---- /dev/null -+++ b/out/resources.yaml -@@ -0,0 +1,27 @@ -+# Copyright 2021 The kpt Authors -+# -+# 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 -+ namespace: staging -+spec: -+ replicas: 3 -+--- -+apiVersion: custom.io/v1 -+kind: Custom -+metadata: -+ name: custom -+spec: -+ image: nginx:1.2.3 +diff --git a/out/resources.yaml b/out/resources.yaml +new file mode 100644 +index 0000000..f169ab0 +--- /dev/null ++++ b/out/resources.yaml +@@ -0,0 +1,27 @@ ++# Copyright 2021 The kpt Authors ++# ++# 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 ++ namespace: staging ++spec: ++ replicas: 3 ++--- ++apiVersion: custom.io/v1 ++kind: Custom ++metadata: ++ name: custom ++spec: ++ image: nginx:1.2.3 diff --git a/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/exec.sh b/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/exec.sh index f558ecb6af..3859c162fa 100755 --- a/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/exec.sh +++ b/e2e/testdata/fn-sink/out-of-place-source-sink/.expected/exec.sh @@ -1,22 +1,22 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - -set -eo pipefail - -rm -rf out - -kpt fn source \ -| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -- namespace=staging \ -| kpt fn sink out +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + +set -eo pipefail + +rm -rf out + +kpt fn source \ +| kpt fn eval - --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -- namespace=staging \ +| kpt fn sink out diff --git a/e2e/testdata/fn-sink/out-of-place-source-sink/.krmignore b/e2e/testdata/fn-sink/out-of-place-source-sink/.krmignore index 1f57855a2f..f95f167b7e 100644 --- a/e2e/testdata/fn-sink/out-of-place-source-sink/.krmignore +++ b/e2e/testdata/fn-sink/out-of-place-source-sink/.krmignore @@ -1,2 +1,2 @@ -.expected -out +.expected +out diff --git a/e2e/testdata/fn-sink/out-of-place-source-sink/resources.yaml b/e2e/testdata/fn-sink/out-of-place-source-sink/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-sink/out-of-place-source-sink/resources.yaml +++ b/e2e/testdata/fn-sink/out-of-place-source-sink/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/config.yaml b/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/config.yaml index 72b5520a76..d4a97dcf8e 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/config.yaml +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/config.yaml @@ -1,66 +1,66 @@ -stdOut: |- - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - # Copyright 2021 The kpt Authors - # - # 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: StatefulSet - metadata: - name: db - annotations: - config.kubernetes.io/index: '0' - config.kubernetes.io/path: 'db/resources.yaml' - internal.config.kubernetes.io/index: '0' - internal.config.kubernetes.io/path: 'db/resources.yaml' - internal.config.kubernetes.io/seqindent: 'compact' - spec: - replicas: 3 - - # Copyright 2021 The kpt Authors - # - # 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 - 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' - spec: - replicas: 3 - - apiVersion: custom.io/v1 - kind: Custom - metadata: - name: custom - 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' - spec: +stdOut: |- + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - # Copyright 2021 The kpt Authors + # + # 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: StatefulSet + metadata: + name: db + annotations: + config.kubernetes.io/index: '0' + config.kubernetes.io/path: 'db/resources.yaml' + internal.config.kubernetes.io/index: '0' + internal.config.kubernetes.io/path: 'db/resources.yaml' + internal.config.kubernetes.io/seqindent: 'compact' + spec: + replicas: 3 + - # Copyright 2021 The kpt Authors + # + # 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 + 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' + spec: + replicas: 3 + - apiVersion: custom.io/v1 + kind: Custom + metadata: + name: custom + 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' + spec: image: nginx:1.2.3 \ No newline at end of file diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/exec.sh b/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/exec.sh index 4660e12e7e..7fdd3d83f7 100755 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/exec.sh +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/.expected/exec.sh @@ -1,19 +1,19 @@ -#! /bin/bash -# Copyright 2021 The kpt Authors -# -# 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. - - -set -eo pipefail - -kpt fn source +#! /bin/bash +# Copyright 2021 The kpt Authors +# +# 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. + + +set -eo pipefail + +kpt fn source diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/.krmignore b/e2e/testdata/fn-source/subpkgs-with-krmignore/.krmignore index 9d7a4007d6..058e13ff7e 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/.krmignore +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/.krmignore @@ -1 +1 @@ -.expected +.expected diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/Kptfile b/e2e/testdata/fn-source/subpkgs-with-krmignore/Kptfile index dcf093e845..d6d2a4c2c1 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/Kptfile +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: app-with-db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: staging - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:latest - configMap: - tier: db +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: app-with-db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: staging + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:latest + configMap: + tier: db diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/db/Kptfile b/e2e/testdata/fn-source/subpkgs-with-krmignore/db/Kptfile index a0e6f2d512..d1d9b871f3 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/db/Kptfile +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/db/Kptfile @@ -1,12 +1,12 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: db -pipeline: - mutators: - - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest - configMap: - namespace: db - - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:latest - configMap: - app: backend +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: db +pipeline: + mutators: + - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest + configMap: + namespace: db + - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:latest + configMap: + app: backend diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/db/non-krm.yaml b/e2e/testdata/fn-source/subpkgs-with-krmignore/db/non-krm.yaml index 63a8c95e55..75c9fa06df 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/db/non-krm.yaml +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/db/non-krm.yaml @@ -1,17 +1,17 @@ -# Copyright 2021 The kpt Authors -# -# 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. -- op: replace - path: /spec - value: - group: kubeflow.org +# Copyright 2021 The kpt Authors +# +# 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. +- op: replace + path: /spec + value: + group: kubeflow.org diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/db/resources.yaml b/e2e/testdata/fn-source/subpkgs-with-krmignore/db/resources.yaml index dabe43cfa9..c9c269b1d7 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/db/resources.yaml +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/db/resources.yaml @@ -1,19 +1,19 @@ -# Copyright 2021 The kpt Authors -# -# 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: StatefulSet -metadata: - name: db -spec: - replicas: 3 +# Copyright 2021 The kpt Authors +# +# 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: StatefulSet +metadata: + name: db +spec: + replicas: 3 diff --git a/e2e/testdata/fn-source/subpkgs-with-krmignore/resources.yaml b/e2e/testdata/fn-source/subpkgs-with-krmignore/resources.yaml index f2eec524c6..9d1f786283 100644 --- a/e2e/testdata/fn-source/subpkgs-with-krmignore/resources.yaml +++ b/e2e/testdata/fn-source/subpkgs-with-krmignore/resources.yaml @@ -1,26 +1,26 @@ -# Copyright 2021 The kpt Authors -# -# 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 +# Copyright 2021 The kpt Authors +# +# 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 diff --git a/e2e/testdata/live-apply/apply-depends-on/config.yaml b/e2e/testdata/live-apply/apply-depends-on/config.yaml index c6a5e5418b..4d5f9ae72f 100644 --- a/e2e/testdata/live-apply/apply-depends-on/config.yaml +++ b/e2e/testdata/live-apply/apply-depends-on/config.yaml @@ -1,54 +1,54 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "apply" - - "--reconcile-timeout=2m" - -stdOut: | - inventory update started - inventory update finished - apply phase started - deployment.apps/first-nginx apply successful - apply phase finished - reconcile phase started - deployment.apps/first-nginx reconcile successful - reconcile phase finished - apply phase started - deployment.apps/second-nginx apply successful - apply phase finished - reconcile phase started - deployment.apps/second-nginx reconcile successful - reconcile phase finished - inventory update started - inventory update finished - apply result: 2 attempted, 2 successful, 0 skipped, 0 failed - reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out - -optionalStdOut: - - deployment.apps/first-nginx reconcile pending - - deployment.apps/second-nginx reconcile pending - -inventory: - - group: apps - kind: Deployment - name: first-nginx - namespace: apply-depends-on - - group: apps - kind: Deployment - name: second-nginx +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "apply" + - "--reconcile-timeout=2m" + +stdOut: | + inventory update started + inventory update finished + apply phase started + deployment.apps/first-nginx apply successful + apply phase finished + reconcile phase started + deployment.apps/first-nginx reconcile successful + reconcile phase finished + apply phase started + deployment.apps/second-nginx apply successful + apply phase finished + reconcile phase started + deployment.apps/second-nginx reconcile successful + reconcile phase finished + inventory update started + inventory update finished + apply result: 2 attempted, 2 successful, 0 skipped, 0 failed + reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out + +optionalStdOut: + - deployment.apps/first-nginx reconcile pending + - deployment.apps/second-nginx reconcile pending + +inventory: + - group: apps + kind: Deployment + name: first-nginx + namespace: apply-depends-on + - group: apps + kind: Deployment + name: second-nginx namespace: apply-depends-on \ No newline at end of file diff --git a/e2e/testdata/live-apply/apply-depends-on/resources/Kptfile b/e2e/testdata/live-apply/apply-depends-on/resources/Kptfile index 10c5447118..2b91300435 100644 --- a/e2e/testdata/live-apply/apply-depends-on/resources/Kptfile +++ b/e2e/testdata/live-apply/apply-depends-on/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: name: apply-depends-on \ No newline at end of file diff --git a/e2e/testdata/live-apply/apply-depends-on/resources/first.yaml b/e2e/testdata/live-apply/apply-depends-on/resources/first.yaml index a6c67fc138..d666507c34 100644 --- a/e2e/testdata/live-apply/apply-depends-on/resources/first.yaml +++ b/e2e/testdata/live-apply/apply-depends-on/resources/first.yaml @@ -1,38 +1,38 @@ -# Copyright 2021 The kpt Authors -# -# 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: first-nginx - namespace: apply-depends-on -spec: - replicas: 1 - selector: - matchLabels: - app: first-nginx - template: - metadata: - labels: - app: first-nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: - - containerPort: 80 - initContainers: - - name: init - image: busybox:1.28 +# Copyright 2021 The kpt Authors +# +# 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: first-nginx + namespace: apply-depends-on +spec: + replicas: 1 + selector: + matchLabels: + app: first-nginx + template: + metadata: + labels: + app: first-nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 + initContainers: + - name: init + image: busybox:1.28 command: ['sh', '-c', 'sleep 10'] \ No newline at end of file diff --git a/e2e/testdata/live-apply/apply-depends-on/resources/resourcegroup.yaml b/e2e/testdata/live-apply/apply-depends-on/resources/resourcegroup.yaml index 28a6b9c87e..40997002f2 100644 --- a/e2e/testdata/live-apply/apply-depends-on/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/apply-depends-on/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: apply-depends-on - namespace: apply-depends-on - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: apply-depends-on + namespace: apply-depends-on + labels: cli-utils.sigs.k8s.io/inventory-id: apply-depends-on \ No newline at end of file diff --git a/e2e/testdata/live-apply/apply-depends-on/resources/second.yaml b/e2e/testdata/live-apply/apply-depends-on/resources/second.yaml index 93320dc011..e44df7357f 100644 --- a/e2e/testdata/live-apply/apply-depends-on/resources/second.yaml +++ b/e2e/testdata/live-apply/apply-depends-on/resources/second.yaml @@ -1,40 +1,40 @@ -# Copyright 2021 The kpt Authors -# -# 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: second-nginx - namespace: apply-depends-on - annotations: - config.kubernetes.io/depends-on: apps/namespaces/apply-depends-on/Deployment/first-nginx -spec: - replicas: 1 - selector: - matchLabels: - app: second-nginx - template: - metadata: - labels: - app: second-nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: - - containerPort: 80 - initContainers: - - name: init - image: busybox:1.28 +# Copyright 2021 The kpt Authors +# +# 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: second-nginx + namespace: apply-depends-on + annotations: + config.kubernetes.io/depends-on: apps/namespaces/apply-depends-on/Deployment/first-nginx +spec: + replicas: 1 + selector: + matchLabels: + app: second-nginx + template: + metadata: + labels: + app: second-nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 + initContainers: + - name: init + image: busybox:1.28 command: ['sh', '-c', 'sleep 10'] \ No newline at end of file diff --git a/e2e/testdata/live-apply/crd-and-cr/config.yaml b/e2e/testdata/live-apply/crd-and-cr/config.yaml index 95cf45a0fc..4c9baed25a 100644 --- a/e2e/testdata/live-apply/crd-and-cr/config.yaml +++ b/e2e/testdata/live-apply/crd-and-cr/config.yaml @@ -1,52 +1,52 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "apply" - - "--reconcile-timeout=1m" - -stdOut: | - inventory update started - inventory update finished - apply phase started - customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev apply successful - apply phase finished - reconcile phase started - customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconcile successful - reconcile phase finished - apply phase started - custom.kpt.dev/cr apply successful - apply phase finished - reconcile phase started - custom.kpt.dev/cr reconcile successful - reconcile phase finished - inventory update started - inventory update finished - apply result: 2 attempted, 2 successful, 0 skipped, 0 failed - reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out - -optionalStdOut: - - customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconcile pending - - custom.kpt.dev/cr reconcile pending - -inventory: - - group: apiextensions.k8s.io - kind: CustomResourceDefinition - name: customs.kpt.dev - - group: kpt.dev - kind: Custom +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "apply" + - "--reconcile-timeout=1m" + +stdOut: | + inventory update started + inventory update finished + apply phase started + customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev apply successful + apply phase finished + reconcile phase started + customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconcile successful + reconcile phase finished + apply phase started + custom.kpt.dev/cr apply successful + apply phase finished + reconcile phase started + custom.kpt.dev/cr reconcile successful + reconcile phase finished + inventory update started + inventory update finished + apply result: 2 attempted, 2 successful, 0 skipped, 0 failed + reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out + +optionalStdOut: + - customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconcile pending + - custom.kpt.dev/cr reconcile pending + +inventory: + - group: apiextensions.k8s.io + kind: CustomResourceDefinition + name: customs.kpt.dev + - group: kpt.dev + kind: Custom name: cr \ No newline at end of file diff --git a/e2e/testdata/live-apply/crd-and-cr/resources/Kptfile b/e2e/testdata/live-apply/crd-and-cr/resources/Kptfile index d6bc18894c..4f47687fc2 100644 --- a/e2e/testdata/live-apply/crd-and-cr/resources/Kptfile +++ b/e2e/testdata/live-apply/crd-and-cr/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: crd-and-cr +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: crd-and-cr diff --git a/e2e/testdata/live-apply/crd-and-cr/resources/cr.yaml b/e2e/testdata/live-apply/crd-and-cr/resources/cr.yaml index 4469a1e516..615bbe4926 100644 --- a/e2e/testdata/live-apply/crd-and-cr/resources/cr.yaml +++ b/e2e/testdata/live-apply/crd-and-cr/resources/cr.yaml @@ -1,18 +1,18 @@ -# Copyright 2021 The kpt Authors -# -# 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: kpt.dev/v1 -kind: Custom -metadata: - name: cr +# Copyright 2021 The kpt Authors +# +# 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: kpt.dev/v1 +kind: Custom +metadata: + name: cr diff --git a/e2e/testdata/live-apply/crd-and-cr/resources/crd.yaml b/e2e/testdata/live-apply/crd-and-cr/resources/crd.yaml index 55818ee815..89a45adbd4 100644 --- a/e2e/testdata/live-apply/crd-and-cr/resources/crd.yaml +++ b/e2e/testdata/live-apply/crd-and-cr/resources/crd.yaml @@ -1,43 +1,43 @@ -# Copyright 2021 The kpt Authors -# -# 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: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: customs.kpt.dev -spec: - conversion: - strategy: None - group: kpt.dev - names: - kind: Custom - listKind: CustomList - plural: customs - singular: custom - scope: Cluster - versions: - - name: v1 - schema: - openAPIV3Schema: - properties: - apiVersion: - type: string - kind: - type: string - metadata: - type: object - type: object - served: true - storage: true - subresources: {} +# Copyright 2021 The kpt Authors +# +# 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: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: customs.kpt.dev +spec: + conversion: + strategy: None + group: kpt.dev + names: + kind: Custom + listKind: CustomList + plural: customs + singular: custom + scope: Cluster + versions: + - name: v1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + type: object + served: true + storage: true + subresources: {} diff --git a/e2e/testdata/live-apply/crd-and-cr/resources/resourcegroup.yaml b/e2e/testdata/live-apply/crd-and-cr/resources/resourcegroup.yaml index 4b87a0c45b..292cb7563f 100644 --- a/e2e/testdata/live-apply/crd-and-cr/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/crd-and-cr/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: crd-and-cr - namespace: crd-and-cr - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: crd-and-cr + namespace: crd-and-cr + labels: cli-utils.sigs.k8s.io/inventory-id: crd-and-cr \ No newline at end of file diff --git a/e2e/testdata/live-apply/dry-run-with-install-rg/config.yaml b/e2e/testdata/live-apply/dry-run-with-install-rg/config.yaml index e3ef5ae98b..054888263d 100644 --- a/e2e/testdata/live-apply/dry-run-with-install-rg/config.yaml +++ b/e2e/testdata/live-apply/dry-run-with-install-rg/config.yaml @@ -1,27 +1,27 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: false -noResourceGroup: true -kptArgs: - - "live" - - "apply" - - "--dry-run" - - "--install-resource-group" -stdOut: | - deployment.apps/nginx-deployment created - 1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed -stdErr: | - installing inventory ResourceGroup CRD. +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: false +noResourceGroup: true +kptArgs: + - "live" + - "apply" + - "--dry-run" + - "--install-resource-group" +stdOut: | + deployment.apps/nginx-deployment created + 1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed +stdErr: | + installing inventory ResourceGroup CRD. exitCode: 0 \ No newline at end of file diff --git a/e2e/testdata/live-apply/dry-run-with-install-rg/resources/Kptfile b/e2e/testdata/live-apply/dry-run-with-install-rg/resources/Kptfile index 2550e3f4e2..e933715aea 100644 --- a/e2e/testdata/live-apply/dry-run-with-install-rg/resources/Kptfile +++ b/e2e/testdata/live-apply/dry-run-with-install-rg/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: dry-run-with-install-rg +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: dry-run-with-install-rg diff --git a/e2e/testdata/live-apply/dry-run-with-install-rg/resources/deployment.yaml b/e2e/testdata/live-apply/dry-run-with-install-rg/resources/deployment.yaml index 2df332158a..1f647b8381 100644 --- a/e2e/testdata/live-apply/dry-run-with-install-rg/resources/deployment.yaml +++ b/e2e/testdata/live-apply/dry-run-with-install-rg/resources/deployment.yaml @@ -1,42 +1,42 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: dry-run-with-install-rg - labels: - app: nginx-deployment -spec: - strategy: - rollingUpdate: - maxUnavailable: 1 - maxSurge: 0 - replicas: 1 - selector: - matchLabels: - app: nginx-deployment - template: - metadata: - labels: - app: nginx-deployment - pdb: mypdb - spec: - containers: - - name: nginx - image: nginx:1.7.10 - ports: - - containerPort: 80 - protocol: TCP +# Copyright 2021 The kpt Authors +# +# 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 + namespace: dry-run-with-install-rg + labels: + app: nginx-deployment +spec: + strategy: + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + replicas: 1 + selector: + matchLabels: + app: nginx-deployment + template: + metadata: + labels: + app: nginx-deployment + pdb: mypdb + spec: + containers: + - name: nginx + image: nginx:1.7.10 + ports: + - containerPort: 80 + protocol: TCP diff --git a/e2e/testdata/live-apply/dry-run-with-install-rg/resources/resourcegroup.yaml b/e2e/testdata/live-apply/dry-run-with-install-rg/resources/resourcegroup.yaml index b475f62426..ef704dc882 100644 --- a/e2e/testdata/live-apply/dry-run-with-install-rg/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/dry-run-with-install-rg/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: dry-run-with-install-rg - namespace: dry-run-with-install-rg - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: dry-run-with-install-rg + namespace: dry-run-with-install-rg + labels: cli-utils.sigs.k8s.io/inventory-id: dry-run-with-install-rg \ No newline at end of file diff --git a/e2e/testdata/live-apply/dry-run-without-rg/config.yaml b/e2e/testdata/live-apply/dry-run-without-rg/config.yaml index 5a8061f300..6f0d7b3bc9 100644 --- a/e2e/testdata/live-apply/dry-run-without-rg/config.yaml +++ b/e2e/testdata/live-apply/dry-run-without-rg/config.yaml @@ -1,23 +1,23 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: false -noResourceGroup: true -kptArgs: - - "live" - - "apply" - - "--dry-run" -stdErr: | - Error: The ResourceGroup CRD was not found in the cluster. Please install it either by using the '--install-resource-group' flag or the 'kpt live install-resource-group' command. +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: false +noResourceGroup: true +kptArgs: + - "live" + - "apply" + - "--dry-run" +stdErr: | + Error: The ResourceGroup CRD was not found in the cluster. Please install it either by using the '--install-resource-group' flag or the 'kpt live install-resource-group' command. exitCode: 1 \ No newline at end of file diff --git a/e2e/testdata/live-apply/dry-run-without-rg/resources/Kptfile b/e2e/testdata/live-apply/dry-run-without-rg/resources/Kptfile index 60134cc795..38ed992f49 100644 --- a/e2e/testdata/live-apply/dry-run-without-rg/resources/Kptfile +++ b/e2e/testdata/live-apply/dry-run-without-rg/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: dry-run-without-rg +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: dry-run-without-rg diff --git a/e2e/testdata/live-apply/dry-run-without-rg/resources/deployment.yaml b/e2e/testdata/live-apply/dry-run-without-rg/resources/deployment.yaml index 31feefaf29..253191c126 100644 --- a/e2e/testdata/live-apply/dry-run-without-rg/resources/deployment.yaml +++ b/e2e/testdata/live-apply/dry-run-without-rg/resources/deployment.yaml @@ -1,42 +1,42 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: dry-run-without-rg - labels: - app: nginx-deployment -spec: - strategy: - rollingUpdate: - maxUnavailable: 1 - maxSurge: 0 - replicas: 2 - selector: - matchLabels: - app: nginx-deployment - template: - metadata: - labels: - app: nginx-deployment - pdb: mypdb - spec: - containers: - - name: nginx - image: nginx:1.7.10 - ports: - - containerPort: 80 - protocol: TCP +# Copyright 2021 The kpt Authors +# +# 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 + namespace: dry-run-without-rg + labels: + app: nginx-deployment +spec: + strategy: + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + replicas: 2 + selector: + matchLabels: + app: nginx-deployment + template: + metadata: + labels: + app: nginx-deployment + pdb: mypdb + spec: + containers: + - name: nginx + image: nginx:1.7.10 + ports: + - containerPort: 80 + protocol: TCP diff --git a/e2e/testdata/live-apply/dry-run-without-rg/resources/resourcegroup.yaml b/e2e/testdata/live-apply/dry-run-without-rg/resources/resourcegroup.yaml index c210ca3130..5070e03e4c 100644 --- a/e2e/testdata/live-apply/dry-run-without-rg/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/dry-run-without-rg/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: dry-run-without-rg - namespace: dry-run-without-rg - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: dry-run-without-rg + namespace: dry-run-without-rg + labels: cli-utils.sigs.k8s.io/inventory-id: dry-run-without-rg \ No newline at end of file diff --git a/e2e/testdata/live-apply/install-rg-on-apply/config.yaml b/e2e/testdata/live-apply/install-rg-on-apply/config.yaml index 251f86f5b1..3e82580828 100644 --- a/e2e/testdata/live-apply/install-rg-on-apply/config.yaml +++ b/e2e/testdata/live-apply/install-rg-on-apply/config.yaml @@ -1,30 +1,30 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: false -noResourceGroup: true -kptArgs: - - "live" - - "apply" - - "--reconcile-timeout=1m" -stdOut: | - deployment.apps/nginx-deployment created - 1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed -stdErr: | - installing inventory ResourceGroup CRD. -inventory: - - group: apps - kind: Deployment - name: nginx-deployment +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: false +noResourceGroup: true +kptArgs: + - "live" + - "apply" + - "--reconcile-timeout=1m" +stdOut: | + deployment.apps/nginx-deployment created + 1 resource(s) applied. 1 created, 0 unchanged, 0 configured, 0 failed +stdErr: | + installing inventory ResourceGroup CRD. +inventory: + - group: apps + kind: Deployment + name: nginx-deployment namespace: install-rg-on-apply \ No newline at end of file diff --git a/e2e/testdata/live-apply/install-rg-on-apply/resources/Kptfile b/e2e/testdata/live-apply/install-rg-on-apply/resources/Kptfile index cd2ed9dae5..3ae83d3cd8 100644 --- a/e2e/testdata/live-apply/install-rg-on-apply/resources/Kptfile +++ b/e2e/testdata/live-apply/install-rg-on-apply/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: install-rg-on-apply +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: install-rg-on-apply diff --git a/e2e/testdata/live-apply/install-rg-on-apply/resources/deployment.yaml b/e2e/testdata/live-apply/install-rg-on-apply/resources/deployment.yaml index c01c371b25..8d03cc6130 100644 --- a/e2e/testdata/live-apply/install-rg-on-apply/resources/deployment.yaml +++ b/e2e/testdata/live-apply/install-rg-on-apply/resources/deployment.yaml @@ -1,42 +1,42 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: install-rg-on-apply - labels: - app: nginx-deployment -spec: - strategy: - rollingUpdate: - maxUnavailable: 1 - maxSurge: 0 - replicas: 1 - selector: - matchLabels: - app: nginx-deployment - template: - metadata: - labels: - app: nginx-deployment - pdb: mypdb - spec: - containers: - - name: nginx - image: nginx:1.7.10 - ports: - - containerPort: 80 - protocol: TCP +# Copyright 2021 The kpt Authors +# +# 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 + namespace: install-rg-on-apply + labels: + app: nginx-deployment +spec: + strategy: + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + replicas: 1 + selector: + matchLabels: + app: nginx-deployment + template: + metadata: + labels: + app: nginx-deployment + pdb: mypdb + spec: + containers: + - name: nginx + image: nginx:1.7.10 + ports: + - containerPort: 80 + protocol: TCP diff --git a/e2e/testdata/live-apply/install-rg-on-apply/resources/resourcegroup.yaml b/e2e/testdata/live-apply/install-rg-on-apply/resources/resourcegroup.yaml index e125343c8f..58559f8467 100644 --- a/e2e/testdata/live-apply/install-rg-on-apply/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/install-rg-on-apply/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: install-rg-on-apply - namespace: install-rg-on-apply - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: install-rg-on-apply + namespace: install-rg-on-apply + labels: cli-utils.sigs.k8s.io/inventory-id: install-rg-on-apply \ No newline at end of file diff --git a/e2e/testdata/live-apply/invalid-annotation-type/config.yaml b/e2e/testdata/live-apply/invalid-annotation-type/config.yaml index b60c0a7f90..9061433327 100644 --- a/e2e/testdata/live-apply/invalid-annotation-type/config.yaml +++ b/e2e/testdata/live-apply/invalid-annotation-type/config.yaml @@ -1,26 +1,26 @@ -# Copyright 2026 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "apply" - -# Expected exit code is non-zero (failure) -exitCode: 1 - -# Error should be in stderr with clear message about which field failed -stdErr: | - error: annotation "example.com/enabled" must be a string, got boolean +# Copyright 2026 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "apply" + +# Expected exit code is non-zero (failure) +exitCode: 1 + +# Error should be in stderr with clear message about which field failed +stdErr: | + error: annotation "example.com/enabled" must be a string, got boolean diff --git a/e2e/testdata/live-apply/invalid-annotation-type/resources/Kptfile b/e2e/testdata/live-apply/invalid-annotation-type/resources/Kptfile index b9885409ca..12d45416ab 100644 --- a/e2e/testdata/live-apply/invalid-annotation-type/resources/Kptfile +++ b/e2e/testdata/live-apply/invalid-annotation-type/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: invalid-annotation-type +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: invalid-annotation-type diff --git a/e2e/testdata/live-apply/invalid-annotation-type/resources/configmap.yaml b/e2e/testdata/live-apply/invalid-annotation-type/resources/configmap.yaml index 0374425ca3..4868913e4f 100644 --- a/e2e/testdata/live-apply/invalid-annotation-type/resources/configmap.yaml +++ b/e2e/testdata/live-apply/invalid-annotation-type/resources/configmap.yaml @@ -1,8 +1,8 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: bad-config - annotations: - example.com/enabled: true -data: - key: value +apiVersion: v1 +kind: ConfigMap +metadata: + name: bad-config + annotations: + example.com/enabled: true +data: + key: value diff --git a/e2e/testdata/live-apply/invalid-annotation-type/resources/resourcegroup.yaml b/e2e/testdata/live-apply/invalid-annotation-type/resources/resourcegroup.yaml index 743400581e..55327fb043 100644 --- a/e2e/testdata/live-apply/invalid-annotation-type/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/invalid-annotation-type/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: inventory-obj - namespace: invalid-annotation-type - labels: - cli-utils.sigs.k8s.io/inventory-id: test-invalid-annotation +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: inventory-obj + namespace: invalid-annotation-type + labels: + cli-utils.sigs.k8s.io/inventory-id: test-invalid-annotation diff --git a/e2e/testdata/live-apply/invalid-label-type/config.yaml b/e2e/testdata/live-apply/invalid-label-type/config.yaml index 0e6801f469..56edcfe2a5 100644 --- a/e2e/testdata/live-apply/invalid-label-type/config.yaml +++ b/e2e/testdata/live-apply/invalid-label-type/config.yaml @@ -1,26 +1,26 @@ -# Copyright 2026 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "apply" - -# Expected exit code is non-zero (failure) -exitCode: 1 - -# Error should be in stderr with clear message about which field failed -stdErr: | - error: label "app.kubernetes.io/enabled" must be a string, got boolean +# Copyright 2026 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "apply" + +# Expected exit code is non-zero (failure) +exitCode: 1 + +# Error should be in stderr with clear message about which field failed +stdErr: | + error: label "app.kubernetes.io/enabled" must be a string, got boolean diff --git a/e2e/testdata/live-apply/invalid-label-type/resources/Kptfile b/e2e/testdata/live-apply/invalid-label-type/resources/Kptfile index b012510030..cb56ca9e64 100644 --- a/e2e/testdata/live-apply/invalid-label-type/resources/Kptfile +++ b/e2e/testdata/live-apply/invalid-label-type/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: invalid-label-type +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: invalid-label-type diff --git a/e2e/testdata/live-apply/invalid-label-type/resources/configmap.yaml b/e2e/testdata/live-apply/invalid-label-type/resources/configmap.yaml index 0b6b83639b..e78d405db6 100644 --- a/e2e/testdata/live-apply/invalid-label-type/resources/configmap.yaml +++ b/e2e/testdata/live-apply/invalid-label-type/resources/configmap.yaml @@ -1,8 +1,8 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: bad-label-config - labels: - app.kubernetes.io/enabled: true -data: - key: value +apiVersion: v1 +kind: ConfigMap +metadata: + name: bad-label-config + labels: + app.kubernetes.io/enabled: true +data: + key: value diff --git a/e2e/testdata/live-apply/invalid-label-type/resources/resourcegroup.yaml b/e2e/testdata/live-apply/invalid-label-type/resources/resourcegroup.yaml index 532e201fd6..18f1d49478 100644 --- a/e2e/testdata/live-apply/invalid-label-type/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/invalid-label-type/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: inventory-obj - namespace: invalid-label-type - labels: - cli-utils.sigs.k8s.io/inventory-id: test-invalid-label +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: inventory-obj + namespace: invalid-label-type + labels: + cli-utils.sigs.k8s.io/inventory-id: test-invalid-label diff --git a/e2e/testdata/live-apply/json-output/config.yaml b/e2e/testdata/live-apply/json-output/config.yaml index 6ea446894b..2c42228532 100644 --- a/e2e/testdata/live-apply/json-output/config.yaml +++ b/e2e/testdata/live-apply/json-output/config.yaml @@ -1,67 +1,67 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: true -kptArgs: - - "live" - - "apply" - - "--output=json" - - "--reconcile-timeout=2m" -stdOut: | - {"action":"Inventory","status":"Started","timestamp":"","type":"group"} - {"action":"Inventory","status":"Finished","timestamp":"","type":"group"} - {"action":"Apply","status":"Started","timestamp":"","type":"group"} - {"group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","status":"Successful","timestamp":"","type":"apply"} - {"action":"Apply","count":1,"failed":0,"skipped":0,"status":"Finished","successful":1,"timestamp":"","type":"group"} - {"action":"Wait","status":"Started","timestamp":"","type":"group"} - {"group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} - {"action":"Wait","count":1,"failed":0,"skipped":0,"status":"Finished","successful":1,"timeout":0,"timestamp":"","type":"group"} - {"action":"Apply","status":"Started","timestamp":"","type":"group"} - {"group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"apply"} - {"action":"Apply","count":2,"failed":0,"skipped":0,"status":"Finished","successful":2,"timestamp":"","type":"group"} - {"action":"Wait","status":"Started","timestamp":"","type":"group"} - {"group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} - {"action":"Wait","count":2,"failed":0,"skipped":0,"status":"Finished","successful":2,"timeout":0,"timestamp":"","type":"group"} - {"action":"Prune","status":"Started","timestamp":"","type":"group"} - {"group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"prune"} - {"action":"Prune","count":1,"failed":0,"skipped":0,"status":"Finished","successful":1,"timestamp":"","type":"group"} - {"action":"Wait","status":"Started","timestamp":"","type":"group"} - {"group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} - {"action":"Wait","count":3,"failed":0,"skipped":0,"status":"Finished","successful":3,"timeout":0,"timestamp":"","type":"group"} - {"action":"Prune","status":"Started","timestamp":"","type":"group"} - {"group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"prune"} - {"action":"Prune","count":2,"failed":0,"skipped":0,"status":"Finished","successful":2,"timestamp":"","type":"group"} - {"action":"Wait","status":"Started","timestamp":"","type":"group"} - {"group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} - {"action":"Wait","count":4,"failed":0,"skipped":0,"status":"Finished","successful":4,"timeout":0,"timestamp":"","type":"group"} - {"action":"Inventory","status":"Started","timestamp":"","type":"group"} - {"action":"Inventory","status":"Finished","timestamp":"","type":"group"} - {"action":"Apply","count":2,"failed":0,"skipped":0,"successful":2,"timestamp":"","type":"summary"} - {"action":"Prune","count":2,"failed":0,"skipped":0,"successful":2,"timestamp":"","type":"summary"} - {"action":"Wait","count":4,"failed":0,"skipped":0,"successful":4,"timeout":0,"timestamp":"","type":"summary"} - -optionalStdOut: - - '{"group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' - - '{"group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' - - '{"group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' - - '{"group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' - -inventory: - - kind: ConfigMap - name: cm - namespace: json-output - - group: apps - kind: Deployment - name: nginx +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: true +kptArgs: + - "live" + - "apply" + - "--output=json" + - "--reconcile-timeout=2m" +stdOut: | + {"action":"Inventory","status":"Started","timestamp":"","type":"group"} + {"action":"Inventory","status":"Finished","timestamp":"","type":"group"} + {"action":"Apply","status":"Started","timestamp":"","type":"group"} + {"group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","status":"Successful","timestamp":"","type":"apply"} + {"action":"Apply","count":1,"failed":0,"skipped":0,"status":"Finished","successful":1,"timestamp":"","type":"group"} + {"action":"Wait","status":"Started","timestamp":"","type":"group"} + {"group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} + {"action":"Wait","count":1,"failed":0,"skipped":0,"status":"Finished","successful":1,"timeout":0,"timestamp":"","type":"group"} + {"action":"Apply","status":"Started","timestamp":"","type":"group"} + {"group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"apply"} + {"action":"Apply","count":2,"failed":0,"skipped":0,"status":"Finished","successful":2,"timestamp":"","type":"group"} + {"action":"Wait","status":"Started","timestamp":"","type":"group"} + {"group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} + {"action":"Wait","count":2,"failed":0,"skipped":0,"status":"Finished","successful":2,"timeout":0,"timestamp":"","type":"group"} + {"action":"Prune","status":"Started","timestamp":"","type":"group"} + {"group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"prune"} + {"action":"Prune","count":1,"failed":0,"skipped":0,"status":"Finished","successful":1,"timestamp":"","type":"group"} + {"action":"Wait","status":"Started","timestamp":"","type":"group"} + {"group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} + {"action":"Wait","count":3,"failed":0,"skipped":0,"status":"Finished","successful":3,"timeout":0,"timestamp":"","type":"group"} + {"action":"Prune","status":"Started","timestamp":"","type":"group"} + {"group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"prune"} + {"action":"Prune","count":2,"failed":0,"skipped":0,"status":"Finished","successful":2,"timestamp":"","type":"group"} + {"action":"Wait","status":"Started","timestamp":"","type":"group"} + {"group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","status":"Successful","timestamp":"","type":"wait"} + {"action":"Wait","count":4,"failed":0,"skipped":0,"status":"Finished","successful":4,"timeout":0,"timestamp":"","type":"group"} + {"action":"Inventory","status":"Started","timestamp":"","type":"group"} + {"action":"Inventory","status":"Finished","timestamp":"","type":"group"} + {"action":"Apply","count":2,"failed":0,"skipped":0,"successful":2,"timestamp":"","type":"summary"} + {"action":"Prune","count":2,"failed":0,"skipped":0,"successful":2,"timestamp":"","type":"summary"} + {"action":"Wait","count":4,"failed":0,"skipped":0,"successful":4,"timeout":0,"timestamp":"","type":"summary"} + +optionalStdOut: + - '{"group":"","kind":"ConfigMap","name":"cm","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' + - '{"group":"apps","kind":"Deployment","name":"nginx","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' + - '{"group":"apps","kind":"Deployment","name":"second-nginx","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' + - '{"group":"apps","kind":"Deployment","name":"first-nginx","namespace":"json-output","status":"Pending","timestamp":"","type":"wait"}' + +inventory: + - kind: ConfigMap + name: cm + namespace: json-output + - group: apps + kind: Deployment + name: nginx namespace: json-output \ No newline at end of file diff --git a/e2e/testdata/live-apply/json-output/pre-apply/first.yaml b/e2e/testdata/live-apply/json-output/pre-apply/first.yaml index 40b5b531f5..92f2048b27 100644 --- a/e2e/testdata/live-apply/json-output/pre-apply/first.yaml +++ b/e2e/testdata/live-apply/json-output/pre-apply/first.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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: first-nginx - namespace: json-output - annotations: - config.k8s.io/owning-inventory: json-output -spec: - replicas: 1 - selector: - matchLabels: - app: first-nginx - template: - metadata: - labels: - app: first-nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: +# Copyright 2021 The kpt Authors +# +# 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: first-nginx + namespace: json-output + annotations: + config.k8s.io/owning-inventory: json-output +spec: + replicas: 1 + selector: + matchLabels: + app: first-nginx + template: + metadata: + labels: + app: first-nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: - containerPort: 80 \ No newline at end of file diff --git a/e2e/testdata/live-apply/json-output/pre-apply/rg.yaml b/e2e/testdata/live-apply/json-output/pre-apply/rg.yaml index 59014ff382..0e8443768d 100644 --- a/e2e/testdata/live-apply/json-output/pre-apply/rg.yaml +++ b/e2e/testdata/live-apply/json-output/pre-apply/rg.yaml @@ -1,31 +1,31 @@ -# Copyright 2021 The kpt Authors -# -# 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: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - labels: - cli-utils.sigs.k8s.io/inventory-id: json-output - name: json-output - namespace: json-output -spec: - resources: - - group: apps - kind: Deployment - name: first-nginx - namespace: json-output - - group: apps - kind: Deployment - name: second-nginx +# Copyright 2021 The kpt Authors +# +# 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: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + labels: + cli-utils.sigs.k8s.io/inventory-id: json-output + name: json-output + namespace: json-output +spec: + resources: + - group: apps + kind: Deployment + name: first-nginx + namespace: json-output + - group: apps + kind: Deployment + name: second-nginx namespace: json-output \ No newline at end of file diff --git a/e2e/testdata/live-apply/json-output/pre-apply/second.yaml b/e2e/testdata/live-apply/json-output/pre-apply/second.yaml index bfd63d113d..ed1a680695 100644 --- a/e2e/testdata/live-apply/json-output/pre-apply/second.yaml +++ b/e2e/testdata/live-apply/json-output/pre-apply/second.yaml @@ -1,37 +1,37 @@ -# Copyright 2021 The kpt Authors -# -# 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: second-nginx - namespace: json-output - annotations: - config.k8s.io/owning-inventory: json-output - config.kubernetes.io/depends-on: apps/namespaces/json-output/Deployment/first-nginx -spec: - replicas: 1 - selector: - matchLabels: - app: second-nginx - template: - metadata: - labels: - app: second-nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: +# Copyright 2021 The kpt Authors +# +# 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: second-nginx + namespace: json-output + annotations: + config.k8s.io/owning-inventory: json-output + config.kubernetes.io/depends-on: apps/namespaces/json-output/Deployment/first-nginx +spec: + replicas: 1 + selector: + matchLabels: + app: second-nginx + template: + metadata: + labels: + app: second-nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: - containerPort: 80 \ No newline at end of file diff --git a/e2e/testdata/live-apply/json-output/resources/Kptfile b/e2e/testdata/live-apply/json-output/resources/Kptfile index bbda252a67..bbfaaa1274 100644 --- a/e2e/testdata/live-apply/json-output/resources/Kptfile +++ b/e2e/testdata/live-apply/json-output/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: json-output +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: json-output diff --git a/e2e/testdata/live-apply/json-output/resources/cm.yaml b/e2e/testdata/live-apply/json-output/resources/cm.yaml index 556cf4e6b6..c920e4b7f2 100644 --- a/e2e/testdata/live-apply/json-output/resources/cm.yaml +++ b/e2e/testdata/live-apply/json-output/resources/cm.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: cm - namespace: json-output -data: +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: cm + namespace: json-output +data: foo: bar \ No newline at end of file diff --git a/e2e/testdata/live-apply/json-output/resources/dep.yaml b/e2e/testdata/live-apply/json-output/resources/dep.yaml index ea4808df4d..21c022b678 100644 --- a/e2e/testdata/live-apply/json-output/resources/dep.yaml +++ b/e2e/testdata/live-apply/json-output/resources/dep.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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 - namespace: json-output - annotations: - config.kubernetes.io/depends-on: /namespaces/json-output/ConfigMap/cm -spec: - replicas: 1 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: +# Copyright 2021 The kpt Authors +# +# 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 + namespace: json-output + annotations: + config.kubernetes.io/depends-on: /namespaces/json-output/ConfigMap/cm +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: - containerPort: 80 \ No newline at end of file diff --git a/e2e/testdata/live-apply/json-output/resources/resourcegroup.yaml b/e2e/testdata/live-apply/json-output/resources/resourcegroup.yaml index a592a77aaf..b77956cf13 100644 --- a/e2e/testdata/live-apply/json-output/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/json-output/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: json-output - namespace: json-output - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: json-output + namespace: json-output + labels: cli-utils.sigs.k8s.io/inventory-id: json-output \ No newline at end of file diff --git a/e2e/testdata/live-apply/prune-depends-on/config.yaml b/e2e/testdata/live-apply/prune-depends-on/config.yaml index 8dd762a011..38c8c226ba 100644 --- a/e2e/testdata/live-apply/prune-depends-on/config.yaml +++ b/e2e/testdata/live-apply/prune-depends-on/config.yaml @@ -1,58 +1,58 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "apply" - - "--reconcile-timeout=1m" - -stdOut: | - inventory update started - inventory update finished - apply phase started - configmap/cm apply successful - apply phase finished - reconcile phase started - configmap/cm reconcile successful - reconcile phase finished - prune phase started - deployment.apps/second-nginx prune successful - prune phase finished - reconcile phase started - deployment.apps/second-nginx reconcile successful - reconcile phase finished - prune phase started - deployment.apps/first-nginx prune successful - prune phase finished - reconcile phase started - deployment.apps/first-nginx reconcile successful - reconcile phase finished - inventory update started - inventory update finished - apply result: 1 attempted, 1 successful, 0 skipped, 0 failed - prune result: 2 attempted, 2 successful, 0 skipped, 0 failed - reconcile result: 3 attempted, 3 successful, 0 skipped, 0 failed, 0 timed out - - -optionalStdOut: - - configmap/cm reconcile pending - - deployment.apps/second-nginx reconcile pending - - deployment.apps/first-nginx reconcile pending - -inventory: - - kind: ConfigMap - name: cm +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "apply" + - "--reconcile-timeout=1m" + +stdOut: | + inventory update started + inventory update finished + apply phase started + configmap/cm apply successful + apply phase finished + reconcile phase started + configmap/cm reconcile successful + reconcile phase finished + prune phase started + deployment.apps/second-nginx prune successful + prune phase finished + reconcile phase started + deployment.apps/second-nginx reconcile successful + reconcile phase finished + prune phase started + deployment.apps/first-nginx prune successful + prune phase finished + reconcile phase started + deployment.apps/first-nginx reconcile successful + reconcile phase finished + inventory update started + inventory update finished + apply result: 1 attempted, 1 successful, 0 skipped, 0 failed + prune result: 2 attempted, 2 successful, 0 skipped, 0 failed + reconcile result: 3 attempted, 3 successful, 0 skipped, 0 failed, 0 timed out + + +optionalStdOut: + - configmap/cm reconcile pending + - deployment.apps/second-nginx reconcile pending + - deployment.apps/first-nginx reconcile pending + +inventory: + - kind: ConfigMap + name: cm namespace: prune-depends-on \ No newline at end of file diff --git a/e2e/testdata/live-apply/prune-depends-on/pre-apply/first.yaml b/e2e/testdata/live-apply/prune-depends-on/pre-apply/first.yaml index 86b4608ba8..29ea00ab66 100644 --- a/e2e/testdata/live-apply/prune-depends-on/pre-apply/first.yaml +++ b/e2e/testdata/live-apply/prune-depends-on/pre-apply/first.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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: first-nginx - namespace: prune-depends-on - annotations: - config.k8s.io/owning-inventory: prune-depends-on -spec: - replicas: 1 - selector: - matchLabels: - app: first-nginx - template: - metadata: - labels: - app: first-nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: +# Copyright 2021 The kpt Authors +# +# 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: first-nginx + namespace: prune-depends-on + annotations: + config.k8s.io/owning-inventory: prune-depends-on +spec: + replicas: 1 + selector: + matchLabels: + app: first-nginx + template: + metadata: + labels: + app: first-nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: - containerPort: 80 \ No newline at end of file diff --git a/e2e/testdata/live-apply/prune-depends-on/pre-apply/rg.yaml b/e2e/testdata/live-apply/prune-depends-on/pre-apply/rg.yaml index 8aa803bac0..bff250280c 100644 --- a/e2e/testdata/live-apply/prune-depends-on/pre-apply/rg.yaml +++ b/e2e/testdata/live-apply/prune-depends-on/pre-apply/rg.yaml @@ -1,31 +1,31 @@ -# Copyright 2021 The kpt Authors -# -# 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: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - labels: - cli-utils.sigs.k8s.io/inventory-id: prune-depends-on - name: prune-depends-on - namespace: prune-depends-on -spec: - resources: - - group: apps - kind: Deployment - name: first-nginx - namespace: prune-depends-on - - group: apps - kind: Deployment - name: second-nginx +# Copyright 2021 The kpt Authors +# +# 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: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + labels: + cli-utils.sigs.k8s.io/inventory-id: prune-depends-on + name: prune-depends-on + namespace: prune-depends-on +spec: + resources: + - group: apps + kind: Deployment + name: first-nginx + namespace: prune-depends-on + - group: apps + kind: Deployment + name: second-nginx namespace: prune-depends-on \ No newline at end of file diff --git a/e2e/testdata/live-apply/prune-depends-on/pre-apply/second.yaml b/e2e/testdata/live-apply/prune-depends-on/pre-apply/second.yaml index 511d8740d9..d3d07c9b24 100644 --- a/e2e/testdata/live-apply/prune-depends-on/pre-apply/second.yaml +++ b/e2e/testdata/live-apply/prune-depends-on/pre-apply/second.yaml @@ -1,37 +1,37 @@ -# Copyright 2021 The kpt Authors -# -# 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: second-nginx - namespace: prune-depends-on - annotations: - config.k8s.io/owning-inventory: prune-depends-on - config.kubernetes.io/depends-on: apps/namespaces/prune-depends-on/Deployment/first-nginx -spec: - replicas: 1 - selector: - matchLabels: - app: second-nginx - template: - metadata: - labels: - app: second-nginx - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: +# Copyright 2021 The kpt Authors +# +# 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: second-nginx + namespace: prune-depends-on + annotations: + config.k8s.io/owning-inventory: prune-depends-on + config.kubernetes.io/depends-on: apps/namespaces/prune-depends-on/Deployment/first-nginx +spec: + replicas: 1 + selector: + matchLabels: + app: second-nginx + template: + metadata: + labels: + app: second-nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: - containerPort: 80 \ No newline at end of file diff --git a/e2e/testdata/live-apply/prune-depends-on/resources/Kptfile b/e2e/testdata/live-apply/prune-depends-on/resources/Kptfile index e53a1c30e4..05b748d033 100644 --- a/e2e/testdata/live-apply/prune-depends-on/resources/Kptfile +++ b/e2e/testdata/live-apply/prune-depends-on/resources/Kptfile @@ -1,4 +1,4 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: prune-depends-on +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: prune-depends-on diff --git a/e2e/testdata/live-apply/prune-depends-on/resources/cm.yaml b/e2e/testdata/live-apply/prune-depends-on/resources/cm.yaml index 053db10b60..9a9b843f1f 100644 --- a/e2e/testdata/live-apply/prune-depends-on/resources/cm.yaml +++ b/e2e/testdata/live-apply/prune-depends-on/resources/cm.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: cm - namespace: prune-depends-on -data: +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: cm + namespace: prune-depends-on +data: foo: bar \ No newline at end of file diff --git a/e2e/testdata/live-apply/prune-depends-on/resources/resourcegroup.yaml b/e2e/testdata/live-apply/prune-depends-on/resources/resourcegroup.yaml index a23b3d3941..2444639761 100644 --- a/e2e/testdata/live-apply/prune-depends-on/resources/resourcegroup.yaml +++ b/e2e/testdata/live-apply/prune-depends-on/resources/resourcegroup.yaml @@ -1,7 +1,7 @@ -apiVersion: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - name: prune-depends-on - namespace: prune-depends-on - labels: +apiVersion: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + name: prune-depends-on + namespace: prune-depends-on + labels: cli-utils.sigs.k8s.io/inventory-id: prune-depends-on \ No newline at end of file diff --git a/e2e/testdata/live-plan/create/config.yaml b/e2e/testdata/live-plan/create/config.yaml index b9124540ee..e0b9ab3199 100644 --- a/e2e/testdata/live-plan/create/config.yaml +++ b/e2e/testdata/live-plan/create/config.yaml @@ -1,61 +1,61 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "plan" - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - apiVersion: config.google.com/v1alpha1 - kind: Plan - metadata: - name: plan - spec: - actions: - - action: ApplyCreate - kind: ConfigMap - name: foo - namespace: create - after: - object: - apiVersion: v1 - data: - key: value - kind: ConfigMap - metadata: - annotations: - config.k8s.io/owning-inventory: create - creationTimestamp: "" - managedFields: - - apiVersion: v1 - fieldsType: FieldsV1 - fieldsV1: - f:data: - f:key: {} - f:metadata: - f:annotations: - f:config.k8s.io/owning-inventory: {} - manager: kubectl - operation: Apply - time: "" - name: foo - namespace: create - uid: - - +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "plan" + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - apiVersion: config.google.com/v1alpha1 + kind: Plan + metadata: + name: plan + spec: + actions: + - action: ApplyCreate + kind: ConfigMap + name: foo + namespace: create + after: + object: + apiVersion: v1 + data: + key: value + kind: ConfigMap + metadata: + annotations: + config.k8s.io/owning-inventory: create + creationTimestamp: "" + managedFields: + - apiVersion: v1 + fieldsType: FieldsV1 + fieldsV1: + f:data: + f:key: {} + f:metadata: + f:annotations: + f:config.k8s.io/owning-inventory: {} + manager: kubectl + operation: Apply + time: "" + name: foo + namespace: create + uid: + + diff --git a/e2e/testdata/live-plan/create/resources/Kptfile b/e2e/testdata/live-plan/create/resources/Kptfile index 946835b48f..74ad0548cc 100644 --- a/e2e/testdata/live-plan/create/resources/Kptfile +++ b/e2e/testdata/live-plan/create/resources/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: create -inventory: - namespace: create - name: create - inventoryID: create +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: create +inventory: + namespace: create + name: create + inventoryID: create diff --git a/e2e/testdata/live-plan/create/resources/cm.yaml b/e2e/testdata/live-plan/create/resources/cm.yaml index 73dd2cd700..01d955bc9b 100644 --- a/e2e/testdata/live-plan/create/resources/cm.yaml +++ b/e2e/testdata/live-plan/create/resources/cm.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: foo - namespace: create -data: +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: foo + namespace: create +data: key: value \ No newline at end of file diff --git a/e2e/testdata/live-plan/prune/config.yaml b/e2e/testdata/live-plan/prune/config.yaml index b3eefec1f0..c08e2dbccb 100644 --- a/e2e/testdata/live-plan/prune/config.yaml +++ b/e2e/testdata/live-plan/prune/config.yaml @@ -1,210 +1,210 @@ -# Copyright 2021 The kpt Authors -# -# 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. - -parallel: true - -kptArgs: - - "live" - - "plan" - -stdOut: | - apiVersion: config.kubernetes.io/v1 - kind: ResourceList - items: - - apiVersion: config.google.com/v1alpha1 - kind: Plan - metadata: - name: plan - spec: - actions: - - action: ApplyChanges - kind: ConfigMap - name: cm - namespace: prune - before: - object: - apiVersion: v1 - data: - key: value - kind: ConfigMap - metadata: - annotations: - config.k8s.io/owning-inventory: prune - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"v1","data":{"key":"value"},"kind":"ConfigMap","metadata":{"annotations":{"config.k8s.io/owning-inventory":"prune"},"name":"cm","namespace":"prune"}} - creationTimestamp: "" - managedFields: - - apiVersion: v1 - fieldsType: FieldsV1 - fieldsV1: - f:data: - .: {} - f:key: {} - f:metadata: - f:annotations: - .: {} - f:config.k8s.io/owning-inventory: {} - f:kubectl.kubernetes.io/last-applied-configuration: {} - manager: kubectl-client-side-apply - operation: Update - time: "" - name: cm - namespace: prune - resourceVersion: "" - uid: - after: - object: - apiVersion: v1 - data: - key: value - kind: ConfigMap - metadata: - annotations: - config.k8s.io/owning-inventory: prune - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"v1","data":{"key":"value"},"kind":"ConfigMap","metadata":{"annotations":{"config.k8s.io/owning-inventory":"prune"},"name":"cm","namespace":"prune"}} - creationTimestamp: "" - managedFields: - - apiVersion: v1 - fieldsType: FieldsV1 - fieldsV1: - f:data: - f:key: {} - f:metadata: - f:annotations: - f:config.k8s.io/owning-inventory: {} - manager: kubectl - operation: Apply - time: "" - - apiVersion: v1 - fieldsType: FieldsV1 - fieldsV1: - f:data: - .: {} - f:key: {} - f:metadata: - f:annotations: - .: {} - f:config.k8s.io/owning-inventory: {} - f:kubectl.kubernetes.io/last-applied-configuration: {} - manager: kubectl-client-side-apply - operation: Update - time: "" - name: cm - namespace: prune - resourceVersion: "" - uid: - - action: PrunePruned - apiVersion: apps - kind: Deployment - name: dep - namespace: prune - before: - object: - apiVersion: apps/v1 - kind: Deployment - metadata: - annotations: - config.k8s.io/owning-inventory: prune - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{"config.k8s.io/owning-inventory":"prune"},"name":"dep","namespace":"prune"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"dep"}},"template":{"metadata":{"labels":{"app":"dep"}},"spec":{"containers":[{"image":"nginx:1.14.2","name":"nginx","ports":[{"containerPort":80}]}]}}}} - creationTimestamp: "" - generation: 1 - managedFields: - - apiVersion: apps/v1 - fieldsType: FieldsV1 - fieldsV1: - f:metadata: - f:annotations: - .: {} - f:config.k8s.io/owning-inventory: {} - f:kubectl.kubernetes.io/last-applied-configuration: {} - f:spec: - f:progressDeadlineSeconds: {} - f:replicas: {} - f:revisionHistoryLimit: {} - f:selector: {} - f:strategy: - f:rollingUpdate: - .: {} - f:maxSurge: {} - f:maxUnavailable: {} - f:type: {} - f:template: - f:metadata: - f:labels: - .: {} - f:app: {} - f:spec: - f:containers: - k:{"name":"nginx"}: - .: {} - f:image: {} - f:imagePullPolicy: {} - f:name: {} - f:ports: - .: {} - k:{"containerPort":80,"protocol":"TCP"}: - .: {} - f:containerPort: {} - f:protocol: {} - f:resources: {} - f:terminationMessagePath: {} - f:terminationMessagePolicy: {} - f:dnsPolicy: {} - f:restartPolicy: {} - f:schedulerName: {} - f:securityContext: {} - f:terminationGracePeriodSeconds: {} - manager: kubectl-client-side-apply - operation: Update - time: "" - name: dep - namespace: prune - resourceVersion: "" - uid: - spec: - progressDeadlineSeconds: 600 - replicas: 1 - revisionHistoryLimit: 10 - selector: - matchLabels: - app: dep - strategy: - rollingUpdate: - maxSurge: 25% - maxUnavailable: 25% - type: RollingUpdate - template: - metadata: - creationTimestamp: null - labels: - app: dep - spec: - containers: - - image: nginx:1.14.2 - imagePullPolicy: IfNotPresent - name: nginx - ports: - - containerPort: 80 - protocol: TCP - resources: {} - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - dnsPolicy: ClusterFirst - restartPolicy: Always - schedulerName: default-scheduler - securityContext: {} - terminationGracePeriodSeconds: 30 - status: {} +# Copyright 2021 The kpt Authors +# +# 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. + +parallel: true + +kptArgs: + - "live" + - "plan" + +stdOut: | + apiVersion: config.kubernetes.io/v1 + kind: ResourceList + items: + - apiVersion: config.google.com/v1alpha1 + kind: Plan + metadata: + name: plan + spec: + actions: + - action: ApplyChanges + kind: ConfigMap + name: cm + namespace: prune + before: + object: + apiVersion: v1 + data: + key: value + kind: ConfigMap + metadata: + annotations: + config.k8s.io/owning-inventory: prune + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"v1","data":{"key":"value"},"kind":"ConfigMap","metadata":{"annotations":{"config.k8s.io/owning-inventory":"prune"},"name":"cm","namespace":"prune"}} + creationTimestamp: "" + managedFields: + - apiVersion: v1 + fieldsType: FieldsV1 + fieldsV1: + f:data: + .: {} + f:key: {} + f:metadata: + f:annotations: + .: {} + f:config.k8s.io/owning-inventory: {} + f:kubectl.kubernetes.io/last-applied-configuration: {} + manager: kubectl-client-side-apply + operation: Update + time: "" + name: cm + namespace: prune + resourceVersion: "" + uid: + after: + object: + apiVersion: v1 + data: + key: value + kind: ConfigMap + metadata: + annotations: + config.k8s.io/owning-inventory: prune + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"v1","data":{"key":"value"},"kind":"ConfigMap","metadata":{"annotations":{"config.k8s.io/owning-inventory":"prune"},"name":"cm","namespace":"prune"}} + creationTimestamp: "" + managedFields: + - apiVersion: v1 + fieldsType: FieldsV1 + fieldsV1: + f:data: + f:key: {} + f:metadata: + f:annotations: + f:config.k8s.io/owning-inventory: {} + manager: kubectl + operation: Apply + time: "" + - apiVersion: v1 + fieldsType: FieldsV1 + fieldsV1: + f:data: + .: {} + f:key: {} + f:metadata: + f:annotations: + .: {} + f:config.k8s.io/owning-inventory: {} + f:kubectl.kubernetes.io/last-applied-configuration: {} + manager: kubectl-client-side-apply + operation: Update + time: "" + name: cm + namespace: prune + resourceVersion: "" + uid: + - action: PrunePruned + apiVersion: apps + kind: Deployment + name: dep + namespace: prune + before: + object: + apiVersion: apps/v1 + kind: Deployment + metadata: + annotations: + config.k8s.io/owning-inventory: prune + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{"config.k8s.io/owning-inventory":"prune"},"name":"dep","namespace":"prune"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"dep"}},"template":{"metadata":{"labels":{"app":"dep"}},"spec":{"containers":[{"image":"nginx:1.14.2","name":"nginx","ports":[{"containerPort":80}]}]}}}} + creationTimestamp: "" + generation: 1 + managedFields: + - apiVersion: apps/v1 + fieldsType: FieldsV1 + fieldsV1: + f:metadata: + f:annotations: + .: {} + f:config.k8s.io/owning-inventory: {} + f:kubectl.kubernetes.io/last-applied-configuration: {} + f:spec: + f:progressDeadlineSeconds: {} + f:replicas: {} + f:revisionHistoryLimit: {} + f:selector: {} + f:strategy: + f:rollingUpdate: + .: {} + f:maxSurge: {} + f:maxUnavailable: {} + f:type: {} + f:template: + f:metadata: + f:labels: + .: {} + f:app: {} + f:spec: + f:containers: + k:{"name":"nginx"}: + .: {} + f:image: {} + f:imagePullPolicy: {} + f:name: {} + f:ports: + .: {} + k:{"containerPort":80,"protocol":"TCP"}: + .: {} + f:containerPort: {} + f:protocol: {} + f:resources: {} + f:terminationMessagePath: {} + f:terminationMessagePolicy: {} + f:dnsPolicy: {} + f:restartPolicy: {} + f:schedulerName: {} + f:securityContext: {} + f:terminationGracePeriodSeconds: {} + manager: kubectl-client-side-apply + operation: Update + time: "" + name: dep + namespace: prune + resourceVersion: "" + uid: + spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: dep + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + creationTimestamp: null + labels: + app: dep + spec: + containers: + - image: nginx:1.14.2 + imagePullPolicy: IfNotPresent + name: nginx + ports: + - containerPort: 80 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + status: {} diff --git a/e2e/testdata/live-plan/prune/pre-apply/cm.yaml b/e2e/testdata/live-plan/prune/pre-apply/cm.yaml index 533f8e6db0..113c158578 100644 --- a/e2e/testdata/live-plan/prune/pre-apply/cm.yaml +++ b/e2e/testdata/live-plan/prune/pre-apply/cm.yaml @@ -1,23 +1,23 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: cm - namespace: prune - annotations: - config.k8s.io/owning-inventory: prune -data: +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: cm + namespace: prune + annotations: + config.k8s.io/owning-inventory: prune +data: key: value \ No newline at end of file diff --git a/e2e/testdata/live-plan/prune/pre-apply/dep.yaml b/e2e/testdata/live-plan/prune/pre-apply/dep.yaml index 12e0eb208d..6f90edba3e 100644 --- a/e2e/testdata/live-plan/prune/pre-apply/dep.yaml +++ b/e2e/testdata/live-plan/prune/pre-apply/dep.yaml @@ -1,36 +1,36 @@ -# Copyright 2021 The kpt Authors -# -# 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: dep - namespace: prune - annotations: - config.k8s.io/owning-inventory: prune -spec: - replicas: 1 - selector: - matchLabels: - app: dep - template: - metadata: - labels: - app: dep - spec: - containers: - - name: nginx - image: nginx:1.14.2 - ports: +# Copyright 2021 The kpt Authors +# +# 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: dep + namespace: prune + annotations: + config.k8s.io/owning-inventory: prune +spec: + replicas: 1 + selector: + matchLabels: + app: dep + template: + metadata: + labels: + app: dep + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: - containerPort: 80 \ No newline at end of file diff --git a/e2e/testdata/live-plan/prune/pre-apply/rg.yaml b/e2e/testdata/live-plan/prune/pre-apply/rg.yaml index c395e36394..011585f5c4 100644 --- a/e2e/testdata/live-plan/prune/pre-apply/rg.yaml +++ b/e2e/testdata/live-plan/prune/pre-apply/rg.yaml @@ -1,31 +1,31 @@ -# Copyright 2021 The kpt Authors -# -# 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: kpt.dev/v1alpha1 -kind: ResourceGroup -metadata: - labels: - cli-utils.sigs.k8s.io/inventory-id: prune - name: prune - namespace: prune -spec: - resources: - - group: "" - kind: ConfigMap - name: cm - namespace: prune - - group: apps - kind: Deployment - name: dep +# Copyright 2021 The kpt Authors +# +# 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: kpt.dev/v1alpha1 +kind: ResourceGroup +metadata: + labels: + cli-utils.sigs.k8s.io/inventory-id: prune + name: prune + namespace: prune +spec: + resources: + - group: "" + kind: ConfigMap + name: cm + namespace: prune + - group: apps + kind: Deployment + name: dep namespace: prune \ No newline at end of file diff --git a/e2e/testdata/live-plan/prune/resources/Kptfile b/e2e/testdata/live-plan/prune/resources/Kptfile index b29cf0463b..10d9074a68 100644 --- a/e2e/testdata/live-plan/prune/resources/Kptfile +++ b/e2e/testdata/live-plan/prune/resources/Kptfile @@ -1,8 +1,8 @@ -apiVersion: kpt.dev/v1 -kind: Kptfile -metadata: - name: prune -inventory: - namespace: prune - name: prune +apiVersion: kpt.dev/v1 +kind: Kptfile +metadata: + name: prune +inventory: + namespace: prune + name: prune inventoryID: prune \ No newline at end of file diff --git a/e2e/testdata/live-plan/prune/resources/cm.yaml b/e2e/testdata/live-plan/prune/resources/cm.yaml index 6661e62dcc..820e92362f 100644 --- a/e2e/testdata/live-plan/prune/resources/cm.yaml +++ b/e2e/testdata/live-plan/prune/resources/cm.yaml @@ -1,21 +1,21 @@ -# Copyright 2021 The kpt Authors -# -# 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: v1 -kind: ConfigMap -metadata: - name: cm - namespace: prune -data: +# Copyright 2021 The kpt Authors +# +# 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: v1 +kind: ConfigMap +metadata: + name: cm + namespace: prune +data: key: value \ No newline at end of file From c770085a9217e641ced0ccc8d9ab8e4868ba0f72 Mon Sep 17 00:00:00 2001 From: SurbhiAgarwal1 Date: Sat, 7 Mar 2026 17:35:12 +0000 Subject: [PATCH 3/6] Add new expected diff.patch files for fn-eval tests --- .../pkg/.expected/diff.patch | 57 ++++++ .../missing-fn-config/.expected/diff.patch | 57 ++++++ .../fn-eval/no-op/.expected/diff.patch | 169 ++++++++++++++++++ .../preserve-comments/.expected/diff.patch | 139 ++++++++++++++ 4 files changed, 422 insertions(+) create mode 100644 e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch create mode 100644 e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch create mode 100644 e2e/testdata/fn-eval/no-op/.expected/diff.patch create mode 100644 e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch new file mode 100644 index 0000000000..a1d026435c --- /dev/null +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch @@ -0,0 +1,57 @@ +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 diff --git a/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch b/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch new file mode 100644 index 0000000000..a1d026435c --- /dev/null +++ b/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch @@ -0,0 +1,57 @@ +diff --git a/resources.yaml b/resources.yaml +index 9d1f786..f2eec52 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,26 +1,26 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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 diff --git a/e2e/testdata/fn-eval/no-op/.expected/diff.patch b/e2e/testdata/fn-eval/no-op/.expected/diff.patch new file mode 100644 index 0000000000..fae99e6adb --- /dev/null +++ b/e2e/testdata/fn-eval/no-op/.expected/diff.patch @@ -0,0 +1,169 @@ +diff --git a/resources.yaml b/resources.yaml +index c0974f0..60f96f2 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,82 +1,82 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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 ++# Copyright 2021 The kpt Authors ++# ++# 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/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch b/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch new file mode 100644 index 0000000000..a9370fd36c --- /dev/null +++ b/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch @@ -0,0 +1,139 @@ +diff --git a/resources.yaml b/resources.yaml +index 020331f..5e8b5fe 100755 +--- a/resources.yaml ++++ b/resources.yaml +@@ -1,67 +1,67 @@ +-# Copyright 2021 The kpt Authors +-# +-# 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)$ ++# Copyright 2021 The kpt Authors ++# ++# 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)$ From 67310d8fadfd25357e7449826519b6707bfbdd4e Mon Sep 17 00:00:00 2001 From: Surbhi Date: Sat, 7 Mar 2026 23:50:39 +0530 Subject: [PATCH 4/6] Fix file mode in diff.patch files (100755 -> 100644) Signed-off-by: Surbhi --- .../pkg/.expected/diff.patch | 54 +++--- .../missing-fn-config/.expected/diff.patch | 54 +++--- .../fn-eval/no-op/.expected/diff.patch | 166 +++++++++--------- .../preserve-comments/.expected/diff.patch | 136 +++++++------- 4 files changed, 205 insertions(+), 205 deletions(-) diff --git a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch index a1d026435c..c6f4cee599 100644 --- a/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch +++ b/e2e/testdata/fn-eval/fn-success-with-stderr/pkg/.expected/diff.patch @@ -1,34 +1,34 @@ diff --git a/resources.yaml b/resources.yaml -index 9d1f786..f2eec52 100755 +index 9d1f786..f2eec52 100644 --- a/resources.yaml +++ b/resources.yaml @@ -1,26 +1,26 @@ --# Copyright 2021 The kpt Authors --# --# 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 +-# Copyright 2021 The kpt Authors +-# +-# 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 +# Copyright 2021 The kpt Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch b/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch index a1d026435c..c6f4cee599 100644 --- a/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch +++ b/e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch @@ -1,34 +1,34 @@ diff --git a/resources.yaml b/resources.yaml -index 9d1f786..f2eec52 100755 +index 9d1f786..f2eec52 100644 --- a/resources.yaml +++ b/resources.yaml @@ -1,26 +1,26 @@ --# Copyright 2021 The kpt Authors --# --# 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 +-# Copyright 2021 The kpt Authors +-# +-# 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 +# Copyright 2021 The kpt Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/e2e/testdata/fn-eval/no-op/.expected/diff.patch b/e2e/testdata/fn-eval/no-op/.expected/diff.patch index fae99e6adb..d8c21c2859 100644 --- a/e2e/testdata/fn-eval/no-op/.expected/diff.patch +++ b/e2e/testdata/fn-eval/no-op/.expected/diff.patch @@ -1,90 +1,90 @@ diff --git a/resources.yaml b/resources.yaml -index c0974f0..60f96f2 100755 +index c0974f0..60f96f2 100644 --- a/resources.yaml +++ b/resources.yaml @@ -1,82 +1,82 @@ --# Copyright 2021 The kpt Authors --# --# 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 +-# Copyright 2021 The kpt Authors +-# +-# 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 +# Copyright 2021 The kpt Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch b/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch index a9370fd36c..aa5bac2b61 100644 --- a/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch +++ b/e2e/testdata/fn-eval/preserve-comments/.expected/diff.patch @@ -1,75 +1,75 @@ diff --git a/resources.yaml b/resources.yaml -index 020331f..5e8b5fe 100755 +index 020331f..5e8b5fe 100644 --- a/resources.yaml +++ b/resources.yaml @@ -1,67 +1,67 @@ --# Copyright 2021 The kpt Authors --# --# 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)$ +-# Copyright 2021 The kpt Authors +-# +-# 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)$ +# Copyright 2021 The kpt Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); From 27741cb90b47524a68d9e181052a53035ff50e09 Mon Sep 17 00:00:00 2001 From: Surbhi Date: Sun, 8 Mar 2026 00:01:10 +0530 Subject: [PATCH 5/6] Fix line endings: normalize all files to LF Added .gitattributes to ensure shell scripts always use LF line endings, preventing 'bash\r' errors in CI. Signed-off-by: Surbhi --- documentation/static/images/func.svg | 1460 ++++----- .../static/images/lifecycle/flow1.svg | 1464 ++++----- .../static/images/lifecycle/flow2.svg | 1464 ++++----- .../static/images/lifecycle/flow3.svg | 1460 ++++----- .../static/images/lifecycle/flow4.svg | 1436 ++++----- .../static/images/lifecycle/flow5.svg | 1452 ++++----- documentation/static/images/pipeline.svg | 1484 +++++----- documentation/static/images/status.svg | 1460 ++++----- e2e/README.md | 104 +- e2e/fn_test.go | 186 +- e2e/live/end-to-end-test.sh | 2632 ++++++++--------- e2e/live/testdata/Kptfile | 22 +- e2e/live/testdata/continue-on-error/Kptfile | 22 +- .../testdata/continue-on-error/namespace.yaml | 14 +- .../testdata/continue-on-error/pod-a.yaml | 28 +- .../testdata/continue-on-error/pod-b.yaml | 28 +- .../example-resource-group.yaml | 40 +- e2e/live/testdata/inventory-template.yaml | 96 +- .../testdata/rbac-error-step-1/namespace.yaml | 36 +- .../rbac-error-step-1/role-binding.yaml | 56 +- .../rbac-error-step-1/service-account.yaml | 38 +- .../rbac-error-step-2/user-secret.yaml | 42 +- e2e/live/testdata/rbac-error-step-3/Kptfile | 28 +- .../rbac-error-step-3/config-map.yaml | 42 +- .../rbac-error-step-3/error-config-map.yaml | 38 +- e2e/live/testdata/rg-test-case-1a/Kptfile | 22 +- .../testdata/rg-test-case-1a/namespace.yaml | 14 +- e2e/live/testdata/rg-test-case-1a/pod-a.yaml | 28 +- e2e/live/testdata/rg-test-case-1a/pod-b.yaml | 28 +- e2e/live/testdata/rg-test-case-1a/pod-c.yaml | 28 +- e2e/live/testdata/rg-test-case-1b/Kptfile | 22 +- .../testdata/rg-test-case-1b/namespace.yaml | 14 +- e2e/live/testdata/rg-test-case-1b/pod-b.yaml | 28 +- e2e/live/testdata/rg-test-case-1b/pod-c.yaml | 28 +- e2e/live/testdata/rg-test-case-1b/pod-d.yaml | 28 +- e2e/live/testdata/stdin-test/pods.yaml | 138 +- e2e/live/testdata/template-rg-namespace.yaml | 96 +- .../testdata/template-test-namespace.yaml | 96 +- e2e/live/testdata/test-case-1a/Kptfile | 22 +- .../test-case-1a/inventory-template.yaml | 96 +- e2e/live/testdata/test-case-1a/namespace.yaml | 14 +- e2e/live/testdata/test-case-1a/pod-a.yaml | 28 +- e2e/live/testdata/test-case-1a/pod-b.yaml | 28 +- e2e/live/testdata/test-case-1a/pod-c.yaml | 28 +- e2e/live/testdata/test-case-1b/Kptfile | 22 +- .../test-case-1b/inventory-template.yaml | 96 +- e2e/live/testdata/test-case-1b/namespace.yaml | 14 +- e2e/live/testdata/test-case-1b/pod-b.yaml | 28 +- e2e/live/testdata/test-case-1b/pod-c.yaml | 28 +- e2e/live/testdata/test-case-1b/pod-d.yaml | 28 +- e2e/live/testdata/test-case-1c/Kptfile | 22 +- e2e/live/testdata/test-case-1c/namespace.yaml | 14 +- e2e/live/testdata/test-case-1c/pod-a.yaml | 28 +- e2e/live/testdata/test-case-1c/pod-b.yaml | 28 +- e2e/live/testdata/test-case-1c/pod-c.yaml | 28 +- e2e/live_test.go | 196 +- .../pkg/.expected/config.yaml | 34 +- .../pkg/.expected/diff.patch | 64 +- .../all-resource-deletion/pkg/.krmignore | 2 +- .../all-resource-deletion/pkg/resources.yaml | 52 +- .../starlark-delete-resource.yaml | 38 +- .../default-runtime/.expected/diff.patch | 38 +- .../fn-eval/default-runtime/.expected/exec.sh | 50 +- .../fn-eval/default-runtime/.krmignore | 2 +- .../fn-eval/default-runtime/resources.yaml | 52 +- .../error-in-pipe/.expected/config.yaml | 32 +- .../fn-eval/error-in-pipe/.expected/exec.sh | 46 +- e2e/testdata/fn-eval/error-in-pipe/.krmignore | 4 +- .../.expected/config.yaml | 40 +- .../exec-function-stderr/.expected/diff.patch | 42 +- .../exec-function-stderr/.expected/exec.sh | 36 +- .../fn-eval/exec-function-stderr/.krmignore | 2 +- .../fn-eval/exec-function-stderr/function.sh | 42 +- .../exec-function-stderr/resources.yaml | 56 +- .../.expected/diff.patch | 42 +- .../exec-function-with-args/.expected/exec.sh | 36 +- .../exec-function-with-args/.krmignore | 2 +- .../exec-function-with-args/resources.yaml | 56 +- .../exec-function/.expected/config.yaml | 32 +- .../exec-function/.expected/diff.patch | 42 +- e2e/testdata/fn-eval/exec-function/.krmignore | 2 +- .../fn-eval/exec-function/function.sh | 34 +- .../fn-eval/exec-function/resources.yaml | 56 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 60 +- .../fn-eval/fn-config-file-in-pkg/.krmignore | 2 +- .../fn-eval/fn-config-file-in-pkg/config.yaml | 38 +- .../fn-config-file-in-pkg/resources.yaml | 52 +- .../fn-eval/fn-config-file/config.yaml | 38 +- .../fn-config-file/pkg/.expected/config.yaml | 34 +- .../fn-config-file/pkg/.expected/diff.patch | 38 +- .../fn-eval/fn-config-file/pkg/.krmignore | 2 +- .../fn-eval/fn-config-file/pkg/resources.yaml | 52 +- .../.expected/diff.patch | 150 +- .../.expected/exec.sh | 44 +- .../.krmignore | 4 +- .../Kptfile | 16 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/diff.patch | 150 +- .../include-meta-resources/.expected/exec.sh | 44 +- .../include-meta-resources/.krmignore | 2 +- .../fn-source/include-meta-resources/Kptfile | 16 +- .../include-meta-resources/labelconfig.yaml | 38 +- .../include-meta-resources/resources.yaml | 52 +- .../pkg/.expected/config.yaml | 32 +- .../pkg/.expected/results.yaml | 18 +- .../fn-success-with-stderr/pkg/.krmignore | 2 +- .../fn-success-with-stderr/pkg/resources.yaml | 52 +- .../fn-success-with-stderr/starlark.yaml | 40 +- .../fn-eval/fnconfig-missing-name/config.yaml | 34 +- .../pkg/.expected/config.yaml | 38 +- .../fnconfig-missing-name/pkg/.krmignore | 2 +- .../fnconfig-missing-name/pkg/resources.yaml | 52 +- .../function-chain/.expected/diff.patch | 90 +- .../fn-eval/function-chain/.expected/exec.sh | 46 +- .../fn-eval/function-chain/.krmignore | 2 +- .../fn-eval/function-chain/resources.yaml | 52 +- .../function-env/.expected/config.yaml | 32 +- .../fn-eval/function-env/.expected/exec.sh | 44 +- e2e/testdata/fn-eval/function-env/.krmignore | 2 +- .../.expected/config.yaml | 40 +- .../.expected/setup.sh | 50 +- .../image-pull-policy-always/.krmignore | 2 +- .../.expected/config.yaml | 40 +- .../.expected/setup.sh | 48 +- .../.krmignore | 2 +- .../.expected/config.yaml | 42 +- .../image-pull-policy-never/.krmignore | 2 +- .../image-pull-policy-never/resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../.krmignore | 2 +- .../include-meta-resources-v1alpha1/Kptfile | 202 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../.krmignore | 2 +- .../include-meta-resources-v1alpha2/Kptfile | 16 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../fn-eval/include-meta-resources/.krmignore | 2 +- .../fn-eval/include-meta-resources/Kptfile | 16 +- .../include-meta-resources/labelconfig.yaml | 38 +- .../include-meta-resources/resources.yaml | 52 +- .../invalid-fn-config-file/config.yaml | 30 +- .../pkg/.expected/config.yaml | 38 +- .../invalid-fn-config-file/pkg/.krmignore | 2 +- .../invalid-fn-config-file/pkg/resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 112 +- .../krm-check-exclude-kustomize/.krmignore | 2 +- .../krm-check-exclude-kustomize/Kptfile | 18 +- .../kustomization.yaml | 34 +- .../resources.yaml | 52 +- .../missing-fn-config/.expected/config.yaml | 36 +- .../fn-eval/missing-fn-config/.krmignore | 2 +- .../fn-eval/missing-fn-config/resources.yaml | 52 +- .../missing-fn-image/.expected/config.yaml | 40 +- .../fn-eval/missing-fn-image/.krmignore | 2 +- .../fn-eval/missing-fn-image/resources.yaml | 52 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 8 +- .../modify-legacy-path-annotation/.krmignore | 2 +- .../deployment.yaml | 70 +- .../starlark-fn.yaml | 42 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 8 +- .../fn-eval/modify-path-annotation/.krmignore | 2 +- .../modify-path-annotation/deployment.yaml | 70 +- .../modify-path-annotation/starlark-fn.yaml | 42 +- .../multiple-fn-config-one-file/config.yaml | 52 +- .../pkg/.expected/config.yaml | 38 +- .../pkg/resources.yaml | 52 +- .../no-image-pull/.expected/config.yaml | 2 +- .../fn-eval/no-image-pull/.expected/exec.sh | 52 +- .../fn-eval/no-image-pull/.expected/setup.sh | 44 +- e2e/testdata/fn-eval/no-image-pull/.krmignore | 2 +- .../fn-eval/no-image-pull/resources.yaml | 38 +- .../fn-eval/no-op/.expected/config.yaml | 32 +- e2e/testdata/fn-eval/no-op/.krmignore | 2 +- e2e/testdata/fn-eval/no-op/resources.yaml | 164 +- .../non-krm-resource/.expected/config.yaml | 44 +- .../fn-eval/non-krm-resource/.krmignore | 2 +- .../fn-eval/non-krm-resource/nonkrm.yaml | 26 +- .../fn-eval/non-krm-resource/resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/exec.sh | 40 +- .../out-of-place-dir-exists-error/.krmignore | 4 +- .../resources.yaml | 52 +- .../out-of-place-dir/.expected/config.yaml | 32 +- .../out-of-place-dir/.expected/diff.patch | 68 +- .../out-of-place-dir/.expected/exec.sh | 40 +- .../fn-eval/out-of-place-dir/.krmignore | 4 +- .../fn-eval/out-of-place-dir/resources.yaml | 52 +- .../.expected/config.yaml | 148 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-stdout/.krmignore | 2 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 152 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-unwrap/.krmignore | 2 +- .../out-of-place-fnchain-unwrap/Kptfile | 18 +- .../resources.yaml | 54 +- .../output-to-stdout/.expected/config.yaml | 114 +- .../output-to-stdout/.expected/exec.sh | 38 +- .../fn-eval/output-to-stdout/.krmignore | 2 +- .../fn-eval/output-to-stdout/resources.yaml | 52 +- .../preserve-comments/.expected/config.yaml | 32 +- .../fn-eval/preserve-comments/.krmignore | 2 +- .../fn-eval/preserve-comments/resources.yaml | 134 +- .../.expected/config.yaml | 40 +- .../.krmignore | 2 +- .../Kptfile | 98 +- .../resources.yaml | 70 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 38 +- .../preserve-order-null-values/.krmignore | 2 +- .../preserve-order-null-values/resources.yaml | 54 +- .../disable-network/.expected/config.yaml | 30 +- .../disable-network/.expected/exec.sh | 42 +- .../disable-network/.krmginore | 2 +- .../disable-network/resources.yaml | 42 +- .../enable-network/.expected/exec.sh | 44 +- .../enable-network/.krmginore | 2 +- .../enable-network/resources.yaml | 42 +- .../mount/.expected/config.yaml | 4 +- .../privilege-options/mount/.krmignore | 4 +- .../privilege-options/mount/resources.yaml | 42 +- .../pkg/.expected/config.yaml | 34 +- .../pkg/.expected/diff.patch | 30 +- .../fn-eval/resource-deletion/pkg/.krmignore | 2 +- .../resource-deletion/pkg/resources.yaml | 52 +- .../starlark-delete-resource.yaml | 58 +- .../custom-pkg-path/.expected/config.yaml | 58 +- .../custom-pkg-path/.expected/diff.patch | 86 +- .../save-fn/custom-pkg-path/.expected/exec.sh | 36 +- .../save-fn/custom-pkg-path/.krmignore | 2 +- .../save-fn/custom-pkg-path/sub-pkg/Kptfile | 8 +- .../custom-pkg-path/sub-pkg/fn-config.yaml | 38 +- .../custom-pkg-path/sub-pkg/resources.yaml | 52 +- .../save-fn/exec/.expected/config.yaml | 36 +- .../fn-eval/save-fn/exec/.expected/diff.patch | 66 +- .../fn-eval/save-fn/exec/.expected/exec.sh | 34 +- e2e/testdata/fn-eval/save-fn/exec/.krmignore | 2 +- e2e/testdata/fn-eval/save-fn/exec/Kptfile | 8 +- .../fn-eval/save-fn/exec/fn-config.yaml | 42 +- e2e/testdata/fn-eval/save-fn/exec/function.sh | 32 +- .../fn-eval/save-fn/exec/resources.yaml | 56 +- .../save-fn/image/.expected/config.yaml | 58 +- .../save-fn/image/.expected/diff.patch | 66 +- .../fn-eval/save-fn/image/.expected/exec.sh | 36 +- e2e/testdata/fn-eval/save-fn/image/.krmignore | 2 +- e2e/testdata/fn-eval/save-fn/image/Kptfile | 8 +- .../fn-eval/save-fn/image/resources.yaml | 52 +- .../match-selector/.expected/config.yaml | 44 +- .../match-selector/.expected/diff.patch | 54 +- .../save-fn/match-selector/.expected/exec.sh | 38 +- .../fn-eval/save-fn/match-selector/.krmignore | 2 +- .../fn-eval/save-fn/match-selector/Kptfile | 8 +- .../save-fn/match-selector/resources.yaml | 52 +- .../no-save-when-fail/.expected/config.yaml | 58 +- .../no-save-when-fail/.expected/diff.patch | 38 +- .../no-save-when-fail/.expected/exec.sh | 36 +- .../save-fn/no-save-when-fail/.krmignore | 2 +- .../save-fn/no-save-when-fail/resources.yaml | 52 +- .../save-fn/override-fn/.expected/config.yaml | 58 +- .../save-fn/override-fn/.expected/diff.patch | 74 +- .../save-fn/override-fn/.expected/exec.sh | 36 +- .../fn-eval/save-fn/override-fn/.krmignore | 2 +- .../fn-eval/save-fn/override-fn/Kptfile | 20 +- .../save-fn/override-fn/resources.yaml | 52 +- .../.expected/config.yaml | 58 +- .../.expected/diff.patch | 64 +- .../.expected/exec.sh | 36 +- .../preserve-kptfile-comments/.krmignore | 2 +- .../save-fn/preserve-kptfile-comments/Kptfile | 12 +- .../preserve-kptfile-comments/resources.yaml | 52 +- .../validator-type/.expected/config.yaml | 58 +- .../validator-type/.expected/diff.patch | 66 +- .../save-fn/validator-type/.expected/exec.sh | 36 +- .../fn-eval/save-fn/validator-type/.krmignore | 2 +- .../fn-eval/save-fn/validator-type/Kptfile | 8 +- .../save-fn/validator-type/resources.yaml | 52 +- .../basicpipeline/.expected/config.yaml | 34 +- .../basicpipeline/.expected/diff.patch | 24 +- .../selectors/basicpipeline/.expected/exec.sh | 36 +- .../selectors/basicpipeline/.krmignore | 2 +- .../selectors/basicpipeline/resources.yaml | 52 +- .../selectors/exclude/.expected/config.yaml | 34 +- .../selectors/exclude/.expected/diff.patch | 24 +- .../selectors/exclude/.expected/exec.sh | 36 +- .../fn-eval/selectors/exclude/.krmignore | 2 +- .../fn-eval/selectors/exclude/resources.yaml | 52 +- .../.expected/config.yaml | 110 +- .../.expected/exec.sh | 44 +- .../out-of-place-fnchain-unwrap/.krmignore | 2 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 34 +- .../.expected/diff.patch | 24 +- .../selectors-with-exclude/.expected/exec.sh | 36 +- .../selectors-with-exclude/.krmignore | 2 +- .../selectors-with-exclude/resources.yaml | 82 +- .../short-image-path/.expected/config.yaml | 54 +- .../short-image-path/.expected/diff.patch | 38 +- .../short-image-path/.expected/results.yaml | 16 +- .../fn-eval/short-image-path/.krmignore | 2 +- .../fn-eval/short-image-path/resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 38 +- .../simple-function-symlink/.expected/exec.sh | 42 +- .../simple-function-symlink/.krmignore | 2 +- .../simple-function-symlink/resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../.expected/diff.patch | 22 +- .../simple-function-with-tag/.krmignore | 2 +- .../simple-function-with-tag/resources.yaml | 52 +- .../simple-function/.expected/config.yaml | 36 +- .../simple-function/.expected/diff.patch | 38 +- .../fn-eval/simple-function/.krmignore | 2 +- .../fn-eval/simple-function/resources.yaml | 52 +- .../.expected/config.yaml | 46 +- .../.expected/diff.patch | 26 +- .../.expected/results.yaml | 28 +- .../structured-results-in-stdout/.krmignore | 4 +- .../resources.yaml | 52 +- .../search-replace-conf.yaml | 44 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 152 +- .../.krmignore | 2 +- .../Kptfile | 16 +- .../db/Kptfile | 16 +- .../db/labelconfig.yaml | 42 +- .../db/resources.yaml | 38 +- .../labelconfig.yaml | 42 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 82 +- .../subpkg-has-samename-subdir/.krmignore | 2 +- .../subpkg-has-samename-subdir/Kptfile | 12 +- .../subpkg-has-samename-subdir/pkg-a/Kptfile | 12 +- .../pkg-a/pkg-a/resources.yaml | 52 +- .../.expected/config.yaml | 42 +- .../subpkg-include-meta-resources/.krmignore | 2 +- .../subpkg-include-meta-resources/Kptfile | 16 +- .../subpkg-include-meta-resources/db/Kptfile | 16 +- .../db/labelconfig.yaml | 38 +- .../db/resources.yaml | 38 +- .../labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/diff.patch | 60 +- .../fn-eval/subpkgs-with-krmignore/.krmignore | 4 +- .../subpkgs-with-krmignore/db/non-krm.yaml | 34 +- .../subpkgs-with-krmignore/db/resources.yaml | 38 +- .../subpkgs-with-krmignore/resources.yaml | 52 +- .../fn-eval/subpkgs/.expected/config.yaml | 36 +- .../fn-eval/subpkgs/.expected/diff.patch | 60 +- e2e/testdata/fn-eval/subpkgs/.krmignore | 2 +- .../fn-eval/subpkgs/db/resources.yaml | 38 +- e2e/testdata/fn-eval/subpkgs/resources.yaml | 52 +- .../wasm-function/.expected/config.yaml | 40 +- .../wasm-function/.expected/diff.patch | 22 +- e2e/testdata/fn-eval/wasm-function/.krmignore | 2 +- .../fn-eval/wasm-function/resources.yaml | 38 +- .../.expected/diff.patch | 156 +- .../all-resource-deletion/.krmignore | 2 +- .../fn-render/all-resource-deletion/Kptfile | 28 +- .../all-resource-deletion/delete-all.yaml | 44 +- .../all-resource-deletion/deployment.yaml | 48 +- .../all-resource-deletion/resources.yaml | 38 +- .../.expected/diff.patch | 132 +- .../.expected/exec.sh | 42 +- .../basicpipeline-out-of-place/.krmignore | 4 +- .../basicpipeline-out-of-place/Kptfile | 24 +- .../basicpipeline-out-of-place/resources.yaml | 52 +- .../.expected/config.yaml | 28 +- .../basicpipeline-semver/.expected/diff.patch | 80 +- .../fn-render/basicpipeline-semver/.krmignore | 2 +- .../fn-render/basicpipeline-semver/Kptfile | 28 +- .../basicpipeline-semver/resources.yaml | 52 +- .../.expected/config.yaml | 58 +- .../.expected/diff.patch | 88 +- .../basicpipeline-symlink/.expected/exec.sh | 42 +- .../basicpipeline-symlink/.krmignore | 2 +- .../fn-render/basicpipeline-symlink/Kptfile | 24 +- .../basicpipeline-symlink/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../basicpipeline-v1alpha1/.krmignore | 2 +- .../fn-render/basicpipeline-v1alpha1/Kptfile | 202 +- .../basicpipeline-v1alpha1/labelconfig.yaml | 38 +- .../basicpipeline-v1alpha1/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../basicpipeline-v1alpha2/.krmignore | 2 +- .../fn-render/basicpipeline-v1alpha2/Kptfile | 24 +- .../basicpipeline-v1alpha2/resources.yaml | 52 +- .../basicpipeline-wasm/.expected/config.yaml | 32 +- .../basicpipeline-wasm/.expected/diff.patch | 58 +- .../basicpipeline-wasm/.expected/setup.sh | 32 +- .../basicpipeline-wasm/.expected/teardown.sh | 32 +- .../fn-render/basicpipeline-wasm/.krmignore | 2 +- .../fn-render/basicpipeline-wasm/Kptfile | 34 +- .../basicpipeline-wasm/resources.yaml | 52 +- .../basicpipeline/.expected/config.yaml | 28 +- .../basicpipeline/.expected/diff.patch | 76 +- .../fn-render/basicpipeline/.krmignore | 2 +- e2e/testdata/fn-render/basicpipeline/Kptfile | 24 +- .../fn-render/basicpipeline/resources.yaml | 52 +- .../default-runtime/.expected/diff.patch | 88 +- .../default-runtime/.expected/exec.sh | 50 +- .../fn-render/default-runtime/.krmignore | 2 +- .../fn-render/default-runtime/Kptfile | 24 +- .../fn-render/default-runtime/resources.yaml | 52 +- .../fn-render/empty-pipeline/.krmignore | 2 +- e2e/testdata/fn-render/empty-pipeline/Kptfile | 8 +- .../fn-render/empty-pipeline/resources.yaml | 52 +- .../.expected/config.yaml | 40 +- .../exec-function-stderr/.expected/diff.patch | 42 +- .../fn-render/exec-function-stderr/.krmignore | 2 +- .../fn-render/exec-function-stderr/Kptfile | 14 +- .../exec-function-stderr/function.sh | 42 +- .../exec-function-stderr/resources.yaml | 56 +- .../.expected/config.yaml | 30 +- .../.expected/diff.patch | 70 +- .../exec-function-with-args/.krmignore | 2 +- .../fn-render/exec-function-with-args/Kptfile | 14 +- .../exec-function-with-args/resources.yaml | 56 +- .../.expected/config.yaml | 30 +- .../exec-without-permissions/.krmignore | 2 +- .../exec-without-permissions/Kptfile | 14 +- .../exec-without-permissions/resources.yaml | 56 +- .../.expected/config.yaml | 38 +- .../fn-failure-output-no-truncate/.krmignore | 2 +- .../fn-failure-output-no-truncate/Kptfile | 18 +- .../resources.yaml | 52 +- .../fn-failure/.expected/config.yaml | 48 +- e2e/testdata/fn-render/fn-failure/.krmignore | 2 +- e2e/testdata/fn-render/fn-failure/Kptfile | 30 +- .../fn-failure/deployment_httpbin.yaml | 74 +- .../fn-render/fn-failure/resources.yaml | 52 +- .../fn-failure/starlark-failure-fn.yaml | 52 +- .../.expected/diff.patch | 108 +- .../fn-success-with-stderr/.krmignore | 2 +- .../fn-render/fn-success-with-stderr/Kptfile | 16 +- .../fn-success-with-stderr/resources.yaml | 52 +- .../fn-success-with-stderr/starlark.yaml | 40 +- .../.expected/diff.patch | 162 +- .../.krmignore | 2 +- .../Kptfile | 18 +- .../db/Kptfile | 16 +- .../db/labelconfig.yaml | 38 +- .../db/resources.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../fnconfig-cannot-refer-subpkgs/.krmignore | 2 +- .../fnconfig-cannot-refer-subpkgs/Kptfile | 16 +- .../fnconfig-cannot-refer-subpkgs/db/Kptfile | 8 +- .../db/labelconfig.yaml | 38 +- .../db/resources.yaml | 58 +- .../resources.yaml | 78 +- .../fnconfig-in-subdir/.expected/config.yaml | 28 +- .../fnconfig-in-subdir/.expected/diff.patch | 106 +- .../fn-render/fnconfig-in-subdir/.krmignore | 2 +- .../fn-render/fnconfig-in-subdir/Kptfile | 16 +- .../fnconfig-in-subdir/db/labelconfig.yaml | 38 +- .../fnconfig-in-subdir/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../fnconfig-missing-name/.krmignore | 2 +- .../fn-render/fnconfig-missing-name/Kptfile | 22 +- .../fnconfig-missing-name/labelconfig.yaml | 34 +- .../fnconfig-missing-name/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../fnconfig-multiple-config-one-file/Kptfile | 16 +- .../labelconfig.yaml | 52 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../fnconfig-not-relative/.krmignore | 2 +- .../fn-render/fnconfig-not-relative/Kptfile | 16 +- .../fnconfig-not-relative/labelconfig.yaml | 38 +- .../fnconfig-not-relative/resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../fnconfig-outside-package/.krmignore | 2 +- .../fnconfig-outside-package/Kptfile | 20 +- .../fnconfig-outside-package/labelconfig.yaml | 38 +- .../fnconfig-outside-package/resources.yaml | 52 +- .../.expected/diff.patch | 106 +- .../fnconfig-pkgfn-refers-subdir/.krmignore | 2 +- .../fnconfig-pkgfn-refers-subdir/Kptfile | 16 +- .../confs/labelconfig.yaml | 38 +- .../resources.yaml | 52 +- .../.expected/diff.patch | 168 +- .../fnconfig-updated-in-render/.krmignore | 2 +- .../fnconfig-updated-in-render/Kptfile | 36 +- .../fnconfig-updated-in-render/app.yaml | 44 +- .../label-input.yaml | 20 +- .../fnconfig-updated-in-render/namespace.yaml | 14 +- .../package-context.yaml | 16 +- .../update-labels.yaml | 38 +- .../fn-render/fnconfig/.expected/diff.patch | 174 +- e2e/testdata/fn-render/fnconfig/.krmignore | 2 +- e2e/testdata/fn-render/fnconfig/Kptfile | 22 +- e2e/testdata/fn-render/fnconfig/db/Kptfile | 24 +- .../fn-render/fnconfig/db/resources.yaml | 38 +- .../fn-render/fnconfig/labelconfig.yaml | 38 +- .../fn-render/fnconfig/resources.yaml | 52 +- .../fnresult-fn-failure/.expected/config.yaml | 36 +- .../fn-render/fnresult-fn-failure/.krmignore | 2 +- .../fn-render/fnresult-fn-failure/Kptfile | 18 +- .../fnresult-fn-failure/resources.yaml | 52 +- .../fnresult-fn-success/.expected/config.yaml | 36 +- .../fnresult-fn-success/.expected/diff.patch | 110 +- .../fn-render/fnresult-fn-success/.krmignore | 2 +- .../fn-render/fnresult-fn-success/Kptfile | 16 +- .../fnresult-fn-success/resources.yaml | 52 +- .../search-replace-conf.yaml | 42 +- .../format-on-success/.expected/diff.patch | 138 +- .../fn-render/format-on-success/.krmignore | 2 +- .../fn-render/format-on-success/Kptfile | 18 +- .../fn-render/format-on-success/db/Kptfile | 18 +- .../format-on-success/db/resources.yaml | 38 +- .../format-on-success/resources.yaml | 64 +- .../.expected/diff.patch | 174 +- .../generator-absolute-path/.krmignore | 2 +- .../fn-render/generator-absolute-path/Kptfile | 16 +- .../generator-absolute-path/resources.yaml | 38 +- .../starlark-httpbin.yaml | 120 +- .../fn-render/generator-subpkgs/.krmignore | 2 +- .../fn-render/generator-subpkgs/Kptfile | 16 +- .../fn-render/generator-subpkgs/db/Kptfile | 16 +- .../generator-subpkgs/db/fn-config.yaml | 12 +- .../generator-subpkgs/db/resources.yaml | 38 +- .../generator-subpkgs/fn-config.yaml | 14 +- .../generator-subpkgs/resources.yaml | 52 +- .../fn-render/generator/.expected/diff.patch | 252 +- e2e/testdata/fn-render/generator/.krmignore | 2 +- e2e/testdata/fn-render/generator/Kptfile | 24 +- e2e/testdata/fn-render/generator/db/Kptfile | 28 +- .../fn-render/generator/db/resources.yaml | 38 +- .../generator/db/starlark-httpbin.yaml | 110 +- .../fn-render/generator/resources.yaml | 52 +- .../.expected/config.yaml | 36 +- .../.expected/setup.sh | 50 +- .../image-pull-policy-always/.krmignore | 2 +- .../image-pull-policy-always/Kptfile | 14 +- .../image-pull-policy-always/resources.yaml | 38 +- .../.expected/config.yaml | 36 +- .../.expected/setup.sh | 48 +- .../.krmignore | 2 +- .../image-pull-policy-if-not-present/Kptfile | 14 +- .../resources.yaml | 38 +- .../.expected/config.yaml | 38 +- .../image-pull-policy-never/.krmignore | 2 +- .../fn-render/image-pull-policy-never/Kptfile | 14 +- .../image-pull-policy-never/resources.yaml | 52 +- .../.expected/config.yaml | 30 +- .../invalid-configmap-fnconfig/.krmignore | 2 +- .../invalid-configmap-fnconfig/Kptfile | 32 +- .../invalid-configmap-fnconfig/resources.yaml | 52 +- .../fn-render/invalid-inline-fnconfig/Kptfile | 32 +- .../invalid-kptfile/.expected/config.yaml | 30 +- .../fn-render/invalid-kptfile/.krmignore | 2 +- .../fn-render/invalid-kptfile/Kptfile | 8 +- .../fn-render/invalid-kptfile/resources.yaml | 52 +- .../.expected/config.yaml | 38 +- .../kptfile-unknown-fields/.krmignore | 2 +- .../fn-render/kptfile-unknown-fields/Kptfile | 28 +- .../kptfile-unknown-fields/resources.yaml | 52 +- .../.expected/diff.patch | 104 +- .../krm-check-exclude-kustomize/Kptfile | 18 +- .../kustomization.yaml | 34 +- .../resources.yaml | 52 +- e2e/testdata/fn-render/krmignore/.krmignore | 4 +- e2e/testdata/fn-render/krmignore/Kptfile | 18 +- .../fn-render/krmignore/resources.yaml | 48 +- .../kubeval-failure/.expected/config.yaml | 34 +- .../fn-render/kubeval-failure/.krmignore | 2 +- .../fn-render/kubeval-failure/Kptfile | 18 +- .../fn-render/kubeval-failure/resources.yaml | 52 +- .../missing-fn-image/.expected/config.yaml | 32 +- .../fn-render/missing-fn-image/.krmignore | 2 +- .../fn-render/missing-fn-image/Kptfile | 24 +- .../fn-render/missing-fn-image/resources.yaml | 52 +- .../missing-fnconfig/.expected/config.yaml | 40 +- .../fn-render/missing-fnconfig/.krmignore | 2 +- .../fn-render/missing-fnconfig/Kptfile | 22 +- .../fn-render/missing-fnconfig/db/Kptfile | 24 +- .../missing-fnconfig/db/resources.yaml | 38 +- .../missing-fnconfig/labelconfig.yaml | 38 +- .../fn-render/missing-fnconfig/resources.yaml | 52 +- .../missing-kptfile/.expected/config.yaml | 30 +- .../fn-render/missing-kptfile/.krmignore | 2 +- .../fn-render/missing-kptfile/resources.yaml | 52 +- .../.expected/diff.patch | 98 +- .../modify-legacy-path-annotation/.krmignore | 2 +- .../modify-legacy-path-annotation/Kptfile | 16 +- .../deployment.yaml | 38 +- .../starlark-fn.yaml | 44 +- .../.expected/diff.patch | 98 +- .../modify-path-annotation/.krmignore | 2 +- .../fn-render/modify-path-annotation/Kptfile | 16 +- .../modify-path-annotation/deployment.yaml | 38 +- .../modify-path-annotation/starlark-fn.yaml | 44 +- .../multiple-fnconfig/.expected/config.yaml | 32 +- .../fn-render/multiple-fnconfig/.krmignore | 2 +- .../fn-render/multiple-fnconfig/Kptfile | 20 +- .../multiple-fnconfig/configmap.yaml | 38 +- .../multiple-fnconfig/resources.yaml | 56 +- .../.expected/diff.patch | 144 +- .../mutate-legacy-path-index/.krmignore | 2 +- .../mutate-legacy-path-index/Kptfile | 16 +- .../starlark-mutate-path-index.yaml | 76 +- .../fn-render/mutate-legacy-path-index/x.yaml | 52 +- .../mutate-path-index/.expected/diff.patch | 144 +- .../fn-render/mutate-path-index/.krmignore | 2 +- .../fn-render/mutate-path-index/Kptfile | 16 +- .../starlark-mutate-path-index.yaml | 76 +- .../fn-render/mutate-path-index/x.yaml | 52 +- .../no-fnconfig/.expected/config.yaml | 48 +- e2e/testdata/fn-render/no-fnconfig/.krmignore | 2 +- e2e/testdata/fn-render/no-fnconfig/Kptfile | 20 +- .../fn-render/no-fnconfig/resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../fn-render/no-format-on-failure/.krmignore | 2 +- .../fn-render/no-format-on-failure/Kptfile | 20 +- .../fn-render/no-format-on-failure/db/Kptfile | 18 +- .../no-format-on-failure/db/resources.yaml | 38 +- .../no-format-on-failure/resources.yaml | 52 +- .../fn-render/no-op/.expected/config.yaml | 28 +- .../fn-render/no-op/.expected/diff.patch | 178 +- e2e/testdata/fn-render/no-op/.krmignore | 2 +- e2e/testdata/fn-render/no-op/Kptfile | 14 +- e2e/testdata/fn-render/no-op/resources.yaml | 164 +- .../.expected/diff.patch | 84 +- .../no-pipeline-in-subpackage/.krmignore | 2 +- .../no-pipeline-in-subpackage/Kptfile | 24 +- .../no-pipeline-in-subpackage/db/Kptfile | 8 +- .../db/resources.yaml | 52 +- e2e/testdata/fn-render/no-pipeline/.krmignore | 2 +- e2e/testdata/fn-render/no-pipeline/Kptfile | 8 +- .../fn-render/no-pipeline/resources.yaml | 52 +- .../no-resources/.expected/diff.patch | 198 +- .../fn-render/no-resources/.krmignore | 2 +- e2e/testdata/fn-render/no-resources/Kptfile | 16 +- .../no-resources/starlark-httpbin.yaml | 182 +- .../.expected/config.yaml | 30 +- .../non-krm-resource-no-pipeline/.krmignore | 2 +- .../non-krm-resource-no-pipeline/Kptfile | 8 +- .../non-krm-resource-no-pipeline/non-krm.yaml | 26 +- .../resources.yaml | 52 +- .../non-krm-resource/.expected/config.yaml | 30 +- .../fn-render/non-krm-resource/.krmignore | 2 +- .../fn-render/non-krm-resource/Kptfile | 24 +- .../fn-render/non-krm-resource/non-krm.yaml | 26 +- .../fn-render/non-krm-resource/resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/exec.sh | 42 +- .../out-of-place-dir-exists-error/.krmignore | 4 +- .../out-of-place-dir-exists-error/Kptfile | 18 +- .../resources.yaml | 54 +- .../out-of-place-dir/.expected/config.yaml | 32 +- .../out-of-place-dir/.expected/diff.patch | 100 +- .../out-of-place-dir/.expected/exec.sh | 42 +- .../fn-render/out-of-place-dir/.krmignore | 4 +- .../fn-render/out-of-place-dir/Kptfile | 18 +- .../fn-render/out-of-place-dir/resources.yaml | 54 +- .../.expected/config.yaml | 168 +- .../.expected/exec.sh | 52 +- .../.krmignore | 2 +- .../Kptfile | 18 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 182 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-stdout/.krmignore | 2 +- .../out-of-place-fnchain-stdout/Kptfile | 18 +- .../resources.yaml | 54 +- .../.expected/config.yaml | 120 +- .../.expected/exec.sh | 42 +- .../out-of-place-fnchain-unwrap/.krmignore | 2 +- .../out-of-place-fnchain-unwrap/Kptfile | 18 +- .../resources.yaml | 54 +- .../out-of-place-stdout/.expected/config.yaml | 134 +- .../out-of-place-stdout/.expected/exec.sh | 38 +- .../fn-render/out-of-place-stdout/.krmignore | 2 +- .../fn-render/out-of-place-stdout/Kptfile | 18 +- .../out-of-place-stdout/resources.yaml | 54 +- .../out-of-place-unwrap/.expected/config.yaml | 68 +- .../out-of-place-unwrap/.expected/exec.sh | 38 +- .../fn-render/out-of-place-unwrap/.krmignore | 2 +- .../fn-render/out-of-place-unwrap/Kptfile | 18 +- .../out-of-place-unwrap/resources.yaml | 54 +- .../path-index-ancestor/.expected/config.yaml | 30 +- .../fn-render/path-index-ancestor/.krmignore | 2 +- .../fn-render/path-index-ancestor/Kptfile | 8 +- .../fn-render/path-index-ancestor/db/Kptfile | 16 +- .../path-index-ancestor/db/resources.yaml | 38 +- .../db/starlark-httpbin-gen.yaml | 118 +- .../path-index-ancestor/resources.yaml | 52 +- .../path-index-current/.expected/diff.patch | 188 +- .../fn-render/path-index-current/.krmignore | 2 +- .../fn-render/path-index-current/Kptfile | 16 +- .../path-index-current/resources.yaml | 52 +- .../starlark-httpbin-gen.yaml | 120 +- .../.expected/diff.patch | 234 +- .../path-index-descendent/.krmignore | 2 +- .../fn-render/path-index-descendent/Kptfile | 16 +- .../path-index-descendent/db/Kptfile | 8 +- .../path-index-descendent/db/resources.yaml | 38 +- .../path-index-descendent/resources.yaml | 52 +- .../starlark-httpbin-gen.yaml | 120 +- .../.expected/config.yaml | 36 +- .../fn-render/path-index-duplicate/.krmignore | 2 +- .../fn-render/path-index-duplicate/Kptfile | 16 +- .../path-index-duplicate/resources.yaml | 38 +- .../starlark-gen-duplicate-path.yaml | 120 +- .../.expected/config.yaml | 30 +- .../path-index-outofpackage/.krmignore | 2 +- .../fn-render/path-index-outofpackage/Kptfile | 8 +- .../path-index-outofpackage/db/Kptfile | 16 +- .../path-index-outofpackage/db/resources.yaml | 38 +- .../db/starlark-httpbin-gen.yaml | 118 +- .../preserve-comments/.expected/config.yaml | 28 +- .../preserve-comments/.expected/diff.patch | 148 +- .../fn-render/preserve-comments/.krmignore | 2 +- .../fn-render/preserve-comments/Kptfile | 14 +- .../preserve-comments/resources.yaml | 134 +- .../.expected/diff.patch | 78 +- .../preserve-order-null-values/.krmignore | 2 +- .../preserve-order-null-values/Kptfile | 24 +- .../preserve-order-null-values/resources.yaml | 54 +- .../resource-deletion/.expected/diff.patch | 200 +- .../fn-render/resource-deletion/.krmignore | 2 +- .../fn-render/resource-deletion/Kptfile | 28 +- .../resource-deletion/deployment_httpbin.yaml | 72 +- .../resource-deletion/resources.yaml | 52 +- .../resource-deletion/starlark-httpbin.yaml | 48 +- .../.expected/diff.patch | 360 +-- .../resource-has-pkgname-prefix/.krmignore | 2 +- .../resource-has-pkgname-prefix/Kptfile | 18 +- .../resource-has-pkgname-prefix/mysql/Kptfile | 18 +- .../mysql/mysql-deployment.yaml | 162 +- .../wordpress-deployment.yaml | 162 +- .../bfs-basicpipeline/.expected/config.yaml | 4 +- .../bfs-basicpipeline/.expected/diff.patch | 48 +- .../bfs-basicpipeline/.krmignore | 2 +- .../bfs-basicpipeline/Kptfile | 36 +- .../bfs-basicpipeline/resources.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 112 +- .../bfs-deep-nested-middle-fails/.krmignore | 2 +- .../bfs-deep-nested-middle-fails/Kptfile | 28 +- .../configmap.yaml | 12 +- .../level1/Kptfile | 26 +- .../level1/configmap.yaml | 12 +- .../level1/level2/Kptfile | 22 +- .../level1/level2/configmap.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 136 +- .../bfs-multiple-subpkgs-one-fails/.krmignore | 2 +- .../bfs-multiple-subpkgs-one-fails/Kptfile | 28 +- .../service.yaml | 14 +- .../sub1/Kptfile | 18 +- .../sub1/deployment.yaml | 12 +- .../sub2/Kptfile | 22 +- .../sub2/deployment.yaml | 12 +- .../sub3/Kptfile | 18 +- .../sub3/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 84 +- .../.krmignore | 2 +- .../bfs-parent-and-subpkg-both-fail/Kptfile | 32 +- .../configmap.yaml | 12 +- .../subpkg/Kptfile | 26 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 78 +- .../bfs-parent-mutator-fails/.krmignore | 2 +- .../bfs-parent-mutator-fails/Kptfile | 30 +- .../bfs-parent-mutator-fails/configmap.yaml | 12 +- .../bfs-parent-mutator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 80 +- .../bfs-parent-validator-fails/.krmignore | 2 +- .../bfs-parent-validator-fails/Kptfile | 32 +- .../bfs-parent-validator-fails/configmap.yaml | 12 +- .../bfs-parent-validator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 76 +- .../bfs-subpkg-mutator-fails/.krmignore | 2 +- .../bfs-subpkg-mutator-fails/Kptfile | 28 +- .../bfs-subpkg-mutator-fails/deployment.yaml | 12 +- .../bfs-subpkg-mutator-fails/subpkg/Kptfile | 24 +- .../subpkg/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 82 +- .../bfs-subpkg-validator-fails/.krmignore | 2 +- .../bfs-subpkg-validator-fails/Kptfile | 30 +- .../deployment.yaml | 14 +- .../bfs-subpkg-validator-fails/subpkg/Kptfile | 26 +- .../subpkg/deployment.yaml | 12 +- .../dfs-basicpipeline/.expected/config.yaml | 4 +- .../dfs-basicpipeline/.expected/diff.patch | 46 +- .../dfs-basicpipeline/.krmignore | 2 +- .../dfs-basicpipeline/Kptfile | 34 +- .../dfs-basicpipeline/resources.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 110 +- .../dfs-deep-nested-middle-fails/.krmignore | 2 +- .../dfs-deep-nested-middle-fails/Kptfile | 26 +- .../configmap.yaml | 12 +- .../level1/Kptfile | 26 +- .../level1/configmap.yaml | 12 +- .../level1/level2/Kptfile | 22 +- .../level1/level2/configmap.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 104 +- .../dfs-multiple-subpkgs-one-fails/.krmignore | 2 +- .../dfs-multiple-subpkgs-one-fails/Kptfile | 26 +- .../service.yaml | 14 +- .../sub1/Kptfile | 18 +- .../sub1/deployment.yaml | 12 +- .../sub2/Kptfile | 22 +- .../sub2/deployment.yaml | 12 +- .../sub3/Kptfile | 18 +- .../sub3/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 82 +- .../.krmignore | 2 +- .../dfs-parent-and-subpkg-both-fail/Kptfile | 30 +- .../configmap.yaml | 12 +- .../subpkg/Kptfile | 26 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 76 +- .../dfs-parent-mutator-fails/.krmignore | 2 +- .../dfs-parent-mutator-fails/Kptfile | 28 +- .../dfs-parent-mutator-fails/configmap.yaml | 12 +- .../dfs-parent-mutator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 78 +- .../dfs-parent-validator-fails/.krmignore | 2 +- .../dfs-parent-validator-fails/Kptfile | 30 +- .../dfs-parent-validator-fails/configmap.yaml | 12 +- .../dfs-parent-validator-fails/subpkg/Kptfile | 22 +- .../subpkg/service.yaml | 14 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 74 +- .../dfs-subpkg-mutator-fails/.krmignore | 2 +- .../dfs-subpkg-mutator-fails/Kptfile | 26 +- .../dfs-subpkg-mutator-fails/deployment.yaml | 12 +- .../dfs-subpkg-mutator-fails/subpkg/Kptfile | 24 +- .../subpkg/deployment.yaml | 12 +- .../.expected/config.yaml | 4 +- .../.expected/diff.patch | 80 +- .../dfs-subpkg-validator-fails/.krmignore | 2 +- .../dfs-subpkg-validator-fails/Kptfile | 28 +- .../deployment.yaml | 14 +- .../dfs-subpkg-validator-fails/subpkg/Kptfile | 26 +- .../subpkg/deployment.yaml | 12 +- .../.expected/config.yaml | 6 +- .../no-save-on-render-failure/.krmignore | 2 +- .../no-save-on-render-failure/Kptfile | 30 +- .../no-save-on-render-failure/resources.yaml | 12 +- .../basicpipeline/.expected/config.yaml | 58 +- .../basicpipeline/.expected/diff.patch | 82 +- .../selectors/basicpipeline/.krmignore | 2 +- .../fn-render/selectors/basicpipeline/Kptfile | 30 +- .../selectors/basicpipeline/resources.yaml | 52 +- .../selectors/exclude/.expected/config.yaml | 56 +- .../selectors/exclude/.expected/diff.patch | 86 +- .../fn-render/selectors/exclude/.krmignore | 2 +- .../fn-render/selectors/exclude/Kptfile | 34 +- .../selectors/exclude/resources.yaml | 52 +- .../selectors/generator/.expected/config.yaml | 70 +- .../selectors/generator/.expected/diff.patch | 268 +- .../fn-render/selectors/generator/.krmignore | 2 +- .../fn-render/selectors/generator/Kptfile | 32 +- .../fn-render/selectors/generator/db/Kptfile | 36 +- .../selectors/generator/db/resources.yaml | 38 +- .../generator/db/starlark-httpbin.yaml | 110 +- .../selectors/generator/resources.yaml | 52 +- .../.expected/config.yaml | 56 +- .../.expected/diff.patch | 94 +- .../selectors-with-exclude/.krmignore | 2 +- .../selectors/selectors-with-exclude/Kptfile | 34 +- .../selectors-with-exclude/resources.yaml | 60 +- .../selectors/validate-subset/.krmignore | 2 +- .../selectors/validate-subset/Kptfile | 20 +- .../selectors/validate-subset/resources.yaml | 54 +- .../validate-subset/starlark-httpbin-val.yaml | 48 +- .../short-image-path/.expected/config.yaml | 56 +- .../short-image-path/.expected/diff.patch | 76 +- .../fn-render/short-image-path/.krmignore | 2 +- .../fn-render/short-image-path/Kptfile | 24 +- .../fn-render/short-image-path/resources.yaml | 52 +- .../.expected/config.yaml | 34 +- .../.krmignore | 2 +- .../Kptfile | 22 +- .../resources.yaml | 178 +- .../subpkg-fn-failure/.expected/config.yaml | 32 +- .../fn-render/subpkg-fn-failure/.krmignore | 2 +- .../fn-render/subpkg-fn-failure/Kptfile | 28 +- .../fn-render/subpkg-fn-failure/db/Kptfile | 28 +- .../subpkg-fn-failure/db/resources.yaml | 52 +- .../db/statefulset-filter.yaml | 52 +- .../subpkg-fn-failure/deployment_httpbin.yaml | 72 +- .../subpkg-fn-failure/resources.yaml | 38 +- .../subpkg-fn-failure/starlark-httpbin.yaml | 50 +- .../.expected/config.yaml | 30 +- .../subpkg-has-invalid-kptfile/.krmignore | 2 +- .../subpkg-has-invalid-kptfile/Kptfile | 24 +- .../subpkg-has-invalid-kptfile/db/Kptfile | 30 +- .../db/resources.yaml | 52 +- .../db/statefulset-filter.yaml | 50 +- .../subpkg-has-invalid-kptfile/resources.yaml | 38 +- .../.krmignore | 2 +- .../Kptfile | 12 +- .../pkg-a/Kptfile | 12 +- .../pkg-a/pkg-a/resources.yaml | 52 +- .../.expected/diff.patch | 86 +- .../subpkg-has-samename-subdir/.krmignore | 2 +- .../subpkg-has-samename-subdir/Kptfile | 12 +- .../subpkg-has-samename-subdir/pkg-a/Kptfile | 22 +- .../pkg-a/pkg-a/resources.yaml | 52 +- .../.expected/diff.patch | 314 +- .../subpkg-resource-deletion/.krmignore | 2 +- .../subpkg-resource-deletion/Kptfile | 28 +- .../subpkg-resource-deletion/db/Kptfile | 28 +- .../db/resources.yaml | 52 +- .../db/statefulset-filter.yaml | 48 +- .../deployment_httpbin.yaml | 72 +- .../subpkg-resource-deletion/resources.yaml | 38 +- .../starlark-httpbin.yaml | 48 +- .../.expected/diff.patch | 138 +- .../subpkgs-with-krmignore/.krmignore | 2 +- .../fn-render/subpkgs-with-krmignore/Kptfile | 24 +- .../subpkgs-with-krmignore/db/Kptfile | 24 +- .../subpkgs-with-krmignore/db/non-krm.yaml | 34 +- .../subpkgs-with-krmignore/db/resources.yaml | 38 +- .../subpkgs-with-krmignore/resources.yaml | 52 +- .../fn-render/subpkgs/.expected/diff.patch | 138 +- e2e/testdata/fn-render/subpkgs/.krmignore | 2 +- e2e/testdata/fn-render/subpkgs/Kptfile | 24 +- e2e/testdata/fn-render/subpkgs/db/Kptfile | 24 +- .../fn-render/subpkgs/db/resources.yaml | 38 +- e2e/testdata/fn-render/subpkgs/resources.yaml | 52 +- .../success-stdout/.expected/config.yaml | 30 +- .../success-stdout/.expected/diff.patch | 76 +- .../fn-render/success-stdout/.krmignore | 2 +- e2e/testdata/fn-render/success-stdout/Kptfile | 24 +- .../fn-render/success-stdout/resources.yaml | 52 +- .../.expected/diff.patch | 232 +- .../validate-generated-resource/.krmignore | 2 +- .../validate-generated-resource/Kptfile | 22 +- .../resources.yaml | 52 +- .../starlark-httpbin-gen.yaml | 110 +- .../starlark-httpbin-val.yaml | 48 +- .../.expected/config.yaml | 38 +- .../validate-resource-failure/.krmignore | 2 +- .../validate-resource-failure/Kptfile | 16 +- .../validate-resource-failure/resources.yaml | 52 +- .../starlark-httpbin-val.yaml | 48 +- .../validator-mutates-resources/.krmignore | 2 +- .../validator-mutates-resources/Kptfile | 18 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/exec.sh | 42 +- .../.krmignore | 4 +- .../resources.yaml | 52 +- .../.expected/config.yaml | 32 +- .../.expected/diff.patch | 66 +- .../.expected/exec.sh | 44 +- .../out-of-place-source-sink/.krmignore | 4 +- .../out-of-place-source-sink/resources.yaml | 52 +- .../.expected/config.yaml | 130 +- .../subpkgs-with-krmignore/.expected/exec.sh | 38 +- .../subpkgs-with-krmignore/.krmignore | 2 +- .../fn-source/subpkgs-with-krmignore/Kptfile | 24 +- .../subpkgs-with-krmignore/db/Kptfile | 24 +- .../subpkgs-with-krmignore/db/non-krm.yaml | 34 +- .../subpkgs-with-krmignore/db/resources.yaml | 38 +- .../subpkgs-with-krmignore/resources.yaml | 52 +- .../live-apply/apply-depends-on/config.yaml | 106 +- .../apply-depends-on/resources/Kptfile | 6 +- .../apply-depends-on/resources/first.yaml | 74 +- .../resources/resourcegroup.yaml | 12 +- .../apply-depends-on/resources/second.yaml | 78 +- .../live-apply/crd-and-cr/config.yaml | 102 +- .../live-apply/crd-and-cr/resources/Kptfile | 8 +- .../live-apply/crd-and-cr/resources/cr.yaml | 36 +- .../live-apply/crd-and-cr/resources/crd.yaml | 86 +- .../crd-and-cr/resources/resourcegroup.yaml | 12 +- .../dry-run-with-install-rg/config.yaml | 52 +- .../dry-run-with-install-rg/resources/Kptfile | 8 +- .../resources/deployment.yaml | 84 +- .../resources/resourcegroup.yaml | 12 +- .../live-apply/dry-run-without-rg/config.yaml | 44 +- .../dry-run-without-rg/resources/Kptfile | 8 +- .../resources/deployment.yaml | 84 +- .../resources/resourcegroup.yaml | 12 +- .../install-rg-on-apply/config.yaml | 58 +- .../install-rg-on-apply/resources/Kptfile | 8 +- .../resources/deployment.yaml | 84 +- .../resources/resourcegroup.yaml | 12 +- .../invalid-annotation-type/config.yaml | 52 +- .../invalid-annotation-type/resources/Kptfile | 8 +- .../resources/configmap.yaml | 16 +- .../resources/resourcegroup.yaml | 14 +- .../live-apply/invalid-label-type/config.yaml | 52 +- .../invalid-label-type/resources/Kptfile | 8 +- .../resources/configmap.yaml | 16 +- .../resources/resourcegroup.yaml | 14 +- .../live-apply/json-output/config.yaml | 132 +- .../json-output/pre-apply/first.yaml | 70 +- .../live-apply/json-output/pre-apply/rg.yaml | 60 +- .../json-output/pre-apply/second.yaml | 72 +- .../live-apply/json-output/resources/Kptfile | 8 +- .../live-apply/json-output/resources/cm.yaml | 40 +- .../live-apply/json-output/resources/dep.yaml | 70 +- .../json-output/resources/resourcegroup.yaml | 12 +- .../live-apply/prune-depends-on/config.yaml | 114 +- .../prune-depends-on/pre-apply/first.yaml | 70 +- .../prune-depends-on/pre-apply/rg.yaml | 60 +- .../prune-depends-on/pre-apply/second.yaml | 72 +- .../prune-depends-on/resources/Kptfile | 8 +- .../prune-depends-on/resources/cm.yaml | 40 +- .../resources/resourcegroup.yaml | 12 +- e2e/testdata/live-plan/create/config.yaml | 122 +- .../live-plan/create/resources/Kptfile | 16 +- .../live-plan/create/resources/cm.yaml | 40 +- e2e/testdata/live-plan/prune/config.yaml | 420 +-- .../live-plan/prune/pre-apply/cm.yaml | 44 +- .../live-plan/prune/pre-apply/dep.yaml | 70 +- .../live-plan/prune/pre-apply/rg.yaml | 60 +- .../live-plan/prune/resources/Kptfile | 14 +- .../live-plan/prune/resources/cm.yaml | 40 +- 1038 files changed, 27627 insertions(+), 27627 deletions(-) diff --git a/documentation/static/images/func.svg b/documentation/static/images/func.svg index f2fdeaf871..f709c1a931 100644 --- a/documentation/static/images/func.svg +++ b/documentation/static/images/func.svg @@ -8,736 +8,736 @@ link input to FUNC-->RenderPublishApply StatusReconcileReconcile Status