Skip to content

fix: Improve kpt version command output and add comprehensive tests#4479

Open
NETIZEN-11 wants to merge 9 commits intokptdev:mainfrom
NETIZEN-11:feat/issue-4450-pr2-cli-version
Open

fix: Improve kpt version command output and add comprehensive tests#4479
NETIZEN-11 wants to merge 9 commits intokptdev:mainfrom
NETIZEN-11:feat/issue-4450-pr2-cli-version

Conversation

@NETIZEN-11
Copy link
Copy Markdown

Description

This PR improves the kpt version command to provide clear, consistent semantic version output across all architectures and adds comprehensive test coverage.

Part of #4450 - Stabilize kpt API to version 1

Changes Made

Version Command Enhancement (run/run.go)

  • Updated version command to display semantic version format clearly
  • Added proper handling for unknown/development builds
  • Improved user-facing output with descriptive messages
  • Ensures the version follows semantic versioning format (vMAJOR.MINOR.PATCH)

Test Coverage (run/run_test.go)

  • Added comprehensive test suite for version command
  • Tests cover multiple scenarios:
    • Semantic version format (v1.0.0)
    • Development versions (v1.0.0-dev)
    • Unknown versions (development builds)
    • Versions with build metadata (v1.0.0+abc123)
  • Validates output format consistency
  • Ensures proper handling of edge cases

Testing

# Build and test the version command
make build
./bin/kpt version

# Run tests
go test ./run/...

NETIZEN-11 and others added 5 commits April 1, 2026 20:48
…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 <kumarnitesh121411@gmail.com>
…n, and CRLF

- Update testdata Kptfiles to use apply-setters:v0.2.4 (was v0.2.0)
  which is not registered in the functions map, causing TestRender failures
- Fix validateFnConfigPathSyntax to use path.IsAbs (forward-slash) instead
  of filepath.IsAbs so absolute path detection works correctly on all platforms
- Normalize CRLF to LF in pkg_context_test.go when reading expected output
  files to fix TestPkgContextGenerator on Windows
- Remove unused absPath helper and os import from executor_test.go

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
- Remove duplicate entries for apply-setters (v0.2.2) and krm-functions-sdk (v1.0.2)
- Bump k8s.io/apiextensions-apiserver from v0.34.1 to v0.35.0 to align all k8s deps
- Remove gogo/protobuf indirect dep (no longer needed)
- Run go mod tidy to validate

Addresses reviewer feedback on PR kptdev#4432

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

The PR bumps apply-setters to v0.2.4 in go.mod. Adding v0.2.4 to the
functions registry is required so Kptfiles referencing the new version
work with the built-in runner. v0.2.0 is kept for backward compatibility
with existing Kptfiles that already reference that version.

Also revert testdata Kptfiles back to v0.2.0 since both versions are
now supported by the functions map.

Addresses reviewer question on PR kptdev#4432

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

netlify Bot commented Apr 13, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 13a7744
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69dd5bca0b8b740008146c71
😎 Deploy Preview https://deploy-preview-4479--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.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request go Pull requests that update Go code labels Apr 13, 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.

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

NETIZEN-11 added 3 commits April 14, 2026 02:32
Enhance the kpt version command to provide clear, consistent semantic
version output for both development and release builds.

Changes:
- Add initVersion() function that enriches version with VCS revision from
  Go's debug.ReadBuildInfo() for development builds
- Update Makefile LDFLAGS to inject v0.0.0-dev+<commit> format for local
  builds, separate from goreleaser-managed release versioning
- Release builds continue to use proper semver tags injected by goreleaser

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
Bug fixes and improvements from testing:

- Add apply-setters:v0.2.0 to functions map for backward compatibility
- Use path.IsAbs instead of filepath.IsAbs for cross-platform path validation
- Normalize CRLF to LF in pkg_context_test.go for Windows compatibility
- Fix path handling in executor_test.go with absPath helper
- Remove extra blank line in runner.go

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
- Bump k8s.io/apiextensions-apiserver from v0.34.1 to v0.35.0
- Update indirect dependency chain for consistency
- Remove outdated transitive dependencies

Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
@NETIZEN-11 NETIZEN-11 force-pushed the feat/issue-4450-pr2-cli-version branch from 30b4ec1 to 5461e64 Compare April 13, 2026 21:09
@liamfallon
Copy link
Copy Markdown
Contributor

This PR contains dependency uplifts and changes to path handling as well as the described changes. Please separate these aspects into separate PRs. Also, please consider the comment made on PR #4468 #4468 (comment)

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

Labels

enhancement New feature or request go Pull requests that update Go code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants