From 510b99751790f680a3f6422f2fcc8dea098c6e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= Date: Wed, 25 Feb 2026 10:45:35 +0100 Subject: [PATCH 1/4] rename UpstreamLock type to Locator, add generic locator type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mózes László Máté --- commands/pkg/get/cmdget_test.go | 4 ++-- commands/pkg/update/cmdupdate_test.go | 2 +- internal/testutil/pkgbuilder/builder.go | 2 +- internal/testutil/setup_manager.go | 2 +- internal/testutil/testutil.go | 2 +- internal/util/diff/pkgdiff.go | 4 ++-- internal/util/fetch/fetch_test.go | 8 ++++---- internal/util/get/get_test.go | 18 +++++++++--------- pkg/api/kptfile/v1/types.go | 24 +++++++++++++++++++++--- pkg/kptfile/kptfileutil/util.go | 2 +- pkg/lib/kptops/clone.go | 6 +++--- pkg/lib/kptops/clone_test.go | 4 ++-- pkg/lib/kptops/pkgupdate.go | 4 ++-- 13 files changed, 50 insertions(+), 32 deletions(-) diff --git a/commands/pkg/get/cmdget_test.go b/commands/pkg/get/cmdget_test.go index 8c8a5f2d3a..6d01057592 100644 --- a/commands/pkg/get/cmdget_test.go +++ b/commands/pkg/get/cmdget_test.go @@ -81,7 +81,7 @@ func TestCmd_execute(t *testing.T) { }, UpdateStrategy: kptfilev1.ResourceMerge, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -142,7 +142,7 @@ func TestCmdMainBranch_execute(t *testing.T) { }, UpdateStrategy: kptfilev1.ResourceMerge, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", diff --git a/commands/pkg/update/cmdupdate_test.go b/commands/pkg/update/cmdupdate_test.go index ec7626f8c9..5dfa5bbb14 100644 --- a/commands/pkg/update/cmdupdate_test.go +++ b/commands/pkg/update/cmdupdate_test.go @@ -118,7 +118,7 @@ func TestCmd_execute(t *testing.T) { }, UpdateStrategy: kptfilev1.FastForward, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Repo: "file://" + g.RepoDirectory, diff --git a/internal/testutil/pkgbuilder/builder.go b/internal/testutil/pkgbuilder/builder.go index 9dd7ebea30..9d943e7cef 100644 --- a/internal/testutil/pkgbuilder/builder.go +++ b/internal/testutil/pkgbuilder/builder.go @@ -610,7 +610,7 @@ func buildKptfile(pkg *pkg, pkgName string, reposInfo ReposInfo) string { } } if pkg.Kptfile.UpstreamLock != nil { - kptfile.UpstreamLock = &kptfilev1.UpstreamLock{ + kptfile.UpstreamLock = &kptfilev1.Locator{ Type: "git", Git: &kptfilev1.GitLock{ Repo: pkg.Kptfile.UpstreamLock.Repo, diff --git a/internal/testutil/setup_manager.go b/internal/testutil/setup_manager.go index 1d8d0ba28f..27a546852c 100644 --- a/internal/testutil/setup_manager.go +++ b/internal/testutil/setup_manager.go @@ -236,7 +236,7 @@ func (g *TestSetupManager) AssertKptfile(name, commit, ref string, strategy kptf }, UpdateStrategy: strategy, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: "git", Git: &kptfilev1.GitLock{ Directory: g.GetSubDirectory, diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index d64d6c8f2c..283e0ffb0f 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -654,7 +654,7 @@ func replaceData(repo, data string) error { if dataKptfile.Upstream == nil || reflect.DeepEqual(dataKptfile.Upstream, kptfilev1.Upstream{}) { dataKptfile.Upstream = repoKptfile.Upstream } - if dataKptfile.UpstreamLock == nil || reflect.DeepEqual(dataKptfile.UpstreamLock, kptfilev1.UpstreamLock{}) { + if dataKptfile.UpstreamLock == nil || reflect.DeepEqual(dataKptfile.UpstreamLock, kptfilev1.Locator{}) { dataKptfile.UpstreamLock = repoKptfile.UpstreamLock } dataKptfile.Name = repoKptfile.Name diff --git a/internal/util/diff/pkgdiff.go b/internal/util/diff/pkgdiff.go index a9ee7484b8..e41681ed33 100644 --- a/internal/util/diff/pkgdiff.go +++ b/internal/util/diff/pkgdiff.go @@ -90,9 +90,9 @@ func kptfilesEqual(pkg1, pkg2, filePath string) (bool, error) { // Diffs in Upstream and UpstreamLock should be ignored. pkg1Kf.Upstream = &kptfilev1.Upstream{} - pkg1Kf.UpstreamLock = &kptfilev1.UpstreamLock{} + pkg1Kf.UpstreamLock = &kptfilev1.Locator{} pkg2Kf.Upstream = &kptfilev1.Upstream{} - pkg2Kf.UpstreamLock = &kptfilev1.UpstreamLock{} + pkg2Kf.UpstreamLock = &kptfilev1.Locator{} pkg1Bytes, err := yaml.Marshal(pkg1Kf) if err != nil { diff --git a/internal/util/fetch/fetch_test.go b/internal/util/fetch/fetch_test.go index eab906aa45..44458d903c 100644 --- a/internal/util/fetch/fetch_test.go +++ b/internal/util/fetch/fetch_test.go @@ -208,7 +208,7 @@ func TestCommand_Run(t *testing.T) { }, UpdateStrategy: kptfilev1.ResourceMerge, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: "git", Git: &kptfilev1.GitLock{ Directory: "/", @@ -270,7 +270,7 @@ func TestCommand_Run_subdir(t *testing.T) { }, UpdateStrategy: kptfilev1.ResourceMerge, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Commit: commit, @@ -347,7 +347,7 @@ func TestCommand_Run_branch(t *testing.T) { }, UpdateStrategy: kptfilev1.ResourceMerge, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -429,7 +429,7 @@ func TestCommand_Run_tag(t *testing.T) { }, UpdateStrategy: kptfilev1.ResourceMerge, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: "git", Git: &kptfilev1.GitLock{ Directory: "/", diff --git a/internal/util/get/get_test.go b/internal/util/get/get_test.go index e0b17a669d..ab965599b1 100644 --- a/internal/util/get/get_test.go +++ b/internal/util/get/get_test.go @@ -107,7 +107,7 @@ func TestCommand_Run(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -166,7 +166,7 @@ func TestCommand_Run_subdir(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: "git", Git: &kptfilev1.GitLock{ Commit: commit, @@ -237,7 +237,7 @@ func TestCommand_Run_subdir_symlinks(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: "git", Git: &kptfilev1.GitLock{ Commit: commit, @@ -298,7 +298,7 @@ func TestCommand_Run_destination(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -362,7 +362,7 @@ func TestCommand_Run_subdirAndDestination(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Commit: commit, @@ -440,7 +440,7 @@ func TestCommand_Run_branch(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -523,7 +523,7 @@ func TestCommand_Run_tag(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -695,7 +695,7 @@ func TestCommand_Run_failExistingDir(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", @@ -748,7 +748,7 @@ func TestCommand_Run_failExistingDir(t *testing.T) { APIVersion: kptfilev1.TypeMeta.APIVersion, Kind: kptfilev1.TypeMeta.Kind}, }, - UpstreamLock: &kptfilev1.UpstreamLock{ + UpstreamLock: &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Directory: "/", diff --git a/pkg/api/kptfile/v1/types.go b/pkg/api/kptfile/v1/types.go index 4afb56af5a..a0dcc16504 100644 --- a/pkg/api/kptfile/v1/types.go +++ b/pkg/api/kptfile/v1/types.go @@ -72,7 +72,7 @@ type KptFile struct { Upstream *Upstream `yaml:"upstream,omitempty" json:"upstream,omitempty"` // UpstreamLock is a resolved locator for the last fetch of the package. - UpstreamLock *UpstreamLock `yaml:"upstreamLock,omitempty" json:"upstreamLock,omitempty"` + UpstreamLock *Locator `yaml:"upstreamLock,omitempty" json:"upstreamLock,omitempty"` // Info contains metadata such as license, documentation, etc. Info *PackageInfo `yaml:"info,omitempty" json:"info,omitempty"` @@ -92,6 +92,9 @@ type OriginType string const ( // GitOrigin specifies a package as having been cloned from a git repository. GitOrigin OriginType = "git" + + // GenericOrigin specifies a package being stored in a custom storage. + GenericOrigin OriginType = "generic" ) // UpdateStrategyType defines the strategy for updating a package from upstream. @@ -171,13 +174,16 @@ type Git struct { Ref string `yaml:"ref,omitempty" json:"ref,omitempty"` } -// UpstreamLock is a resolved locator for the last fetch of the package. -type UpstreamLock struct { +// Locator is a resolved locator for the last fetch of the package. +type Locator struct { // Type is the type of origin. Type OriginType `yaml:"type,omitempty" json:"type,omitempty"` // Git is the resolved locator for a package on Git. Git *GitLock `yaml:"git,omitempty" json:"git,omitempty"` + + // Generic is a minimal locator for a package stored in some generic storage type (e.g.: a database) + Generic *GenericLock `yaml:"generic,omitempty" json:"generic,omitempty"` } // GitLock is the resolved locator for a package on Git. @@ -199,6 +205,18 @@ type GitLock struct { Commit string `yaml:"commit,omitempty" json:"commit,omitempty"` } +type GenericLock struct { + // StoreID is a descriptor of the underlying storage type. + // e.g. 'DB' for database + StoreID string `yaml:"storeID" json:"storeID"` + // ResourceID is a unique identifier of the resource. + // The format depends on the underlying storage. + ResourceID string `yaml:"resourceID" json:"resourceID"` + // ResourceVersion indicates the last fetched version of the resource. + // The format depends on the underlying storage. + ResourceVersion string `yaml:"resourceVersion" json:"resourceVersion"` +} + // PackageInfo contains optional information about the package such as license, documentation, etc. // These fields are not consumed by any functionality in kpt and are simply passed through. // Note that like any other KRM resource, humans and automation can also use `metadata.labels` and diff --git a/pkg/kptfile/kptfileutil/util.go b/pkg/kptfile/kptfileutil/util.go index c2018f9e23..01018a3ff4 100644 --- a/pkg/kptfile/kptfileutil/util.go +++ b/pkg/kptfile/kptfileutil/util.go @@ -251,7 +251,7 @@ func UpdateUpstreamLockFromGit(path string, spec *git.RepoSpec) error { } // populate the cloneFrom values so we know where the package came from - kpgfile.UpstreamLock = &kptfilev1.UpstreamLock{ + kpgfile.UpstreamLock = &kptfilev1.Locator{ Type: kptfilev1.GitOrigin, Git: &kptfilev1.GitLock{ Repo: spec.OrgRepo, diff --git a/pkg/lib/kptops/clone.go b/pkg/lib/kptops/clone.go index ac21347c9b..f982ab789c 100644 --- a/pkg/lib/kptops/clone.go +++ b/pkg/lib/kptops/clone.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/kustomize/kyaml/yaml" ) -func UpdateUpstream(kptfileContents string, name string, upstream kptfilev1.Upstream, lock kptfilev1.UpstreamLock) (string, error) { +func UpdateUpstream(kptfileContents string, name string, upstream kptfilev1.Upstream, lock kptfilev1.Locator) (string, error) { kptfile, err := kptfileutil.DecodeKptfile(strings.NewReader(kptfileContents)) if err != nil { return "", fmt.Errorf("cannot parse Kptfile: %w", err) @@ -66,7 +66,7 @@ func UpdateName(kptfileContents string, name string) (string, error) { return string(b), nil } -func UpdateKptfileUpstream(name string, contents map[string]string, upstream kptfilev1.Upstream, lock kptfilev1.UpstreamLock) error { +func UpdateKptfileUpstream(name string, contents map[string]string, upstream kptfilev1.Upstream, lock kptfilev1.Locator) error { kptfile, found := contents[kptfilev1.KptFileName] if !found { return fmt.Errorf("package %q is missing Kptfile", name) @@ -110,7 +110,7 @@ func normalizeGitFields(u *kptfilev1.Upstream) { } // normalizeGitLockFields ensures consistent formatting for UpstreamLock git fields -func normalizeGitLockFields(l *kptfilev1.UpstreamLock) { +func normalizeGitLockFields(l *kptfilev1.Locator) { if l.Git != nil { // Ensure .git suffix is present if !strings.HasSuffix(l.Git.Repo, ".git") { diff --git a/pkg/lib/kptops/clone_test.go b/pkg/lib/kptops/clone_test.go index f69e9a18f5..d2123bbfbc 100644 --- a/pkg/lib/kptops/clone_test.go +++ b/pkg/lib/kptops/clone_test.go @@ -53,7 +53,7 @@ func TestNormalizeGitFields(t *testing.T) { func TestNormalizeGitLockFields(t *testing.T) { // Test case 1: Add .git suffix and normalize directory path - lock := &kptfilev1.UpstreamLock{ + lock := &kptfilev1.Locator{ Git: &kptfilev1.GitLock{ Repo: exampleRepoURL, Directory: "/path/to/dir", @@ -68,7 +68,7 @@ func TestNormalizeGitLockFields(t *testing.T) { } // Test case 2: Already has .git suffix - lock = &kptfilev1.UpstreamLock{ + lock = &kptfilev1.Locator{ Git: &kptfilev1.GitLock{ Repo: exampleRepoURL, Directory: "path/to/dir", diff --git a/pkg/lib/kptops/pkgupdate.go b/pkg/lib/kptops/pkgupdate.go index 0ded4bdcc5..1db2ab3e7d 100644 --- a/pkg/lib/kptops/pkgupdate.go +++ b/pkg/lib/kptops/pkgupdate.go @@ -132,14 +132,14 @@ func PkgUpdate(ctx context.Context, ref string, packageDir string, _ PkgUpdateOp // return errors.E(op, p.UniquePath, err) // } - // if kf.UpstreamLock != nil { + // if kf.Locator != nil { // originDir, err = ioutil.TempDir("", "kpt-get-") // if err != nil { // return errors.E(op, errors.Internal, fmt.Errorf("error creating temp directory: %w", err)) // } // defer os.RemoveAll(originDir) - // if err = fetch.ClonerUsingOciPull(ctx, kf.UpstreamLock.Oci.Image, nil, originDir, options); err != nil { + // if err = fetch.ClonerUsingOciPull(ctx, kf.Locator.Oci.Image, nil, originDir, options); err != nil { // return errors.E(op, p.UniquePath, err) // } // } else { From afffb3c3a9855151deffc91496b89b538571531b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= Date: Wed, 25 Feb 2026 11:13:31 +0100 Subject: [PATCH 2/4] add deprecated type alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mózes László Máté --- pkg/api/kptfile/v1/types.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/api/kptfile/v1/types.go b/pkg/api/kptfile/v1/types.go index a0dcc16504..b0e8f7cab2 100644 --- a/pkg/api/kptfile/v1/types.go +++ b/pkg/api/kptfile/v1/types.go @@ -186,6 +186,9 @@ type Locator struct { Generic *GenericLock `yaml:"generic,omitempty" json:"generic,omitempty"` } +// Deprecated: use `Locator` instead. +type UpstreamLock = Locator + // GitLock is the resolved locator for a package on Git. type GitLock struct { // Repo is the git repository that was fetched. From b9aaa82ef2a18d69989af43e60dd838f84dd75c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= Date: Wed, 25 Feb 2026 15:30:17 +0100 Subject: [PATCH 3/4] fix additional copilot comments, fix schema generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mózes László Máté --- Makefile | 4 +- .../en/reference/schema/kptfile/kptfile.json | 62 +- .../en/reference/schema/kptfile/kptfile.yaml | 881 +++++++++--------- internal/testutil/testutil.go | 6 +- pkg/api/kptfile/v1/types.go | 1 + pkg/lib/kptops/clone.go | 2 +- pkg/lib/kptops/pkgupdate.go | 6 +- scripts/generate-schema.sh | 10 +- 8 files changed, 517 insertions(+), 455 deletions(-) diff --git a/Makefile b/Makefile index 9485eec802..4072ef7d57 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ install-golangci-lint: .PHONY: install-swagger install-swagger: - go install github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 + go install github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1 .PHONY: install-mdtogo install-mdtogo: @@ -76,7 +76,7 @@ fix: fmt: go fmt ./... -schema: +schema: install-swagger GOBIN=$(GOBIN) scripts/generate-schema.sh generate: install-mdtogo diff --git a/documentation/content/en/reference/schema/kptfile/kptfile.json b/documentation/content/en/reference/schema/kptfile/kptfile.json index bb0f42eb52..b35206fcf8 100644 --- a/documentation/content/en/reference/schema/kptfile/kptfile.json +++ b/documentation/content/en/reference/schema/kptfile/kptfile.json @@ -37,6 +37,7 @@ "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" }, "Function": { + "description": "+kubebuilder:object:generate=true", "type": "object", "title": "Function specifies a KRM function.", "properties": { @@ -83,6 +84,33 @@ "$ref": "#/definitions/Selector" }, "x-go-name": "Selectors" + }, + "tag": { + "description": "`Tag` is an optional field for specifying/overriding the tag of the function image.\nCan be a semver constraint satisfying this spec: https://github.com/Masterminds/semver?tab=readme-ov-file#checking-version-constraints", + "type": "string", + "x-go-name": "Tag" + } + }, + "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" + }, + "GenericLock": { + "type": "object", + "title": "GenericLock is a minimal locator for a package stored in a generic storage backend.", + "properties": { + "resourceID": { + "description": "ResourceID is a unique identifier of the resource.\nThe format depends on the underlying storage.", + "type": "string", + "x-go-name": "ResourceID" + }, + "resourceVersion": { + "description": "ResourceVersion indicates the last fetched version of the resource.\nThe format depends on the underlying storage.", + "type": "string", + "x-go-name": "ResourceVersion" + }, + "storeID": { + "description": "StoreID is a descriptor of the underlying storage type.\ne.g. 'DB' for database", + "type": "string", + "x-go-name": "StoreID" } }, "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" @@ -173,6 +201,22 @@ }, "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" }, + "Locator": { + "type": "object", + "title": "Locator is a resolved locator for the last fetch of the package.", + "properties": { + "generic": { + "$ref": "#/definitions/GenericLock" + }, + "git": { + "$ref": "#/definitions/GitLock" + }, + "type": { + "$ref": "#/definitions/OriginType" + } + }, + "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" + }, "NameMeta": { "type": "object", "title": "NameMeta contains name information.", @@ -285,6 +329,7 @@ "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" }, "Pipeline": { + "description": "+kubebuilder:object:generate=true", "type": "object", "title": "Pipeline declares a pipeline of functions used to mutate or validate resources.", "properties": { @@ -361,7 +406,7 @@ "x-go-package": "sigs.k8s.io/kustomize/kyaml/yaml" }, "Selector": { - "description": "Selector specifies the selection criteria\nplease update IsEmpty method if more properties are added", + "description": "Selector specifies the selection criteria\nplease update IsEmpty method if more properties are added\n+kubebuilder:object:generate=true", "type": "object", "properties": { "annotations": { @@ -454,19 +499,6 @@ }, "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" }, - "UpstreamLock": { - "type": "object", - "title": "UpstreamLock is a resolved locator for the last fetch of the package.", - "properties": { - "git": { - "$ref": "#/definitions/GitLock" - }, - "type": { - "$ref": "#/definitions/OriginType" - } - }, - "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" - }, "kptfile": { "type": "object", "title": "KptFile contains information about a package managed with kpt.", @@ -523,7 +555,7 @@ "$ref": "#/definitions/Upstream" }, "upstreamLock": { - "$ref": "#/definitions/UpstreamLock" + "$ref": "#/definitions/Locator" } }, "x-go-name": "KptFile", diff --git a/documentation/content/en/reference/schema/kptfile/kptfile.yaml b/documentation/content/en/reference/schema/kptfile/kptfile.yaml index 1274c73a48..efdb4c415d 100644 --- a/documentation/content/en/reference/schema/kptfile/kptfile.yaml +++ b/documentation/content/en/reference/schema/kptfile/kptfile.yaml @@ -1,446 +1,477 @@ definitions: - Condition: - properties: - message: - type: string - x-go-name: Message - reason: - type: string - x-go-name: Reason - status: - $ref: '#/definitions/ConditionStatus' - type: - type: string - x-go-name: Type - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - ConditionStatus: - type: string - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - Function: - properties: - configMap: - additionalProperties: - type: string - description: '`ConfigMap` is a convenient way to specify a function config - of kind ConfigMap.' + Condition: + properties: + message: + type: string + x-go-name: Message + reason: + type: string + x-go-name: Reason + status: + $ref: '#/definitions/ConditionStatus' + type: + type: string + x-go-name: Type type: object - x-go-name: ConfigMap - configPath: - description: |- - `ConfigPath` specifies a slash-delimited relative path to a file in the current directory - containing a KRM resource used as the function config. This resource is - excluded when resolving 'sources', and as a result cannot be operated on - by the pipeline. - type: string - x-go-name: ConfigPath - exclude: - description: |- - `Exclude` are used to specify resources on which the function should NOT be executed. - If not specified, all resources selected by `Selectors` are selected. - items: - $ref: '#/definitions/Selector' - type: array - x-go-name: Exclusions - exec: - description: |- - Exec specifies the function binary executable. - The executable can be fully qualified or it must exists in the $PATH e.g: + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + ConditionStatus: + type: string + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Function: + description: +kubebuilder:object:generate=true + properties: + configMap: + additionalProperties: + type: string + description: '`ConfigMap` is a convenient way to specify a function config of kind ConfigMap.' + type: object + x-go-name: ConfigMap + configPath: + description: |- + `ConfigPath` specifies a slash-delimited relative path to a file in the current directory + containing a KRM resource used as the function config. This resource is + excluded when resolving 'sources', and as a result cannot be operated on + by the pipeline. + type: string + x-go-name: ConfigPath + exclude: + description: |- + `Exclude` are used to specify resources on which the function should NOT be executed. + If not specified, all resources selected by `Selectors` are selected. + items: + $ref: '#/definitions/Selector' + type: array + x-go-name: Exclusions + exec: + description: |- + Exec specifies the function binary executable. + The executable can be fully qualified or it must exists in the $PATH e.g: - exec: set-namespace - exec: /usr/local/bin/my-custom-fn - type: string - x-go-name: Exec - image: - description: |- - `Image` specifies the function container image. - It can either be fully qualified, e.g.: + exec: set-namespace + exec: /usr/local/bin/my-custom-fn + type: string + x-go-name: Exec + image: + description: |- + `Image` specifies the function container image. + It can either be fully qualified, e.g.: - image: ghcr.io/kptdev/krm-functions-catalog/set-labels + image: ghcr.io/kptdev/krm-functions-catalog/set-labels - Optionally, kpt can be configured to use a image - registry host-path that will be used to resolve the image path in case - the image path is missing (Defaults to ghcr.io/kptdev/krm-functions-catalog). - e.g. The following resolves to ghcr.io/kptdev/krm-functions-catalog/set-labels + Optionally, kpt can be configured to use a image + registry host-path that will be used to resolve the image path in case + the image path is missing (Defaults to ghcr.io/kptdev/krm-functions-catalog). + e.g. The following resolves to ghcr.io/kptdev/krm-functions-catalog/set-labels - image: set-labels - type: string - x-go-name: Image - name: - description: |- - `Name` is used to uniquely identify the function declaration - this is primarily used for merging function declaration with upstream counterparts - type: string - x-go-name: Name - selectors: - description: |- - `Selectors` are used to specify resources on which the function should be executed - if not specified, all resources are selected - items: - $ref: '#/definitions/Selector' - type: array - x-go-name: Selectors - title: Function specifies a KRM function. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - Git: - properties: - directory: - description: |- - Directory is the sub directory of the git repository. - e.g. 'staging/cockroachdb' - type: string - x-go-name: Directory - ref: - description: Ref can be a Git branch, tag, or a commit SHA-1. - type: string - x-go-name: Ref - repo: - description: |- - Repo is the git repository the package. - e.g. 'https://github.com/kubernetes/examples.git' - type: string - x-go-name: Repo - title: Git is the user-specified locator for a package on Git. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - GitLock: - properties: - commit: - description: |- - Commit is the SHA-1 for the last fetch of the package. - This is set by kpt for bookkeeping purposes. - type: string - x-go-name: Commit - directory: - description: |- - Directory is the sub directory of the git repository that was fetched. - e.g. 'staging/cockroachdb' - type: string - x-go-name: Directory - ref: - description: |- - Ref can be a Git branch, tag, or a commit SHA-1 that was fetched. - e.g. 'master' - type: string - x-go-name: Ref - repo: - description: |- - Repo is the git repository that was fetched. - e.g. 'https://github.com/kubernetes/examples.git' - type: string - x-go-name: Repo - title: GitLock is the resolved locator for a package on Git. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - Inventory: - description: All of the the parameters are required if any are set. - properties: - annotations: - additionalProperties: - type: string + image: set-labels + type: string + x-go-name: Image + name: + description: |- + `Name` is used to uniquely identify the function declaration + this is primarily used for merging function declaration with upstream counterparts + type: string + x-go-name: Name + selectors: + description: |- + `Selectors` are used to specify resources on which the function should be executed + if not specified, all resources are selected + items: + $ref: '#/definitions/Selector' + type: array + x-go-name: Selectors + tag: + description: |- + `Tag` is an optional field for specifying/overriding the tag of the function image. + Can be a semver constraint satisfying this spec: https://github.com/Masterminds/semver?tab=readme-ov-file#checking-version-constraints + type: string + x-go-name: Tag + title: Function specifies a KRM function. type: object - x-go-name: Annotations - inventoryID: - description: Unique label to identify inventory resource in cluster. - type: string - x-go-name: InventoryID - labels: - additionalProperties: - type: string + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + GenericLock: + properties: + resourceID: + description: |- + ResourceID is a unique identifier of the resource. + The format depends on the underlying storage. + type: string + x-go-name: ResourceID + resourceVersion: + description: |- + ResourceVersion indicates the last fetched version of the resource. + The format depends on the underlying storage. + type: string + x-go-name: ResourceVersion + storeID: + description: |- + StoreID is a descriptor of the underlying storage type. + e.g. 'DB' for database + type: string + x-go-name: StoreID + title: GenericLock is a minimal locator for a package stored in a generic storage backend. type: object - x-go-name: Labels - name: - description: Name of the inventory resource. - type: string - x-go-name: Name - namespace: - description: Namespace for the inventory resource. - type: string - x-go-name: Namespace - title: Inventory encapsulates the parameters for the inventory resource applied - to a cluster. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - NameMeta: - properties: - name: - description: Name is the metadata.name field of a Resource - type: string - x-go-name: Name - namespace: - description: Namespace is the metadata.namespace field of a Resource - type: string - x-go-name: Namespace - title: NameMeta contains name information. - type: object - x-go-package: sigs.k8s.io/kustomize/kyaml/yaml - ObjectMeta: - description: ObjectMeta contains metadata about a Resource - properties: - annotations: - additionalProperties: - type: string - description: Annotations is the metadata.annotations field of a Resource. + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Git: + properties: + directory: + description: |- + Directory is the sub directory of the git repository. + e.g. 'staging/cockroachdb' + type: string + x-go-name: Directory + ref: + description: Ref can be a Git branch, tag, or a commit SHA-1. + type: string + x-go-name: Ref + repo: + description: |- + Repo is the git repository the package. + e.g. 'https://github.com/kubernetes/examples.git' + type: string + x-go-name: Repo + title: Git is the user-specified locator for a package on Git. type: object - x-go-name: Annotations - labels: - additionalProperties: - type: string - description: Labels is the metadata.labels field of a Resource + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + GitLock: + properties: + commit: + description: |- + Commit is the SHA-1 for the last fetch of the package. + This is set by kpt for bookkeeping purposes. + type: string + x-go-name: Commit + directory: + description: |- + Directory is the sub directory of the git repository that was fetched. + e.g. 'staging/cockroachdb' + type: string + x-go-name: Directory + ref: + description: |- + Ref can be a Git branch, tag, or a commit SHA-1 that was fetched. + e.g. 'master' + type: string + x-go-name: Ref + repo: + description: |- + Repo is the git repository that was fetched. + e.g. 'https://github.com/kubernetes/examples.git' + type: string + x-go-name: Repo + title: GitLock is the resolved locator for a package on Git. type: object - x-go-name: Labels - name: - description: Name is the metadata.name field of a Resource - type: string - x-go-name: Name - namespace: - description: Namespace is the metadata.namespace field of a Resource - type: string - x-go-name: Namespace - type: object - x-go-package: sigs.k8s.io/kustomize/kyaml/yaml - OriginType: - title: OriginType defines the type of origin for a package. - type: string - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - PackageInfo: - description: |- - These fields are not consumed by any functionality in kpt and are simply passed through. - Note that like any other KRM resource, humans and automation can also use `metadata.labels` and - `metadata.annotations` as the extension mechanism. - properties: - description: - description: Description contains a short description of the package. - type: string - x-go-name: Description - emails: - description: Email is the list of emails for the package authors. - items: - type: string - type: array - x-go-name: Emails - keywords: - description: Keywords is a list of keywords for this package. - items: - type: string - type: array - x-go-name: Keywords - license: - description: 'SPDX license identifier (e.g. "Apache-2.0"). See: https://spdx.org/licenses/' - type: string - x-go-name: License - licenseFile: - description: Relative slash-delimited path to the license file (e.g. LICENSE.txt) - type: string - x-go-name: LicenseFile - man: - description: Man is the path to documentation about the package - type: string - x-go-name: Man - readinessGates: - items: - $ref: '#/definitions/ReadinessGate' - type: array - x-go-name: ReadinessGates - site: - description: Site is the URL for package web page. + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Inventory: + description: All of the the parameters are required if any are set. + properties: + annotations: + additionalProperties: + type: string + type: object + x-go-name: Annotations + inventoryID: + description: Unique label to identify inventory resource in cluster. + type: string + x-go-name: InventoryID + labels: + additionalProperties: + type: string + type: object + x-go-name: Labels + name: + description: Name of the inventory resource. + type: string + x-go-name: Name + namespace: + description: Namespace for the inventory resource. + type: string + x-go-name: Namespace + title: Inventory encapsulates the parameters for the inventory resource applied to a cluster. + type: object + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Locator: + properties: + generic: + $ref: '#/definitions/GenericLock' + git: + $ref: '#/definitions/GitLock' + type: + $ref: '#/definitions/OriginType' + title: Locator is a resolved locator for the last fetch of the package. + type: object + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + NameMeta: + properties: + name: + description: Name is the metadata.name field of a Resource + type: string + x-go-name: Name + namespace: + description: Namespace is the metadata.namespace field of a Resource + type: string + x-go-name: Namespace + title: NameMeta contains name information. + type: object + x-go-package: sigs.k8s.io/kustomize/kyaml/yaml + ObjectMeta: + description: ObjectMeta contains metadata about a Resource + properties: + annotations: + additionalProperties: + type: string + description: Annotations is the metadata.annotations field of a Resource. + type: object + x-go-name: Annotations + labels: + additionalProperties: + type: string + description: Labels is the metadata.labels field of a Resource + type: object + x-go-name: Labels + name: + description: Name is the metadata.name field of a Resource + type: string + x-go-name: Name + namespace: + description: Namespace is the metadata.namespace field of a Resource + type: string + x-go-name: Namespace + type: object + x-go-package: sigs.k8s.io/kustomize/kyaml/yaml + OriginType: + title: OriginType defines the type of origin for a package. type: string - x-go-name: Site - title: PackageInfo contains optional information about the package such as license, - documentation, etc. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - Pipeline: - properties: - mutators: - description: Mutators defines a list of of KRM functions that mutate resources. - items: - $ref: '#/definitions/Function' - type: array - x-go-name: Mutators - validators: + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + PackageInfo: description: |- - Validators defines a list of KRM functions that validate resources. - Validators are not permitted to mutate resources. - items: - $ref: '#/definitions/Function' - type: array - x-go-name: Validators - title: Pipeline declares a pipeline of functions used to mutate or validate resources. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - ReadinessGate: - properties: - conditionType: - type: string - x-go-name: ConditionType - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - ResourceMeta: - properties: - annotations: - additionalProperties: - type: string - description: Annotations is the metadata.annotations field of a Resource. + These fields are not consumed by any functionality in kpt and are simply passed through. + Note that like any other KRM resource, humans and automation can also use `metadata.labels` and + `metadata.annotations` as the extension mechanism. + properties: + description: + description: Description contains a short description of the package. + type: string + x-go-name: Description + emails: + description: Email is the list of emails for the package authors. + items: + type: string + type: array + x-go-name: Emails + keywords: + description: Keywords is a list of keywords for this package. + items: + type: string + type: array + x-go-name: Keywords + license: + description: 'SPDX license identifier (e.g. "Apache-2.0"). See: https://spdx.org/licenses/' + type: string + x-go-name: License + licenseFile: + description: Relative slash-delimited path to the license file (e.g. LICENSE.txt) + type: string + x-go-name: LicenseFile + man: + description: Man is the path to documentation about the package + type: string + x-go-name: Man + readinessGates: + items: + $ref: '#/definitions/ReadinessGate' + type: array + x-go-name: ReadinessGates + site: + description: Site is the URL for package web page. + type: string + x-go-name: Site + title: PackageInfo contains optional information about the package such as license, documentation, etc. type: object - x-go-name: Annotations - apiVersion: - description: APIVersion is the apiVersion field of a Resource - type: string - x-go-name: APIVersion - kind: - description: Kind is the kind field of a Resource - type: string - x-go-name: Kind - labels: - additionalProperties: - type: string - description: Labels is the metadata.labels field of a Resource + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Pipeline: + description: +kubebuilder:object:generate=true + properties: + mutators: + description: Mutators defines a list of of KRM functions that mutate resources. + items: + $ref: '#/definitions/Function' + type: array + x-go-name: Mutators + validators: + description: |- + Validators defines a list of KRM functions that validate resources. + Validators are not permitted to mutate resources. + items: + $ref: '#/definitions/Function' + type: array + x-go-name: Validators + title: Pipeline declares a pipeline of functions used to mutate or validate resources. type: object - x-go-name: Labels - name: - description: Name is the metadata.name field of a Resource - type: string - x-go-name: Name - namespace: - description: Namespace is the metadata.namespace field of a Resource - type: string - x-go-name: Namespace - title: ResourceMeta contains the metadata for a both Resource Type and Resource. - type: object - x-go-package: sigs.k8s.io/kustomize/kyaml/yaml - Selector: - description: |- - Selector specifies the selection criteria - please update IsEmpty method if more properties are added - properties: - annotations: - additionalProperties: - type: string - description: Annotations on the target resources + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + ReadinessGate: + properties: + conditionType: + type: string + x-go-name: ConditionType type: object - x-go-name: Annotations - apiVersion: - description: APIVersion of the target resources - type: string - x-go-name: APIVersion - kind: - description: Kind of the target resources - type: string - x-go-name: Kind - labels: - additionalProperties: - type: string - description: Labels on the target resources + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + ResourceMeta: + properties: + annotations: + additionalProperties: + type: string + description: Annotations is the metadata.annotations field of a Resource. + type: object + x-go-name: Annotations + apiVersion: + description: APIVersion is the apiVersion field of a Resource + type: string + x-go-name: APIVersion + kind: + description: Kind is the kind field of a Resource + type: string + x-go-name: Kind + labels: + additionalProperties: + type: string + description: Labels is the metadata.labels field of a Resource + type: object + x-go-name: Labels + name: + description: Name is the metadata.name field of a Resource + type: string + x-go-name: Name + namespace: + description: Namespace is the metadata.namespace field of a Resource + type: string + x-go-name: Namespace + title: ResourceMeta contains the metadata for a both Resource Type and Resource. type: object - x-go-name: Labels - name: - description: Name of the target resources - type: string - x-go-name: Name - namespace: - description: Namespace of the target resources - type: string - x-go-name: Namespace - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - Status: - properties: - conditions: - items: - $ref: '#/definitions/Condition' - type: array - x-go-name: Conditions - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - TypeMeta: - description: |- - TypeMeta partially copies apimachinery/pkg/apis/meta/v1.TypeMeta - No need for a direct dependence; the fields are stable. - properties: - apiVersion: - description: APIVersion is the apiVersion field of a Resource - type: string - x-go-name: APIVersion - kind: - description: Kind is the kind field of a Resource - type: string - x-go-name: Kind - type: object - x-go-package: sigs.k8s.io/kustomize/kyaml/yaml - UpdateStrategyType: - title: UpdateStrategyType defines the strategy for updating a package from upstream. - type: string - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - Upstream: - properties: - git: - $ref: '#/definitions/Git' - type: - $ref: '#/definitions/OriginType' - updateStrategy: - $ref: '#/definitions/UpdateStrategyType' - title: Upstream is a user-specified upstream locator for a package. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - UpstreamLock: - properties: - git: - $ref: '#/definitions/GitLock' - type: - $ref: '#/definitions/OriginType' - title: UpstreamLock is a resolved locator for the last fetch of the package. - type: object - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 - kptfile: - properties: - annotations: - additionalProperties: - type: string - description: Annotations is the metadata.annotations field of a Resource. + x-go-package: sigs.k8s.io/kustomize/kyaml/yaml + Selector: + description: |- + Selector specifies the selection criteria + please update IsEmpty method if more properties are added + +kubebuilder:object:generate=true + properties: + annotations: + additionalProperties: + type: string + description: Annotations on the target resources + type: object + x-go-name: Annotations + apiVersion: + description: APIVersion of the target resources + type: string + x-go-name: APIVersion + kind: + description: Kind of the target resources + type: string + x-go-name: Kind + labels: + additionalProperties: + type: string + description: Labels on the target resources + type: object + x-go-name: Labels + name: + description: Name of the target resources + type: string + x-go-name: Name + namespace: + description: Namespace of the target resources + type: string + x-go-name: Namespace type: object - x-go-name: Annotations - apiVersion: - description: APIVersion is the apiVersion field of a Resource - type: string - x-go-name: APIVersion - info: - $ref: '#/definitions/PackageInfo' - inventory: - $ref: '#/definitions/Inventory' - kind: - description: Kind is the kind field of a Resource - type: string - x-go-name: Kind - labels: - additionalProperties: - type: string - description: Labels is the metadata.labels field of a Resource + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Status: + properties: + conditions: + items: + $ref: '#/definitions/Condition' + type: array + x-go-name: Conditions type: object - x-go-name: Labels - name: - description: Name is the metadata.name field of a Resource - type: string - x-go-name: Name - namespace: - description: Namespace is the metadata.namespace field of a Resource - type: string - x-go-name: Namespace - pipeline: - $ref: '#/definitions/Pipeline' - status: - $ref: '#/definitions/Status' - upstream: - $ref: '#/definitions/Upstream' - upstreamLock: - $ref: '#/definitions/UpstreamLock' - title: KptFile contains information about a package managed with kpt. - type: object - x-go-name: KptFile - x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + TypeMeta: + description: |- + TypeMeta partially copies apimachinery/pkg/apis/meta/v1.TypeMeta + No need for a direct dependence; the fields are stable. + properties: + apiVersion: + description: APIVersion is the apiVersion field of a Resource + type: string + x-go-name: APIVersion + kind: + description: Kind is the kind field of a Resource + type: string + x-go-name: Kind + type: object + x-go-package: sigs.k8s.io/kustomize/kyaml/yaml + UpdateStrategyType: + title: UpdateStrategyType defines the strategy for updating a package from upstream. + type: string + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + Upstream: + properties: + git: + $ref: '#/definitions/Git' + type: + $ref: '#/definitions/OriginType' + updateStrategy: + $ref: '#/definitions/UpdateStrategyType' + title: Upstream is a user-specified upstream locator for a package. + type: object + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 + kptfile: + properties: + annotations: + additionalProperties: + type: string + description: Annotations is the metadata.annotations field of a Resource. + type: object + x-go-name: Annotations + apiVersion: + description: APIVersion is the apiVersion field of a Resource + type: string + x-go-name: APIVersion + info: + $ref: '#/definitions/PackageInfo' + inventory: + $ref: '#/definitions/Inventory' + kind: + description: Kind is the kind field of a Resource + type: string + x-go-name: Kind + labels: + additionalProperties: + type: string + description: Labels is the metadata.labels field of a Resource + type: object + x-go-name: Labels + name: + description: Name is the metadata.name field of a Resource + type: string + x-go-name: Name + namespace: + description: Namespace is the metadata.namespace field of a Resource + type: string + x-go-name: Namespace + pipeline: + $ref: '#/definitions/Pipeline' + status: + $ref: '#/definitions/Status' + upstream: + $ref: '#/definitions/Upstream' + upstreamLock: + $ref: '#/definitions/Locator' + title: KptFile contains information about a package managed with kpt. + type: object + x-go-name: KptFile + x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 info: - title: Kptfile schema. - version: v1 + title: Kptfile schema. + version: v1 paths: {} swagger: "2.0" diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index 283e0ffb0f..6d7040b7f4 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -31,7 +31,7 @@ import ( "github.com/kptdev/kpt/pkg/kptfile/kptfileutil" "github.com/kptdev/kpt/pkg/lib/util/addmergecomment" "github.com/kptdev/kpt/pkg/printer/fake" - toposort "github.com/philopon/go-toposort" + "github.com/philopon/go-toposort" "github.com/stretchr/testify/assert" assertnow "gotest.tools/assert" "sigs.k8s.io/kustomize/kyaml/copyutil" @@ -651,10 +651,10 @@ func replaceData(repo, data string) error { } // Only copy over the Upstream section from the existing // Kptfile if other values hasn't been provided. - if dataKptfile.Upstream == nil || reflect.DeepEqual(dataKptfile.Upstream, kptfilev1.Upstream{}) { + if dataKptfile.Upstream == nil || reflect.DeepEqual(*dataKptfile.Upstream, kptfilev1.Upstream{}) { dataKptfile.Upstream = repoKptfile.Upstream } - if dataKptfile.UpstreamLock == nil || reflect.DeepEqual(dataKptfile.UpstreamLock, kptfilev1.Locator{}) { + if dataKptfile.UpstreamLock == nil || reflect.DeepEqual(*dataKptfile.UpstreamLock, kptfilev1.Locator{}) { dataKptfile.UpstreamLock = repoKptfile.UpstreamLock } dataKptfile.Name = repoKptfile.Name diff --git a/pkg/api/kptfile/v1/types.go b/pkg/api/kptfile/v1/types.go index b0e8f7cab2..35816c882d 100644 --- a/pkg/api/kptfile/v1/types.go +++ b/pkg/api/kptfile/v1/types.go @@ -208,6 +208,7 @@ type GitLock struct { Commit string `yaml:"commit,omitempty" json:"commit,omitempty"` } +// GenericLock is a minimal locator for a package stored in a generic storage backend. type GenericLock struct { // StoreID is a descriptor of the underlying storage type. // e.g. 'DB' for database diff --git a/pkg/lib/kptops/clone.go b/pkg/lib/kptops/clone.go index f982ab789c..0cd51c402b 100644 --- a/pkg/lib/kptops/clone.go +++ b/pkg/lib/kptops/clone.go @@ -109,7 +109,7 @@ func normalizeGitFields(u *kptfilev1.Upstream) { } } -// normalizeGitLockFields ensures consistent formatting for UpstreamLock git fields +// normalizeGitLockFields ensures consistent formatting for Locator git fields func normalizeGitLockFields(l *kptfilev1.Locator) { if l.Git != nil { // Ensure .git suffix is present diff --git a/pkg/lib/kptops/pkgupdate.go b/pkg/lib/kptops/pkgupdate.go index 1db2ab3e7d..642cdedf39 100644 --- a/pkg/lib/kptops/pkgupdate.go +++ b/pkg/lib/kptops/pkgupdate.go @@ -25,7 +25,7 @@ import ( "github.com/kptdev/kpt/internal/util/update" kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1" "github.com/kptdev/kpt/pkg/kptfile/kptfileutil" - updatetypes "github.com/kptdev/kpt/pkg/lib/update/updatetypes" + "github.com/kptdev/kpt/pkg/lib/update/updatetypes" "github.com/kptdev/kpt/pkg/printer" "k8s.io/klog/v2" ) @@ -132,14 +132,14 @@ func PkgUpdate(ctx context.Context, ref string, packageDir string, _ PkgUpdateOp // return errors.E(op, p.UniquePath, err) // } - // if kf.Locator != nil { + // if kf.UpstreamLock != nil { // originDir, err = ioutil.TempDir("", "kpt-get-") // if err != nil { // return errors.E(op, errors.Internal, fmt.Errorf("error creating temp directory: %w", err)) // } // defer os.RemoveAll(originDir) - // if err = fetch.ClonerUsingOciPull(ctx, kf.Locator.Oci.Image, nil, originDir, options); err != nil { + // if err = fetch.ClonerUsingOciPull(ctx, kf.UpstreamLock.Oci.Image, nil, originDir, options); err != nil { // return errors.E(op, p.UniquePath, err) // } // } else { diff --git a/scripts/generate-schema.sh b/scripts/generate-schema.sh index bcc77b1fa3..535d917c12 100755 --- a/scripts/generate-schema.sh +++ b/scripts/generate-schema.sh @@ -23,12 +23,10 @@ fi REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" cd "${REPO_ROOT}" -make install-swagger - -$GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o site/reference/schema/kptfile/kptfile.yaml -$GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o site/reference/schema/kptfile/kptfile.json +$GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o documentation/content/en/reference/schema/kptfile/kptfile.yaml +$GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o documentation/content/en/reference/schema/kptfile/kptfile.json # We need to add schema header for schema to work in cloud-code. # See https://github.com/kptdev/kpt/pull/2520/files/aac23473c121252ec6341fdb2bcce389ae6cb122#r717867089 -jq -s '.[0] * .[1]' scripts/schema-header.json site/reference/schema/kptfile/kptfile.json > /tmp/kptfile-schema.json -mv /tmp/kptfile-schema.json site/reference/schema/kptfile/kptfile.json \ No newline at end of file +jq -s '.[0] * .[1]' scripts/schema-header.json documentation/content/en/reference/schema/kptfile/kptfile.json > /tmp/kptfile-schema.json +mv /tmp/kptfile-schema.json documentation/content/en/reference/schema/kptfile/kptfile.json \ No newline at end of file From 232c2ecc5994ee65ec362fe10384369654ab18b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= Date: Fri, 27 Feb 2026 14:58:59 +0100 Subject: [PATCH 4/4] strip kubebuilder annos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mózes László Máté --- .gitignore | 3 +++ .../en/reference/schema/kptfile/kptfile.json | 4 +--- .../en/reference/schema/kptfile/kptfile.yaml | 3 --- pkg/api/kptfile/v1/types.go | 6 ++--- scripts/generate-schema.sh | 24 +++++++++++++++---- scripts/strip-kubebuilder-annos.jq | 10 ++++++++ 6 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 scripts/strip-kubebuilder-annos.jq diff --git a/.gitignore b/.gitignore index 2cdd29e6df..bceb332581 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ tmp/ .hugo* resources/ public/ + +# Build directory +.build/ diff --git a/documentation/content/en/reference/schema/kptfile/kptfile.json b/documentation/content/en/reference/schema/kptfile/kptfile.json index b35206fcf8..4c97f45fb0 100644 --- a/documentation/content/en/reference/schema/kptfile/kptfile.json +++ b/documentation/content/en/reference/schema/kptfile/kptfile.json @@ -37,7 +37,6 @@ "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" }, "Function": { - "description": "+kubebuilder:object:generate=true", "type": "object", "title": "Function specifies a KRM function.", "properties": { @@ -329,7 +328,6 @@ "x-go-package": "github.com/kptdev/kpt/pkg/api/kptfile/v1" }, "Pipeline": { - "description": "+kubebuilder:object:generate=true", "type": "object", "title": "Pipeline declares a pipeline of functions used to mutate or validate resources.", "properties": { @@ -406,7 +404,7 @@ "x-go-package": "sigs.k8s.io/kustomize/kyaml/yaml" }, "Selector": { - "description": "Selector specifies the selection criteria\nplease update IsEmpty method if more properties are added\n+kubebuilder:object:generate=true", + "description": "Selector specifies the selection criteria\nplease update IsEmpty method if more properties are added", "type": "object", "properties": { "annotations": { diff --git a/documentation/content/en/reference/schema/kptfile/kptfile.yaml b/documentation/content/en/reference/schema/kptfile/kptfile.yaml index efdb4c415d..e13c8fc233 100644 --- a/documentation/content/en/reference/schema/kptfile/kptfile.yaml +++ b/documentation/content/en/reference/schema/kptfile/kptfile.yaml @@ -18,7 +18,6 @@ definitions: type: string x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 Function: - description: +kubebuilder:object:generate=true properties: configMap: additionalProperties: @@ -290,7 +289,6 @@ definitions: type: object x-go-package: github.com/kptdev/kpt/pkg/api/kptfile/v1 Pipeline: - description: +kubebuilder:object:generate=true properties: mutators: description: Mutators defines a list of of KRM functions that mutate resources. @@ -353,7 +351,6 @@ definitions: description: |- Selector specifies the selection criteria please update IsEmpty method if more properties are added - +kubebuilder:object:generate=true properties: annotations: additionalProperties: diff --git a/pkg/api/kptfile/v1/types.go b/pkg/api/kptfile/v1/types.go index 35816c882d..14197510a9 100644 --- a/pkg/api/kptfile/v1/types.go +++ b/pkg/api/kptfile/v1/types.go @@ -212,13 +212,13 @@ type GitLock struct { type GenericLock struct { // StoreID is a descriptor of the underlying storage type. // e.g. 'DB' for database - StoreID string `yaml:"storeID" json:"storeID"` + StoreID string `yaml:"storeID,omitempty" json:"storeID,omitempty"` // ResourceID is a unique identifier of the resource. // The format depends on the underlying storage. - ResourceID string `yaml:"resourceID" json:"resourceID"` + ResourceID string `yaml:"resourceID,omitempty" json:"resourceID,omitempty"` // ResourceVersion indicates the last fetched version of the resource. // The format depends on the underlying storage. - ResourceVersion string `yaml:"resourceVersion" json:"resourceVersion"` + ResourceVersion string `yaml:"resourceVersion,omitempty" json:"resourceVersion,omitempty"` } // PackageInfo contains optional information about the package such as license, documentation, etc. diff --git a/scripts/generate-schema.sh b/scripts/generate-schema.sh index 535d917c12..4dc8676a7f 100755 --- a/scripts/generate-schema.sh +++ b/scripts/generate-schema.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2021 The kpt Authors +# 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. @@ -13,20 +13,36 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit -o nounset -o pipefail -o posix +set -o errexit -o nounset -o pipefail -o posix -x if ! command -v jq >/dev/null; then echo "jq must be installed. Follow https://stedolan.github.io/jq/download/ to install jq." exit 1 fi +if ! command -v yq >/dev/null; then + echo "yq must be installed. Follow https://github.com/mikefarah/yq/releases to install yq." + exit 1 +fi + REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +BUILD_DIR="${REPO_ROOT}/.build" +mkdir -p ${BUILD_DIR} cd "${REPO_ROOT}" $GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o documentation/content/en/reference/schema/kptfile/kptfile.yaml $GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o documentation/content/en/reference/schema/kptfile/kptfile.json +# Strip kubebuilder annotations from generated schema files. +jq -f ${REPO_ROOT}/scripts/strip-kubebuilder-annos.jq documentation/content/en/reference/schema/kptfile/kptfile.json > "${BUILD_DIR}/kptfile-schema.json" +yq -o json documentation/content/en/reference/schema/kptfile/kptfile.yaml \ + | jq -f ${REPO_ROOT}/scripts/strip-kubebuilder-annos.jq \ + | yq -P -I 4 -o yaml > "${BUILD_DIR}/kptfile-schema.yaml" + # We need to add schema header for schema to work in cloud-code. # See https://github.com/kptdev/kpt/pull/2520/files/aac23473c121252ec6341fdb2bcce389ae6cb122#r717867089 -jq -s '.[0] * .[1]' scripts/schema-header.json documentation/content/en/reference/schema/kptfile/kptfile.json > /tmp/kptfile-schema.json -mv /tmp/kptfile-schema.json documentation/content/en/reference/schema/kptfile/kptfile.json \ No newline at end of file +jq -s '.[0] * .[1]' scripts/schema-header.json ${BUILD_DIR}/kptfile-schema.json > ${BUILD_DIR}/kptfile-schema-with-header.json + +rm -f ${BUILD_DIR}/kptfile-schema.json +mv ${BUILD_DIR}/kptfile-schema-with-header.json documentation/content/en/reference/schema/kptfile/kptfile.json +mv ${BUILD_DIR}/kptfile-schema.yaml documentation/content/en/reference/schema/kptfile/kptfile.yaml diff --git a/scripts/strip-kubebuilder-annos.jq b/scripts/strip-kubebuilder-annos.jq new file mode 100644 index 0000000000..d5fed5f9a7 --- /dev/null +++ b/scripts/strip-kubebuilder-annos.jq @@ -0,0 +1,10 @@ +walk( + if type == "object" and has("description") and (.description | type) == "string" + then + if .description == "+kubebuilder:object:generate=true" + then del(.description) + else .description |= (split("\n") | map(select(test("^\\+kubebuilder") | not)) | join("\n") | rtrimstr("\n")) + end + else . + end +)