-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (59 loc) · 2.96 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
DOCKER_REGISTRY=radixdev.azurecr.io
VERSION=latest
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
IMAGE_NAME=$(DOCKER_REGISTRY)/radix-vulnerability-scanner-api:$(BRANCH)-$(VERSION)
.PHONY: build
build:
docker build -t $(IMAGE_NAME) .
.PHONY: push
push:
az acr login -n $(DOCKER_REGISTRY)
docker push $(IMAGE_NAME)
.PHONY: test
test:
go test -cover `go list ./...`
.PHONY: lint
lint: bootstrap
golangci-lint run --max-same-issues 0
.PHONY: generate-radix-api-client
generate-radix-api-client: bootstrap
swagger generate client -t ./radix_api/generated_client -f https://api.radix.equinor.com/swaggerui/swagger.json -A RadixApi
.PHONY: radixconfigs
radixconfigs:
# radix-id-vulnerability-scan-reader-<env>
AZURE_CLIENT_ID=5bf4ef3d-6c0b-4eee-89ed-966a897eef6e SQL_SERVER=sql-radix-vulnerability-scan-dev.database.windows.net envsubst < radixconfig.tpl.yaml > radixconfig.dev.yaml
AZURE_CLIENT_ID=5381b944-c904-4c5d-8672-7cedadaf50af SQL_SERVER=sql-radix-vulnerability-scan-c2.database.windows.net envsubst < radixconfig.tpl.yaml > radixconfig.c2.yaml
AZURE_CLIENT_ID=96ef36ff-ac7d-4d30-94b3-ea72ad29a7e2 SQL_SERVER=sql-radix-vulnerability-scan-platform.database.windows.net envsubst < radixconfig.tpl.yaml > radixconfig.platform.yaml
AZURE_CLIENT_ID=5dfa299b-f2bf-459a-b780-10ff32f98b4d SQL_SERVER=sql-radix-vulnerability-scan-playground.database.windows.net envsubst < radixconfig.tpl.yaml > radixconfig.playground.yaml
# This make command is only needed for local testing now
# we also do make swagger inside Dockerfile
# swagger generate spec -o ./swagger.json --scan-models
.PHONY: swagger
swagger: bootstrap
swagger generate spec -o ./swaggerui/html/swagger.json -m -x=github.com/equinor/radix-vulnerability-scanner-api/radix_api/generated_client/models
swagger validate ./swaggerui/html/swagger.json
.PHONY: mocks
mocks: bootstrap
mockgen -source ./api/vulnerability/handler.go -destination ./api/vulnerability/mock/handler.go -package mock
mockgen -source ./repository/repository.go -destination ./repository/mock/repository.go -package mock
mockgen -source ./service/radixapi.go -destination ./service/mock/radixapi.go -package mock
mockgen -source ./radix_api/generated_client/client/environment/environment_client.go -destination ./radix_api/mock_client/client/environment/environment_client.go -package environmentmock
mockgen -source ./utils/auth/auth_provider.go -destination ./utils/auth/mock/auth_provider.go -package mock
.PHONY: generate
generate: radixconfigs mocks swagger
.PHONY: verify-generate
verify-generate: generate
git diff --exit-code
HAS_SWAGGER := $(shell command -v swagger;)
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;)
HAS_MOCKGEN := $(shell command -v mockgen;)
bootstrap:
ifndef HAS_SWAGGER
go install github.com/go-swagger/go-swagger/cmd/[email protected]
endif
ifndef HAS_GOLANGCI_LINT
go install github.com/golangci/golangci-lint/cmd/[email protected]
endif
ifndef HAS_MOCKGEN
go install github.com/golang/mock/[email protected]
endif