Skip to content

fix(build): stamp ko images via .ko.yaml, drop unsupported ko --ldflags#163

Closed
Davanum Srinivas (dims) wants to merge 1 commit into
agent-substrate:mainfrom
dims:fix/ko-ldflags-version-stamping
Closed

fix(build): stamp ko images via .ko.yaml, drop unsupported ko --ldflags#163
Davanum Srinivas (dims) wants to merge 1 commit into
agent-substrate:mainfrom
dims:fix/ko-ldflags-version-stamping

Conversation

@dims
Copy link
Copy Markdown
Collaborator

UGH! i made a mistake.. ko build has no --ldflags flag (only ko run/delete tolerate unknown flags), so make build-images and make build-demos aborted with "unknown flag: --ldflags". It went unnoticed because no CI workflow runs make build*: e2e installs via hack/install-ate.sh, which builds images with ko apply/ko resolve. Only the plain go-build targets (kubectl-ate, atenet) actually stamped anything.

Fixes #<issue_number_goes_here>

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

ko build has no --ldflags flag (only ko run/delete tolerate unknown
flags), so `make build-images` and `make build-demos` aborted with
"unknown flag: --ldflags". It went unnoticed because no CI workflow runs
`make build*`: e2e installs via hack/install-ate.sh, which builds images
with `ko apply`/`ko resolve`. Only the plain go-build targets (kubectl-ate,
atenet) actually stamped anything.

Move image stamping to ko's supported mechanism -- defaultLdflags in .ko.yaml
with git/date templating. This also stamps the ko apply/resolve install path,
with no env wiring. Version uses {{.Git.ShortCommit}} because no release tag
is reachable from HEAD ({{.Git.Tag}} would emit a misleading "v0.0.0"). The
go-built CLI binaries keep `go build -ldflags "$(LDFLAGS)"` unchanged.

Verified: ko-built ateapi image runs as
  4cbac18 commit=4cbac189030646eb30644664798232a7cba70c64 built=... linux/arm64
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@thockin
Copy link
Copy Markdown
Collaborator

compare to #162 ?

@dims
Copy link
Copy Markdown
Collaborator Author

Tim Hockin (@thockin) beat me to it! #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants