-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
96 lines (73 loc) · 3.19 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
# # /bin/sh does not support source command needed in make test
#SHELL := /bin/bash
ROOT_DIR=$(shell git rev-parse --show-toplevel)
# Platforms supported
PLATFORMS ?= linux/amd64,linux/arm64
VERSION ?= 2.2.0
# Image URL to use all building/pushing aerospike-kubernetes-init image targets
IMG ?= aerospike/aerospike-kubernetes-init-nightly:${VERSION}
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
.PHONY: all
all: build
##@ General
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.54.0
.PHONY: golanci-lint
golanci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) $(GOLANGCI_LINT_VERSION)
go-lint: golanci-lint ## Run golangci-lint against code.
$(GOLANGCI_LINT) run
##@ Build
.PHONY: build
build: fmt vet ## Build akoinit binary.
go build -o bin/akoinit main.go
.PHONY: run
run: fmt vet ## Run a akoinit from your host.
go run ./main.go
.PHONY: docker-buildx-build
docker-buildx-build: ## Build docker image for the init container for cross-platform support
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
docker buildx build --load --no-cache --provenance=false --tag ${IMG} --build-arg VERSION=$(VERSION) .
- docker buildx rm project-v3-builder
.PHONY: docker-buildx-build-push
docker-buildx-build-push: ## Build and push docker image for the init container for cross-platform support
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
docker buildx build --push --no-cache --provenance=false --platform=$(PLATFORMS) --tag ${IMG} --build-arg VERSION=$(VERSION) .
- docker buildx rm project-v3-builder
.PHONY: docker-buildx-build-push-openshift
docker-buildx-build-push-openshift: ## Build and push docker image for the init container for openshift cross-platform support
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
docker buildx build --push --no-cache --provenance=false --platform=$(PLATFORMS) --tag ${IMG} --build-arg VERSION=$(VERSION) --build-arg USER=1001 .
- docker buildx rm project-v3-builder
.PHONY: enable-pre-commit
enable-pre-commit:
pip3 install pre-commit
pre-commit install