-
-
Notifications
You must be signed in to change notification settings - Fork 258
/
Makefile
176 lines (149 loc) · 5.66 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
ifeq ($(OS),Windows_NT)
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
ARCH=amd64
OS=windows
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS=linux
ARCH=amd64
endif
ifeq ($(UNAME_S),Darwin)
OS=darwin
ifeq ($(shell uname -m),x86_64)
ARCH=amd64
endif
ifeq ($(shell uname -m),arm64)
ARCH=arm64
endif
endif
endif
SHELL=/bin/bash -euo pipefail
export PATH := .bin:${PATH}
export PWD := $(shell pwd)
export VERSION=$(shell echo ${RELEASE_VERSION} | sed s/v//g)
export K3SIMAGE := docker.io/rancher/k3s:v1.29.4-k3s1
.bin/yq: go.mod
go build -o .bin/yq github.com/mikefarah/yq/v3
.bin/helm: Makefile
HELM_INSTALL_DIR=.bin bash <(curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3) -v v3.12.0 --no-sudo
.bin/ory: Makefile
# pin to version v0.3.4 due to a bug in validation
curl https://raw.githubusercontent.com/ory/meta/master/install.sh | bash -s -- -b .bin ory v0.3.4
touch .bin/ory
.bin/goimports:
GOBIN=$(shell pwd)/.bin go install golang.org/x/tools/cmd/goimports@latest
.bin/licenses: Makefile
curl https://raw.githubusercontent.com/ory/ci/master/licenses/install | sh
.bin/helm-docs: Makefile
@URL=$$(.bin/ory dev ci deps url -o ${OS} -a ${ARCH} -c .deps/helm-docs.yaml); \
echo "Downloading 'helm-docs' $${URL}...."; \
curl -L $${URL} | tar -xmz -C .bin helm-docs; \
chmod +x .bin/helm-docs;
.bin/k3d: Makefile
@URL=$$(.bin/ory dev ci deps url -o ${OS} -a ${ARCH} -c .deps/k3d.yaml); \
echo "Downloading 'k3d' $${URL}...."; \
curl -Lo .bin/k3d $${URL}; \
chmod +x .bin/k3d;
.bin/kubectl: Makefile
@URL=$$(.bin/ory dev ci deps url -o ${OS} -a ${ARCH} -c .deps/kubectl.yaml); \
echo "Downloading 'kubectl' $${URL}...."; \
curl -Lo .bin/kubectl $${URL}; \
chmod +x .bin/kubectl;
.PHONY: deps
deps: .bin/ory .bin/helm .bin/yq .bin/helm-docs .bin/k3d .bin/kubectl
.PHONY: release
release: ory-repo
yq w -i helm/charts/example-idp/Chart.yaml version "${VERSION}"
yq w -i helm/charts/hydra-maester/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/hydra/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/hydra/Chart.yaml "dependencies.(name==hydra-maester).version" "${VERSION}"; \
yq w -i helm/charts/keto/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/kratos/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/kratos-selfservice-ui-node/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/oathkeeper-maester/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/oathkeeper/Chart.yaml version "${VERSION}"; \
yq w -i helm/charts/oathkeeper/Chart.yaml "dependencies.(name==oathkeeper-maester).version" "${VERSION}"; \
helm dep update ./helm/charts/oathkeeper/; \
helm package -d docs/helm/charts/ ./helm/charts/oathkeeper/ --version "${VERSION}"; \
helm package -d docs/helm/charts/ ./helm/charts/oathkeeper-maester/ --version "${VERSION}"; \
helm dep update ./helm/charts/hydra/; \
helm package -d docs/helm/charts/ ./helm/charts/hydra/ --version "${VERSION}"; \
helm package -d docs/helm/charts/ ./helm/charts/hydra-maester/ --version "${VERSION}"; \
helm package -d docs/helm/charts/ ./helm/charts/example-idp/ --version "${VERSION}"; \
helm package -d docs/helm/charts/ ./helm/charts/kratos/ --version "${VERSION}"; \
helm package -d docs/helm/charts/ ./helm/charts/keto/ --version "${VERSION}"; \
helm package -d docs/helm/charts/ ./helm/charts/kratos-selfservice-ui-node/ --version "${VERSION}"; \
helm repo index docs/helm/charts/
make helm-docs
make format
.PHONY: k3d-up
k3d-up:
k3d cluster create --image $${K3SIMAGE} ory-k8s -p "8080:80@server:0" \
--k3s-arg=--kube-apiserver-arg="enable-admission-plugins=NodeRestriction,ServiceAccount@server:0" \
--k3s-arg=feature-gates="NamespaceDefaultLabelName=true@server:0";
kubectl apply -R -f hacks/manifests
.PHONY: k3d-run
k3d-run: k3d-up postgresql prometheus
.PHONY: k3d-down
k3d-down:
k3d cluster delete ory-k8s || true
.PHONY: postgresql
postgresql:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install postgresql bitnami/postgresql --atomic --debug -f hacks/values/postgres.yaml
.PHONY: prometheus
prometheus:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
kubectl create ns prometheus --dry-run=client -o yaml | kubectl apply -f -
helm install prometheus prometheus-community/kube-prometheus-stack -f hacks/values/prometheus.yaml
.PHONY: ory-repo
ory-repo:
helm repo add ory https://k8s.ory.sh/helm/charts
helm repo update
.PHONY: helm-test
helm-test: k3d-up postgresql prometheus
@if [ ! "${HELM_CHART}" ]; then \
echo 'No helm chart specified, cancelling, please specify HELM_CHART'; \
exit 1; \
fi; \
hacks/helm-test.sh ${HELM_CHART}
make k3d-down
.PHONY: helm-upgrade
helm-upgrade: k3d-up postgresql ory-repo prometheus
@if [ ! "${HELM_CHART}" ]; then \
echo 'No helm chart specified, cancelling, please specify HELM_CHART'; \
exit 1; \
fi; \
hacks/helm-upgrade.sh ${HELM_CHART}
make k3d-down
.PHONY: helm-lint
helm-lint:
@if [ ! "${HELM_CHART}" ]; then \
echo 'No helm chart specified, cancelling, please specify HELM_CHART'; \
exit 1; \
fi; \
helm lint ./helm/charts/${HELM_CHART}/
.PHONY: helm-validate
helm-validate:
@if [ ! "${HELM_CHART}" ]; then \
echo 'No helm chart specified, cancelling, please specify HELM_CHART'; \
exit 1; \
fi; \
hacks/helm-validate.sh ${HELM_CHART}
.PHONY: helm-docs
helm-docs:
helm-docs -c helm/charts/
.PHONY: format
format: .bin/goimports .bin/ory node_modules
.bin/ory dev headers copyright --type=open-source
.bin/goimports -w .
npm exec -- prettier --write .
licenses: .bin/licenses node_modules # checks open-source licenses
.bin/licenses
node_modules: package-lock.json
npm ci
touch node_modules