Skip to content

Commit 8ace373

Browse files
test(fn-eval): update fn eval E2E tests to use :latest set-namespace
This PR updates the kpt fn eval E2E test suite to use the :latest version of the set-namespace function. Key changes: - Add isUnknown() heuristic in internal/kptops/set-namespace.go to detect Custom Resources by API group, skipping namespace for unknown CRs without existing namespace - Update Kptfile references from pinned set-namespace image tags to :latest (ghcr.io/kptdev/krm-functions/set-namespace:latest) - Update .expected/ golden files to reflect new :latest behavior - Add .gitattributes to force LF for *.sh and CRLF for *.bat/*.cmd, preventing bash errors in CI - Update internal/fnruntime/runner_test.go to align with new function behavior Part 1 of 2 from the original PR #4420 (fn-eval portion). Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
1 parent bebee38 commit 8ace373

47 files changed

Lines changed: 524 additions & 75 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Set default behavior to automatically normalize line endings
2+
* text=auto
3+
4+
# Force bash scripts to always use LF line endings
5+
*.sh text eol=lf
6+
7+
# Force batch scripts to always use CRLF line endings
8+
*.bat text eol=crlf
9+
*.cmd text eol=crlf

e2e/testdata/fn-eval/fn-config-file-in-pkg/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414

1515
testType: eval
16-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
16+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1717
fnConfig: ../config.yaml

e2e/testdata/fn-eval/fn-config-file/pkg/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414

1515
testType: eval
16-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
16+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1717
fnConfig: ../../config.yaml
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 9d1f786..f2eec52 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -1,26 +1,26 @@
6+
-# Copyright 2021 The kpt Authors
7+
-#
8+
-# Licensed under the Apache License, Version 2.0 (the "License");
9+
-# you may not use this file except in compliance with the License.
10+
-# You may obtain a copy of the License at
11+
-#
12+
-# http://www.apache.org/licenses/LICENSE-2.0
13+
-#
14+
-# Unless required by applicable law or agreed to in writing, software
15+
-# distributed under the License is distributed on an "AS IS" BASIS,
16+
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
-# See the License for the specific language governing permissions and
18+
-# limitations under the License.
19+
-apiVersion: apps/v1
20+
-kind: Deployment
21+
-metadata:
22+
- name: nginx-deployment
23+
-spec:
24+
- replicas: 3
25+
----
26+
-apiVersion: custom.io/v1
27+
-kind: Custom
28+
-metadata:
29+
- name: custom
30+
-spec:
31+
- image: nginx:1.2.3
32+
+# Copyright 2021 The kpt Authors
33+
+#
34+
+# Licensed under the Apache License, Version 2.0 (the "License");
35+
+# you may not use this file except in compliance with the License.
36+
+# You may obtain a copy of the License at
37+
+#
38+
+# http://www.apache.org/licenses/LICENSE-2.0
39+
+#
40+
+# Unless required by applicable law or agreed to in writing, software
41+
+# distributed under the License is distributed on an "AS IS" BASIS,
42+
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43+
+# See the License for the specific language governing permissions and
44+
+# limitations under the License.
45+
+apiVersion: apps/v1
46+
+kind: Deployment
47+
+metadata:
48+
+ name: nginx-deployment
49+
+spec:
50+
+ replicas: 3
51+
+---
52+
+apiVersion: custom.io/v1
53+
+kind: Custom
54+
+metadata:
55+
+ name: custom
56+
+spec:
57+
+ image: nginx:1.2.3

e2e/testdata/fn-eval/fnconfig-missing-name/pkg/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
testType: eval
16-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
16+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1717
fnConfig: ../../config.yaml
1818
exitCode: 1
1919
stdErr: "resource must have `metadata.name`"

e2e/testdata/fn-eval/include-meta-resources-v1alpha1/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
runCount: 2
1616
testType: eval
17-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
17+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1818
includeMetaResources: true
1919
exitCode: 1
2020
args:

e2e/testdata/fn-eval/include-meta-resources-v1alpha2/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
runCount: 2
1616
testType: eval
17-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
17+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1818
includeMetaResources: true
1919
exitCode: 1
2020
args:

e2e/testdata/fn-eval/include-meta-resources/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
runCount: 2
1616
testType: eval
17-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
17+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1818
includeMetaResources: true
1919
exitCode: 1
2020
args:

e2e/testdata/fn-eval/invalid-fn-config-file/pkg/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414

1515
testType: eval
1616
exitCode: 1
17-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
17+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1818
fnConfig: ../../config.yaml
1919
stdErr: "wrong node kind: expected MappingNode but got ScalarNode: node contents:\nI am not a valid config file\n"

e2e/testdata/fn-eval/missing-fn-config/.expected/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414

1515
testType: eval
1616
exitCode: 1
17-
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
17+
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
1818
stdErr: "failed to configure function: input namespace cannot be empty"

0 commit comments

Comments
 (0)