-
Notifications
You must be signed in to change notification settings - Fork 15
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
Added version argument on the CLI #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First up, thanks for taking a run at this.
Unfortunately, the approach of shelling out to git won't work unless someone is running from source. If you're happy to take another run, the following should help. But happy to answer questions too in the comments.
Cobra supports a Version
property rather than needing a new command. You can see that in use https://github.com/open-policy-agent/conftest/blob/master/internal/commands/default.go#LL32C24-L32C24
Typically that's calculated at build time, and then passed to the compilation step, like so https://github.com/open-policy-agent/conftest/blob/master/.goreleaser.yml#L17-L20
You can see some of the implementation here
https://github.com/open-policy-agent/conftest/blob/master/internal/commands/default.go#L22-L25
@garethr but in https://github.com/snyk/parlay/blob/main/.goreleaser.yml#21-L24 the line is commented out. |
@garethr Thanks for your guidance. I implemented change with cobra's version attribute. I have enabled command in the goreleaser to get the version. but i am not sure where does the goreleaser will get the version. i am currently researching that, it would be helpful if can share any insights you might have. |
Goreleaser is opionated about versions, and then exposes that as a template variable That's what this example uses: ldflags are a way of passing buildtime information to be embedded in the resulting binary https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications The above example binds the value passed in to this variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved these issues. Can you review it once @garethr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick scan of this, this looks great. One minor typo and good to merge this I think. Much appreciated.
Dismissing stale review (typo was fixed in meantime) to merge and release.
Closes #15