Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Commit cce197c

Browse files
authored
Rename environment prefix/app name to fleetdb (#8)
1 parent f2a287d commit cce197c

File tree

10 files changed

+37
-37
lines changed

10 files changed

+37
-37
lines changed

.github/workflows/lint-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
args: --timeout=5m
3737

3838
- name: Run go tests and generate coverage report
39-
run: SERVERSERVICE_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=serverservice_test" go test -test.v -race -coverprofile=coverage.txt -covermode=atomic -tags testtools -p 1 ./...
40-
39+
run: FLEETDB_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=fleetdb_test" go test -race -coverprofile=coverage.txt -covermode=atomic -tags testtools -p 1 ./...
40+
4141
- name: Stop test database
4242
run: cockroach node drain --insecure --host=localhost:26257
4343

Dockerfile.dev

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ RUN go mod tidy
1616
# Build the binary.
1717
# -mod=readonly ensures immutable go.mod and go.sum in container builds.
1818
RUN export LDFLAG_LOCATION="go.infratographer.com/x/versionx" && \
19-
CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o fleetdb \
19+
CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o fleetdb \
2020
-ldflags \
21-
"-X ${LDFLAG_LOCATION}.appName=serverservice \
22-
-X ${LDFLAG_LOCATION}.commit=$(git rev-parse --short HEAD) \
23-
-X ${LDFLAG_LOCATION}.version=$(git describe --tags 2>/dev/null) \
24-
-X ${LDFLAG_LOCATION}.date=$(date -u '+%H:%M:%S-%Y-%m-%d')"
21+
"-X ${LDFLAG_LOCATION}.appName=fleetdb \
22+
-X ${LDFLAG_LOCATION}.commit=$(git rev-parse --short HEAD) \
23+
-X ${LDFLAG_LOCATION}.version=$(git describe --tags 2>/dev/null) \
24+
-X ${LDFLAG_LOCATION}.date=$(date -u '+%H:%M:%S-%Y-%m-%d')"
2525

2626
# Use the official Alpine image for a lean production container.
2727
# https://hub.docker.com/_/alpine

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ all: lint test
22
PHONY: test coverage lint golint clean vendor local-dev-databases docker-up docker-down integration-test unit-test
33
GOOS=linux
44
DB_STRING=host=localhost port=26257 user=root sslmode=disable
5-
DEV_DB=${DB_STRING} dbname=serverservice
6-
TEST_DB=${DB_STRING} dbname=serverservice_test
5+
DEV_DB=${DB_STRING} dbname=fleetdb
6+
TEST_DB=${DB_STRING} dbname=fleetdb_test
77
DOCKER_IMAGE := "ghcr.io/metal-toolbox/fleetdb"
88
PROJECT_NAME := fleetdb
99
REPO := "https://github.com/metal-toolbox/fleetdb.git"
@@ -14,7 +14,7 @@ test: | unit-test integration-test
1414
## run integration tests
1515
integration-test: test-database
1616
@echo Running integration tests...
17-
@SERVERSERVICE_CRDB_URI="${TEST_DB}" go test -cover -tags testtools,integration -p 1 ./...
17+
@FLEETDB_CRDB_URI="${TEST_DB}" go test -cover -tags testtools,integration -p 1 ./...
1818

1919
## run lint and unit tests
2020
unit-test: | lint
@@ -24,7 +24,7 @@ unit-test: | lint
2424
## check test coverage
2525
coverage: | test-database
2626
@echo Generating coverage report...
27-
@SERVERSERVICE_CRDB_URI="${TEST_DB}" go test ./... -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1
27+
@FLEETDB_CRDB_URI="${TEST_DB}" go test ./... -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1
2828
@go tool cover -func=coverage.out
2929
@go tool cover -html=coverage.out
3030

@@ -60,16 +60,16 @@ docker-clean:
6060

6161
## setup devel database
6262
dev-database: | vendor
63-
@cockroach sql --insecure -e "drop database if exists serverservice"
64-
@cockroach sql --insecure -e "create database serverservice"
65-
@SERVERSERVICE_CRDB_URI="${DEV_DB}" go run main.go migrate up
63+
@cockroach sql --insecure -e "drop database if exists fleetdb"
64+
@cockroach sql --insecure -e "create database fleetdb"
65+
@FLEETDB_CRDB_URI="${DEV_DB}" go run main.go migrate up
6666

6767
## setup test database
6868
test-database: | vendor
69-
@cockroach sql --insecure -e "drop database if exists serverservice_test"
70-
@cockroach sql --insecure -e "create database serverservice_test"
71-
@SERVERSERVICE_CRDB_URI="${TEST_DB}" go run main.go migrate up
72-
@cockroach sql --insecure -e "use serverservice_test; ALTER TABLE attributes DROP CONSTRAINT check_server_id_server_component_id; ALTER TABLE versioned_attributes DROP CONSTRAINT check_server_id_server_component_id;"
69+
@cockroach sql --insecure -e "drop database if exists fleetdb_test"
70+
@cockroach sql --insecure -e "create database fleetdb_test"
71+
@FLEETDB_CRDB_URI="${TEST_DB}" go run main.go migrate up
72+
@cockroach sql --insecure -e "use fleetdb_test; ALTER TABLE attributes DROP CONSTRAINT check_server_id_server_component_id; ALTER TABLE versioned_attributes DROP CONSTRAINT check_server_id_server_component_id;"
7373

7474
## Build linux bin
7575
build-linux:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ sqlboiler crdb --add-soft-deletes
5454
Export the DB URI required for integration tests.
5555

5656
```bash
57-
export SERVERSERVICE_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=serverservice_test"
57+
export FLEETDB_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=fleetdb_test"
5858
```
5959

6060
Run test.

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
var (
21-
appName = "serverservice"
21+
appName = "fleetdb"
2222
cfgFile string
2323
logger *zap.SugaredLogger
2424
)
@@ -69,7 +69,7 @@ func initConfig() {
6969
}
7070

7171
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
72-
viper.SetEnvPrefix("serverservice")
72+
viper.SetEnvPrefix("fleetdb")
7373
viper.AutomaticEnv() // read in environment variables that match
7474

7575
// If a config file is found, read it in.

internal/dbtools/testtools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
// TestDBURI is the URI for the test database
30-
var TestDBURI = os.Getenv("SERVERSERVICE_CRDB_URI")
30+
var TestDBURI = os.Getenv("FLEETDB_CRDB_URI")
3131
var testDB *sqlx.DB
3232
var testKeeper *secrets.Keeper
3333

quickstart-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
version: "3.9"
22

33
services:
4-
serverservice:
4+
fleetdb:
55
build:
66
context: .
77
dockerfile: Dockerfile.dev
88

9-
serverservice-migrate:
9+
fleetdb-migrate:
1010
build:
1111
context: .
1212
dockerfile: Dockerfile.dev

quickstart-tracing.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
version: '3.7'
22

33
services:
4-
serverservice:
4+
fleetdb:
55
depends_on:
66
- jaeger
77
environment:
8-
- SERVERSERVICE_TRACING_ENABLED=true
9-
- SERVERSERVICE_TRACING_ENVIRONMENT=dev-dockercompose
10-
- SERVERSERVICE_TRACING_PROVIDER=jaeger
11-
- SERVERSERVICE_TRACING_JAEGER_ENDPOINT=http://jaeger:14268/api/traces
8+
- FLEETDB_TRACING_ENABLED=true
9+
- FLEETDB_TRACING_ENVIRONMENT=dev-dockercompose
10+
- FLEETDB_TRACING_PROVIDER=jaeger
11+
- FLEETDB_TRACING_JAEGER_ENDPOINT=http://jaeger:14268/api/traces
1212

1313
jaeger:
1414
image: jaegertracing/all-in-one:1.48.0

quickstart.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
version: "3.9"
22

33
services:
4-
serverservice:
4+
fleetdb:
55
image: ghcr.io/metal-toolbox/fleetdb:latest
66
depends_on:
77
- crdb
8-
- serverservice-migrate
8+
- fleetdb-migrate
99
environment:
10-
- SERVERSERVICE_OIDC_ENABLED=false
11-
- SERVERSERVICE_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable
12-
- SERVERSERVICE_DB_ENCRYPTION_DRIVER=base64key://smGbjm71Nxd1Ig5FS0wj9SlbzAIrnolCz9bQQ6uAhl4=
10+
- FLEETDB_OIDC_ENABLED=false
11+
- FLEETDB_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable
12+
- FLEETDB_DB_ENCRYPTION_DRIVER=base64key://smGbjm71Nxd1Ig5FS0wj9SlbzAIrnolCz9bQQ6uAhl4=
1313
ports:
1414
- "8000:8000"
1515
restart: unless-stopped
1616
networks:
1717
- hollow
1818

19-
serverservice-migrate:
19+
fleetdb-migrate:
2020
image: ghcr.io/metal-toolbox/fleetdb:latest
2121
command:
2222
migrate up
2323
depends_on:
2424
- crdb
2525
environment:
26-
- SERVERSERVICE_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable
26+
- FLEETDB_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable
2727
restart: on-failure
2828
networks:
2929
- hollow

sqlboiler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pkgname = "models"
33
output = "internal/models"
44

55
[crdb]
6-
dbname = "serverservice_test"
6+
dbname = "fleetdb_test"
77
host = "localhost"
88
port = 26257
99
user = "root"

0 commit comments

Comments
 (0)