-
Notifications
You must be signed in to change notification settings - Fork 164
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
properly determine go versions #3251
Conversation
1242df6
to
3af81f5
Compare
@@ -6,7 +6,7 @@ RUN eve-alpine-deploy.sh | |||
COPY ./ /newlog/. | |||
WORKDIR /newlog | |||
|
|||
RUN GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w" -mod=vendor -o /out/usr/bin/newlogd ./cmd | |||
RUN GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w -X=main.Version=$(cat gopkgversion)" -mod=vendor -o /out/usr/bin/newlogd ./cmd |
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.
RUN GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w -X=main.Version=$(cat gopkgversion)" -mod=vendor -o /out/usr/bin/newlogd ./cmd | |
RUN GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w -X=main.Version=$(<gopkgversion)" -mod=vendor -o /out/usr/bin/newlogd ./cmd |
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.
or is that a bashism?
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.
It is a bashism. I originally had that, and spent easily 20-30 mins trying to figure out why the ldflag was blank. If I had submitted it right away, yetus would have told me, but I insisted on figuring it out myself first. 😆
Signed-off-by: Avi Deitcher <avi@deitcher.net>
3af81f5
to
d320ff6
Compare
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
I wonder if we take this opportunity to do the eve-version in similar ways e.g., by having the Makefile drop the ROOTFS_VERSION into ./eve-version and then use that. But this can be a separate PR.
I am happy to get a PR in for that. We also were thinking of doing that for kernel builds, so we can avoid some of the complex templating we do. I will try top get to a PR on that too. |
This extracts the unique
pkg/pillar/scripts/getversion.sh
and replaces it withtools/goversion.sh
, which calculates the actual version for a go package using the go semver + pseudo-version rules. Unfortunately, no standard go tool does this for you.getversion.sh
was being used only to set-X main.Version=<version>
for pillar. That version was interesting, and didn't actually confirm to go rules.This now uses the standard version at a higher level, and then includes it in the 3 go binaries we build: edge-view, newlog, pillar.
The process is as follows:
Makefile
, have everyeve-<pkg>
target depend uponpkg/%/gopkgversion
Makefile
, thepkg/%/gopkgversion
generates the version fromgoversion.sh
and saves it in the package inpkg/%/gopkgversion
*gopkgversion
has been added to.gitignore
-X main.Version=<version>
has been updated to source from that file.The
gopkgversion
non-tracked file allows us to build in subdirs likepkg/pillar/
orpkg/newlog/
without requiring the entire.git
directory in the context.