From 1757373d6410a774d80f5a0d374fc417fe987bf4 Mon Sep 17 00:00:00 2001 From: Ridwan Sharif Date: Thu, 9 Nov 2023 21:57:53 +0000 Subject: [PATCH] makefile: add ld flags to use the VERSION file in the useragent and self metrics Change-Id: Iff9c3af4e6eddfa7c129817d98964916c416f02d --- Makefile | 8 +++++--- VERSION | 3 +-- collector/service/main.go | 4 ++-- confgenerator/agentmetrics.go | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 37ab05c..ad26b98 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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: diff --git a/VERSION b/VERSION index ee0311e..9358f6c 100644 --- a/VERSION +++ b/VERSION @@ -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 diff --git a/collector/service/main.go b/collector/service/main.go index 8f88fbb..40b1091 100644 --- a/collector/service/main.go +++ b/collector/service/main.go @@ -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, } diff --git a/confgenerator/agentmetrics.go b/confgenerator/agentmetrics.go index 6ec0c94..9e9ec6e 100644 --- a/confgenerator/agentmetrics.go +++ b/confgenerator/agentmetrics.go @@ -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)}, }}, }},