-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (84 loc) · 3.36 KB
/
Copy pathMakefile
File metadata and controls
97 lines (84 loc) · 3.36 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
SHELL := /bin/bash
PACKAGE ?= flux-gitops-stack
XRD_DIR := apis/fluxgitopsstacks
COMPOSITION := $(XRD_DIR)/composition.yaml
DEFINITION := $(XRD_DIR)/definition.yaml
CONFIGURATION := $(XRD_DIR)/configuration.yaml
EXAMPLE_DEFAULT := examples/fluxgitopsstacks/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/fluxgitopsstacks/minimal.yaml:: \
examples/fluxgitopsstacks/standard.yaml:: \
examples/fluxgitopsstacks/nodepool.yaml:: \
examples/fluxgitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/1/ \
examples/fluxgitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/2/ \
examples/fluxgitopsstacks/eso.yaml:: \
examples/fluxgitopsstacks/eso.yaml::examples/test/mocks/observed-resources/eso/steps/1/ \
examples/fluxgitopsstacks/eso.yaml::examples/test/mocks/observed-resources/eso/steps/2/ \
examples/fluxgitopsstacks/eso.yaml::examples/test/mocks/observed-resources/eso/steps/3/
# Render all examples.
render\:all:
@set -euo pipefail; \
for entry in $(EXAMPLES); do \
example=$${entry%%::*}; \
observed=$${entry#*::}; \
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 ""; \
done
# Validate all examples.
validate\:all: generate-configuration
@set -euo pipefail; \
for entry in $(EXAMPLES); do \
example=$${entry%%::*}; \
observed=$${entry#*::}; \
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 ""; \
done
# Shorthand aliases
.PHONY: render validate generate-configuration
render: ; @$(MAKE) 'render:all'
validate: ; @$(MAKE) generate-configuration 'validate:all'
# Single example targets
render\:%:
@example="examples/fluxgitopsstacks/$*.yaml"; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example
validate\:%: generate-configuration
@example="examples/fluxgitopsstacks/$*.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)