-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile.tmpl
More file actions
110 lines (88 loc) · 2.73 KB
/
Makefile.tmpl
File metadata and controls
110 lines (88 loc) · 2.73 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
# FIXME: This Makefile was generated by `grafana-app-sdk project init`,
# With all possible pre-made make targets, and should be customized to your project based on your needs.
SOURCES := $(shell find . -type f -name "*.go")
MOD_FILES := go.mod go.sum
VENDOR := vendor
COVOUT := coverage.out
OPERATOR_DOCKERIMAGE := "{{ .ModuleName }}"
.PHONY: all
all: deps lint test build
.PHONY: deps
deps: $(VENDOR)
.PHONY: lint
lint:
golangci-lint run --max-same-issues=0 --max-issues-per-linter=0
.PHONY: test
test:
go test -count=1 -cover -covermode=atomic -coverprofile=$(COVOUT) ./...
.PHONY: coverage
coverage: test
go tool cover -html=$(COVOUT)
.PHONY: build
build: build/plugin build/operator
.PHONY: build/plugin
build/plugin: build/plugin-backend build/plugin-frontend
.PHONY: build/plugin-frontend
build/plugin-frontend:
ifeq ("$(wildcard plugin/src/plugin.json)","plugin/src/plugin.json")
@cd plugin && yarn install && yarn build
else
@echo "No plugin.json found, skipping frontend build"
endif
.PHONY: build/plugin-backend
build/plugin-backend:
ifeq ("$(wildcard plugin/Magefile.go)","plugin/Magefile.go")
@cd plugin && mage -v
else
@echo "No Magefile.go found, skipping backend build"
endif
.PHONY: build/operator
build/operator:
ifeq ("$(wildcard cmd/operator/Dockerfile)","cmd/operator/Dockerfile")
docker build -t $(OPERATOR_DOCKERIMAGE) -f cmd/operator/Dockerfile .
else
@echo "No cmd/operator/Dockerfile, skipping operator build"
endif
.PHONY: compile/operator
compile/operator:
if [ ! -d "./cmd/operator" ]; then
@echo "cmd/operator does not exist, skipping operator compile"
else
@go build -o "target/operator" cmd/operator/*.go
fi
.PHONY: generate
generate:
@grafana-app-sdk generate --source kinds --format cue
.PHONY: local/up
local/up: local/generate
@local/scripts/cluster.sh create "local/generated/k3d-config.json"
@cd local && tilt up
.PHONY: local/generate
local/generate:
@grafana-app-sdk project local generate
.PHONY: local/down
local/down:
@cd local && tilt down
.PHONY: local/deploy_plugin
local/deploy_plugin:
-tilt disable grafana
@mkdir -p local/mounted-files/plugin/dist
cp -R plugin/dist/* local/mounted-files/plugin/dist/
-tilt enable grafana
.PHONY: local/push_operator
local/push_operator:
# Tag the docker image as part of localhost, which is what the generated k8s uses to avoid confusion with the real operator image
@docker tag "$(OPERATOR_DOCKERIMAGE):latest" "localhost/$(OPERATOR_DOCKERIMAGE):latest"
@local/scripts/push_image.sh "localhost/$(OPERATOR_DOCKERIMAGE):latest"
.PHONY: local/clean
local/clean: local/down
@local/scripts/cluster.sh delete
.PHONY: clean
clean:
@rm -f $(COVOUT)
@rm -rf $(VENDOR)
.PHONY: $(VENDOR)
$(VENDOR): $(SOURCES) $(MOD_FILES)
@go mod tidy
@go mod vendor
@touch $@