kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Fix install_kustomize.sh

Open bewing opened this issue 1 year ago • 12 comments

Github recently changed their API to sometimes remove whitespace from JSON responses. This commit updates the find_release_url bash function to use grep's --only-matching option to return just the browser_download_url keys and values regardless of whitespace.

I was able to test the regex against old and new by passing the JSON document through jq first:

$ curl -s --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubernetes-sigs/kustomize/releases | grep -o '"browser_download_url":[[:space:]]*"[^" ]\+linux_amd64
[^" ]\+' | cut -d '"' -f 4 | sort -V
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.4/kustomize_v4.5.4_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.6/kustomize_v4.5.6_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.7/kustomize_v4.5.7_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.0/kustomize_v5.0.0_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.1/kustomize_v5.0.1_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.2/kustomize_v5.0.2_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz

$ curl -s --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubernetes-sigs/kustomize/releases | jq . | grep -o '"browser_download_url":[[:space:]]*"[^" ]\+linu
x_amd64[^" ]\+' | cut -d '"' -f 4 | sort -V
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.4/kustomize_v4.5.4_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.6/kustomize_v4.5.6_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.7/kustomize_v4.5.7_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.0/kustomize_v5.0.0_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.1/kustomize_v5.0.1_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.2/kustomize_v5.0.2_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz

closes #4769

bewing avatar Jun 05 '23 17:06 bewing

Welcome @bewing!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot avatar Jun 05 '23 17:06 k8s-ci-robot

Hi @bewing. 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/test-infra repository.

k8s-ci-robot avatar Jun 05 '23 17:06 k8s-ci-robot

I have tested it too. It works for me.

@Aisuko ➜ /workspaces/kustomize (install_fix) $ /bin/bash ./hack/install_kustomize.sh
v5.1.0
kustomize installed to /workspaces/kustomize/kustomize

Aisuko avatar Jun 30 '23 04:06 Aisuko

/assign

Aisuko avatar Jun 30 '23 04:06 Aisuko

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 20 '24 07:01 k8s-triage-robot

/remove-lifecycle stale

oxr463 avatar Jan 20 '24 15:01 oxr463

Thanks for your kontribution @bewing !

/ok-to-test

antoooks avatar Mar 31 '24 14:03 antoooks

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Aisuko, bewing, oxr463 Once this PR has been reviewed and has the lgtm label, please assign varshaprasad96 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 avatar Mar 31 '24 18:03 k8s-ci-robot

@ncapps or @knverey can I get a review of this PR?

bewing avatar Mar 31 '24 19:03 bewing

Hi,

Thank you for your contribution. I am not able to reproduce the issue described in https://github.com/kubernetes-sigs/kustomize/issues/4769.

The install_kustomize.sh script appears to be installing the correct kustomize version on my machine. I am using the zsh shell.

zsh --version
zsh 5.9 (x86_64-apple-darwin23.0)

grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
# Install kustomize version 5.3.0 in tmp directory
$ ./hack/install_kustomize.sh 5.3.0 tmp
v5.3.0
kustomize installed to /Users/nick/go/src/github.com/ncapps/kustomize/tmp/kustomize

# Verify kustomize 5.3.0 is installed
$ tmp/kustomize version
v5.3.0

# Install kustomize version 5.2.1 in tmp directory
$ ./hack/install_kustomize.sh 5.2.1 tmp
v5.2.1
kustomize installed to /Users/nick/go/src/github.com/ncapps/kustomize/tmp/kustomize

# Verify kustomize 5.2.1 is installed
$ tmp/kustomize version             
v5.2.1

ncapps avatar Apr 02 '24 04:04 ncapps

I'm still seeing single-line output from the Github API in my location (Chicago, IL)

$ dig AAAA +short github.com
$ dig +short github.com
140.82.114.3

$ curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases | wc -l
0


$ hack/install_kustomize.sh
tar (child): ./kustomize_v*_linux_amd64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

bewing avatar Apr 02 '24 12:04 bewing

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jul 01 '24 12:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Jul 31 '24 13:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-triage-robot avatar Aug 30 '24 14:08 k8s-triage-robot

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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 avatar Aug 30 '24 14:08 k8s-ci-robot