Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set default behavior to automatically normalize line endings
* text=auto
Comment on lines +1 to +2
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description/title focus on splitting fn eval namespace behavior and updating fn eval E2E data, but this diff also removes a very large portion of e2e/testdata/fn-render/** fixtures and expected outputs (plus a vendored license). If the intent is truly “part 1: fn-eval only”, these fn-render deletions should be moved to a separate PR (or reverted here) to avoid mixing concerns and accidental loss of fn render coverage/data.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting * text=auto applies line-ending normalization repo-wide and can cause broad, noisy churn in golden files (including .expected/*.patch and YAML) depending on contributor Git settings and platform. If the goal is specifically to prevent bash\r issues in CI, consider scoping normalization to just the script patterns (e.g., only *.sh, *.bat, *.cmd) or explicitly documenting/accepting that the whole repo will be normalized to avoid surprise diffs.

Suggested change
# Set default behavior to automatically normalize line endings
* text=auto
# Enforce consistent line endings for script files

Copilot uses AI. Check for mistakes.

# Force bash scripts to always use LF line endings
*.sh text eol=lf

# Force batch scripts to always use CRLF line endings
*.bat text eol=crlf
*.cmd text eol=crlf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ index 003e3fe..7a2ceea 100644
data:
namespace: staging
diff --git a/resources.yaml b/resources.yaml
index f2eec52..b66c419 100644
index f2eec52..f169ab0 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -15,6 +15,7 @@ apiVersion: apps/v1
Expand All @@ -20,11 +20,3 @@ index f2eec52..b66c419 100644
+ 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
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 1 addition & 9 deletions e2e/testdata/fn-eval/fn-config-file/pkg/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/resources.yaml b/resources.yaml
index f2eec52..b66c419 100644
index f2eec52..f169ab0 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -15,6 +15,7 @@ apiVersion: apps/v1
Expand All @@ -9,11 +9,3 @@ index f2eec52..b66c419 100644
+ 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
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@
# limitations under the License.

testType: eval
exitCode: 1
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
stdErr: "failed to configure function: input namespace cannot be empty"
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
4 changes: 2 additions & 2 deletions e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s
2 changes: 1 addition & 1 deletion e2e/testdata/fn-eval/out-of-place-dir/.expected/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ 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
kpt fn eval --image ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest -o out -- namespace=staging
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -67,7 +67,6 @@ stdOut: |
internal.config.kubernetes.io/path: resources.yaml
internal.config.kubernetes.io/seqindent: compact
foo: bar
namespace: staging
labels:
tier: backend
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

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-namespace:latest -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Comment on lines 20 to 27
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff updates the stderr output (set-namespace version change), but the expected output for the custom resource (around line 66-77) was not updated. According to the new isUnknown() behavior in set-namespace.go, the custom.io/v1 resource should NOT have namespace: staging added since it lacks an existing namespace. The expected config.yaml needs to be updated to remove the namespace from the custom resource in stdOut.

Copilot uses AI. Check for mistakes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

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-namespace:latest -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
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ stdOut: |
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
2 changes: 1 addition & 1 deletion e2e/testdata/fn-eval/output-to-stdout/.expected/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
set -eo pipefail

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-namespace:latest -- namespace=staging
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/resources.yaml b/resources.yaml
index f410b70..13bc056 100644
index f410b70..6d94d47 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -16,6 +16,7 @@ kind: Deployment
Expand All @@ -9,11 +9,3 @@ index f410b70..13bc056 100644
+ 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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

set -eo pipefail

kpt fn eval ./sub-pkg -s -t mutator -i set-namespace:v0.2.0 --fn-config=./sub-pkg/fn-config.yaml
kpt fn eval ./sub-pkg -s -t mutator -i set-namespace:latest --fn-config=./sub-pkg/fn-config.yaml
9 changes: 5 additions & 4 deletions e2e/testdata/fn-eval/save-fn/image/.expected/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
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\""
- "[Results]: [info]: namespace [default] updated to \"staging\", 1 value(s) changed, [info]: all `depends-on` annotations are up-to-date. no `namespace` changed"

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.
2 changes: 1 addition & 1 deletion e2e/testdata/fn-eval/save-fn/image/.expected/diff.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ index d9e2f05..d0d3425 100644
+ 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
diff --git a/resources.yaml b/resources.yaml
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/fn-eval/save-fn/image/.expected/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

set -eo pipefail

kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging
kpt fn eval -s -t mutator -i set-namespace:latest -- namespace=staging
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ index d9e2f05..3456414 100644
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

set -eo pipefail

kpt fn eval -s -t mutator -i set-namespace:v0.2.0 --match-kind Deployment -- namespace=staging
kpt fn eval -s -t mutator -i set-namespace:latest --match-kind Deployment -- namespace=staging
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

set -eo pipefail

kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=staging
kpt fn eval -s -t mutator -i set-namespace:latest -- namespace=staging
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ index c093436..6dd6980 100644
+ namespace: newNs
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: 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
- name: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
+ configMap:
+ namespace: newNs
diff --git a/resources.yaml b/resources.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

set -eo pipefail

kpt fn eval -s -t mutator -i set-namespace:v0.2.0 -- namespace=newNs
kpt fn eval -s -t mutator -i set-namespace:latest -- namespace=newNs
Loading
Loading