Skip to content

Commit 5ca8e5d

Browse files
committed
Update Theatre go ldflags
It seems that we created v3, these settings aren't working. It's very clear since the last release that I added a metric that shows this in Prometheus. This are the required changes to fix this: - In Dockefile, override two variables: VERSION and GIT_REVISION. The last one is a build argument that is injected on build time. - Fixed the path in the go package by adding the version, and update these references in goreleaser and the Makefile
1 parent 2589933 commit 5ca8e5d

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.goreleaser.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ builds:
1919
- goos: linux
2020
goarch: arm64
2121
ldflags: >
22-
-X github.com/gocardless/theatre/cmd.Version={{.Version}}
23-
-X github.com/gocardless/theatre/cmd.Commit={{.Commit}}
24-
-X github.com/gocardless/theatre/cmd.Date={{.Date}}
22+
-X github.com/gocardless/theatre/v3/cmd.Version={{.Version}}
23+
-X github.com/gocardless/theatre/v3/cmd.Commit={{.Commit}}
24+
-X github.com/gocardless/theatre/v3/cmd.Date={{.Date}}
2525
-a
2626
-installsuffix cgo
2727
env:

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ FROM golang:1.20.5 as builder
33
WORKDIR /go/src/github.com/gocardless/theatre
44

55
COPY . /go/src/github.com/gocardless/theatre
6+
ARG git_revision=unset
7+
RUN echo $git_revision > REVISION
68
RUN set -x \
7-
&& make VERSION="$(cat VERSION)" build
9+
&& make VERSION="$(cat VERSION)" GIT_REVISION="$(cat REVISION)" build
810

911
# Use ubuntu as our base package to enable generic system tools
1012
FROM ubuntu:jammy-20230522
@@ -20,4 +22,6 @@ RUN set -x \
2022

2123
WORKDIR /
2224
COPY --from=builder /go/src/github.com/gocardless/theatre/bin/* /usr/local/bin/
25+
ARG git_revision=unset
26+
RUN echo $git_revision > REVISION
2327
ENTRYPOINT ["/bin/bash"]

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
PROG=bin/rbac-manager bin/vault-manager bin/theatre-secrets bin/workloads-manager bin/theatre-consoles
22
PROJECT=github.com/gocardless/theatre
33
IMAGE=eu.gcr.io/gc-containers/gocardless/theatre
4-
VERSION=$(shell git rev-parse --short HEAD)-dev
5-
BUILD_COMMAND=go build -ldflags "-s -w -X main.Version=$(VERSION)"
4+
VERSION=$(shell git describe --tags --dirty --long)
5+
GIT_REVISION=$(shell git rev-parse HEAD)
6+
DATE=$(shell date +"%Y%m%d.%H%M%S")
7+
LDFLAGS=-ldflags "-s -X github.com/gocardless/theatre/v3/cmd.Version=$(VERSION) -X github.com/gocardless/theatre/v3/cmd.Commit=$(GIT_REVISION) -X github.com/gocardless/theatre/v3/cmd.Date=$(DATE)"
8+
BUILD_COMMAND=go build $(LDFLAGS)
69

710
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
811
ifeq (,$(shell go env GOBIN))

0 commit comments

Comments
 (0)