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
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.0
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
Comment on lines +28 to +33
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
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
Loading