Skip to content

Commit 7aa3494

Browse files
authored
VAULT 13901/inject version (#105)
1 parent 36141fd commit 7aa3494

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
env:
8686
GOOS: ${{ matrix.goos }}
8787
GOARCH: ${{ matrix.goarch }}
88+
VERSION: ${{ needs.get-product-version.outputs.product-version }}
8889
run: |
8990
make build
9091
pushd pkg

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ GOOS?=linux
22
GOARCH?=amd64
33
CI_TEST_ARGS=
44
TERRAFORM_ARGS=
5-
5+
PKG=github.com/hashicorp/vault-lambda-extension/internal/config
6+
VERSION?=0.0.0-dev
67
.PHONY: build zip lint test clean mod quick-start quick-start-destroy publish-layer-version
78

89
build: clean
910
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build \
10-
-ldflags '-s -w' \
11+
-ldflags "-s -w -X '$(PKG).ExtensionVersion=$(VERSION)'" \
1112
-a -o pkg/extensions/vault-lambda-extension \
1213
.
1314

internal/config/info.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package config
22

33
const (
4-
ExtensionName = "vault-lambda-extension"
5-
ExtensionVersion = "0.9.0"
6-
VaultLogLevel = "VAULT_LOG_LEVEL" // Optional, one of TRACE, DEBUG, INFO, WARN, ERROR, OFF
7-
VaultRunMode = "VAULT_RUN_MODE"
4+
ExtensionName = "vault-lambda-extension"
5+
VaultLogLevel = "VAULT_LOG_LEVEL" // Optional, one of TRACE, DEBUG, INFO, WARN, ERROR, OFF
6+
VaultRunMode = "VAULT_RUN_MODE"
7+
)
8+
9+
var (
10+
// ExtensionVersion should be a var type, so the go build tool can override and inject a custom version.
11+
ExtensionVersion = "0.0.0-dev"
812
)

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func main() {
3333
Level: hclog.LevelFromString(os.Getenv(config.VaultLogLevel)),
3434
})
3535

36+
logger.Info(fmt.Sprintf("Starting Vault Lambda Extension %v", config.ExtensionVersion))
3637
runMode := runmode.ModeDefault
3738
if runModeEnv := os.Getenv(config.VaultRunMode); runModeEnv != "" {
3839
runMode = runmode.ParseMode(runModeEnv)

0 commit comments

Comments
 (0)