Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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
stdErr: |
Package: "basicpipeline-print-fn-versions"
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:latest"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:latest" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.3"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.3" in 0s
[Results]: [info]: namespace [default] updated to "staging", 1 value(s) changed, [info]: all `depends-on` annotations are up-to-date. no `namespace` changed
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels@sha256:b087fe8968d1641f495ee382f8f5b8c8e23b062903042775cc28fa6c6a64f6c1"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels@sha256:b087fe8968d1641f495ee382f8f5b8c8e23b062903042775cc28fa6c6a64f6c1" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "ghcr.io:443/kptdev/krm-functions-catalog/set-labels:latest"
[PASS] "ghcr.io:443/kptdev/krm-functions-catalog/set-labels:latest" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "ghcr.io:443/kptdev/krm-functions-catalog/set-labels:latest"
[PASS] "ghcr.io:443/kptdev/krm-functions-catalog/set-labels:latest" in 0s
[Results]: [info]: set 4 labels in total
[RUNNING] "builtins/gen-pkg-context"
[PASS] "builtins/gen-pkg-context" in 0s
[Results]: [info]: generated package context
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/Kptfile b/Kptfile
index abd5626..15c9ac1 100644
--- a/Kptfile
+++ b/Kptfile
@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: app
+ labels:
+ tier: backend
pipeline:
mutators:
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels
diff --git a/package-context.yaml b/package-context.yaml
new file mode 100644
index 0000000..5607ec6
--- /dev/null
+++ b/package-context.yaml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: kptfile.kpt.dev
+ annotations:
+ config.kubernetes.io/local-config: "true"
+data:
+ name: app
diff --git a/resources.yaml b/resources.yaml
index 1f15150..faa5100 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -15,12 +15,20 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
+ labels:
+ tier: backend
+ namespace: staging
spec:
replicas: 3
+ selector:
+ matchLabels:
+ tier: backend
---
apiVersion: custom.io/v1
kind: Custom
metadata:
name: custom
+ labels:
+ tier: backend
spec:
image: nginx:1.2.3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
36 changes: 36 additions & 0 deletions e2e/testdata/fn-render/basicpipeline-print-fn-versions/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: app
pipeline:
mutators:
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels
configMap:
tier: backend
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4
configMap:
tier: backend
- 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.4 <0.2.5"
configMap:
tier: backend
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels@sha256:b087fe8968d1641f495ee382f8f5b8c8e23b062903042775cc28fa6c6a64f6c1
tag: ">=v0.2.4 <v0.2.5"
configMap:
tier: backend
- image: ghcr.io/kptdev/krm-functions-catalog/set-labels@sha256:b087fe8968d1641f495ee382f8f5b8c8e23b062903042775cc28fa6c6a64f6c1
configMap:
tier: backend
- image: ghcr.io:443/kptdev/krm-functions-catalog/set-labels
configMap:
tier: backend
- image: ghcr.io:443/kptdev/krm-functions-catalog/set-labels:latest
configMap:
tier: backend
# built-in pseudo-image has no versions and ignores `tag`
- image: builtins/gen-pkg-context
tag: "v0.1.x"
Original file line number Diff line number Diff line change
@@ -0,0 +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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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-print-fn-version"
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:v0.5.5"
[FAIL] "ghcr.io/kptdev/krm-functions-catalog/starlark:v0.5.5" in 0s
[Results]: [error]: httpbin-gen:3:73: got newline, want primary expression
Stderr: failed to evaluate function: error: function failure Exit code: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
13 changes: 13 additions & 0 deletions e2e/testdata/fn-render/fn-failure-print-fn-version/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
tag: ">=0.5.5, <0.5.6"
configPath: starlark-failure-fn.yaml
- image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
configMap:
namespace: staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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:
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
Original file line number Diff line number Diff line change
@@ -0,0 +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
Original file line number Diff line number Diff line change
@@ -0,0 +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: 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)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

exitCode: 1
stdErr: |
[RESOLUTION FAIL] "ghcr.io/kptdev/krm-functions-catalog/dne:0.4.x"
Error: failed to list tags for image "ghcr.io/kptdev/krm-functions-catalog/dne": failed to list tags for ghcr.io/kptdev/krm-functions-catalog/dne:latest: unauthorized
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
10 changes: 10 additions & 0 deletions e2e/testdata/fn-render/missing-fn-image-print-tag/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: app
pipeline:
mutators:
- image: ghcr.io/kptdev/krm-functions-catalog/dne # non-existing image
tag: "0.4.x"
configMap:
tier: backend
Original file line number Diff line number Diff line change
@@ -0,0 +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
16 changes: 0 additions & 16 deletions internal/fnruntime/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ type ContainerFn struct {

// Image is the container image to run
Image string
Tag string
// ImagePullPolicy controls the image pulling behavior.
ImagePullPolicy runneroptions.ImagePullPolicy
// Container function will be killed after this timeour.
Expand Down Expand Up @@ -152,21 +151,6 @@ func (f *ContainerFn) Run(reader io.Reader, writer io.Writer) error {
return err
}

if f.Tag != "" {
tagResolver := &TagResolver{
lister: &RegClientLister{
client: regclient.New(
regclient.WithUserAgent(UserAgent),
regclient.WithDockerCreds(),
),
},
}
f.Image, err = tagResolver.ResolveFunctionImage(f.Ctx, f.Image, f.Tag)
if err != nil {
return err
}
}

switch runtime {
case Podman:
return f.runCLI(reader, writer, podmanBin, filterPodmanCLIOutput)
Expand Down
Loading