-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (58 loc) · 1.78 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
export GOPRIVATE = $(shell cat .go_private_repos | tr '\n' ',' | sed -e 's/,$$//')
fmt:
@echo "Formatting sentinel..."
sentinel fmt $(shell find . -name "*.sentinel" -type f)
@echo "Formatting terraform..."
terraform fmt -recursive .
@echo "Done."
.PHONY: fmt
tests:
@echo "Running sentinel tests..."
sentinel test -verbose $(shell find . -name "*.sentinel" -type f ! -path "*/mocks/*" ! -path "*/example/*" ! -path "*/modules/*")
@echo "Done."
.PHONY: tests
test:
ifeq ($(strip $(name)),)
@echo flag needs an argument: name without the `.sentinel` extension
@echo Usage: make test name=test-policy
else
sentinel test -verbose $(shell find . -name "$(name).sentinel" -type f ! -path "*/mocks/*" ! -path "*/example/*" ! -path "*/modules/*")
endif
.PHONY: test
generate-policy:
ifeq ($(strip $(name)),)
@echo flag needs an argument: name
@echo Usage: make generate name=test-policy
else
@mkdir -p policies
@mkdir -p docs/policies
@cp example/policy.sentinel policies/$(name).sentinel
@mkdir -p policies/test
@mkdir -p policies/test/$(name)
@cp -r example/test/policy/* policies/test/$(name)
@cp example/policy.md docs/policies/$(name).md
@echo Policy written to policies/$(name)/$(name).sentinel
@echo Done.
endif
.PHONY: generate-policy
go-private:
@echo export GOPRIVATE="$(GOPRIVATE)"
.PHONY: go-private
modules:
go mod download && go mod verify
.PHONY: modules
test-linux-amd64:
make replace_plugin_paths os=linux arch=amd64
make tests
.PHONY: test-linux-amd64
replace_plugin_paths:
ifeq ($(strip $(os)),)
@echo "Error: OS is not specified."
@exit 1
endif
ifeq ($(strip $(arch)),)
@echo "Error: Architecture is not specified."
@exit 1
endif
find './policies/test' -type f -name '*.hcl' -exec sed -i 's|plugins/darwin/arm64|plugins/$(os)/$(arch)|g' {} +
.PHONY: replace_plugin_paths