Skip to content

Commit

Permalink
refactor(V1.0):refactor the overall structure (#43)
Browse files Browse the repository at this point in the history
* update vendor

* update Makefile

* chore(*):remove obsolete files

* refactor(deploy):refactor the deploy.yml

* feat(metrics):add more metrics

* refactor(collector):refactor the collector

* feat(utils):add test and signal utils

* chore(*):update README.md and OWNERS

* feat(*):upgrade golang image to 1.13-security

* update Makefile to set CGO_ENABLED=0

* update Dockerfile to use static image

* fix(Dockerfile):use standard image

* fix(test):disabled prometheus test lint

* fix(metric):rename build info metric

* fix(*):reduce factory resync duration

* fix(*):adjust description

* fix(Dockerfile):use public image

* fix(*):unified image name
  • Loading branch information
seymourtang committed Nov 2, 2020
1 parent cecd02f commit b7605b3
Show file tree
Hide file tree
Showing 799 changed files with 102,114 additions and 114,503 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
event_exporter
/bin/
/coverage.out
75 changes: 54 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,74 @@ COMMIT = $(shell git rev-parse HEAD)
BRANCH = $(shell git branch | grep \* | cut -d ' ' -f2)
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')


# It's necessary to set the errexit flags for the bash shell.
export SHELLOPTS := errexit

# This will force go to use the vendor files instead of using the `$GOPATH/pkg/mod`. (vendor mode)
# more info: https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away
export GOFLAGS := -mod=vendor

# this is not a public registry; change it to your own
REGISTRY ?= cargo.dev.caicloud.xyz/release
BASE_REGISTRY ?= cargo.caicloud.xyz/library

ARCH ?= amd64
GO_VERSION = 1.13
GO_VERSION ?= 1.13

CPUS ?= $(shell /bin/bash hack/read_cpus_available.sh)

# Track code version with Docker Label.
DOCKER_LABELS ?= git-describe="$(shell date -u +v%Y%m%d)-$(shell git describe --tags --always --dirty)"

GOPATH ?= $(shell go env GOPATH)
BIN_DIR := $(GOPATH)/bin
GOLANGCI_LINT := $(BIN_DIR)/golangci-lint
CMD_DIR := ./cmd
OUTPUT_DIR := ./bin
BUILD_DIR := ./build
.PHONY: lint test build build-local build-linux container push clean

.PHONY: lint test build build-local container push clean

build:
@docker run --rm -t \
-v "${PWD}:/go/src/github.com/caicloud/event_exporter" \
-w /go/src/github.com/caicloud/event_exporter \
golang:${GO_VERSION} make build-local
build: build-local

build-local: clean
@echo ">> building binaries"
@GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) CGO_ENABLED=0 \
go build -mod=vendor -ldflags "-s -w \
-X $(ROOT)/pkg/version.Version=${VERSION} \
-X $(ROOT)/pkg/version.Branch=${BRANCH} \
-X $(ROOT)/pkg/version.Commit=${COMMIT} \
-X $(ROOT)/pkg/version.BuildDate=${BUILD_DATE}" \
-o event_exporter

container: build
@echo ">> building binaries"``
@GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) CGO_ENABLED=0 \
go build -i -v -o $(OUTPUT_DIR)/event_exporter -p $(CPUS) \
-ldflags "-s -w \
-X $(ROOT)/pkg/version.Version=${VERSION} \
-X $(ROOT)/pkg/version.Branch=${BRANCH} \
-X $(ROOT)/pkg/version.Commit=${COMMIT} \
-X $(ROOT)/pkg/version.BuildDate=${BUILD_DATE}" \
$(CMD_DIR)/

build-linux:
@docker run --rm -t \
-v $(PWD):/go/src/$(ROOT) \
-w /go/src/$(ROOT) \
-e GOOS=linux \
-e GOARCH=amd64 \
-e GOPATH=/go \
-e CGO_ENABLED=0 \
-e GOFLAGS=$(GOFLAGS) \
-e SHELLOPTS=$(SHELLOPTS) \
$(BASE_REGISTRY)/golang:$(GO_VERSION) \
/bin/bash -c ' \
go build -i -v -o $(OUTPUT_DIR)/event_exporter -p $(CPUS) \
-ldflags "-s -w \
-X $(ROOT)/pkg/version.Version=${VERSION} \
-X $(ROOT)/pkg/version.Branch=${BRANCH} \
-X $(ROOT)/pkg/version.Commit=${COMMIT} \
-X $(ROOT)/pkg/version.BuildDate=${BUILD_DATE}" \
$(CMD_DIR)/' \

container: build-linux
@echo ">> building image"
@docker build -t $(REGISTRY)/event_exporter:$(VERSION) -f ./Dockerfile .
@docker build -t $(REGISTRY)/event-exporter:$(VERSION) --label $(DOCKER_LABELS) -f $(BUILD_DIR)/Dockerfile .

push: container
@echo ">> pushing image"
@docker push $(REGISTRY)/event_exporter:$(VERSION)
@docker push $(REGISTRY)/event-exporter:$(VERSION)

lint: $(GOLANGCI_LINT)
@echo ">> running golangci-lint"
Expand All @@ -73,4 +105,5 @@ test:

clean:
@echo ">> cleaning up"
@rm -f event_exporter coverage.out
@-rm -vrf ${OUTPUT_DIR}
@rm -f coverage.out
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
approvers:
- supereagle
- lichuan0620
- seymourtang
reviewers:
- supereagle
- lichuan0620
- seymourtang
256 changes: 172 additions & 84 deletions README.md

Large diffs are not rendered by default.

109 changes: 0 additions & 109 deletions backoff.go

This file was deleted.

0 comments on commit b7605b3

Please sign in to comment.