This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathMakefile
151 lines (116 loc) · 4.25 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
# Copyright (c) 2018 VMware Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The binary to build (just the basename).
BIN := controller
# This repo's root import path (under GOPATH)
PRO := github.com/vmware/purser
DEP := vendor
BUILD := build
PKG := pkg
CMD := cmd/controller
# Where to push the docker image.
REGISTRY?=docker.io
DOCKER_REPO?=kreddyj
# Which architecture to build - see $(ALL_ARCH) for options.
ARCH?= amd64
# This version-strategy uses a manual value to set the version string
VERSION := controller-1.0.2
###
### These variables should not need tweaking.
###
ALL_ARCH := amd64 arm arm64 ppc64le
BASEIMAGE?=photon
BUILD_IMAGE?=golang:1.11
DOCKER_MOUNT_MODE=delegated
# Set dep management tool parameters
VENDOR_DIR := vendor
DEP_BIN_NAME := dep
DEP_BIN_DIR := ./tmp/bin
DEP_BIN := $(DEP_BIN_DIR)/$(DEP_BIN_NAME)
DEP_VERSION := v0.5.0
# Define and get the vakue for UNAME_S variable from shell
UNAME_S := $(shell uname -s)
.PHONY: travis-build
travis-build: install-plugin install-controller travis-success
.PHONY: install-plugin
install-plugin:
go install github.com/vmware/purser/cmd/plugin
.PHONY: install-controller
install-controller: build container
.PHONY: travis-success
travis-success:
@echo "travis build success"
# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
# If you want to build AND push all containers, see the 'all-push' rule.
.PHONY: all
all: deps build check
build-%:
@$(MAKE) --no-print-directory ARCH=$* build
container-%:
@$(MAKE) --no-print-directory ARCH=$* container
push-%:
@$(MAKE) --no-print-directory ARCH=$* push
.PHONY: all-build
all-build: $(addprefix build-, $(ALL_ARCH))
.PHONY: all-container
all-container: $(addprefix container-, $(ALL_ARCH))
.PHONY: all-push
all-push: $(addprefix push-, $(ALL_ARCH))
.PHONY: deps
## Download build dependencies.
deps: $(DEP_BIN) $(VENDOR_DIR)
# install dep in a the tmp/bin dir of the repo
$(DEP_BIN):
@echo "Installing 'dep' $(DEP_VERSION) at '$(DEP_BIN_DIR)'..."
mkdir -p $(DEP_BIN_DIR)
ifeq ($(UNAME_S),Darwin)
@curl -L -s https://github.com/golang/dep/releases/download/$(DEP_VERSION)/dep-darwin-amd64 -o $(DEP_BIN)
@cd $(DEP_BIN_DIR) && \
echo "1a7bdb0d6c31ecba8b3fd213a1170adf707657123e89dff234871af9e0498be2 dep" > dep-darwin-amd64.sha256 && \
shasum -a 256 --check dep-darwin-amd64.sha256
else
@curl -L -s https://github.com/golang/dep/releases/download/$(DEP_VERSION)/dep-linux-amd64 -o $(DEP_BIN)
@cd $(DEP_BIN_DIR) && \
echo "287b08291e14f1fae8ba44374b26a2b12eb941af3497ed0ca649253e21ba2f83 dep" > dep-linux-amd64.sha256 && \
sha256sum -c dep-linux-amd64.sha256
endif
@chmod +x $(DEP_BIN)
$(VENDOR_DIR): Gopkg.toml Gopkg.lock
@echo "checking dependencies..."
@$(DEP_BIN) ensure -v
.PHONY: install
install: ## Fetches all dependencies using dep
@$(DEP_BIN) ensure -v
.PHONY: update
update: ## Updates all dependencies defined for dep
@$(DEP_BIN) ensure -update -v
include ./.make/Makefile.deploy.controller
include ./.make/Makefile.deploy.purser
.PHONY: version
version:
@echo $(VERSION)
.PHONY: clean-vendor ## Removes the ./vendor directory.
clean-vendor:
-rm -rf $(VENDOR_DIR)
GOFORMAT_FILES := $(shell find . -name '*.go' | grep -v /vendor/)
.PHONY: format ## Formats any go file that differs from gofmt's style and removes unused imports
format:
@gofmt -s -l -w ${GOFORMAT_FILES}
@goimports -l -w ${GOFORMAT_FILES}
.PHONY: tools
tools: ## Installs required go tools
@go get -u github.com/alecthomas/gometalinter && gometalinter --install
@go get -u golang.org/x/tools/cmd/goimports
.PHONY: check
check: ## Concurrently runs a whole bunch of static analysis tools
gometalinter --enable=misspell --enable-gc --vendor --deadline 300s ./...