-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
193 lines (145 loc) · 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#----------------------------------------------------------------------------------
# Base
#----------------------------------------------------------------------------------
ROOTDIR := $(shell pwd)
OUTPUT_DIR ?= $(ROOTDIR)/_output
SOURCES := $(shell find . -name "*.go" | grep -v test.go | grep -v '\.\#*')
RELEASE := "true"
ifeq ($(TAGGED_VERSION),)
# TAGGED_VERSION := $(shell git describe --tags)
# This doesn't work in CI, need to find another way...
TAGGED_VERSION := vdev
RELEASE := "false"
endif
VERSION ?= $(shell echo $(TAGGED_VERSION) | cut -c 2-)
LDFLAGS := "-X github.com/solo-io/sqoop/version.Version=$(VERSION)"
GCFLAGS := all="-N -l"
#----------------------------------------------------------------------------------
# Repo setup
#----------------------------------------------------------------------------------
# https://www.viget.com/articles/two-ways-to-share-git-hooks-with-your-team/
.PHONY: init
init:
git config core.hooksPath .githooks
.PHONY: update-deps
update-deps:
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/gogo/protobuf/gogoproto
go get -u github.com/gogo/protobuf/protoc-gen-gogo
go get -u github.com/envoyproxy/protoc-gen-validate
go get -u github.com/paulvollmer/2gobytes
.PHONY: pin-repos
pin-repos:
go run ci/pin_repos.go
.PHONY: check-format
check-format:
NOT_FORMATTED=$$(gofmt -l ./pkg/ ./test/) && if [ -n "$$NOT_FORMATTED" ]; then echo These files are not formatted: $$NOT_FORMATTED; exit 1; fi
check-spelling:
./ci/spell.sh check
.PHONY: generated-code
generated-code: $(OUTPUT_DIR)/.generated-code
SUBDIRS:=pkg cmd
$(OUTPUT_DIR)/.generated-code:
SKIP_MOCK_GEN=1 go generate ./...
(rm -f docs/cli/sqoopctl*; go run cli/cmd/docs/main.go)
gofmt -w $(SUBDIRS)
goimports -w $(SUBDIRS)
mkdir -p $(OUTPUT_DIR)
touch $@
#----------------------------------------------------------------------------------
# Clean
#----------------------------------------------------------------------------------
# Important to clean before pushing new releases. Dockerfiles and binaries may not update properly
.PHONY: clean
clean:
rm -rf _output
rm -fr site
#----------------------------------------------------------------------------------
# sqoop
#----------------------------------------------------------------------------------
SQOOP_DIR=.
SQOOP_SOURCES=$(call get_sources,$(SQOOP_DIR))
$(OUTPUT_DIR)/sqoop-linux-amd64: $(SQOOP_SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(SQOOP_DIR)/cmd/main.go
.PHONY: sqoop
sqoop: $(OUTPUT_DIR)/sqoop-linux-amd64
$(OUTPUT_DIR)/Dockerfile.sqoop: $(SQOOP_DIR)/cmd/Dockerfile
cp $< $@
sqoop-docker: $(OUTPUT_DIR)/sqoop-linux-amd64 $(OUTPUT_DIR)/Dockerfile.sqoop
docker build -t soloio/sqoop:$(VERSION) $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.sqoop
#----------------------------------------------------------------------------------
# Deployment Manifests / Helm
#----------------------------------------------------------------------------------
HELM_SYNC_DIR := $(OUTPUT_DIR)/helm
HELM_DIR := install/helm
MANIFEST_DIR := install/manifest
.PHONY: manifest
manifest: helm-template init-helm install/manifest/sqoop.yaml update-helm-chart
# creates Chart.yaml, values.yaml, and requirements.yaml
.PHONY: helm-template
helm-template:
mkdir -p $(MANIFEST_DIR)
go run install/helm/sqoop/generate.go $(VERSION)
update-helm-chart:
ifeq ($(RELEASE),"true")
mkdir -p $(HELM_SYNC_DIR)/charts
helm package --destination $(HELM_SYNC_DIR)/charts $(HELM_DIR)/sqoop
helm repo index $(HELM_SYNC_DIR)
endif
install/manifest/sqoop.yaml: helm-template
helm template install/helm/sqoop --namespace gloo-system --name=sqoop > $@
init-helm:
helm repo add gloo https://storage.googleapis.com/solo-public-helm
helm dependency update install/helm/sqoop
#----------------------------------------------------------------------------------
# sqoopctl
#----------------------------------------------------------------------------------
CLI_DIR=cli
$(OUTPUT_DIR)/sqoopctl: $(SOURCES)
go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/sqoopctl-linux-amd64: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/sqoopctl-darwin-amd64: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/sqoopctl-windows-amd64.exe: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
.PHONY: sqoopctl
sqoopctl: $(OUTPUT_DIR)/sqoopctl
.PHONY: sqoopctl-linux-amd64
sqoopctl-linux-amd64: $(OUTPUT_DIR)/sqoopctl-linux-amd64
.PHONY: sqoopctl-darwin-amd64
sqoopctl-darwin-amd64: $(OUTPUT_DIR)/sqoopctl-darwin-amd64
.PHONY: sqoopctl-windows-amd64
sqoopctl-windows-amd64: $(OUTPUT_DIR)/sqoopctl-windows-amd64.exe
#----------------------------------------------------------------------------------
# Release
#----------------------------------------------------------------------------------
.PHONY: build-cli
build-cli: sqoopctl-linux-amd64 sqoopctl-darwin-amd64 sqoopctl-windows-amd64
.PHONY: upload-github-release-assets
upload-github-release-assets:
go run ci/upload_github_release_assets.go
.PHONY: push-docs
push-docs:
go run ci/push_docs.go
#----------------------------------------------------------------------------------
# Docker
#----------------------------------------------------------------------------------
#
#---------
#--------- Push
#---------
DOCKER_IMAGES :=
ifeq ($(RELEASE),"true")
DOCKER_IMAGES := docker
endif
.PHONY: docker docker-push
docker: sqoop-docker
# Depends on DOCKER_IMAGES, which is set to docker if RELEASE is "true", otherwise empty (making this a no-op).
# This prevents executing the dependent targets if RELEASE is not true, while still enabling `make docker`
# to be used for local testing.
# docker-push is intended to be run by CI
docker-push: $(DOCKER_IMAGES)
ifeq ($(RELEASE),"true")
docker push soloio/sqoop:$(VERSION)
endif