-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
90 lines (67 loc) · 3.06 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
.PHONY: ginkgo
ginkgo:
go install github.com/onsi/ginkgo/v2/ginkgo
test: ginkgo
ginkgo -r -v
fmt:
go fmt ./...
.PHONY: lint
lint:
golangci-lint run
CONTROLLER_TOOLS_VERSION ?= v0.14.0
LOCALBIN ?= $(shell pwd)/.bin
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object paths="./types/..."
$(CONTROLLER_GEN) object paths="./connection/..."
$(CONTROLLER_GEN) object paths="./models/..."
$(CONTROLLER_GEN) object paths="./shell/..."
$(CONTROLLER_GEN) object paths="./"
$(LOCALBIN):
mkdir -p $(LOCALBIN)
download-openapi-schemas:
mkdir -p tmp
# Canary Checker
git clone --depth=1 [email protected]:flanksource/canary-checker.git tmp/canary-checker && cp tmp/canary-checker/config/schemas/* schema/openapi/
# create schemas for specs only
cat tmp/canary-checker/config/schemas/canary.schema.json | jq '.["$$ref"] = "#/$$defs/CanarySpec"' > schema/openapi/canary.spec.schema.json
cat tmp/canary-checker/config/schemas/component.schema.json | jq '.["$$ref"] = "#/$$defs/ComponentSpec"' > schema/openapi/component.spec.schema.json
cat tmp/canary-checker/config/schemas/topology.schema.json | jq '.["$$ref"] = "#/$$defs/TopologySpec"' > schema/openapi/topology.spec.schema.json
# Config DB
git clone --depth=1 [email protected]:flanksource/config-db.git tmp/config-db && cp tmp/config-db/config/schemas/* schema/openapi/
# APM-Hub
git clone --depth=1 [email protected]:flanksource/apm-hub.git tmp/apm-hub && cp tmp/apm-hub/config/schemas/* schema/openapi/
# Mission control
git clone --depth=1 [email protected]:flanksource/mission-control.git tmp/mission-control && cp tmp/mission-control/config/schemas/* schema/openapi/
# create schemas for specs only
cat tmp/config-db/config/schemas/scrape_config.schema.json | jq '.["$$ref"] = "#/definitions/ScraperSpec"' > schema/openapi/scrape_config.spec.schema.json
# Cleanup
rm -rf tmp
hack/migrate/go.mod: tidy
cp go.mod hack/migrate && \
cd hack/migrate && \
go mod edit -module=github.com/flanksource/duty/hack/generate-schemas && \
go mod edit -require=github.com/flanksource/[email protected] && \
go mod edit -replace=github.com/flanksource/duty=../../ && \
go mod tidy
.PHONY: migrate-test
migrate-test: hack/migrate/go.mod
cd hack/migrate && go run ./main.go
cp-playbook-schema:
cp ../incident-commander/config/schemas/playbook-spec.schema.json schema/
fmt_json:
ls fixtures/expectations/*.json | while read -r jf; do \
cat <<< $$(jq . $$jf) > $$jf; \
done;
fmt_sql:
ls views/*.sql | while read -r sqlf; do \
pg_format -s 2 -o $$sqlf $$sqlf; \
done;
tidy:
go mod tidy