Skip to content

Commit

Permalink
makefile: add ld flags to use the VERSION file in the useragent and s…
Browse files Browse the repository at this point in the history
…elf metrics

Change-Id: Iff9c3af4e6eddfa7c129817d98964916c416f02d
  • Loading branch information
ridwanmsharif committed Nov 9, 2023
1 parent f33f5c6 commit 1757373
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ ALL_SRC := $(shell find . -name '*.go' -type f | sort)
ALL_DOC := $(shell find . \( -name "*.md" -o -name "*.yaml" \) -type f | sort)
GIT_SHA := $(shell git rev-parse --short HEAD)

BUILD_INFO_IMPORT_PATH := collector/internal/version
BUILD_INFO_IMPORT_PATH := github.com/GoogleCloudPlatform/run-gmp-sidecar/collector/internal/version
ENTRYPOINT_BUILD_INFO_IMPORT_PATH := github.com/GoogleCloudPlatform/run-gmp-sidecar/confgenerator
BUILD_X1 := -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA)
BUILD_X2 := -X $(BUILD_INFO_IMPORT_PATH).Version=$(PKG_VERSION)
LD_FLAGS := -ldflags "${BUILD_X1} ${BUILD_X2}"
BUILD_X3 := -X $(ENTRYPOINT_BUILD_INFO_IMPORT_PATH).Version=$(PKG_VERSION)
LD_FLAGS := -ldflags "${BUILD_X1} ${BUILD_X2} ${BUILD_X3}"

TOOLS_DIR := internal/tools

Expand Down Expand Up @@ -111,7 +113,7 @@ build-collector-full-name:
ENTRYPOINT_BINARY = run-gmp-entrypoint
.PHONY: build-run-gmp-entrypoint
build-run-gmp-entrypoint:
CGO_ENABLED=0 go build -tags=$(GO_BUILD_TAGS) -o ./bin/$(ENTRYPOINT_BINARY) -buildvcs=false entrypoint.go
CGO_ENABLED=0 go build -tags=$(GO_BUILD_TAGS) -o ./bin/$(ENTRYPOINT_BINARY) $(LD_FLAGS) -buildvcs=false entrypoint.go

.PHONY: build
build:
Expand Down
3 changes: 1 addition & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# The release version and build number of the google-cloud-metrics-agent package.
PKG_VERSION=0.0.2
PKG_VERSION=0.1.0
PKG_BUILD=1
4 changes: 2 additions & 2 deletions collector/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func MainContext(ctx context.Context) {
}

info := component.BuildInfo{
Command: "google-cloud-metrics-agent",
Description: "Google Cloud Metrics Agent",
Command: "run-gmp-sidecar",
Description: "Google Cloud Run GMP Sidecar",
Version: version.Version,
}

Expand Down
1 change: 0 additions & 1 deletion confgenerator/agentmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func (r AgentSelfMetrics) OTelReceiverPipeline() otel.ReceiverPipeline {
"job_name": "run-gmp-sidecar",
"scrape_interval": "1m",
"static_configs": []map[string]interface{}{{
// TODO(b/196990135): Customization for the port number
"targets": []string{fmt.Sprintf("0.0.0.0:%d", r.Port)},
}},
}},
Expand Down

0 comments on commit 1757373

Please sign in to comment.