Skip to content

Commit e84c880

Browse files
authored
Merge pull request #60 from PureStorage-OpenConnect/version_string
Make build version number dynamic in useragent string
2 parents 85c2a77 + b4ed86b commit e84c880

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GOTEST=$(GOCMD) test
33
GOVET=$(GOCMD) vet
44
BINARY_NAME=pure-fb-om-exporter
55
MODULE_NAME=purestorage/fb-openmetrics-exporter
6-
VERSION?=1.0.10
6+
VERSION?=1.0.11
77
SERVICE_PORT?=9491
88
DOCKER_REGISTRY?= quay.io/purestorage/
99
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
@@ -25,11 +25,11 @@ init:
2525

2626
build: ## Build project and put the output binary in out/bin/
2727
mkdir -p out/bin
28-
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -a -mod=readonly -tags 'netgo osusergo static_build' -ldflags='-X main.version=v$(VERSION)' -o out/bin/$(BINARY_NAME) cmd/fb-om-exporter/main.go
28+
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -a -mod=readonly -tags 'netgo osusergo static_build' -ldflags="-X 'main.version=v$(VERSION)' -X 'purestorage/fb-openmetrics-exporter/internal/rest-client.UserAgentVersion=$(VERSION)'" -o out/bin/$(BINARY_NAME) cmd/fb-om-exporter/main.go
2929

3030
build-with-vendor: ## Build project using the vendor directory and put the output binary in out/bin/
3131
mkdir -p out/bin
32-
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -a -mod=vendor -tags 'netgo osusergo static_build' -ldflags='-X main.version=v$(VERSION)' -o out/bin/$(BINARY_NAME) cmd/fb-om-exporter/main.go
32+
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -a -mod=vendor -tags 'netgo osusergo static_build' -ldflags="-X 'main.version=v$(VERSION)' -X 'purestorage/fb-openmetrics-exporter/internal/rest-client.UserAgentVersion=$(VERSION)'" -o out/bin/$(BINARY_NAME) cmd/fb-om-exporter/main.go
3333

3434
clean: ## Remove build related file
3535
rm -fr ./bin

build/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM golang:alpine as build
2-
ARG VERSION=1.0.10
2+
ARG VERSION=1.0.11
33

44
WORKDIR /usr/src/app
55

@@ -8,7 +8,7 @@ COPY go.mod go.sum ./
88
RUN go mod download && go mod verify
99

1010
COPY . .
11-
RUN CGO_ENABLED=1 go build -mod=readonly -a -tags 'netgo osusergo static_build' -ldflags="-X main.version=v$VERSION" -v -o /usr/local/bin/pure-fb-om-exporter cmd/fb-om-exporter/main.go
11+
RUN CGO_ENABLED=1 go build -mod=readonly -a -tags 'netgo osusergo static_build' -ldflags="-X 'main.version=v$VERSION' -X 'purestorage/fb-openmetrics-exporter/internal/rest-client.UserAgentVersion=$VERSION'" -v -o /usr/local/bin/pure-fb-om-exporter cmd/fb-om-exporter/main.go
1212

1313

1414
# alpine is used here as it seems to be the minimal image that passes quay.io vulnerability scan

internal/rest-client/flashblade_client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
"github.com/go-resty/resty/v2"
88
)
99

10-
const FBRestUserAgent = "Pure_FB_OpenMetrics_exporter/1.0"
10+
var UserAgentVersion string = "development"
11+
12+
var FBRestUserAgent string = "Pure_FB_OpenMetrics_exporter/" + UserAgentVersion
1113

1214
type Client interface {
1315
GetAlerts(filter string) *AlertsList
@@ -92,7 +94,7 @@ func NewRestClient(endpoint string, apitoken string, apiversion string, uagent s
9294
fb.XAuthToken = res.Header().Get("x-auth-token")
9395
fb.RestClient.SetBaseURL("https://" + endpoint + "/api/" + fb.ApiVersion)
9496
fb.RestClient.SetHeader("x-auth-token", fb.XAuthToken)
95-
fb.RestClient.SetHeader("User-Agent", FBRestUserAgent + " (" + uagent + ")")
97+
fb.RestClient.SetHeader("User-Agent", FBRestUserAgent+" ("+uagent+")")
9698
return fb
9799
}
98100

0 commit comments

Comments
 (0)