44
55VERSION := $(shell git describe --tags --always --dirty="-dev")
66
7+ # A few colors
8+ RED: =\033[0;31m
9+ GREEN: =\033[0;32m
10+ NC: =\033[0m
11+
712# #@ Help
813
914.PHONY : help
@@ -27,6 +32,16 @@ build: ## Build the HTTP server
2732
2833# #@ Test & Development
2934
35+ .PHONY : lt
36+ lt : lint test # # Run linters and tests (always do this!)
37+
38+ .PHONY : fmt
39+ fmt : # # Format the code (use this often)
40+ gofmt -s -w .
41+ gci write .
42+ gofumpt -w -extra .
43+ go mod tidy
44+
3045.PHONY : test
3146test : # # Run tests
3247 go test ./...
@@ -43,20 +58,10 @@ lint: ## Run linters
4358 staticcheck ./...
4459 golangci-lint run
4560
46- .PHONY : fmt
47- fmt : # # Format the code
48- gofmt -s -w .
49- gci write .
50- gofumpt -w -extra .
51- go mod tidy
52-
5361.PHONY : gofumpt
5462gofumpt : # # Run gofumpt
5563 gofumpt -l -w -extra .
5664
57- .PHONY : lt
58- lt : lint test # # Run linters and tests
59-
6065.PHONY : cover
6166cover : # # Run tests with coverage
6267 go test -coverprofile=/tmp/go-sim-lb.cover.tmp ./...
@@ -72,8 +77,30 @@ cover-html: ## Run tests with coverage and open the HTML report
7277.PHONY : docker-httpserver
7378docker-httpserver : # # Build the HTTP server Docker image
7479 DOCKER_BUILDKIT=1 docker build \
80+ --file docker/httpserver/Dockerfile \
7581 --platform linux/amd64 \
7682 --build-arg VERSION=${VERSION} \
77- --file httpserver.dockerfile \
78- --tag your-project \
83+ --tag builder-hub \
7984 .
85+
86+ .PHONY : db-dump
87+ db-dump : # # Dump the database contents to file 'database.dump'
88+ pg_dump -h localhost -U postgres --column-inserts --data-only postgres -f database.dump
89+ @printf " Database dumped to file: $( GREEN) database.dump$( NC) ✅\n"
90+
91+ .PHONY : dev-db-setup
92+ db-dev-setup : # # Create the basic database entries for testing and development
93+ @printf " $( GREEN) Create the allow-all measurements $( NC) \n"
94+ curl --request POST --url http://localhost:8081/api/admin/v1/measurements --data ' {"measurement_id": "test1","attestation_type": "test","measurements": {}}'
95+
96+ @printf "$(GREEN)Enable the measurements $(NC)\n"
97+ curl --request POST --url http://localhost:8081/api/admin/v1/measurements/activation/test1 --data '{"enabled": true}'
98+
99+ @printf "$(GREEN)Create the builder $(NC)\n"
100+ curl --request POST --url http://localhost:8081/api/admin/v1/builders --data '{"name": "test_builder","ip_address": "1.2.3.4"}'
101+
102+ @printf "$(GREEN)Create the builder configuration $(NC)\n"
103+ curl --request POST --url http://localhost:8081/api/admin/v1/builders/configuration/test_builder --data '{"dns_name": "foobar-v1.a.b.c","rbuilder": {"extra_data": "FooBar"}}'
104+
105+ @printf "$(GREEN)Enable the builder $(NC)\n"
106+ curl --request POST --url http://localhost:8081/api/admin/v1/builders/activation/test_builder --data '{"enabled": true}'
0 commit comments