You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/04/07 06:21:07 UTC
[skywalking-kubernetes-event-exporter] 01/01: chore: reorganize
Makefile, add build and test doc
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch docker-deploy
in repository https://gitbox.apache.org/repos/asf/skywalking-kubernetes-event-exporter.git
commit f7f818ac41b0fd18090713d519a633cea895b0c5
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Wed Apr 7 14:20:57 2021 +0800
chore: reorganize Makefile, add build and test doc
---
.dockerignore | 1 +
.github/workflows/build-and-test.yaml | 3 ++
.gitignore | 3 ++
Makefile | 27 +---------
README.md | 18 +++++--
assets/default-config.yaml | 5 +-
.../package/docker/Dockerfile | 62 +++++++++-------------
.../package/docker/Makefile | 46 ++++------------
deployments/base/cluster-role-binding.yaml | 32 +++++++++++
deployments/base/deployment.yaml | 52 ++++++++++++++++++
deployments/base/kustomization.yaml | 26 +++++++++
deployments/base/namespace.yaml | 24 +++++++++
deployments/base/service-account.yaml | 24 +++++++++
.../dev/Makefile | 43 ++++-----------
deployments/dev/config/config.yaml | 33 ++++++++++++
deployments/dev/kustomization.yaml | 37 +++++++++++++
deployments/release/config/config.yaml | 33 ++++++++++++
deployments/release/kustomization.yaml | 37 +++++++++++++
pkg/k8s/registry.go | 7 +++
.../build-and-test.yaml => scripts/base.mk | 60 ++++++++-------------
20 files changed, 398 insertions(+), 175 deletions(-)
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+bin
diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml
index 7f2913f..ac62b95 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/.github/workflows/build-and-test.yaml
@@ -45,6 +45,9 @@ jobs:
- name: Build
run: make
+ - name: Build Docker Image
+ run: make -C build/package/docker
+
gateway:
name: Gateway
runs-on: ubuntu-latest
diff --git a/.gitignore b/.gitignore
index f005814..aed7f03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,6 @@ bin
# Dependency directories (remove the comment below to include it)
# vendor/
+
+# Development Files
+deployments/dev/kustomization.yaml
diff --git a/Makefile b/Makefile
index c2a1f4a..73aa083 100644
--- a/Makefile
+++ b/Makefile
@@ -16,28 +16,7 @@
# under the License.
#
-export PATH := $(PATH):$(HOME)/usr/local/bin
-export GO111MODULE := on
-
-APP = skywalking-kubernetes-event-exporter
-VERSION ?= latest
-OUT_DIR = bin
-ARCH := $(shell uname)
-OSNAME := $(if $(findstring Darwin,$(ARCH)),darwin,linux)
-
-GO := GO111MODULE=on go
-GO_PATH = $(shell $(GO) env GOPATH)
-GO_BUILD = $(GO) build
-GO_TEST = $(GO) test
-GO_LINT = $(GO_PATH)/bin/golangci-lint
-GO_BUILD_LDFLAGS = -X main.version=$(VERSION)
-
-PLATFORMS := windows linux darwin
-os = $(word 1, $@)
-ARCH = amd64
-
-RELEASE_BIN = $(APP)-$(VERSION)-bin
-RELEASE_SRC = $(APP)-$(VERSION)-src
+include scripts/base.mk
all: clean lint test build
@@ -73,10 +52,6 @@ $(PLATFORMS):
.PHONY: build
build: windows linux darwin
-.PHONY: docker
-docker:
- docker build . -t $(APP):$(VERSION)
-
.PHONY: clean
clean:
-rm -rf api/skywalking
diff --git a/README.md b/README.md
index edc4ef4..eccc635 100644
--- a/README.md
+++ b/README.md
@@ -15,19 +15,31 @@ with the system metrics and thus gives you an overview about how the metrics are
Configurations are in YAML format, or config map if running inside Kubernetes,
otherwise, [the default configuration file](assets/default-config.yaml) will be used if there is neither `-c` option
-specified in the command line interface nor config map is created in Kubernetes.
+specified in the command line interface nor config map created in Kubernetes.
All available configuration items and their documentations can be found
in [the default configuration file](assets/default-config.yaml).
## Deployments
-Go to [the /deployments](deployments) directory, modify according to your needs,
-and `kubectl apply -f skywalking-kubernetes-event-exporter.yaml`.
+Go to [the /deployments/release](deployments/release) directory, modify according to your needs, and
+run `kustomize build | kubectl apply -f -`.
You can also simply run `skywalking-kubernetes-event-exporter start` in command line interface to run this exporter from
outside of Kubernetes.
+## Build and Test
+
+In order to build and test the exporter before an Apache official release, you need set a Docker registry where you can
+push the images, do this by `export HUB=<your-docker-hub-registry>`, and then run `make -C build/package/docker push`
+to build and push the Docker images, finally, run `make -C deployments/dev deploy` to deploy the exporter.
+
+```shell
+export HUB=<your-docker-hub-registry>
+make -C build/package/docker push
+make -C deployments/dev deploy
+```
+
# Download
Go to the [download page](https://skywalking.apache.org/downloads/) to download all available binaries, including macOS,
diff --git a/assets/default-config.yaml b/assets/default-config.yaml
index 9ca1771..11bde2a 100644
--- a/assets/default-config.yaml
+++ b/assets/default-config.yaml
@@ -30,10 +30,11 @@ filters:
exporters: # defines and configures the exporters that can be used in the `filters` section above.
skywalking: # the exporter name, which is declared in the struct type `Exporter`'s Name function.
- template: # exporter-specific configurations, different exporter may have different configuration contents.
+ # Below are exporter-specific configurations, different exporter may have different configuration contents.
+ template: # the event template of SkyWalking exporter, it can be composed of metadata like Event, Pod, and Service.
source:
service: "{{ .Service.Name }}"
serviceInstance: "{{ .Pod.Name }}"
endpoint: ""
message: "{{ .Event.Message }}" # this is default, just to demonstrate the context
- address: "127.0.0.1:11800"
+ address: "127.0.0.1:11800" # the SkyWalking backend address where this exporter will export to.
diff --git a/.github/workflows/build-and-test.yaml b/build/package/docker/Dockerfile
similarity index 55%
copy from .github/workflows/build-and-test.yaml
copy to build/package/docker/Dockerfile
index 7f2913f..d3908e1 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/build/package/docker/Dockerfile
@@ -5,9 +5,9 @@
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,39 +16,25 @@
# under the License.
#
-name: Check
-
-on:
- pull_request:
-
-jobs:
- build-and-test:
- name: Build and Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: true
-
- - uses: actions/setup-go@v2
- with:
- go-version: 1.16
-
- - name: Check License
- uses: apache/skywalking-eyes@main
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Test
- run: make test
-
- - name: Build
- run: make
-
- gateway:
- name: Gateway
- runs-on: ubuntu-latest
- steps:
- - run: echo "Just to make the check statuses passed"
- needs:
- - build-and-test
+# In order to build the Docker image, go to the root directory of this repo, and run
+# make docker
+
+FROM golang:1.16-alpine AS build
+
+WORKDIR /skywalking
+
+ARG VERSION=latest
+
+COPY go.* .
+
+RUN go mod download
+
+COPY .. .
+
+RUN apk add --no-cache make && VERSION=$VERSION make linux
+
+FROM alpine:3
+
+COPY --from=build /skywalking/bin/linux/skywalking-kubernetes-event-exporter /skywalking-kubernetes-event-exporter
+
+ENTRYPOINT ["/skywalking-kubernetes-event-exporter", "start"]
diff --git a/.github/workflows/build-and-test.yaml b/build/package/docker/Makefile
similarity index 55%
copy from .github/workflows/build-and-test.yaml
copy to build/package/docker/Makefile
index 7f2913f..26a80b0 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/build/package/docker/Makefile
@@ -5,9 +5,9 @@
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,39 +16,15 @@
# under the License.
#
-name: Check
-
-on:
- pull_request:
-
-jobs:
- build-and-test:
- name: Build and Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: true
-
- - uses: actions/setup-go@v2
- with:
- go-version: 1.16
-
- - name: Check License
- uses: apache/skywalking-eyes@main
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+include ../../../scripts/base.mk
- - name: Test
- run: make test
+all: build
- - name: Build
- run: make
+.PHONY: build
+build:
+ cd ../../.. ; \
+ docker build --build-arg VERSION=$(VERSION) . -f build/package/docker/Dockerfile -t $(HUB)/$(APP):$(VERSION)
- gateway:
- name: Gateway
- runs-on: ubuntu-latest
- steps:
- - run: echo "Just to make the check statuses passed"
- needs:
- - build-and-test
+.PHONY: push
+push: build
+ docker push $(HUB)/$(APP):$(VERSION)
diff --git a/deployments/base/cluster-role-binding.yaml b/deployments/base/cluster-role-binding.yaml
new file mode 100644
index 0000000..266c8b0
--- /dev/null
+++ b/deployments/base/cluster-role-binding.yaml
@@ -0,0 +1,32 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+ name: skywalking-event-exporter
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: view
+subjects:
+ - kind: ServiceAccount
+ name: skywalking-event-exporter
+ namespace: default
diff --git a/deployments/base/deployment.yaml b/deployments/base/deployment.yaml
new file mode 100644
index 0000000..fab2b61
--- /dev/null
+++ b/deployments/base/deployment.yaml
@@ -0,0 +1,52 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: skywalking-event-exporter
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: skywalking-event-exporter
+ version: v1
+ spec:
+ serviceAccountName: skywalking-event-exporter
+ containers:
+ - name: skywalking-event-exporter
+ image: skywalking-event-exporter
+ imagePullPolicy: Always
+ args:
+ - start
+ - -v=debug
+ - -c=/data/config.yaml
+ volumeMounts:
+ - mountPath: /data
+ name: config
+ volumes:
+ - name: config
+ configMap:
+ name: skywalking-event-exporter-cm
+ selector:
+ matchLabels:
+ app: skywalking-event-exporter
+ version: v1
diff --git a/deployments/base/kustomization.yaml b/deployments/base/kustomization.yaml
new file mode 100644
index 0000000..9c723d5
--- /dev/null
+++ b/deployments/base/kustomization.yaml
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+resources:
+ - cluster-role-binding.yaml
+ - deployment.yaml
+ - namespace.yaml
+ - service-account.yaml
diff --git a/deployments/base/namespace.yaml b/deployments/base/namespace.yaml
new file mode 100644
index 0000000..6b0243c
--- /dev/null
+++ b/deployments/base/namespace.yaml
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+---
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: monitoring
diff --git a/deployments/base/service-account.yaml b/deployments/base/service-account.yaml
new file mode 100644
index 0000000..8a5efeb
--- /dev/null
+++ b/deployments/base/service-account.yaml
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: skywalking-event-exporter
diff --git a/.github/workflows/build-and-test.yaml b/deployments/dev/Makefile
similarity index 55%
copy from .github/workflows/build-and-test.yaml
copy to deployments/dev/Makefile
index 7f2913f..5d45369 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/deployments/dev/Makefile
@@ -16,39 +16,16 @@
# under the License.
#
-name: Check
+include ../../scripts/base.mk
-on:
- pull_request:
+all: deploy
-jobs:
- build-and-test:
- name: Build and Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: true
+.PHONY: deploy
+deploy:
+ kustomize edit set image "skywalking-event-exporter=$(HUB)/$(APP):$(VERSION)"
+ kustomize build | kubectl apply -f -
- - uses: actions/setup-go@v2
- with:
- go-version: 1.16
-
- - name: Check License
- uses: apache/skywalking-eyes@main
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Test
- run: make test
-
- - name: Build
- run: make
-
- gateway:
- name: Gateway
- runs-on: ubuntu-latest
- steps:
- - run: echo "Just to make the check statuses passed"
- needs:
- - build-and-test
+.PHONY: undeploy
+undeploy:
+ kustomize edit set image "skywalking-event-exporter=$(HUB)/$(APP):$(VERSION)"
+ kustomize build | kubectl delete -f -
diff --git a/deployments/dev/config/config.yaml b/deployments/dev/config/config.yaml
new file mode 100644
index 0000000..98b122c
--- /dev/null
+++ b/deployments/dev/config/config.yaml
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+filters:
+ - namespace: istio-system
+ exporters:
+ - skywalking
+
+exporters:
+ skywalking:
+ template:
+ source:
+ service: "{{ .Service.Name }}"
+ serviceInstance: "{{ .Pod.Name }}"
+ endpoint: ""
+ message: "{{ .Event.Message }}" # this is default, just to demonstrate the context
+ address: "skywalking-oap.istio-system:11800"
diff --git a/deployments/dev/kustomization.yaml b/deployments/dev/kustomization.yaml
new file mode 100644
index 0000000..cbd8085
--- /dev/null
+++ b/deployments/dev/kustomization.yaml
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+resources:
+- ../base
+
+namespace: monitoring
+
+configMapGenerator:
+- files:
+ - config.yaml=config/config.yaml
+ name: skywalking-event-exporter-cm
+
+generatorOptions:
+ disableNameSuffixHash: true
+images:
+- name: skywalking-event-exporter
+ newName: kezhenxu94/skywalking-kubernetes-event-exporter
+ newTag: 58c1342
diff --git a/deployments/release/config/config.yaml b/deployments/release/config/config.yaml
new file mode 100644
index 0000000..d44ba59
--- /dev/null
+++ b/deployments/release/config/config.yaml
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+filters:
+ - namespace: istio-system
+ exporters:
+ - skywalking
+
+exporters:
+ skywalking:
+ template:
+ source:
+ service: "{{ .Service.Name }}"
+ serviceInstance: "{{ .Pod.Name }}"
+ endpoint: ""
+ message: "{{ .Event.Message }}"
+ address: "skywalking-oap.istio-system:11800"
diff --git a/deployments/release/kustomization.yaml b/deployments/release/kustomization.yaml
new file mode 100644
index 0000000..06404f9
--- /dev/null
+++ b/deployments/release/kustomization.yaml
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+resources:
+ - ../base
+
+namespace: monitoring
+
+configMapGenerator:
+ - files:
+ - config.yaml=config/config.yaml
+ name: skywalking-event-exporter-cm
+
+generatorOptions:
+ disableNameSuffixHash: true
+images:
+ - name: skywalking-event-exporter
+ newName: apache/skywalking-kubernetes-event-exporter
+ newTag: latest
diff --git a/pkg/k8s/registry.go b/pkg/k8s/registry.go
index a1caea5..cdf6760 100644
--- a/pkg/k8s/registry.go
+++ b/pkg/k8s/registry.go
@@ -140,6 +140,13 @@ func (r *registry) GetContext(e *corev1.Event) TemplateContext {
result.Service = r.idSvcMap[svcID]
}
+ if result.Pod == nil {
+ result.Pod = &corev1.Pod{}
+ }
+ if result.Service == nil {
+ result.Service = &corev1.Service{}
+ }
+
return result
}
diff --git a/.github/workflows/build-and-test.yaml b/scripts/base.mk
similarity index 55%
copy from .github/workflows/build-and-test.yaml
copy to scripts/base.mk
index 7f2913f..02cda63 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/scripts/base.mk
@@ -5,9 +5,9 @@
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,39 +16,23 @@
# under the License.
#
-name: Check
-
-on:
- pull_request:
-
-jobs:
- build-and-test:
- name: Build and Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: true
-
- - uses: actions/setup-go@v2
- with:
- go-version: 1.16
-
- - name: Check License
- uses: apache/skywalking-eyes@main
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Test
- run: make test
-
- - name: Build
- run: make
-
- gateway:
- name: Gateway
- runs-on: ubuntu-latest
- steps:
- - run: echo "Just to make the check statuses passed"
- needs:
- - build-and-test
+HUB ?= docker.io/apache
+APP = skywalking-kubernetes-event-exporter
+VERSION ?= $(shell git rev-parse --short HEAD)
+OUT_DIR = bin
+ARCH := $(shell uname)
+OSNAME := $(if $(findstring Darwin,$(ARCH)),darwin,linux)
+
+GO := GO111MODULE=on go
+GO_PATH = $(shell $(GO) env GOPATH)
+GO_BUILD = $(GO) build
+GO_TEST = $(GO) test
+GO_LINT = $(GO_PATH)/bin/golangci-lint
+GO_BUILD_LDFLAGS = -X main.version=$(VERSION)
+
+PLATFORMS := windows linux darwin
+os = $(word 1, $@)
+ARCH = amd64
+
+RELEASE_BIN = $(APP)-$(VERSION)-bin
+RELEASE_SRC = $(APP)-$(VERSION)-src