Skip to content

fix(kustomize): use VersionStrategy instead #1173

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 1 commit into
base: master
Choose a base branch
from

Conversation

toredash
Copy link

@toredash toredash commented May 26, 2025

Description

Update kustomize tool to use the VersionStrategy of type Github instead of hard-coded value.

closes #1172

Motivation and Context

  • I have raised an issue to propose this change, which has been given a label of design/approved by a maintainer (required) (I cheated)

How Has This Been Tested?

If updating or adding a new CLI to arkade get, run:

go build && ./hack/test-tool.sh TOOL_NAME

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Documentation

  • I have updated the list of tools in README.md if (required) with ./arkade get --format markdown
  • I have updated the list of apps in README.md if (required) with ./arkade install --help

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have tested this on arm, or have added code to prevent deployment

@rgee0
Copy link
Contributor

rgee0 commented May 26, 2025

What happens if you replace the version with a version strategy?

https://github.com/alexellis/arkade/blob/master/pkg/get/tools.go#L57

@toredash toredash changed the title fix(kustomize): bump version fix(kustomize): use VersionStrategy instead May 26, 2025
@toredash
Copy link
Author

Dear lord, of course. I changed the issue, PR and commit to reflect this.

Local test:

Downloading: kustomize
2025/05/26 14:31:11 Looking up version for: kustomize
2025/05/26 14:31:11 Found: v5.6.0
Downloading: https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.6.0/kustomize_v5.6.0_darwin_amd64.tar.gz
5.56 MiB / 5.56 MiB [-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
/var/folders/5k/9tm162cd1rg7msxbfvggtmgc0000gq/T/arkade-1691588751/kustomize_v5.6.0_darwin_amd64.tar.gz written.
2025/05/26 14:31:28 Extracted: /var/folders/5k/9tm162cd1rg7msxbfvggtmgc0000gq/T/arkade-1691588751/kustomize
2025/05/26 14:31:28 Copying /var/folders/5k/9tm162cd1rg7msxbfvggtmgc0000gq/T/arkade-1691588751/kustomize to /Users/X/.arkade/bin/kustomize

Wrote: /Users/X/.arkade/bin/kustomize (14.74MB)

# Add arkade binary directory to your PATH variable
export PATH=$PATH:$HOME/.arkade/bin/

# Test the binary:
/Users/X/.arkade/bin/kustomize

# Or install with:
sudo mv /Users/X/.arkade/bin/kustomize /usr/local/bin/

👏 Say thanks for arkade and sponsor Alex via GitHub: https://github.com/sponsors/alexellis

@rgee0
Copy link
Contributor

rgee0 commented May 28, 2025

Whilst I'd prefer more output in the testing section - the minimal output to provide is created by running the provided command - this change looks reasonable to me.

@alexellis do you want to take this, or prefer that it be addressed as an aside in a future change?

@rgee0
Copy link
Contributor

rgee0 commented May 29, 2025

@toredash I see a 404 on the windows side of things despite the asset being available in the releases.

Can we get the template updated to fix windows and accommodate the arm64 variant?

Test-Tool

➜  arkade git:(patch-1) ./hack/test-tool.sh kustomize
+ ./arkade get kustomize --arch arm64 --os darwin --quiet
+ file /Users/rgee0/.arkade/bin/kustomize
/Users/rgee0/.arkade/bin/kustomize: Mach-O 64-bit executable x86_64
+ rm /Users/rgee0/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch x86_64 --os darwin --quiet
+ file /Users/rgee0/.arkade/bin/kustomize
/Users/rgee0/.arkade/bin/kustomize: Mach-O 64-bit executable x86_64
+ rm /Users/rgee0/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch x86_64 --os linux --quiet
+ file /Users/rgee0/.arkade/bin/kustomize
/Users/rgee0/.arkade/bin/kustomize: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=L7P0yqIUAWCZhV2ri962/kcEj5SGtOb-SSSmxJcaW/YMgj_aP1GxdFt5HvaONj/oFb_grNdglDJmnYtdrvA, stripped
+ rm /Users/rgee0/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch aarch64 --os linux --quiet
+ file /Users/rgee0/.arkade/bin/kustomize
/Users/rgee0/.arkade/bin/kustomize: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=BtU9qNXZoGNA0R0tZaPD/mHy9T4GeOPsmAuDuvz16/pE4izn79t9ydJVABBdGS/DNEGocbI27BZEs5DoHuk, stripped
+ rm /Users/rgee0/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch x86_64 --os mingw --quiet

The requested version of kustomize is not available or configured in arkade for mingw/x86_64

* Check if a binary is available from the project for your Operating System
* View the kustomize releases page: https://github.com/kubernetes-sigs/kustomize/releases
* Feel free to raise an issue at https://github.com/alexellis/arkade/issues for help

Error: server returned status: 404

Functional

➜  arkade git:(patch-1) ./arkade get kustomize
Downloading: kustomize
2025/05/29 06:08:22 Looking up version for: kustomize
2025/05/29 06:08:22 Found: v5.6.0
Downloading: https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.6.0/kustomize_v5.6.0_darwin_amd64.tar.gz
5.56 MiB / 5.56 MiB [--------------------------------------------------------------------] 100.00%
/var/folders/22/3b_f27kj3s37lbfqz_fq44jw0000gp/T/arkade-1271927638/kustomize_v5.6.0_darwin_amd64.tar.gz written.
2025/05/29 06:08:22 Extracted: /var/folders/22/3b_f27kj3s37lbfqz_fq44jw0000gp/T/arkade-1271927638/kustomize
2025/05/29 06:08:22 Copying /var/folders/22/3b_f27kj3s37lbfqz_fq44jw0000gp/T/arkade-1271927638/kustomize to /Users/rgee0/.arkade/bin/kustomize

Wrote: /Users/rgee0/.arkade/bin/kustomize (14.74MB)

# Add arkade binary directory to your PATH variable
export PATH=$PATH:$HOME/.arkade/bin/

# Test the binary:
/Users/rgee0/.arkade/bin/kustomize

# Or install with:
sudo mv /Users/rgee0/.arkade/bin/kustomize /usr/local/bin/

👏 Say thanks for arkade and sponsor Alex via GitHub: https://github.com/sponsors/alexellis

@alexellis
Copy link
Owner

There was a reason why it was done this way - I think because semver had issues locating the proper release - since the kustomize repo was releasing multiple releases all with different suffixes and a version strategy could pick the wrong one depending on what was released last.

I assume that is still the case.

I would advise checking back and seeing.

@rgee0
Copy link
Contributor

rgee0 commented Jun 3, 2025

Its a good spot Alex.

Although releases/latest resolves to: https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize/v5.6.0 and the version strategy approach uses version := loc[strings.LastIndex(loc, "/")+1:] the fact it works looks to be more luck than judgment.

The irregular approach to tagging that is used on kustomize appears to be accommodated by the arkade approach to resolving the version, but https://github.com/kubernetes-sigs/kustomize/releases show you where the potential dragons are.

Its particularly easy to fall into the trap since the version strategy approach was introduced 8 months ago while the last time the kustomize version was updated was 2 years ago, leading you to believe that the previous problem may have been alleviated by more recent changes, however, I'm of the view that if one of the other tag prefixes found itself being provided by latest/releases then we'd find a version like v0.19.0 which would then fail to be found when looking for kustomize at that version.

@toredash toredash marked this pull request as draft June 6, 2025 12:48
@derek derek bot added the no-dco label Jun 12, 2025
Copy link

derek bot commented Jun 12, 2025

Thank you for your contribution. unfortunately, one or more of your commits are missing the required "Signed-off-by:" statement. Signing off is part of the Developer Certificate of Origin (DCO) which is used by this project.

Read the DCO and project contributing guide carefully, and amend your commits using the git CLI. Note that this does not require any cryptography, keys or special steps to be taken.

💡 Shall we fix this?

This will only take a few moments.

First, clone your fork and checkout this branch using the git CLI.

Next, set up your real name and email address:

git config --global user.name "Your Full Name"
git config --global user.email "[email protected]"

Finally, run one of these commands to add the "Signed-off-by" line to your commits.

If you only have one commit so far then run: git commit --amend --signoff and then git push --force.
If you have multiple commits, watch this video.

Check that the message has been added properly by running "git log".

By using VersionStrategy the latest released version of kustomize will be used

Update BinaryTemplate to support the different releases

Signed-off-by: Tore Lønøy <[email protected]>
@toredash
Copy link
Author

toredash commented Jun 12, 2025

@rgee0 Updated the binary template as requested, and the test tool is expanded to cover the arm cases.

 % ./hack/test-tool.sh kustomize
+ ./arkade get kustomize --arch arm64 --os darwin --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize
/Users/tlonoy/.arkade/bin/kustomize: Mach-O 64-bit executable x86_64
+ rm /Users/tlonoy/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch x86_64 --os darwin --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize
/Users/tlonoy/.arkade/bin/kustomize: Mach-O 64-bit executable x86_64
+ rm /Users/tlonoy/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch x86_64 --os linux --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize
/Users/tlonoy/.arkade/bin/kustomize: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=L7P0yqIUAWCZhV2ri962/kcEj5SGtOb-SSSmxJcaW/YMgj_aP1GxdFt5HvaONj/oFb_grNdglDJmnYtdrvA, stripped
+ rm /Users/tlonoy/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch aarch64 --os linux --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize
/Users/tlonoy/.arkade/bin/kustomize: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=BtU9qNXZoGNA0R0tZaPD/mHy9T4GeOPsmAuDuvz16/pE4izn79t9ydJVABBdGS/DNEGocbI27BZEs5DoHuk, stripped
+ rm /Users/tlonoy/.arkade/bin/kustomize
+ echo

+ ./arkade get kustomize --arch x86_64 --os mingw --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize.exe
/Users/tlonoy/.arkade/bin/kustomize.exe: PE32+ executable (console) x86-64, for MS Windows
+ rm /Users/tlonoy/.arkade/bin/kustomize.exe
+ echo

+ ./arkade get kustomize --arch aarch64 --os mingw --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize.exe
/Users/tlonoy/.arkade/bin/kustomize.exe: PE32+ executable (console) Aarch64, for MS Windows
+ rm /Users/tlonoy/.arkade/bin/kustomize.exe
+ echo

+ ./arkade get kustomize --arch arm64 --os mingw --quiet
+ file /Users/tlonoy/.arkade/bin/kustomize.exe
/Users/tlonoy/.arkade/bin/kustomize.exe: PE32+ executable (console) Aarch64, for MS Windows
+ rm /Users/tlonoy/.arkade/bin/kustomize.exe
+ echo

@toredash toredash marked this pull request as ready for review June 12, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kustomize should use VersionStrategy
3 participants