Use runtime-provided os/arch info
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,7 +1,6 @@
|
|||||||
PKG = github.com/sosedoff/pgweb
|
PKG = github.com/sosedoff/pgweb
|
||||||
GIT_COMMIT ?= $(shell git rev-parse HEAD)
|
GIT_COMMIT ?= $(shell git rev-parse HEAD)
|
||||||
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n')
|
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n')
|
||||||
BUILD_ARCH ?= $(shell uname -s | awk '{print tolower($$0)}')/$(shell uname -m)
|
|
||||||
GO_VERSION ?= $(shell go version | awk {'print $$3'})
|
GO_VERSION ?= $(shell go version | awk {'print $$3'})
|
||||||
|
|
||||||
DOCKER_RELEASE_TAG = "sosedoff/pgweb:$(shell git describe --abbrev=0 --tags | sed 's/v//')"
|
DOCKER_RELEASE_TAG = "sosedoff/pgweb:$(shell git describe --abbrev=0 --tags | sed 's/v//')"
|
||||||
@@ -10,7 +9,6 @@ DOCKER_LATEST_TAG = "sosedoff/pgweb:latest"
|
|||||||
LDFLAGS = -s -w
|
LDFLAGS = -s -w
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.GitCommit=$(GIT_COMMIT)
|
LDFLAGS += -X $(PKG)/pkg/command.GitCommit=$(GIT_COMMIT)
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.BuildTime=$(BUILD_TIME)
|
LDFLAGS += -X $(PKG)/pkg/command.BuildTime=$(BUILD_TIME)
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.BuildArch=$(BUILD_ARCH)
|
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.GoVersion=$(GO_VERSION)
|
LDFLAGS += -X $(PKG)/pkg/command.GoVersion=$(GO_VERSION)
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ var (
|
|||||||
BuildTime string
|
BuildTime string
|
||||||
|
|
||||||
// BuildArch contains the OS architecture of the binary
|
// BuildArch contains the OS architecture of the binary
|
||||||
BuildArch string
|
BuildArch string = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
|
||||||
|
|
||||||
// GoVersion contains the build time Go version
|
// GoVersion contains the build time Go version
|
||||||
GoVersion string
|
GoVersion string
|
||||||
@@ -31,8 +32,8 @@ type VersionInfo struct {
|
|||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
GitCommit string `json:"git_sha"`
|
GitCommit string `json:"git_sha"`
|
||||||
BuildTime string `json:"build_time"`
|
BuildTime string `json:"build_time"`
|
||||||
GoVersion string `json:"go_version"`
|
|
||||||
BuildArch string `json:"build_arch"`
|
BuildArch string `json:"build_arch"`
|
||||||
|
GoVersion string `json:"go_version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user