Skip to content

✨ envtest: search the assets index for latest of a release series #3280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cbandy
Copy link
Contributor

@cbandy cbandy commented Aug 14, 2025

This allows configuring the DownloadBinaryAssetsVersion field of envtest.Environment with only the Major.Minor portions of a Kubernetes API version. In that case, the framework searches the asset index for the latest stable version in that release series.

This matches the behavior of setup-envtest use {major}.{minor} without the full complexity of version selectors. The leading v is now optional, too. For example:

Setting the field to Major.Minor.Patch or Major.Minor.Patch-PreRelease behaves the same as before:

  • Existing binaries are used without going to the network.
  • Prereleases can only be selected by spelling them out, precisely as they are in the asset index.

This is an alternative implementation of #3260. It uses the k8s.io/apimachinery/pkg/util/version package and basic comparisons, rather than an external package with range/constraint matchers.

The former is no longer maintained and the latter is designed to
understand Kubernetes versions. This eliminates one direct dependency
introduced in b04d5fd.

Signed-off-by: Chris Bandy <[email protected]>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 14, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 14, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @cbandy. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 14, 2025
@cbandy cbandy changed the title ✨ envtest: search the assets index for latest of a release series #2 ✨ envtest: search the assets index for latest of a release series Aug 15, 2025
@alvaroaleman
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 2025
@alvaroaleman alvaroaleman added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 17, 2025
Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

/hold

lgtm, leaving a hold so @sbueringer can have a look as well

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 17, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2191d46f9db33c664428bf6c032156ef855ef395

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, cbandy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2025
// Use the canonical form of the version from here on.
binaryAssetsVersion = "v" + exact
} else if binaryAssetsVersion == "" || major != 0 || minor != 0 {
// Select a stable version from the release index before continuing.
var err error
binaryAssetsIndex, err = getIndex(ctx, binaryAssetsIndexURL)
if err != nil {
return "", "", "", err
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we add an else branch here that returns to cover error cases?

expectSeriesMajor uint
expectSeriesMinor uint
}{
{
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a test case for the empty string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants