Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
803b856
Add render status conditions to Kptfile (#4418)
aravindtga Mar 16, 2026
104c1f5
Update kyaml/kustomize API versions to current versions in catalog fu…
Mar 17, 2026
9de3b35
Update kyaml/kustomize API versions to current versions in catalog fu…
Mar 17, 2026
5dcc8b9
feat: implement improved RenderStatus schema for better troubleshooting
Mar 18, 2026
9b89f17
fix: resolve CI failures by fixing wasmtime Windows linking and linti…
Mar 19, 2026
095212e
Fix Kubernetes dependencies and render status implementation
Mar 19, 2026
f3a64e5
Fix GitHub Issue #4333: Improve handling of package context in subpac…
Mar 19, 2026
f7e4919
Fix: Remove unrelated changes from PR
NETIZEN-11 Mar 24, 2026
377c08d
Proofreading of chapter 1.
mpgreaves Feb 26, 2026
40b4a54
Apply suggestions from code review
mpgreaves Mar 12, 2026
d472c05
Made a minor amendment to the sentence structure.
mpgreaves Mar 12, 2026
6eb5918
Fix ci failure (#4435)
aravindtga Mar 18, 2026
9de3c75
Fix GitHub Issue #4333: Improve handling of package context in subpac…
NETIZEN-11 Mar 30, 2026
8dbae6a
Fix GitHub Issue #4432: Resolve Kubernetes version mismatch, YAML ser…
NETIZEN-11 Mar 24, 2026
ce42b8c
DCO: Add missing Signed-off-by lines to commits
NETIZEN-11 Mar 24, 2026
29fcfbb
Refactor the Update code in pkg/lib/kptops
NETIZEN-11 Mar 21, 2026
ce9129b
Merge branch 'main' into refactor/update-code-pkg-lib-kptops-4379
NETIZEN-11 Apr 1, 2026
233a47e
fix: resolve test failures from apply-setters version, path validatio…
Apr 1, 2026
c8d4afd
Merge branch 'main' into refactor/update-code-pkg-lib-kptops-4379
NETIZEN-11 Apr 6, 2026
1de6827
Fix all merge conflicts and compilation errors
Apr 6, 2026
f175fd2
feat: Stabilize ResourceGroup API to v1
Apr 6, 2026
596b621
fix: Remove duplicate validator.Filter call and setRenderStatus function
NETIZEN-11 Apr 7, 2026
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
28 changes: 12 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/google/go-cmp v0.7.0
github.com/google/go-containerregistry v0.20.6
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.2
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.4
github.com/kptdev/krm-functions-sdk/go/fn v1.0.2
github.com/otiai10/copy v1.14.1
github.com/philopon/go-toposort v0.0.0-20170620085441-9be86dbd762f
Expand All @@ -25,19 +25,19 @@ require (
golang.org/x/text v0.31.0
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.34.1
k8s.io/apiextensions-apiserver v0.34.1
k8s.io/apimachinery v0.34.1
k8s.io/cli-runtime v0.34.1
k8s.io/client-go v0.34.1
k8s.io/component-base v0.34.1
k8s.io/api v0.35.0
k8s.io/apiextensions-apiserver v0.35.0
k8s.io/apimachinery v0.35.0
k8s.io/cli-runtime v0.35.0
k8s.io/client-go v0.35.0
k8s.io/component-base v0.35.0
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
k8s.io/kubectl v0.34.1
k8s.io/kubectl v0.35.0
sigs.k8s.io/cli-utils v0.37.2
sigs.k8s.io/controller-runtime v0.22.4
sigs.k8s.io/kustomize/api v0.20.1
sigs.k8s.io/kustomize/kyaml v0.20.1
sigs.k8s.io/kustomize/api v0.21.0
sigs.k8s.io/kustomize/kyaml v0.21.0
sigs.k8s.io/yaml v1.6.0
)

Expand Down Expand Up @@ -75,11 +75,9 @@ require (
github.com/go-openapi/swag/stringutils v0.25.1 // indirect
github.com/go-openapi/swag/typeutils v0.25.1 // indirect
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jonboulle/clockwork v0.5.0 // indirect
Expand All @@ -88,14 +86,12 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/spdystream v0.5.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/gomega v1.37.0 // indirect
github.com/onsi/gomega v1.38.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/otiai10/mint v1.6.3 // indirect
Expand Down Expand Up @@ -126,7 +122,7 @@ require (
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-helpers v0.34.1 // indirect
k8s.io/component-helpers v0.35.0 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
Expand Down
99 changes: 30 additions & 69 deletions go.sum

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions internal/builtins/pkg_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ var (
kptfileGVK = resid.NewGvk(kptfilev1.KptFileGVK().Group, kptfilev1.KptFileGVK().Version, kptfilev1.KptFileGVK().Kind)
)

// isRootKptfile checks if the given path represents a root Kptfile
func isRootKptfile(kptfilePath string) bool {
cleanPath := path.Clean(kptfilePath)
base := path.Base(cleanPath)
return base == kptfilev1.KptFileGVK().Kind
}

// PackageContextGenerator is a built-in KRM function that generates
// a KRM object that contains package context information that can be
// used by functions such as `set-namespace` to customize package with
Expand Down Expand Up @@ -115,13 +122,23 @@ func pkgContextResource(kptfile *yaml.RNode, packageConfig *builtintypes.Package
return nil, err
}

// We only want one "package-context.yaml" in each kpt package
if kptfilePath != kptfilev1.KptFileGVK().Kind {
// We only want one "package-context.yaml" in the root kpt package
// Root package has Kptfile at the root path (no subdirectories), while subpackages
// will have paths like "subpkg/Kptfile"
// Normalize the path first to handle relative paths like "./Kptfile"
cleanPath := path.Clean(kptfilePath)
if !isRootKptfile(cleanPath) {
return nil, nil
}

// Check if this is the root package by verifying the Kptfile is at the root level
if path.Dir(cleanPath) != "." {
// This is a subpackage, don't generate package context
return nil, nil
}

annotations := map[string]string{
kioutil.PathAnnotation: path.Join(path.Dir(kptfilePath), builtintypes.PkgContextFile),
kioutil.PathAnnotation: path.Join(path.Dir(cleanPath), builtintypes.PkgContextFile),
}

for k, v := range annotations {
Expand Down
4 changes: 3 additions & 1 deletion internal/builtins/pkg_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ func TestPkgContextGenerator(t *testing.T) {

exp, err := os.ReadFile(filepath.Join("testdata", test.dir, "out.yaml"))
assert.NoError(t, err)
// Normalize line endings to LF for cross-platform comparison
expNormalized := bytes.ReplaceAll(exp, []byte("\r\n"), []byte("\n"))

err = pkgCtxGenerator.Run(bytes.NewReader(in), out)
if err != test.expErr {
t.Errorf("exp: %v got: %v", test.expErr, err)
}
if diff := cmp.Diff(string(exp), out.String()); diff != "" {
if diff := cmp.Diff(string(expNormalized), out.String()); diff != "" {
t.Errorf("pkg context mistmach (-want +got):\n%s", diff)
}
})
Expand Down
6 changes: 3 additions & 3 deletions internal/fnruntime/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ func NewConfigMap(data map[string]string) (*yaml.RNode, error) {
return nil, nil
}
// create a ConfigMap only for configMap config
configMap := yaml.MustParse(`
apiVersion: v1
configMapYAML := `apiVersion: v1
kind: ConfigMap
metadata:
name: function-input
data: {}
`)
`
configMap := yaml.MustParse(configMapYAML)
if err := node.VisitFields(func(node *yaml.MapNode) error {
v := node.Value.YNode()
v.Tag = yaml.NodeTagString
Expand Down
2 changes: 1 addition & 1 deletion internal/fnruntime/wasmtime.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build cgo
//go:build cgo && !windows

// Copyright 2022,2026 The kpt Authors
//
Expand Down
14 changes: 7 additions & 7 deletions internal/fnruntime/wasmtime_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !cgo
//go:build !cgo || windows

// Copyright 2022,2026 The kpt Authors
//
Expand All @@ -20,21 +20,21 @@ package fnruntime
// wasmtime requires cgo, which is not always a viable option.

import (
"fmt"
"errors"
"io"
)

const (
msg = "wasmtime support is not complied into this binary. Binaries with wasmtime is avilable at github.com/kptdev/kpt"
msg = "wasmtime support is not compiled into this binary. Binaries with wasmtime are available at github.com/kptdev/kpt"
)

type WasmtimeFn struct {
}

func NewWasmtimeFn(loader WasmLoader) (*WasmtimeFn, error) {
return nil, fmt.Errorf(msg)
func NewWasmtimeFn(_ WasmLoader) (*WasmtimeFn, error) {
return nil, errors.New(msg)
}

func (f *WasmtimeFn) Run(r io.Reader, w io.Writer) error {
return fmt.Errorf(msg)
func (f *WasmtimeFn) Run(_ io.Reader, _ io.Writer) error {
return errors.New(msg)
}
2 changes: 1 addition & 1 deletion internal/kptops/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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/apply-setters:v0.2.4": 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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ info:
description: A Google Cloud Storage bucket
pipeline:
mutators:
- image: ghcr.io/kptdev/krm-functions-catalog/apply-setters:v0.2.0
- image: ghcr.io/kptdev/krm-functions-catalog/apply-setters:v0.2.4
configPath: setters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
description: A Google Cloud Storage bucket
pipeline:
mutators:
- image: ghcr.io/kptdev/krm-functions-catalog/apply-setters:v0.2.0
- image: ghcr.io/kptdev/krm-functions-catalog/apply-setters:v0.2.4
configMap:
name: updated-bucket-name
namespace: updated-namespace
Expand Down
Loading
Loading