forked from isindir/sops-secrets-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
144 lines (122 loc) · 3.42 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
SHELL := /bin/bash
GO := GO15VENDOREXPERIMENT=1 GO111MODULE=on GOPROXY=https://proxy.golang.org go
IMAGE_NAME?="isindir/sops-secrets-operator"
SDK_IMAGE_NAME?="isindir/sdk"
VERSION?=$(shell awk 'BEGIN { FS=" = " } $$0~/Version = / \
{ gsub(/"/, ""); print $$2; }' version/version.go)
BUILD:=`git rev-parse HEAD`
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
all: clean gen mod fmt check test inspect build
.PHONY: repo-tag
## repo-tag: tags git repository with latest version
repo-tag:
@git tag -a ${VERSION} -m "sops-secrets-operator ${VERSION}"
.PHONY: release
## release: builds operator docker image and pushes it to docker repository
release: build push
.PHONY: mod
## mod: fetches dependencies
mod:
@echo "Go Mod Vendor"
$(GO) mod tidy
$(GO) mod vendor
@echo
.PHONY: echo
## echo: prints image name and version of the operator
echo:
@echo "${IMAGE_NAME}:${VERSION}"
@echo "${BUILD}"
.PHONY: clean
## clean: removes build artifacts from source code
clean:
@echo "Cleaning"
@rm -fr build/_output
@rm -fr vendor
@echo
.PHONY: inspect
## inspect: inspects remote docker 'image tag' - target fails if it does
inspect:
@echo "Inspect remote image"
@! DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest inspect ${IMAGE_NAME}:${VERSION} >/dev/null \
|| { echo "Image already exists"; exit 1; }
.PHONY: build
## build: builds operator docker image
build:
@echo "Building"
@operator-sdk build "${IMAGE_NAME}:${VERSION}"
@docker tag "${IMAGE_NAME}:${VERSION}" "${IMAGE_NAME}:latest"
@echo
.PHONY: build/sdk
## build/sdk: builds sdk docker image (not used)
build/sdk:
@echo "Building sdk image"
@docker build .circleci -t "${SDK_IMAGE_NAME}"
@echo
.PHONY: push
## push: pushes operator docker image to repository
push:
@echo "Pushing"
@docker push "${IMAGE_NAME}:latest"
@docker push "${IMAGE_NAME}:${VERSION}"
@echo
.PHONY: push/sdk
## push/sdk: pushes sdk docker image to repository
push/sdk:
@echo "Pushing"
@docker push "${SDK_IMAGE_NAME}"
@echo
.PHONY: gen
## gen: generates automated code
gen:
@echo "Generating"
@operator-sdk generate k8s
@echo
.PHONY: fmt
## fmt: formats go code
fmt:
@echo "Formatting"
@gofmt -l -w $(SRC)
@echo
.PHONY: check
## check: runs linting
check:
@echo "Linting"
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
@echo
.PHONY: test/unit
## test/unit: runs unit tests
test/unit:
@echo "Running unit tests"
$(GO) test -count=1 -short ./pkg/controller/...
@echo
.PHONY: test/e2e
## test/e2e: runs e2e tests
test/e2e:
@echo "Running e2e tests"
@operator-sdk test local ./test/e2e --up-local --namespace sops
@echo
.PHONY: test/operator
## test/operator: runs following make targets - fmt check test/unit test/e2e
test/operator: fmt check test/unit test/e2e
.PHONY: test
## test: placeholder to run unit and e2e tests
test: test/operator
@echo "TODO: Write some usefull unit and e2e tests"
@echo
.PHONY: run/local
## run/local: runs operator in local mode
run/local:
@OPERATOR_NAME=sops-secrets-operator operator-sdk up local --namespace=sops
.PHONY: run/sdk
## run/sdk: runs sdk docker image
run/sdk:
@docker run -v ~/.gitconfig:/root/.gitconfig \
-v ~/.gnupg:/root/.gnupg \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${PWD}:/go/src/github.com/isindir/sops-secrets-operator \
-ti "${SDK_IMAGE_NAME}" bash
.PHONY: help
## help: prints this help message
help:
@echo "Usage:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'