Skip to content
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

kustomize: Fix the version string (x.y.z -> kustomize/vx.y.z) #60515

Closed
wants to merge 3 commits into from

Conversation

icy
Copy link
Contributor

@icy icy commented Sep 2, 2020

kustomize: Fix the version string (x.y.z -> kustomize/vx.y.z)

The official binary will print an actual tag

$ kustomize version
{Version:kustomize/v3.8.1

while the current binary built by Homebrew just prints {Version:3.8.1}.
This PR will ensure that kustomize version command from the Homebrew binary
uses the same format string.

Explanation

The official kustomize binary is built by (google) cloud build tools.
The build configuration is found at
https://github.com/kubernetes-sigs/kustomize/blob/ba0f583ee5cc47ca436df1910e467613c5e04980/releasing/cloudbuild.sh#L91

This template {.Version} actually uses any current tag (e.g, kustomize/v3.8.2)
https://github.com/kubernetes-sigs/kustomize/blob/ba0f583ee5cc47ca436df1910e467613c5e04980/releasing/cloudbuild.sh#L5

The build tool (goreleaser) is happy to use this non-sematic version
as a specific option is used, as seen in
https://github.com/kubernetes-sigs/kustomize/blob/ba0f583ee5cc47ca436df1910e467613c5e04980/releasing/cloudbuild.sh#L124

In short, the official build flag is, e.g,

-X sigs.k8s.io/kustomize/api/provenance.version=kustomize/v3.8.2

not

-X sigs.k8s.io/kustomize/api/provenance.version=3.8.2
  • Have you followed the guidelines for contributing?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

@BrewTestBot BrewTestBot added the go Go use is a significant feature of the PR or issue label Sep 2, 2020
@icy
Copy link
Contributor Author

icy commented Sep 2, 2020

cc: @monopole maybe you have a look and give some advice. Many thanks

The official binary will print an actual tag

```
$ kustomize version
{Version:kustomize/v3.8.1
```

while the current binary built by Homebrew just prints `{Version:3.8.1}`.
This PR will ensure that `kustomize version` command from the Homebrew binary
uses the same format string.

Explanation
===========

The official kustomize binary is built by (google) cloud build tools.
The build configuration is found at
https://github.com/kubernetes-sigs/kustomize/blob/ba0f583ee5cc47ca436df1910e467613c5e04980/releasing/cloudbuild.sh#L91

This template {.Version} actually uses any current tag (e.g, kustomize/v3.8.2)
https://github.com/kubernetes-sigs/kustomize/blob/ba0f583ee5cc47ca436df1910e467613c5e04980/releasing/cloudbuild.sh#L5

The build tool (goreleaser) is happy to use this non-sematic version
as a specific option is used, as seen in
https://github.com/kubernetes-sigs/kustomize/blob/ba0f583ee5cc47ca436df1910e467613c5e04980/releasing/cloudbuild.sh#L124

In short, the official build flag is, e.g,

    -X sigs.k8s.io/kustomize/api/provenance.version=kustomize/v3.8.2

not

    -X sigs.k8s.io/kustomize/api/provenance.version=3.8.2
@jonchang
Copy link
Contributor

jonchang commented Sep 2, 2020

It looks like it's just the git tag. We could pass the output of git tag --contains instead?

@icy
Copy link
Contributor Author

icy commented Sep 2, 2020

It looks like it's just the git tag.

Exactly.

We could pass the output of git tag --contains instead?

The command will print two tags, for example

$ git tag --contains
cmd/config/v0.7.0
kustomize/v3.8.2

(git tag --points-at HEAD) may also generate multiple outputs. I think we may need another command and/or arguments instead.

@jonchang
Copy link
Contributor

jonchang commented Sep 2, 2020

The command will print two tags, for example

Is that certainly the case? If you run brew fetch -s kustomize and then run git tag --contains in the directory that's checked out, what happens?

@icy
Copy link
Contributor Author

icy commented Sep 2, 2020

The command will print two tags, for example

Is that certainly the case?

Definitively not ;)

If you run brew fetch -s kustomize and then run git tag --contains in the directory that's checked out, what happens?

There is only single tag. Thanks for your pointing out. I didn't know that. (I understand that's because brew fetch doesn't fetch all tags from the remote .)

I have fixed in the recent commit.

In the test block for the formula, there is still a hard-coded way

assert_match "kustomize/v#{version}", shell_output("#{bin}/kustomize version")

Do you think that's fine to keep this?

Thanks

Copy link
Member

@SMillerDev SMillerDev left a comment

Choose a reason for hiding this comment

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

Thanks @icy ! Without contributions like yours it'd be impossible to keep homebrew going with the high standards that users have come to expect from the project. You can feel good knowing that you've made the world a tiny bit better for homebrew users around the world! 👍 🎉

@BrewTestBot
Copy link
Member

🤖 A scheduled task has triggered a merge.

@icy
Copy link
Contributor Author

icy commented Sep 3, 2020

Thanks @icy ! Without contributions like yours it'd be impossible to keep homebrew going with the high standards that users have come to expect from the project. You can feel good knowing that you've made the world a tiny bit better for homebrew users around the world! +1 tada

Thanks a lot for your approval and your feedback. I'm happy that my tiny work helps Homebrew and its users:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Go use is a significant feature of the PR or issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants