Skip to content

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

Open
NETIZEN-11 wants to merge 7 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 7 commits intokptdev:mainfrom
NETIZEN-11:refactor/update-code-pkg-lib-kptops-4379

Conversation

@NETIZEN-11
Copy link

Closes #4379

Refactors the update-related code in pkg/lib/kptops to improve readability, structure, and maintainability.

The changes include removing unused code, simplifying existing logic, and making the implementation more consistent.

No functional changes are introduced; this PR focuses only on code cleanup and organization.

Build and basic checks pass successfully.

Further adjustments may be required after the Porch transfer is completed.

Nitesh added 7 commits March 18, 2026 00:44
…nctions

- Upgrade sigs.k8s.io/kustomize/api from v0.20.1 to v0.21.0
- Upgrade sigs.k8s.io/kustomize/kyaml from v0.20.1 to v0.21.0
- Upgrade k8s.io/api from v0.34.1 to v0.35.0
- Upgrade k8s.io/apimachinery from v0.34.1 to v0.35.0
- Upgrade k8s.io/kubectl from v0.34.1 to v0.35.0
- Upgrade github.com/kptdev/krm-functions-catalog/functions/go/apply-setters from v0.2.2 to v0.2.4
- Update catalog function registry to reference new apply-setters version
- Run go mod tidy to resolve transitive dependencies

Resolves GitHub Issue kptdev#4406

All catalog functions remain compatible with new APIs - zero breaking changes encountered.
Zero compilation errors and zero failing tests across repository.
…nctions

- Upgrade sigs.k8s.io/kustomize/api from v0.20.1 to v0.21.0
- Upgrade sigs.k8s.io/kustomize/kyaml from v0.20.1 to v0.21.0
- Upgrade k8s.io/api from v0.34.1 to v0.35.0
- Upgrade k8s.io/apimachinery from v0.34.1 to v0.35.0
- Upgrade k8s.io/kubectl from v0.34.1 to v0.35.0
- Upgrade github.com/kptdev/krm-functions-catalog/functions/go/apply-setters from v0.2.2 to v0.2.4
- Update catalog function registry to reference new apply-setters version
- Run go mod tidy to resolve transitive dependencies

Resolves GitHub Issue kptdev#4406

All catalog functions remain compatible with new APIs - zero breaking changes encountered.
Zero compilation errors and zero failing tests across repository.

Signed-off-by: NETIZEN-11 <nitesh@example.com>
- Add new RenderStatus and PipelineStepResult structs as per GitHub issue kptdev#4390
- Clearly separate mutation pipeline steps from validation steps
- Capture execution failures (network errors, missing images, command failures)
- Record stderr and exit codes for each pipeline step
- Extract and categorize error results from function results
- Aggregate all failures into comprehensive ErrorSummary
- Update pipeline execution logic to populate detailed step results
- Maintain backward compatibility with existing Rendered conditions
- Add comprehensive unit tests for new functionality
- Fix JSON tags and serialization issues

This addresses the problems with the current schema:
- Difficult troubleshooting → Clear step-by-step execution details
- Unclear error reporting → Structured error information with aggregation
- Inability to represent execution failures → Detailed execution error capture
- Confusing result structure → Clean separation of mutation/validation steps
…ng issues

- Add Windows build constraints to exclude wasmtime support
- Fix linting issues: spelling, unused parameters, unused functions
- Use errors.New for static error strings
- Remove unused setRenderCondition function

This resolves the failing CI checks for docker and podman builds.
- Update k8s.io/apiextensions-apiserver from v0.34.1 to v0.35.0
- Add yaml tags to RenderStatus, PipelineStepResult, and ResultItem structs
- Fix result classification logic to use severity instead of ExitCode
- Fix YAML test input to use proper multiline format
- Run go mod tidy to normalize dependencies

All changes maintain Go formatting and project coding style.
…subpackages

- Add isRootKptfile() helper function for robust root detection
- Enhance pkgContextResource() to generate package-context.yaml only for root packages
- Subpackages are now correctly suppressed to prevent duplicate ConfigMap creation
- Fix path normalization to handle relative paths like './Kptfile'
- Ensure only one ConfigMap 'kptfile.kpt.dev' exists in mutation pipeline

This resolves the 'ConfigMap already exists' error when rendering packages with subpackages.
- Remove 50+ lines of commented dead code
- Resolve TODO comment with proper printer implementation
- Replace hardcoded strings with constants (KptfileName, EmptyTempDirPrefix, RootPackagePath)
- Split monolithic function into 7 focused functions
- Add comprehensive input validation and error handling
- Improve resource cleanup with proper defer statements
- Update copyright to 2022-2026 for modifications

Fixes kptdev#4379

Signed-off-by: NETIZEN-11 <nitesh@example.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 go Pull requests that update Go code labels Mar 21, 2026
@netlify
Copy link

netlify bot commented Mar 21, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit ba6836a
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69bea5468883be00087d5e38
😎 Deploy Preview https://deploy-preview-4441--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
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:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor the Update code in pkg/lib/kptops

2 participants