-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (96 loc) · 3.6 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
SHELL := /bin/bash
PROJECT := github.com/jenkins-x/lighthouse
WEBHOOKS_EXECUTABLE := lighthouse
KEEPER_EXECUTABLE := keeper
FOGHORN_EXECUTABLE := foghorn
GCJOBS_EXECUTABLE := gc-jobs
DOCKER_REGISTRY := jenkinsxio
DOCKER_IMAGE_NAME := lighthouse
WEBHOOKS_MAIN_SRC_FILE=cmd/webhooks/main.go
KEEPER_MAIN_SRC_FILE=cmd/keeper/main.go
FOGHORN_MAIN_SRC_FILE=cmd/foghorn/main.go
GCJOBS_MAIN_SRC_FILE=cmd/gc/main.go
GO := GO111MODULE=on go
GO_NOMOD := GO111MODULE=off go
VERSION ?= $(shell echo "$$(git describe --abbrev=0 --tags 2>/dev/null)-dev+$(REV)" | sed 's/^v//')
GO_LDFLAGS := -X $(PROJECT)/pkg/version.Version='$(VERSION)'
GOTEST := $(GO) test
CLIENTSET_GENERATOR_VERSION := kubernetes-1.15.12
all: check test build
.PHONY: test
test:
CGO_ENABLED=$(CGO_ENABLED) $(GOTEST) -short ./...
.PHONY: check
check: fmt lint sec
.PHONY: fmt
fmt:
@echo "FORMATTING"
@FORMATTED=`$(GO) fmt ./...`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
$(GO_NOMOD) get -u golang.org/x/lint/golint
.PHONY: lint
lint: $(GOLINT)
@echo "VETTING"
$(GO) vet ./...
@echo "LINTING"
$(GOLINT) -set_exit_status ./...
GOSEC := $(GOPATH)/bin/gosec
$(GOSEC):
$(GO_NOMOD) get -u github.com/securego/gosec/cmd/gosec
.PHONY: sec
sec: $(GOSEC)
@echo "SECURITY SCANNING"
$(GOSEC) -fmt=csv ./...
.PHONY: clean
clean:
rm -rf bin build release
.PHONY: build
build: webhooks keeper foghorn gc-jobs
.PHONY: webhooks
webhooks:
$(GO) build -i -ldflags "$(GO_LDFLAGS)" -o bin/$(WEBHOOKS_EXECUTABLE) $(WEBHOOKS_MAIN_SRC_FILE)
.PHONY: keeper
keeper:
$(GO) build -i -ldflags "$(GO_LDFLAGS)" -o bin/$(KEEPER_EXECUTABLE) $(KEEPER_MAIN_SRC_FILE)
.PHONY: foghorn
foghorn:
$(GO) build -i -ldflags "$(GO_LDFLAGS)" -o bin/$(FOGHORN_EXECUTABLE) $(FOGHORN_MAIN_SRC_FILE)
.PHONY: gc-jobs
gc-jobs:
$(GO) build -i -ldflags "$(GO_LDFLAGS)" -o bin/$(GCJOBS_EXECUTABLE) $(GCJOBS_MAIN_SRC_FILE)
.PHONY: mod
mod: build
echo "tidying the go module"
$(GO) mod tidy
.PHONY: build-linux
build-linux: build-webhooks-linux build-foghorn-linux build-gc-jobs-linux build-keeper-linux
.PHONY: build-webhooks-linux
build-webhooks-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags "$(GO_LDFLAGS)" -o bin/$(WEBHOOKS_EXECUTABLE) $(WEBHOOKS_MAIN_SRC_FILE)
.PHONY: build-keeper-linux
build-keeper-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags "$(GO_LDFLAGS)" -o bin/$(KEEPER_EXECUTABLE) $(KEEPER_MAIN_SRC_FILE)
.PHONY: build-foghorn-linux
build-foghorn-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags "$(GO_LDFLAGS)" -o bin/$(FOGHORN_EXECUTABLE) $(FOGHORN_MAIN_SRC_FILE)
.PHONY: build-gc-jobs-linux
build-gc-jobs-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags "$(GO_LDFLAGS)" -o bin/$(GCJOBS_EXECUTABLE) $(GCJOBS_MAIN_SRC_FILE)
.PHONY: container
container:
docker-compose build $(DOCKER_IMAGE_NAME)
.PHONY: production-container
production-container:
docker build --rm -t $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME) .
.PHONY: push-container
push-container: production-container
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME)
CODEGEN_BIN := $(GOPATH)/bin/codegen
$(CODEGEN_BIN):
$(GO_NOMOD) get github.com/jenkins-x/jx/cmd/codegen
generate-client: codegen-clientset fmt ## Generate the client
codegen-clientset: $(CODEGEN_BIN) ## Generate the k8s types and clients
@echo "Generating Kubernetes Clients for pkg/apis/lighthouse/v1alpha1 in pkg/client for lighthouse.jenkins.io:v1alpha1"
$(CODEGEN_BIN) --generator-version $(CLIENTSET_GENERATOR_VERSION) clientset --output-package=pkg/client --input-package=pkg/apis --group-with-version=lighthouse:v1alpha1