This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
75 lines (55 loc) · 2 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
# Set the shell to bash always
SHELL := /bin/bash
# Options
ORG_NAME=crossplane
PROVIDER_NAME=terraform-provider-runtime
# Package setup
PACKAGE=package
export PACKAGE
PACKAGE_REGISTRY=$(PACKAGE)/.registry
PACKAGE_REGISTRY_SOURCE=config/package/manifests
build: generate build-package test
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o ./bin/$(PROVIDER_NAME)-controller cmd/provider/main.go
image: generate build-package test
docker build . -t $(ORG_NAME)/$(PROVIDER_NAME):latest -f cluster/Dockerfile
image-push:
docker push $(ORG_NAME)/$(PROVIDER_NAME):latest
install:
kubectl apply -f config/package/sample/install.package.yaml
install-local: image
docker tag $(ORG_NAME)/$(PROVIDER_NAME):latest $(PROVIDER_NAME):local
$(KIND) load docker-image $(PROVIDER_NAME):local
kubectl apply -f config/package/sample/local.install.package.yaml
run: generate
kubectl apply -f config/crd/ -R
go run cmd/provider/main.go -d
all: image image-push install
generate:
go generate ./...
tidy:
go mod tidy
test:
go test -v ./...
# ====================================================================================
# Package related targets
# Initialize the package folder
$(PACKAGE_REGISTRY):
@mkdir -p $(PACKAGE_REGISTRY)/resources
@touch $(PACKAGE_REGISTRY)/app.yaml $(PACKAGE_REGISTRY)/install.yaml
CRD_DIR=config/crd
build-package: clean $(PACKAGE_REGISTRY)
# Copy CRDs over
@find $(CRD_DIR) -type f -name '*.yaml' | \
while read filename ; do mkdir -p $(PACKAGE_REGISTRY)/resources/$$(basename $${filename%_*});\
concise=$${filename#*_}; \
cat $$filename > \
$(PACKAGE_REGISTRY)/resources/$$( basename $${filename%_*} )/$$( basename $${concise/.yaml/.crd.yaml} ) \
; done
@cp -r $(PACKAGE_REGISTRY_SOURCE)/* $(PACKAGE_REGISTRY)
clean: clean-package
clean-package:
@rm -rf $(PACKAGE)
# ====================================================================================
# Tools
KIND=$(shell which kind)
.PHONY: generate tidy build-package clean clean-package build image all install install-local run