Skip to content

Commit

Permalink
Set restic docker image tag from Makefile during build (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: Emruz Hossain <emruz@appscode.com>
  • Loading branch information
Emruz Hossain authored Oct 7, 2021
1 parent 56a8b85 commit fc3ffb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
GO_VERSION ?= 1.17
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)

RESTIC_VER := 0.12.1

OUTBIN = bin/$(BIN)-$(OS)-$(ARCH)
ifeq ($(OS),windows)
OUTBIN := bin/$(BIN)-$(OS)-$(ARCH).exe
Expand Down Expand Up @@ -156,6 +158,7 @@ $(OUTBIN): .go/$(OUTBIN).stamp
git_tag=$(git_tag) \
commit_hash=$(commit_hash) \
commit_timestamp=$(commit_timestamp) \
RESTIC_VER=$(RESTIC_VER) \
./hack/build.sh \
"
@if ! cmp -s .go/bin/$(OS)_$(ARCH)/$(BIN) $(OUTBIN); then \
Expand Down
6 changes: 6 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ if [ -z "${VERSION:-}" ]; then
exit 1
fi

if [ -z "${RESTIC_VER:-}" ]; then
echo "RESTIC_VER must be set"
exit 1
fi

export CGO_ENABLED=0
export GOARCH="${ARCH}"
export GOOS="${OS}"
Expand All @@ -47,5 +52,6 @@ go install \
-X main.GoVersion=$(go version | cut -d " " -f 3) \
-X main.Compiler=$(go env CC) \
-X main.Platform=${OS}/${ARCH} \
-X stash.appscode.dev/cli/pkg.ResticTag=${RESTIC_VER} \
" \
./...
17 changes: 12 additions & 5 deletions pkg/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ type cliLocalDirectories struct {
downloadDir string // user provided or, current working dir
}

// These variables will be set during build time
var (
imgRestic = docker_image.Docker{
Registry: "restic",
Image: "restic",
Tag: "0.9.5", // TODO: update default release tag
}
ResticRegistry = "restic"
ResticImage = "restic"
ResticTag = "latest"
)

var imgRestic docker_image.Docker

func init() {
imgRestic.Registry = ResticRegistry
imgRestic.Image = ResticImage
imgRestic.Tag = ResticTag
}

func (localDirs *cliLocalDirectories) prepareSecretDir(tempDir string, secret *core.Secret) error {
// write repository secrets in a sub-dir insider tempDir
localDirs.secretDir = filepath.Join(tempDir, secretDirName)
Expand Down

0 comments on commit fc3ffb8

Please sign in to comment.