From 2dfe7d1a34bbc66fcc489d4db81fceb1ef230696 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 11 Sep 2023 12:15:39 -0700 Subject: [PATCH] fix: versions for operator during build --- .goreleaser.yml | 2 +- Makefile | 3 ++- api/client-admin.go | 2 +- pkg/logger/logger.go | 7 +++---- web-app/src/api/operatorApi.ts | 7 ++++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index e05432f5b3a..d8ed4b55e80 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -30,7 +30,7 @@ builds: - CGO_ENABLED=0 main: ./cmd/operator/ ldflags: - - -s -w -X main.version={{.Tag}} + - -s -w -X github.com/minio/operator/pkg.ReleaseTag={{.Tag}} -X github.com/minio/operator/pkg.CommitID={{.FullCommit}} -X github.com/minio/operator/pkg.Version={{.Version}} -X github.com/minio/operator/pkg.ShortCommitID={{.ShortCommit}} -X github.com/minio/operator/pkg.ReleaseTime={{.Date}} flags: - -trimpath hooks: diff --git a/Makefile b/Makefile index d23c6dc4ccc..fb36cd64aa7 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,8 @@ VERSION ?= $(shell git describe --tags) VERSIONV ?= $(shell git describe --tags | sed 's,v,,g') endif TAG ?= "minio/operator:$(VERSION)" -LDFLAGS ?= "-s -w -X main.Version=$(VERSION)" +SHA ?= $(shell git rev-parse --short HEAD) +LDFLAGS ?= "-s -w -X github.com/minio/operator/pkg.ReleaseTag=$(VERSIONV) -X github.com/minio/operator/pkg.Version=$(VERSION) -X github.com/minio/operator/pkg.ShortCommitID=$(SHA)" GOPATH := $(shell go env GOPATH) GOARCH := $(shell go env GOARCH) GOOS := $(shell go env GOOS) diff --git a/api/client-admin.go b/api/client-admin.go index 7f93a348cb8..4858b7681f6 100644 --- a/api/client-admin.go +++ b/api/client-admin.go @@ -51,7 +51,7 @@ func NewAdminClientWithInsecure(url, accessKey, secretKey, sessionToken string, stsClient := PrepareConsoleHTTPClient(insecure) admClient.SetCustomTransport(stsClient.Transport) // set user-agent to differentiate Console UI requests for auditing. - admClient.SetAppInfo("MinIO Console", pkg.Version) + admClient.SetAppInfo("MinIO Operator Console", pkg.Version) return admClient, nil } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index de7b4b663a2..c6c7fb6ec4d 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -444,11 +444,10 @@ func getUserAgent() string { uaAppend := func(p, q string) { userAgentParts = append(userAgentParts, p, q) } - uaAppend("Console (", runtime.GOOS) + uaAppend("Operator Console (", runtime.GOOS) uaAppend("; ", runtime.GOARCH) - uaAppend(") Console/", pkg.Version) - uaAppend(" Console/", pkg.ReleaseTag) - uaAppend(" Console/", pkg.CommitID) + uaAppend(") Operator Console/", pkg.Version) + uaAppend(" Operator Console/", pkg.ShortCommitID) return strings.Join(userAgentParts, "") } diff --git a/web-app/src/api/operatorApi.ts b/web-app/src/api/operatorApi.ts index 0eb6fc4e9d9..a3baca40c0a 100644 --- a/web-app/src/api/operatorApi.ts +++ b/web-app/src/api/operatorApi.ts @@ -1153,9 +1153,10 @@ export class HttpClient { ? { "Content-Type": type } : {}), }, - signal: cancelToken - ? this.createAbortSignal(cancelToken) - : requestParams.signal, + signal: + (cancelToken + ? this.createAbortSignal(cancelToken) + : requestParams.signal) || null, body: typeof body === "undefined" || body === null ? null