-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (131 loc) · 4.66 KB
/
Makefile
File metadata and controls
146 lines (131 loc) · 4.66 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
SHELL := /bin/bash
PACKAGE ?= aws-network
XRD_DIR := apis/networks
COMPOSITION := $(XRD_DIR)/composition.yaml
DEFINITION := $(XRD_DIR)/definition.yaml
CONFIGURATION := $(XRD_DIR)/configuration.yaml
EXAMPLE_DEFAULT := examples/networks/minimal.yaml
RENDER_TESTS := $(wildcard tests/test-*)
E2E_TESTS := $(wildcard tests/e2etest-*)
# Examples list - mirrors GitHub Actions workflow
# Format: example_path::observed_resources_path (observed_resources_path is optional)
# with-ipam is tested at all 4 steps to validate multi-step reconciliation
EXAMPLES := \
examples/networks/minimal.yaml:: \
examples/networks/standard.yaml:: \
examples/networks/dual-stack-ula.yaml:: \
examples/networks/dual-stack-amazon.yaml:: \
examples/networks/high-availability.yaml:: \
examples/networks/import-example.yaml:: \
examples/networks/with-ipam.yaml::examples/test/mocks/observed-resources/with-ipam/steps/1 \
examples/networks/with-ipam.yaml::examples/test/mocks/observed-resources/with-ipam/steps/2 \
examples/networks/with-ipam.yaml::examples/test/mocks/observed-resources/with-ipam/steps/3 \
examples/networks/with-ipam.yaml::examples/test/mocks/observed-resources/with-ipam/steps/4
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)"
# 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 '/:' '__')"; \
( \
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 '/:' '__')"; \
( \
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 render (usage: make render:minimal)
render\:%:
@example="examples/networks/$*.yaml"; \
if [ -f "$$example" ]; then \
echo "=== Rendering $$example ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example; \
else \
echo "Example $$example not found"; \
exit 1; \
fi
# Single example validate (usage: make validate:minimal)
validate\:%: generate-configuration
@example="examples/networks/$*.yaml"; \
if [ -f "$$example" ]; then \
echo "=== Validating $$example ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -; \
else \
echo "Example $$example not found"; \
exit 1; \
fi
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)
generate-definitions:
up xrd generate $(EXAMPLE_DEFAULT)
generate-function:
up function generate --language=go-templating render $(COMPOSITION)