Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ jobs:
- name: Build
run: make build -j3

- name: Build Docker images
run: make docker
7 changes: 2 additions & 5 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,5 @@ jobs:
registry: ${{ env.HUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
run: |
make docker.push || make docker.push
docker tag $HUB/$APP_NAME:{$VERSION,latest}
docker push $HUB/$APP_NAME:latest
- name: Build and push docker images
run: make docker.push || make docker.push
78 changes: 41 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,67 @@ HUB ?= docker.io/apache
RELEASE_BIN = skywalking-cli-$(VERSION)-bin
RELEASE_SRC = skywalking-cli-$(VERSION)-src

OS = $(shell uname)

GO = go
GO_PATH = $$($(GO) env GOPATH)
GO_BUILD = $(GO) build
GO_GET = $(GO) get
GO_INSTALL = $(GO) install
GO_TEST = $(GO) test
GO_LINT = $(GO_PATH)/bin/golangci-lint
GO_LICENSER = $(GO_PATH)/bin/go-licenser
ARCH := $(shell uname)
OSNAME := $(if $(findstring Darwin,$(ARCH)),darwin,linux)
GO_BUILD_FLAGS = -v
GO_BUILD_LDFLAGS = -X main.version=$(VERSION)

PLATFORMS := windows linux darwin
os = $(word 1, $@)
ARCH = amd64
GO_LINT = golangci-lint
LICENSE_EYE = license-eye

SHELL = /bin/bash

BUILDS := darwin-amd64 darwin-arm64 linux-386 linux-amd64 linux-arm64 windows-386 windows-amd64
BUILD_RULE = GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags "$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(BINARY)-$(VERSION)-$(GOOS)-$(GOARCH) cmd/swctl/main.go

all: clean license deps lint test build

tools:
mkdir -p $(GO_PATH)/bin
$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin
$(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u github.com/elastic/go-licenser
.PHONY: $(BUILDS)
$(BUILDS): GOOS = $(word 1,$(subst -, ,$@))
$(BUILDS): GOARCH = $(word 2,$(subst -, ,$@))
$(BUILDS):
$(BUILD_RULE)

.PHONY: build
build: $(BUILDS)

deps: tools
$(GO_GET) -v -t -d ./...
.PHONY: deps
deps:
@$(GO_GET) -v -t -d ./...

.PHONY: $(PLATFORMS)
$(PLATFORMS): clean
mkdir -p $(OUT_DIR)
GOOS=$(os) GOARCH=$(ARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags "$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(BINARY)-$(VERSION)-$(os)-$(ARCH) cmd/swctl/main.go
$(GO_LINT):
@$(GO_LINT) version > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(LICENSE_EYE):
@$(LICENSE_EYE) --version > /dev/null 2>&1 || go install github.com/apache/skywalking-eyes/cmd/license-eye@latest

.PHONY: lint
lint: tools
lint: $(GO_LINT)
$(GO_LINT) run -v --timeout 5m ./...
.PHONY: fix-lint
fix-lint: $(GO_LINT)
$(GO_LINT) run -v --fix ./...

.PHONY: license
license: clean $(LICENSE_EYE)
@$(LICENSE_EYE) header check
.PHONY: fix-license
fix-license: clean $(LICENSE_EYE)
@$(LICENSE_EYE) header fix

.PHONY: fix
fix: fix-lint fix-license

.PHONY: test
test: clean
$(GO_TEST) ./... -coverprofile=coverage.txt -covermode=atomic

.PHONY: build
build: deps windows linux darwin

.PHONY: license
license: clean tools
$(GO_LICENSER) -d -licensor='Apache Software Foundation (ASF)' .

.PHONY: verify
verify: clean license lint test

.PHONY: fix
fix: tools
$(GO_LINT) run -v --fix ./...
$(GO_LICENSER) -licensor='Apache Software Foundation (ASF)' .

.PHONY: coverage
coverage: test
bash <(curl -s https://codecov.io/bash) -t a5af28a3-92a2-4b35-9a77-54ad99b1ae00
Expand Down Expand Up @@ -137,16 +139,18 @@ check-codegen:
fi

.PHONY: docker
docker: clean
docker build --build-arg VERSION=$(VERSION) . -t $(HUB)/$(APP_NAME):$(VERSION)
docker:
docker buildx create --use
docker buildx build $(PUSH) --platform linux/386,linux/amd64,linux/arm64 --build-arg VERSION=$(VERSION) . -t $(HUB)/$(APP_NAME):$(VERSION) -t $(HUB)/$(APP_NAME):latest

.PHONY: docker.push
docker.push: PUSH = --push
docker.push: docker
docker push $(HUB)/$(APP_NAME):$(VERSION)

.PHONY: install
install: $(OSNAME)
-cp $(OUT_DIR)/$(BINARY)-$(VERSION)-$(OSNAME)-$(ARCH) $(DESTDIR)/swctl
install: clean
$(BUILD_RULE)
-cp $(OUT_DIR)/$(BINARY)-$(VERSION)-$(OSNAME)-* $(DESTDIR)/swctl

.PHONY: uninstall
uninstall: $(OSNAME)
Expand Down
3 changes: 1 addition & 2 deletions cmd/swctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package main

import (
"io/ioutil"
"os"
"runtime"

Expand Down Expand Up @@ -192,7 +191,7 @@ func expandConfigFile(c *cli.Context) error {
func tryConfigFile(flags []cli.Flag) cli.BeforeFunc {
return func(c *cli.Context) error {
configFile := c.String("config")
if bytes, err := ioutil.ReadFile(configFile); err == nil {
if bytes, err := os.ReadFile(configFile); err == nil {
log.Debug("Using configurations:\n", string(bytes))

err = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("config"))(c)
Expand Down
5 changes: 4 additions & 1 deletion docs/How-to-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ Vote result should follow these:
svn mv https://dist.apache.org/repos/dist/dev/skywalking/cli/$VERSION https://dist.apache.org/repos/dist/release/skywalking/cli -m"Release SkyWalking CLI $VERSION"
```

1. Push Docker images.
2. Push Docker images.

In order to publish the Docker images, you
have [to enable BuildKit in the Docker daemon](https://docs.docker.com/develop/develop-images/build_enhancements/.

```shell
make docker.push
Expand Down
3 changes: 1 addition & 2 deletions internal/commands/install/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bufio"
"fmt"
"io"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -98,7 +97,7 @@ func loadOverlay(file string, in io.Reader, out interface{}) error {
}
}
} else {
b, err := ioutil.ReadFile(file)
b, err := os.ReadFile(file)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/graphql/dashboard/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package dashboard

import (
"bytes"
"io/ioutil"
"os"
"strings"
"sync"

Expand Down Expand Up @@ -100,7 +100,7 @@ func LoadTemplate(filename string) (*GlobalTemplate, error) {
if filename == DefaultTemplatePath {
byteValue = []byte(assets.Read(filename))
} else {
byteValue, err = ioutil.ReadFile(filename)
byteValue, err = os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down