-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (60 loc) · 2.3 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
IGNORED_PATH := "internal/dependencytrack/client"
GO_PACKAGES := $(shell go list ./... | grep -v $(IGNORED_PATH))
build:
go build -o bin/api ./cmd/api
test:
go test -cover ./...
check: fmt vulncheck deadcode gosec staticcheck
fmt:
@echo "Running go fmt..."
go fmt $(GO_PACKAGES)
staticcheck:
@echo "Running staticcheck..."
go run honnef.co/go/tools/cmd/staticcheck@latest $(GO_PACKAGES)
vulncheck:
@echo "Running vulncheck..."
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
deadcode:
@echo "Running deadcode..."
go run golang.org/x/tools/cmd/deadcode@latest -filter "pkg/api/vulnerabilities/options" -test ./...
gosec:
@echo "Running gosec..."
go run github.com/securego/gosec/v2/cmd/gosec@latest --exclude G404,G101 --exclude-generated -terse ./...
generate: generate-proto generate_dp_track generate-sql generate-mocks
generate-proto:
protoc \
-I pkg/api/vulnerabilities/schema/ \
./pkg/api/vulnerabilities/schema/*.proto \
--go_out=. \
--go-grpc_out=.
generate_dp_track:
@echo "Generating Go code from the OpenAPI specification..."
@openapi-generator generate \
-i schema/dtrack.json \
-g go \
-o internal/dependencytrack/client \
--global-property apiTests=false,modelTests=false \
--package-name client \
--additional-properties=withGoMod=false \
--additional-properties=packageName=client || { \
echo "Error: openapi-generator is not installed or failed to execute."; \
echo "Please visit https://openapi-generator.tech/docs/installation/ for installation instructions."; \
exit 1; \
}
generate-sql:
go run github.com/sqlc-dev/sqlc/cmd/sqlc generate -f .configs/sqlc.yaml
go run github.com/sqlc-dev/sqlc/cmd/sqlc vet -f .configs/sqlc.yaml
generate-mocks:
find internal pkg -type f -name "mock_*.go" -delete
go run github.com/vektra/mockery/v2 --config ./.configs/mockery.yaml
find internal pkg -type f -name "mock_*.go" -exec go run mvdan.cc/gofumpt@latest -w {} \;
refresh-db:
docker compose down -v
# make connect-db I=v13s-d94dc8a5 P=nais-management-7178 S=v13s-sa
connect-db:
@CONNECTION_NAME=$$(gcloud sql instances describe $(I) \
--format="get(connectionName)" \
--project $(P)) && \
cloud-sql-proxy $$CONNECTION_NAME \
--auto-iam-authn \
--impersonate-service-account="$(S)@$(P).iam.gserviceaccount.com"