-
Notifications
You must be signed in to change notification settings - Fork 53
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
✨ Add version flag for operator-controller manager binary #802
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I'd personally like to see |
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.
@yashoza19 Thanks for the PR!
A couple of linter errors from the CI, and I agree with @acornett21 - having the release tag information mentioned is really helpful for debugging.
Thanks for the comments @acornett21 and @varshaprasad96. I have made the necessary changes to also show release tag information with git commit. |
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.
lgtm - one small suggestion on the description for the help flag
@yashoza19 Does the GHA/Makefile need to be updated/enhanced accommodate this? Or do we get that for free somehow? |
The MAKEFILE is updated in this PR. We can open another issue to update the GHA's if required. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #802 +/- ##
==========================================
+ Coverage 64.63% 71.15% +6.51%
==========================================
Files 16 17 +1
Lines 1315 1300 -15
==========================================
+ Hits 850 925 +75
+ Misses 403 303 -100
- Partials 62 72 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
The changes look good, just one nit!
cmd/manager/main.go
Outdated
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts), zap.StacktraceLevel(zapcore.DPanicLevel))) | ||
setupLog.Info("starting up the provisioner", "Git commit", version.String()) |
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.
Nit: Its no longer a provisioner
(as in rukpak), I'd make it a generic controller
setupLog.Info("starting up the provisioner", "Git commit", version.String()) | |
setupLog.Info("starting up the controller", "Git commit", version.String()) |
Makefile
Outdated
export GIT_REPO ?= github.com/operator-framework/operator-controller | ||
export VERSION ?= $(shell git describe --tags --always --abbrev=0) | ||
export VERSION_PATH ?= ${GIT_REPO}/internal/version | ||
export GIT_COMMIT ?= $(shell git rev-parse HEAD) |
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.
Don't use ?=
, especially with shell commands. Because they run every time a variable is referenced. See the changes I made here: #813. I don't think these need to be overridable (do they?), so we can use use :=
instead of ?=
.
Also, I see a mix of spaces and tabs. @m1kola had a good point when he reverted the vertical spacing I added in the above PR, so let's avoid that here as well.
Makefile
Outdated
@@ -207,10 +207,14 @@ CGO_ENABLED := 0 | |||
endif | |||
export CGO_ENABLED | |||
|
|||
export GIT_REPO ?= github.com/operator-framework/operator-controller | |||
export VERSION ?= $(shell git describe --tags --always --abbrev=0) |
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.
We already have a VERSION
variable above. Delete this one. It is important to use --dirty
so that a user knows if the binary was built from a modified git tree. And it is important not to use --abbrev=0
because non-tagged commits would look like they were tagged with that version.
Makefile
Outdated
export GO_BUILD_GCFLAGS := all=-trimpath=$(PWD) | ||
export GO_BUILD_FLAGS := | ||
export GO_BUILD_LDFLAGS := -s -w -X '$(VERSION_PATH).version=$(VERSION)' -X '$(VERSION_PATH).gitCommit=$(GIT_COMMIT)' |
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.
Nit to avoid long lines (note the extra empty line at the end so that we can put \
at the end of each line consistently).
export GO_BUILD_LDFLAGS := -s -w -X '$(VERSION_PATH).version=$(VERSION)' -X '$(VERSION_PATH).gitCommit=$(GIT_COMMIT)' | |
export GO_BUILD_LDFLAGS := -s -w \ | |
-X '$(VERSION_PATH).version=$(VERSION)' \ | |
-X '$(VERSION_PATH).gitCommit=$(GIT_COMMIT)' \ | |
Makefile
Outdated
export GIT_REPO ?= github.com/operator-framework/operator-controller | ||
export VERSION ?= $(shell git describe --tags --always --abbrev=0) | ||
export VERSION_PATH ?= ${GIT_REPO}/internal/version | ||
export GIT_COMMIT ?= $(shell git rev-parse HEAD) |
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.
Looks like debug.BuildInfo
contains the git commit with key vcs.revision
. Could we use that instead of injecting it?
@joelanford and @varshaprasad96, Thanks for the review. I have made the suggested changes, PTAL whenever you get a chance. Thanks! |
Makefile
Outdated
@@ -207,10 +207,13 @@ CGO_ENABLED := 0 | |||
endif | |||
export CGO_ENABLED | |||
|
|||
export GIT_REPO := github.com/operator-framework/operator-controller |
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.
Oh one more think I noticed: This technically needs to be to go module name in order to be used within the $(VERSION_PATH)
variable. So in that case, can we be explicit (and more copy/paste friendly) with this:
export GIT_REPO := github.com/operator-framework/operator-controller | |
export GIT_REPO := $(shell go list -m) |
628c960
to
b3d43cc
Compare
cmd/manager/main.go
Outdated
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts), zap.StacktraceLevel(zapcore.DPanicLevel))) | ||
setupLog.Info("starting up the controller", "Git commit", version.String()) |
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.
Nit: This isn't just the git commit so that might be a bit misleading in the logs. Maybe something like:
setupLog.Info("starting up the controller", "Git commit", version.String()) | |
setupLog.Info("starting up the controller", "version info", version.String()) |
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.
Good catch. fixed it.
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.
One minor nit. Otherwise looks good to me, thanks @yashoza19 !
d9e2ecf
to
7423897
Compare
Signed-off-by: yashoza19 <yoza@redhat.com>
Description
Reviewer Checklist