-
Notifications
You must be signed in to change notification settings - Fork 344
/
Makefile
74 lines (57 loc) · 2.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
VERSION_DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
CI_COMMIT_SHA ?= $(shell git rev-parse HEAD)
GO_FLAGS ?= GOOS=linux GOARCH=amd64 CGO_ENABLED=0
KUBERNETES_CONFIG ?= "$(HOME)/.kube/config"
WATCH_NAMESPACE ?= default
BIN_DIR ?= "_output/bin"
OPERATOR_NAME ?= jaeger-operator
NAMESPACE ?= "$(USER)"
BUILD_IMAGE ?= "$(NAMESPACE)/$(OPERATOR_NAME):latest"
OUTPUT_BINARY ?= "$(BIN_DIR)/$(OPERATOR_NAME)"
VERSION_PKG ?= "github.com/jaegertracing/jaeger-operator/pkg/version"
JAEGER_VERSION ?= "$(shell grep -v '\#' jaeger.version)"
LD_FLAGS ?= "-X $(VERSION_PKG).commit=$(CI_COMMIT_SHA) -X $(VERSION_PKG).buildDate=$(VERSION_DATE) -X $(VERSION_PKG).defaultJaeger=$(JAEGER_VERSION)"
PACKAGES := $(shell go list ./cmd/... ./pkg/...)
.DEFAULT_GOAL := build
check:
@echo Checking...
@$(foreach file, $(shell go fmt $(PACKAGES) 2>&1), echo "Some files need formatting. Failing." || exit 1)
format:
@echo Formatting code...
@go fmt $(PACKAGES)
lint:
@echo Linting...
@golint $(PACKAGES)
@gosec -quiet -exclude=G104 $(PACKAGES) 2>/dev/null
build: format
@echo Building...
@${GO_FLAGS} go build -o $(OUTPUT_BINARY) -ldflags $(LD_FLAGS)
docker:
@docker build -t "$(BUILD_IMAGE)" .
push:
@echo Pushing image $(BUILD_IMAGE)...
@docker push $(BUILD_IMAGE) > /dev/null
unit-tests:
@echo Running unit tests...
@go test $(PACKAGES) -cover -coverprofile=cover.out
e2e-tests: es crd build docker push
@echo Running end-to-end tests...
@cp deploy/rbac.yaml deploy/test/namespace-manifests.yaml
@echo "---" >> deploy/test/namespace-manifests.yaml
@cat deploy/operator.yaml | sed "s~image: jaegertracing\/jaeger-operator\:.*~image: $(BUILD_IMAGE)~gi" >> deploy/test/namespace-manifests.yaml
@go test ./test/e2e/... -kubeconfig $(KUBERNETES_CONFIG) -namespacedMan ../../deploy/test/namespace-manifests.yaml -globalMan ../../deploy/crd.yaml -root .
run: crd
@OPERATOR_NAME=$(OPERATOR_NAME) KUBERNETES_CONFIG=$(KUBERNETES_CONFIG) WATCH_NAMESPACE=$(WATCH_NAMESPACE) go run main.go start
es:
@kubectl create -f ./test/elasticsearch.yml 2>&1 | grep -v "already exists" || true
crd:
@kubectl create -f deploy/crd.yaml 2>&1 | grep -v "already exists" || true
ingress:
# see https://kubernetes.github.io/ingress-nginx/deploy/#verify-installation
@kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.18.0/deploy/mandatory.yaml
@minikube addons enable ingress
generate:
@operator-sdk generate k8s
test: unit-tests e2e-tests
all: check format lint build test
ci: check format lint build unit-tests