-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
73 lines (57 loc) · 1.79 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
SHELL := /bin/bash
GO := GO15VENDOREXPERIMENT=1 go
NAME := sso-operator
OS := $(shell uname)
MAIN_GO := main.go
ROOT_PACKAGE := $(GIT_PROVIDER)/$(ORG)/$(NAME)
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/)
PKGS := $(shell go list ./... | grep -v /vendor | grep -v generated)
PKGS := $(subst :,_,$(PKGS))
BUILDFLAGS := ''
CGO_ENABLED = 0
VENDOR_DIR=vendor
all: bootstrap fmt lint sec test build
DEP := $(GOPATH)/bin/dep
$(DEP):
go get -u github.com/golang/dep/cmd/dep
bootstrap: $(DEP)
@echo "INSTALLING DEPENDENCIES"
$(DEP) ensure
build:
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
test:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v
install:
GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO)
fmt:
@echo "FORMATTING"
@FORMATTED=`$(GO) fmt $(PACKAGE_DIRS)`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
clean:
rm -rf build release $(VENDOR_DIR)
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
go get -u github.com/golang/lint/golint
.PHONY: lint
lint: $(GOLINT)
@echo "VETTING"
go vet $(go list ./... | grep -v /vendor/)
@echo "LINTING"
$(GOLINT) -set_exit_status $(shell go list ./... | grep -v vendor)
GOSEC := $(GOPATH)/bin/gosec
$(GOSEC):
go get -u github.com/securego/gosec/cmd/gosec/...
.PHONY: sec
sec: $(GOSEC)
@echo "SECURITY SCANNING"
$(GOSEC) -fmt=csv ./...
codegen:
@echo "GENERATING KUBERNETES CRDs"
hack/update-codegen.sh
linux:
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
watch:
reflex -r "\.go$" -R "vendor.*" make skaffold-run
install-helm: linux
skaffold run -p install -n $(KUBERNETES_NAMESPACE)