-
Notifications
You must be signed in to change notification settings - Fork 54
/
Makefile
125 lines (98 loc) · 4.33 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
SHELL := /usr/bin/env bash
GIT_COMMIT := $(shell git rev-parse --short HEAD)
VERSION := $(GIT_COMMIT)
CURRENT_RELEASE := $(shell git describe --abbrev=0 --tags)
RELEASE ?= $(shell git describe --abbrev=0 --tags)
.PHONY: all
all: build
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.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: codegen
codegen: generate-crds generate-crdocs ## Generate CRDs and documentation
CRD_BASES := operator/config/crd/bases/
CRDS := pulumi.com_stacks.yaml pulumi.com_programs.yaml auto.pulumi.com_workspaces.yaml auto.pulumi.com_updates.yaml
.PHONY: generate-crds
generate-crds:
cd operator && $(MAKE) manifests
cp $(addprefix $(CRD_BASES), $(CRDS)) deploy/crds/
cp $(addprefix $(CRD_BASES), $(CRDS)) deploy/helm/pulumi-operator/crds/
.PHONY: generate-crdocs
generate-crdocs: crdoc ## Generate API Reference documentation into 'docs/crds/'.
$(CRDOC) --resources deploy/crds/pulumi.com_stacks.yaml --output docs/stacks.md
$(CRDOC) --resources deploy/crds/pulumi.com_programs.yaml --output docs/programs.md
$(CRDOC) --resources deploy/crds/auto.pulumi.com_workspaces.yaml --output docs/workspaces.md
$(CRDOC) --resources deploy/crds/auto.pulumi.com_updates.yaml --output docs/updates.md
.PHONY: test
test:
cd agent && $(MAKE) test
cd operator && $(MAKE) test
##@ Build
.PHONY: build
build: build-agent build-operator build-deploy ## Build the agent and operator binaries and deployment scripts.
.PHONY: build-agent
build-agent: ## Build the agent binary.
@echo "Building agent"
cd agent && $(MAKE) all
.PHONY: build-operator
build-operator: ## Build the operator manager binary.
@echo "Building operator"
cd operator && $(MAKE) all
.PHONY: build-image
build-image: ## Build the operator image.
@echo "Building operator image"
cd operator && $(MAKE) docker-build
.PHONY: push-image
push-image: ## Push the operator image.
cd operator && $(MAKE) docker-push
.PHONY: build-deploy
build-deploy: generate-crds ## Build the deployment scripts.
cd operator && $(MAKE) build-installer
cp operator/dist/install.yaml deploy/yaml/install.yaml
##@ Deployment
.PHONY: install-crds
install-crds: ## Install CRDs into the K8s cluster specified in ~/.kube/config.
cd operator && $(MAKE) install
.PHONY: deploy
deploy: ## Deploy controller manager to the K8s cluster specified in ~/.kube/config.
cd operator && $(MAKE) deploy
##@ Release
.PHONY: prep
prep: ## Prepare the next release (use RELEASE=<next-tag>).
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" README.md
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" agent/version/version.go
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" operator/Makefile
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" operator/version/version.go
cd operator && $(MAKE) build-installer
cp operator/dist/install.yaml deploy/yaml/install.yaml
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" deploy/deploy-operator-yaml/Pulumi.yaml
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" deploy/helm/pulumi-operator/Chart.yaml
sed -i '' -e "s|$(CURRENT_RELEASE)|$(RELEASE)|g" deploy/helm/pulumi-operator/README.md
.PHONY: version
version:
@echo $(VERSION)
##@ Build Dependencies
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
CRDOC ?= $(LOCALBIN)/crdoc
## Tool Versions
CRDOC_VERSION ?= v0.5.2
.PHONY: crdoc
crdoc: $(CRDOC) ## Download crdoc locally if necessary. No version check.
$(CRDOC): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install fybrik.io/crdoc@$(CRDOC_VERSION)