Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong docker image name and -version command #199

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Release Notes.
#### Plugins

#### Bug Fixes
* Fix wrong docker image name and `-version` command.

#### Issues and PR
- All issues are [here](https://github.com/apache/skywalking/milestone/219?closed=1)
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GO_TEST_LDFLAGS =
REPODIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/
LINT_FILE_PATH = $(REPODIR).golangci.yml

VERSION_FILE=VERSION
VERSION_FILE=$(REPODIR)VERSION

SHELL = /bin/bash

Expand All @@ -41,6 +41,8 @@ ifeq ($(strip $(GIT_VERSION)),)
GIT_VERSION = $(shell grep gitCommit $(VERSION_FILE) | awk -F ': ' '{print $$2}')
endif

VERSION ?= $(GIT_VERSION)

LOG_TARGET = echo -e "\033[0;32m===========> Running $@ ... \033[0m"

##@ General
Expand Down Expand Up @@ -146,16 +148,18 @@ docker.push.%: LOAD_OR_PUSH = --push

.PHONY: $(base.all)
$(base.all:%=docker.%): BASE_IMAGE=$($(base.each:docker.%=base.image.%))
$(base.all:%=docker.%): FINAL_TAG=$(GIT_VERSION)-$(base.each:docker.%=%)
$(base.all:%=docker.%): FINAL_TAG=$(VERSION)-$(base.each:docker.%=%)
$(base.all:%=docker.push.%): BASE_IMAGE=$($(base.each:docker.push.%=base.image.%))
$(base.all:%=docker.push.%): FINAL_TAG=$(GIT_VERSION)-$(base.each:docker.push.%=%)
$(base.all:%=docker.%) $(base.all:%=docker.push.%):
$(base.all:%=docker.push.%): FINAL_TAG=$(VERSION)-$(base.each:docker.push.%=%)
$(base.all:%=docker.%) $(base.all:%=docker.push.%): version-check
@$(version-check)
@$(LOG_TARGET)
docker buildx create --use --driver docker-container --name skywalking_go > /dev/null 2>&1 || true
docker buildx build $(PLATFORMS) $(LOAD_OR_PUSH) \
--no-cache \
--build-arg "BASE_GO_IMAGE=$(BASE_IMAGE)" \
--build-arg "VERSION=$(GIT_VERSION)" \
--build-arg "BASE_BUILDER_IMAGE=$(BASE_IMAGE)" \
--build-arg "VERSION=$(VERSION)" \
. -t $(HUB)/$(PROJECT):$(FINAL_TAG)
docker buildx rm skywalking_go || true

Expand Down
4 changes: 2 additions & 2 deletions tools/go-agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GIT_COMMIT := $(shell $(GIT) rev-parse --short HEAD)
ifeq ($(strip $(GIT_COMMIT)),)
GIT_COMMIT = $(shell grep gitCommit $(VERSION_PATH) | awk -F ': ' '{print $$2}')
endif
VERSION := $(shell grep version $(VERSION_PATH) | awk -F ': ' '{print $$2}')
VERSION ?= $(shell grep version $(VERSION_PATH) | awk -F ': ' '{print $$2}')

GO_VERSION := $(shell $(GO) env GOVERSION)
VERSION_PACKAGE := main
Expand All @@ -38,7 +38,7 @@ GO_PATH = $$($(GO) env GOPATH)
GO_BUILD = $(GO) build
GO_LINT = $(GO_PATH)/bin/golangci-lint
GO_BUILD_FLAGS = -v
GO_BUILD_LDFLAGS = -X $(VERSION_PACKAGE).version=$(VERSION) -X $(VERSION_PACKAGE).goVersion=$(GO_VERSION) -X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT)
GO_BUILD_LDFLAGS = -X $(VERSION_PACKAGE).version=$(VERSION) -X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT)
GO_TEST_LDFLAGS =
GO_GET = $(GO) get

Expand Down
4 changes: 2 additions & 2 deletions tools/go-agent/cmd/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ package main
import (
"fmt"
"os"
"runtime"
"text/template"
)

var (
version string
goVersion string
gitCommit string
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func PrintVersion() {
versionInfo := map[string]any{
"Version": version,
"GitCommit": gitCommit,
"GoVersion": goVersion,
"GoVersion": runtime.Version(),
}
if err := versionTmpl.Execute(os.Stdout, versionInfo); err != nil {
fmt.Fprintln(os.Stdout, err)
Expand Down
Loading