forked from openshift/aws-account-shredder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
144 lines (113 loc) · 4.26 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 := /usr/bin/env bash
OPERATOR_DOCKERFILE = ./deploy/Dockerfile
REUSE_UUID := $(shell uuidgen | awk -F- '{ print tolower($$2) }')
REUSE_BUCKET_NAME=test-reuse-bucket-${REUSE_UUID}
# Include shared Makefiles
include project.mk
include standard.mk
GOOS := $(if $(GOOS),$(GOOS),linux)
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GO=CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GO111MODULE=on go
GOVERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1)
GOFLAGS ?=
ACCOUNT_CRD_REF=master
export SHREDDER_NAMESPACE=aws-account-shredder
SHRED_ACCOUNT_CR_NAME=aws-shredder-account-delete
ACCOUNT_OPERATOR_NAMESPACE=aws-account-operator
IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)
IMAGE_TAG=latest
.PHONY: check-shred-account-id
check-shred-account-id:
ifndef ACCOUNT_ID_TO_SHRED
$(error ACCOUNT_ID_TO_SHRED is undefined)
endif
.PHONY: check-aws-account-credentials
check-aws-account-credentials: ## Check if AWS Account Env vars are set
ifndef AWS_ACCESS_KEY_ID
$(error AWS_ACCESS_KEY_ID is undefined)
endif
ifndef AWS_SECRET_ACCESS_KEY
$(error AWS_SECRET_ACCESS_KEY is undefined)
endif
## Check, if we are using a kind or crc oc context to avoid making changes to prod envs
only-local-ctx:
hack/get_current_api_url.sh | grep '127.0.0.1\|api.crc.testing'
# Ensure go modules are enabled:
export GOPROXY=https://proxy.golang.org
.PHONY: docker-build
docker-build: build
# Helper functions to improve local testing experience
.PHONY: create-account
create-account: check-shred-account-id
@oc process --local -f hack/templates/aws-shredder-account-delete-template.yaml \
-p NAMESPACE=$(ACCOUNT_OPERATOR_NAMESPACE) \
-p SHRED_ACCOUNT_CR_NAME=$(SHRED_ACCOUNT_CR_NAME) \
-p ACCOUNT_ID_TO_SHRED=$(ACCOUNT_ID_TO_SHRED) | \
oc apply -f -
.PHONY: shred-account
shred-account: only-local-ctx
@osdctl account set $(SHRED_ACCOUNT_CR_NAME) --state=Failed
.PHONY: delete-account
delete-account: only-local-ctx
@oc delete account -n $(ACCOUNT_OPERATOR_NAMESPACE) $(SHRED_ACCOUNT_CR_NAME)
.PHONY: get-logs
get-logs: only-local-ctx
oc logs --follow deployment/aws-account-shredder -n $(SHREDDER_NAMESPACE)
.PHONY: kill-pod
kill-pod: only-local-ctx
workflow/kill_pod.sh
GOLANGCI_LINT_CACHE ?= /tmp/golangci-cache
.PHONY: lint
lint:
GOLANGCI_LINT_CACHE=${GOLANGCI_LINT_CACHE}
-@golangci-lint run
.PHONY: test
test:
@go test ./...
.PHONY: create-account-crd
create-account-crd: only-local-ctx
curl https://raw.githubusercontent.com/openshift/aws-account-operator/$(ACCOUNT_CRD_REF)/deploy/crds/aws.managed.openshift.io_accounts.yaml | oc apply -f -
.PHONY: delete-account-crd
delete-account-crd: only-local-ctx
curl https://raw.githubusercontent.com/openshift/aws-account-operator/$(ACCOUNT_CRD_REF)/deploy/crds/aws.managed.openshift.io_accounts.yaml | oc delete -f - || true
.PHONY: create-shredder-credentials
create-shredder-credentials: only-local-ctx check-aws-account-credentials
hack/create_shredder_credentials.sh
.PHONY: create-namespace
create-namespace: only-local-ctx
@oc create ns $(SHREDDER_NAMESPACE) || true
@oc create ns $(ACCOUNT_OPERATOR_NAMESPACE) || true
.PHONY: delete-namespace
delete-namespace: only-local-ctx
@oc delete ns $(SHREDDER_NAMESPACE) || true
@oc delete ns $(ACCOUNT_OPERATOR_NAMESPACE) || true
.PHONY: predeploy
predeploy: only-local-ctx create-namespace create-account-crd create-shredder-credentials
.PHONY: redeploy
redeploy: only-local-ctx delete-deploy deploy
.PHONY: deploy
deploy: only-local-ctx
@oc process --local \
-f ./deploy/aws-account-shredder-template.yaml \
-p "IMAGE=$(IMAGE)" \
-p "IMAGE_TAG=$(IMAGE_TAG)" \
-p "REPLICAS=1" | \
oc apply -n "$(SHREDDER_NAMESPACE)" -f -
@oc process --local \
-f ./deploy/aws-account-operator-template.yaml \
-p "SHREDDER_NAMESPACE=$(SHREDDER_NAMESPACE)" | \
oc apply -n "$(ACCOUNT_OPERATOR_NAMESPACE)" -f -
.PHONY: delete-deploy
delete-deploy: only-local-ctx
@oc process --local \
-f ./deploy/aws-account-shredder-template.yaml \
-p "IMAGE=$(IMAGE)" \
-p "IMAGE_TAG=$(IMAGE_TAG)" \
-p "REPLICAS=1" | \
oc delete -n "$(SHREDDER_NAMESPACE)" -f -
@oc process --local \
-f ./deploy/aws-account-operator-template.yaml \
-p "SHREDDER_NAMESPACE=$(SHREDDER_NAMESPACE)" | \
oc delete -n "$(ACCOUNT_OPERATOR_NAMESPACE)" -f -
.PHONY: delete-operator
clean-operator: delete-namespace delete-account-crd