Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (119 loc) · 4.41 KB
/
Copy pathMakefile
File metadata and controls
132 lines (119 loc) · 4.41 KB
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
SHELL := /bin/bash
PACKAGE ?= gitops-stack
XRD_DIR := apis/gitopsstacks
COMPOSITION := $(XRD_DIR)/composition.yaml
DEFINITION := $(XRD_DIR)/definition.yaml
CONFIGURATION := $(XRD_DIR)/configuration.yaml
EXAMPLE_DEFAULT := examples/gitopsstacks/standard.yaml
RENDER_TESTS := $(wildcard tests/test-*)
E2E_TESTS := $(wildcard tests/e2etest-*)
clean:
rm -rf _output
rm -rf .up
rm -f $(CONFIGURATION)
build:
up project build
generate-configuration:
@set -euo pipefail; \
hops validate generate-configuration --path . --api-path "$(XRD_DIR)"
# Examples list - mirrors GitHub Actions workflow
# Format: example_path::observed_resources_path (observed_resources_path is optional)
EXAMPLES := \
examples/gitopsstacks/minimal.yaml:: \
examples/gitopsstacks/standard.yaml:: \
examples/gitopsstacks/nodepool.yaml:: \
examples/gitopsstacks/webhook.yaml:: \
examples/gitopsstacks/private-ui.yaml:: \
examples/gitopsstacks/webhook-only.yaml:: \
examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/1/ \
examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/2/ \
examples/gitopsstacks/eso.yaml:: \
examples/gitopsstacks/eso.yaml::examples/test/mocks/observed-resources/eso/steps/1/ \
examples/gitopsstacks/eso.yaml::examples/test/mocks/observed-resources/eso/steps/2/ \
examples/gitopsstacks/eso.yaml::examples/test/mocks/observed-resources/eso/steps/3/ \
examples/gitopsstacks/zitadel-oidc.yaml:: \
examples/gitopsstacks/zitadel-oidc.yaml::examples/test/mocks/observed-resources/zitadel-oidc/steps/1/
# Render all examples (parallel execution, output shown per-job when complete)
render\:all:
@tmpdir=$$(mktemp -d); \
pids=""; \
for entry in $(EXAMPLES); do \
example=$${entry%%::*}; \
observed=$${entry#*::}; \
outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \
( \
set -euo pipefail; \
if [ -n "$$observed" ]; then \
echo "=== Rendering $$example with observed-resources $$observed ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example --observed-resources=$$observed; \
else \
echo "=== Rendering $$example ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example; \
fi; \
echo "" \
) > "$$outfile" 2>&1 & \
pids="$$pids $$!:$$outfile"; \
done; \
failed=0; \
for pair in $$pids; do \
pid=$${pair%%:*}; \
outfile=$${pair#*:}; \
if ! wait $$pid; then failed=1; fi; \
cat "$$outfile"; \
done; \
rm -rf "$$tmpdir"; \
exit $$failed
# Validate all examples (parallel execution, output shown per-job when complete)
validate\:all: generate-configuration
@tmpdir=$$(mktemp -d); \
pids=""; \
for entry in $(EXAMPLES); do \
example=$${entry%%::*}; \
observed=$${entry#*::}; \
outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \
( \
set -euo pipefail; \
if [ -n "$$observed" ]; then \
echo "=== Validating $$example with observed-resources $$observed ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--observed-resources=$$observed --include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -; \
else \
echo "=== Validating $$example ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -; \
fi; \
echo "" \
) > "$$outfile" 2>&1 & \
pids="$$pids $$!:$$outfile"; \
done; \
failed=0; \
for pair in $$pids; do \
pid=$${pair%%:*}; \
outfile=$${pair#*:}; \
if ! wait $$pid; then failed=1; fi; \
cat "$$outfile"; \
done; \
rm -rf "$$tmpdir"; \
exit $$failed
# Shorthand aliases
.PHONY: render validate generate-configuration
render: ; @$(MAKE) 'render:all'
validate: ; @$(MAKE) generate-configuration 'validate:all'
# Single example targets
render\:%:
@example="examples/gitopsstacks/$*.yaml"; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example
validate\:%: generate-configuration
@example="examples/gitopsstacks/$*.yaml"; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -
test:
up test run $(RENDER_TESTS)
e2e:
up test run $(E2E_TESTS) --e2e
publish:
@if [ -z "$(tag)" ]; then echo "Error: tag is not set. Usage: make publish tag=<version>"; exit 1; fi
up project build --push --tag $(tag)