Skip to content

Refactor update logic in pkg/lib/kptops (cleanup + structure improvements) (#4379)#4441

Open
NETIZEN-11 wants to merge 63 commits intokptdev:mainfrom
NETIZEN-11:refactor/update-code-pkg-lib-kptops-4379
Open

Refactor update logic in pkg/lib/kptops (cleanup + structure improvements) (#4379)#4441
NETIZEN-11 wants to merge 63 commits intokptdev:mainfrom
NETIZEN-11:refactor/update-code-pkg-lib-kptops-4379

Conversation

@NETIZEN-11
Copy link
Copy Markdown

@NETIZEN-11 NETIZEN-11 commented Mar 21, 2026

PR Description: Stabilize ResourceGroup API to v1

## Summary

This PR introduces the stable v1 API for the ResourceGroup type while maintaining full backwar
d compatibility with the existing v1alpha1 API.

## Motivation

The ResourceGroup API has been in v1alpha1 for significant time. This PR stabilizes it to v1,
 indicating API maturity and signaling that users can rely on this API with confidence. Followi
 ng semantic versioning, the v1 API will not introduce breaking changes except in a future v2.0
  release.

Changes

New Files

  • pkg/api/resourcegroup/v1/doc.go - Package documentation with stability guarantees
  • pkg/api/resourcegroup/v1/types.go - Stable v1 ResourceGroup type definition

Modified Files

  • pkg/api/resourcegroup/v1alpha1/types.go - Added deprecation notices pointing users to v1

Key Changes

  1. Stable v1 API (pkg/api/resourcegroup/v1/):

    • ResourceGroupGVK() - Returns stable GroupVersionKind for v1
    • RGFileName, RGInventoryIDLabel, RGFileKind, RGFileGroup, RGFileVersion, RGFile APIVersion constants
    • DefaultMeta - Default ResourceMeta for ResourceGroup instances
    • ResourceGroup struct - The stable inventory type for packages managed with kpt
  2. v1alpha1 Deprecation:

    • Added deprecation notices to all v1alpha1 constants and functions
    • ResourceGroupGVK() in v1alpha1 now returns v1alpha1 GVK but is marked deprecated
      - Users are directed to use github.com/kptdev/kpt/pkg/api/resourcegroup/v1 instead
  3. Backward Compatibility:

    • v1alpha1 API is fully preserved
    • Existing code using v1alpha1 will continue to work
    • Migration path: users can migrate to v1 at their convenience

API Stability

The v1 API follows semantic versioning:

  • Breaking changes will NOT be introduced in v1.x releases
  • Such changes, if needed, will only come in v2.0.0
  • Bug fixes and improvements will be backward-compatible

Testing

  • Build passes: go build ./pkg/api/resourcegroup/...
  • Vet passes: go vet ./pkg/api/resourcegroup/...
  • All existing tests pass

Related Issue

Part of #4450 - API Types Stabilization

Future Work

  • Update all internal usages of ResourceGroup to use v1
  • Eventually deprecate and remove v1alpha1 in v2.0

dosubot Bot and others added 23 commits February 25, 2026 08:31
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 28.5.1+incompatible to 29.2.0+incompatible.
- [Commits](docker/cli@v28.5.1...v29.2.0)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-version: 29.2.0+incompatible
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
docs: updates for PR kptdev#4405
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
…ub.com/docker/cli-29.2.0incompatible

Bump github.com/docker/cli from 28.5.1+incompatible to 29.2.0+incompatible
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
… specified

When users explicitly pass '.' as the destination directory, kpt pkg get
now places files directly in the current directory, matching the behavior
of 'git clone' and 'kpt cfg set'.

Changes:
- Modified parse.GitParseArgs() to track if destination was explicitly provided
- Updated getDest() to use current directory directly when explicitly specified
- Modified get.Run() to allow using existing empty directories
- Preserved default behavior: when no destination is provided, still creates
  a subdirectory with the package name

Fixes kptdev#1407

Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
…tions

- Changed getDest() to check cleaned path (v) instead of originalV for '.' comparison
- Updated tests to expect current directory when './' or '.' is explicitly passed
- Fixed TestCmdMainBranch_execute to not pass './' explicitly
- Fixed TestCmd_fail to use non-existent destination directory

Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
The test was explicitly passing './' as the destination, which with the
new behavior means 'use current directory directly'. Since the test runs
in a non-empty workspace directory, this caused a conflict.

Removing the explicit destination argument allows the default behavior
to create a subdirectory with the package name, which is what the test
expects.

Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
* Replace the image registry from gcr.io to ghcr.io

Signed-off-by: aravind.est <aravindhan.a@est.tech>

* Fix the wasm build failure

New WASM images published.
It's a manual process now.
Fix Go 1.21+ wasm compatibility by renaming the import module from go to gojs in the nodejs JS glue code. The wasmexec library used by the wasmtime runtime has the same issue but requires
a separate upstream fix.

Signed-off-by: aravind.est <aravindhan.a@est.tech>

---------

Signed-off-by: aravind.est <aravindhan.a@est.tech>
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
* Add status.conditions to show the renderstatus to Kptfile

Signed-off-by: aravind.est <aravindhan.a@est.tech>

* Address copilot and dosubot comments

Signed-off-by: aravind.est <aravindhan.a@est.tech>

---------

Signed-off-by: aravind.est <aravindhan.a@est.tech>
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Proofreading of chapter 1.
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
CI failure due to renderstatus merge fixed.
Env variable to use nodejs as wasm env moved to Makefile from Github workflow

Signed-off-by: aravind.est <aravindhan.a@est.tech>
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Copilot AI review requested due to automatic review settings March 21, 2026 14:03
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. cleanup labels Mar 21, 2026
Copilot AI review requested due to automatic review settings April 6, 2026 06:32
@NETIZEN-11
Copy link
Copy Markdown
Author

Hi @CsatariGergely,

Thanks for the review.

I’ve fixed the CI errors and resolved the DCO issue. All checks are now passing.

Could you please take another look when you have time?

Thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

internal/util/render/executor.go:950

  • Malformed if statement. Line 943 opens an if block if function.ConfigPath != "" but is immediately followed by unindented code on line 944 that should be inside the block. The indentation and structure is broken. This appears to be a merge conflict or incomplete refactoring.
	for i, mutator := range mutators {
		function := pl.Mutators[i]
		stepResult := createPipelineStepResult(function, 0, "", "")

		if function.ConfigPath != "" {
		resultCountBeforeExec := len(hctx.fnResults.Items)

		if pl.Mutators[i].ConfigPath != "" {
			// functionConfigs are included in the function inputs during `render`
			// and as a result, they can be mutated during the `render`.
			// So functionConfigs needs be updated in the FunctionRunner instance
			// before every run.

internal/util/render/executor_test.go:610

  • Duplicate field initializations in hydrationContext struct literal. The fields root, pkgs, and fileSystem are initialized twice (lines 603-605 and 607-609). This will cause a compilation error as duplicate struct field initializers are not allowed.
	hctx := &hydrationContext{
		root:         &pkgNode{pkg: rootPkg},
		pkgs:         map[types.UniquePath]*pkgNode{},
		fileSystem:   mockFS,
		renderStatus: &kptfilev1.RenderStatus{},
		root:       &pkgNode{pkg: rootPkg},
		pkgs:       map[types.UniquePath]*pkgNode{},
		fileSystem: mockFS,
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/api/kptfile/v1/types.go
Comment thread internal/util/render/executor.go Outdated
Comment thread internal/util/render/executor.go Outdated
Comment thread internal/util/render/executor_test.go
Comment thread go.mod Outdated
- Remove duplicate dependency declarations in go.mod (apply-setters v0.2.2 and krm-functions-sdk v1.0.0)
- Fix duplicate field initializations in executor_test.go hydrationContext structs
- Fix malformed if statement in runMutators function (removed unclosed if block)
- Implement setRenderConditionWithStatus function properly
- Remove redundant RenderStatus assignment in setRenderStatus function
- Remove duplicate type declarations in types.go (Status, RenderStatus, PipelineStepResult, ResultItem)
- Add Resource field to ResultItem struct (required by executor.go)

All compilation errors resolved and tests compile successfully.

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
@NETIZEN-11 NETIZEN-11 force-pushed the refactor/update-code-pkg-lib-kptops-4379 branch from 5a61c78 to 1de6827 Compare April 6, 2026 06:53
This commit addresses all requirements from issue kptdev#4450 to stabilize
kpt API for v1.0.0 release.

Changes:

1. Documentation (7 new files)
   - docs/VERSIONING.md: Semantic versioning policy
   - docs/MIGRATION_V1.md: Migration guide to v1.0.0
   - docs/BACKWARD_COMPATIBILITY.md: Compatibility guarantees
   - docs/SDK_VERSIONING.md: SDK and function catalog versioning
   - docs/ARCHITECTURE_TESTING.md: Multi-architecture testing
   - docs/UPSTREAM_MIGRATION.md: Upstream dependency migration
   - docs/V1_RELEASE_CHECKLIST.md: Release checklist

2. CLI Version Fix
   - run/run.go: Enhanced version command with semantic version display
   - run/run_test.go: Added comprehensive test coverage

3. API Stabilization
   - pkg/api/resourcegroup/v1/types.go: Stable v1 API
   - pkg/api/resourcegroup/v1/doc.go: API documentation
   - pkg/api/resourcegroup/v1alpha1/types.go: Marked as deprecated

4. Build & Versioning
   - Makefile: Implemented semantic versioning
   - README.md: Added v1.0.0 announcement and documentation links

All changes are backward compatible and follow semantic versioning.

Fixes kptdev#4450

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Copilot AI review requested due to automatic review settings April 6, 2026 08:15
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Apr 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread run/run_test.go
Comment thread pkg/lib/kptops/pkgupdate.go
- Update versionCmd to use RunE field for proper error handling
- Return nil error from version command function
- Fixes Copilot review comment about RunE compatibility

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
@NETIZEN-11 NETIZEN-11 force-pushed the refactor/update-code-pkg-lib-kptops-4379 branch from 2d70ec1 to 1d4f0f0 Compare April 7, 2026 13:05
Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
Copilot AI review requested due to automatic review settings April 7, 2026 13:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

pkg/api/kptfile/v1/types.go:449

  • Duplicate field definition in ResultItem struct. Line 443 defines Resource field but there's evidence from the diff context showing this was added as a new field. However, the struct appears to already have all the necessary fields. Need to verify if Resource field duplication exists in the added code.
type ResultItem struct {
	Resource    string `yaml:"resource,omitempty" json:"resource,omitempty"`
	Message     string `yaml:"message,omitempty" json:"message,omitempty"`
	Severity    string `yaml:"severity,omitempty" json:"severity,omitempty"`
	ResourceRef *ResourceRef `yaml:"resourceRef,omitempty" json:"resourceRef,omitempty"`
	Field       *FieldRef    `yaml:"field,omitempty" json:"field,omitempty"`
	File        *FileRef     `yaml:"file,omitempty" json:"file,omitempty"`
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/api/kptfile/v1/types.go Outdated
Comment thread internal/util/render/executor.go Outdated
Comment thread run/run.go
Comment thread internal/util/render/executor.go
- Remove duplicate setRenderStatus function in executor.go
- Remove duplicate stepName function definition
- Fix code formatting in types.go
- All packages now pass go vet checks

Fixes compilation errors detected by Copilot AI review.

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>

Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
@NETIZEN-11 NETIZEN-11 force-pushed the refactor/update-code-pkg-lib-kptops-4379 branch from 2d859ee to 9bd8817 Compare April 7, 2026 13:35
@liamfallon
Copy link
Copy Markdown
Contributor

This PR is very large. Please provide a comprehensive description of the changes made. It wold be useful if you were free to present your PR to the community at an upcoming community meeting. The meetings are on Wednesdays, see the calendar appointment here: https://www.cncf.io/calendar/ and search for 'kpt'

- Remove unreachable code from aggregateErrors function
- Remove dead code after setRenderConditionWithStatus function
- Fix duplicate Conditions field in Status struct
- Run go mod tidy

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
Copilot AI review requested due to automatic review settings April 14, 2026 16:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings April 20, 2026 22:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup go Pull requests that update Go code size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants