Skip to content

Improve kpt version resolution in setup-go-kpt composite action - #4730

Open
aravindtga wants to merge 1 commit into
kptdev:mainfrom
Nordix:improve-setup-go-kpt-version-resolution
Open

Improve kpt version resolution in setup-go-kpt composite action#4730
aravindtga wants to merge 1 commit into
kptdev:mainfrom
Nordix:improve-setup-go-kpt-version-resolution

Conversation

@aravindtga

@aravindtga aravindtga commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

What changed:

  • Resolve the kpt version with go mod edit -json (parsing the require block) instead of go list -m, reading the version directly from the target go.mod without resolving the full module graph. This mirrors the approach already used by the sibling check-go-mod-replace action.
    • Add an optional kpt-version-file input so callers can resolve the kpt version from a go.mod different from the one used for Go setup. It defaults to go-version-file, preserving existing behaviour.
  • Surface fallback conditions with ::warning:: annotations (missing version file, or github.com/kptdev/kpt not found in the require block) instead of a silently swallowed message, and log the resolved kpt version.
    • Harden the resolution step with set -euo pipefail and a file-existence check before use.
    • Update the default kpt-fallback-version from v1.0.0-beta.65 to v1.0.0 (the current latest kpt release) so the safety-net default is not stale.

Why it's needed:

  • A recent krm-functions-catalog e2e-ci run showed the previous go list -m ... 2>/dev/null logic returning an empty version and silently falling back, then installing a kpt binary that did not match the version the e2e module was built against.

How it works:

  • go mod edit -json | jq reads the declared version straight from the require block of the resolved version file (kpt-version-file if set, otherwise go-version-file), making resolution deterministic and authoritative.
    • If the file is missing, or kpt is not a direct requirement, a ::warning:: annotation is emitted and the action falls back to kpt-fallback-version.
  • This action is consumed by porch, krm-functions-catalog, and krm-functions-sdk. The change is backward compatible: all install-kpt: "false" call sites are unaffected, and every install call site resolves to the same version as before (porch go.mod -> v1.0.0-beta.67, krm-functions-catalog tests/e2etest/go.mod -> v1.0.0-beta.65.1). The new input is opt-in with a behaviour-preserving default, and the fallback default change is inert for current consumers because the fallback path is not exercised when kpt is a direct dependency.

Type of Change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Documentation
  • Tests
  • Other: ________

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:
- Kiro to analyse the composite action and its consumers, verify version resolution behaviour, and draft the PR changes and PR description.

Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@netlify

netlify Bot commented Sep 2, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit f6b70e2
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a98018b27ad4f00080d4ac1
😎 Deploy Preview https://deploy-preview-4730--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@aravindtga
aravindtga marked this pull request as ready for review September 2, 2026 11:18
@aravindtga
aravindtga requested review from a team September 2, 2026 11:18
@aravindtga aravindtga self-assigned this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant