-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
106 lines (84 loc) · 2.73 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
#REGISTRY=quay.io/teiid
REGISTRY?=`whoami`
IMAGE=teiid-operator
TAG?=latest
CRC_REGISTRY=image-registry.openshift-image-registry.svc:5000
QUAY_REPOSITORY?=quay.io/teiid/teiid-operator
IMAGE_NAME=$(REGISTRY)/$(IMAGE):$(TAG)
CRC_IMAGE_NAME=$(CRC_REGISTRY)/`oc project --short`/$(IMAGE):$(TAG)
GO_FLAGS ?= GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on GOROOT=`go env GOROOT`
SDK_VERSION=v0.17.0
GOPATH ?= "$(HOME)/go"
FMT_LOG=fmt.log
.PHONY: all
all: build
.PHONY: vet
vet: sdk-generate
@${GO_FLAGS} go vet ./...
.PHONY: fmt
fmt:
@${GO_FLAGS} gofmt -s -l -w cmd/ pkg/
.PHONY: test
test: vet fmt
GOCACHE=on
@${GO_FLAGS} go test ./...
.PHONY: sdk-generate
sdk-generate:
@${GO_FLAGS} ${GOPATH}/bin/operator-sdk generate k8s
.PHONY: build
build: format test
@echo Building image $(IMAGE_NAME)
go generate ./...
@${GO_FLAGS} ${GOPATH}/bin/operator-sdk build --image-builder buildah $(IMAGE_NAME)
.PHONY: clean
clean:
rm -rf build/_output
./scripts/clean.sh $(IMAGE_NAME)
.PHONY: lint
lint:
scripts/go-lint.sh
images-push:
buildah push $(IMAGE_NAME)
.PHONY: quay-push
quay-push:
buildah push $(IMAGE_NAME) $(QUAY_REPOSITORY):$(TAG)
.PHONY: deploy
deploy: images-push
./scripts/manualDeploy.sh $(IMAGE_NAME) $(CRC_IMAGE_NAME)
.PHONY: install-tools
install-tools:
@${GO_FLAGS} go install \
golang.org/x/lint/golint \
github.com/securego/gosec/cmd/gosec \
golang.org/x/tools/cmd/goimports \
k8s.io/code-generator/cmd/client-gen \
k8s.io/kube-openapi/cmd/openapi-gen
.PHONY: install-sdk
install-sdk:
@echo Installing SDK ${SDK_VERSION}
@SDK_VERSION=$(SDK_VERSION) GOPATH=$(GOPATH) ./scripts/install-sdk.sh
.PHONY: install
install: install-sdk install-tools
.PHONY: ci
ci: install ensure-generate-is-noop check format lint build test
.PHONY: generate
generate: update-connections internal-generate format
.PHONY: update-connections
update-connections:
./scripts/update-connections.sh
.PHONY: internal-generate
internal-generate:
@GOPATH=${GOPATH} ./scripts/generate.sh @${GO_FLAGS}
.PHONY: format
format:
@echo Formatting code...
@GOPATH=${GOPATH} ./scripts/format.sh
.PHONY: ensure-generate-is-noop
ensure-generate-is-noop: generate format
@git diff -s --exit-code pkg/apis/teiid/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@git diff -s --exit-code build/conf/connection_factories.json || (echo "Connection factories is not uptodate. Run 'make generate' and update your PR." && exit 1)
.PHONY: check
check:
@echo Checking...
@GOPATH=${GOPATH} ./scripts/format.sh > $(FMT_LOG)
@[ ! -s "$(FMT_LOG)" ] || (echo "Go fmt, license check, or import ordering failures, run 'make format'" | cat - $(FMT_LOG) && false)