diff --git a/.github/workflows/container-scan-trivy.yml b/.github/workflows/container-scan-trivy.yml index d8a987b..5b1c8b6 100644 --- a/.github/workflows/container-scan-trivy.yml +++ b/.github/workflows/container-scan-trivy.yml @@ -25,7 +25,7 @@ jobs: - name: Build go binary run: | - go build -o serverservice . + go build -o fleetdb . - name: Build uses: docker/build-push-action@v4 diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 8c447de..1496700 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -36,7 +36,7 @@ jobs: args: --timeout=5m - name: Run go tests and generate coverage report - run: SERVERSERVICE_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=serverservice_test" go test -race -coverprofile=coverage.txt -covermode=atomic -tags testtools -p 1 ./... + 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 ./... - name: Stop test database run: cockroach quit --insecure --host=localhost:26257 diff --git a/.golangci.yml b/.golangci.yml index b1be726..273dcc2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: linters-settings: goimports: - local-prefixes: go.hollow.sh/serverservice + local-prefixes: go.hollow.sh/fleetdb gofumpt: extra-rules: true diff --git a/.goreleaser.yml b/.goreleaser.yml index dd4b8c6..6baa529 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: serverservice +project_name: fleetdb before: hooks: - go mod download diff --git a/Dockerfile b/Dockerfile index 8459d81..03b1e8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM gcr.io/distroless/static # Copy the binary that goreleaser built -COPY serverservice /serverservice +COPY fleetdb /fleetdb # Run the web service on container startup. -ENTRYPOINT ["/serverservice"] +ENTRYPOINT ["/fleetdb"] CMD ["serve"] diff --git a/Dockerfile.dev b/Dockerfile.dev index 397d072..d9e7273 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -16,9 +16,9 @@ RUN go mod tidy # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. RUN export LDFLAG_LOCATION="go.infratographer.com/x/versionx" && \ - CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o serverservice \ + CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o fleetdb \ -ldflags \ - "-X ${LDFLAG_LOCATION}.appName=serverservice \ + "-X ${LDFLAG_LOCATION}.appName=fleetdb \ -X ${LDFLAG_LOCATION}.commit=$(git rev-parse --short HEAD) \ -X ${LDFLAG_LOCATION}.version=$(git describe --tags 2>/dev/null) \ -X ${LDFLAG_LOCATION}.date=$(date -u '+%H:%M:%S-%Y-%m-%d')" @@ -30,8 +30,8 @@ FROM alpine:3.18.3 RUN apk add --no-cache ca-certificates # Copy the binary to the production image from the builder stage. -COPY --from=builder /app/serverservice /serverservice +COPY --from=builder /app/fleetdb /fleetdb # Run the web service on container startup. -ENTRYPOINT ["/serverservice"] +ENTRYPOINT ["/fleetdb"] CMD ["serve"] diff --git a/Makefile b/Makefile index 1e92cb6..64271b7 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,9 @@ all: lint test PHONY: test coverage lint golint clean vendor local-dev-databases docker-up docker-down integration-test unit-test GOOS=linux DB_STRING=host=localhost port=26257 user=root sslmode=disable -DEV_DB=${DB_STRING} dbname=serverservice -TEST_DB=${DB_STRING} dbname=serverservice_test -DOCKER_IMAGE := "ghcr.io/metal-toolbox/hollow-serverservice" +DEV_DB=${DB_STRING} dbname=fleetdb +TEST_DB=${DB_STRING} dbname=fleetdb_test +DOCKER_IMAGE := "ghcr.io/metal-toolbox/fleetdb" ## run all tests test: | unit-test integration-test @@ -12,7 +12,7 @@ test: | unit-test integration-test ## run integration tests integration-test: test-database @echo Running integration tests... - @SERVERSERVICE_CRDB_URI="${TEST_DB}" go test -cover -tags testtools,integration -p 1 ./... + @FLEETDB_CRDB_URI="${TEST_DB}" go test -cover -tags testtools,integration -p 1 ./... ## run lint and unit tests unit-test: | lint @@ -22,7 +22,7 @@ unit-test: | lint ## check test coverage coverage: | test-database @echo Generating coverage report... - @SERVERSERVICE_CRDB_URI="${TEST_DB}" go test ./... -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1 + @FLEETDB_CRDB_URI="${TEST_DB}" go test ./... -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1 @go tool cover -func=coverage.out @go tool cover -html=coverage.out @@ -58,23 +58,23 @@ docker-clean: ## setup devel database dev-database: | vendor - @cockroach sql --insecure -e "drop database if exists serverservice" - @cockroach sql --insecure -e "create database serverservice" - @SERVERSERVICE_CRDB_URI="${DEV_DB}" go run main.go migrate up + @cockroach sql --insecure -e "drop database if exists fleetdb" + @cockroach sql --insecure -e "create database fleetdb" + @FLEETDB_CRDB_URI="${DEV_DB}" go run main.go migrate up ## setup test database test-database: | vendor - @cockroach sql --insecure -e "drop database if exists serverservice_test" - @cockroach sql --insecure -e "create database serverservice_test" - @SERVERSERVICE_CRDB_URI="${TEST_DB}" go run main.go migrate up - @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;" + @cockroach sql --insecure -e "drop database if exists fleetdb_test" + @cockroach sql --insecure -e "create database fleetdb_test" + @FLEETDB_CRDB_URI="${TEST_DB}" go run main.go migrate up + @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;" ## Build linux bin build-linux: - GOOS=linux GOARCH=amd64 go build -o serverservice + GOOS=linux GOARCH=amd64 go build -o fleetdb -## build docker image and tag as ghcr.io/metal-toolbox/hollow-serverservice:latest +## build docker image and tag as ghcr.io/metal-toolbox/fleetdb:latest build-image: build-linux docker build --rm=true -f Dockerfile -t ${DOCKER_IMAGE}:latest . \ --label org.label-schema.schema-version=1.0 \ @@ -83,9 +83,9 @@ build-image: build-linux ## build and push devel docker image to KIND image repo used by the sandbox - https://github.com/metal-toolbox/sandbox push-image-devel: build-image - docker tag ${DOCKER_IMAGE}:latest localhost:5001/serverservice:latest - docker push localhost:5001/serverservice:latest - kind load docker-image localhost:5001/serverservice:latest + docker tag ${DOCKER_IMAGE}:latest localhost:5001/fleetdb:latest + docker push localhost:5001/fleetdb:latest + kind load docker-image localhost:5001/fleetdb:latest # https://gist.github.com/prwhite/8168133 diff --git a/README.md b/README.md index 3fcf6d3..65eef73 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Server Service +# FleetDB > This repository is experimental meaning that it's based on untested ideas or techniques and not yet established or finalized or involves a radically new and innovative style! > This means that support is best effort (at best!) and we strongly encourage you to NOT use this in production. -The server service is a microservice within the Hollow eco-system. Server service is responsible for providing a store for physical server information. Support to storing the device components that make up the server is available. You are also able to create attributes and versioned-attributes for both servers and the server components. +The fleetdb is a microservice within the Hollow eco-system. FleetDB is responsible for providing a store for physical server information. Support to storing the device components that make up the server is available. You are also able to create attributes and versioned-attributes for both servers and the server components. ## Quickstart to running locally @@ -13,16 +13,16 @@ The cockroachdb client is required to create and drop the test database. Follow the instructions to install the cockroachdb dependency https://www.cockroachlabs.com/docs/stable/install-cockroachdb.html -### Running server service +### Running fleetdb -To run the server service locally you can bring it up with docker-compose. This will run with released images from the hollow container registry. +To run the fleetdb locally you can bring it up with docker-compose. This will run with released images from the hollow container registry. ```bash docker-compose -f quickstart.yml up ``` ### Enable tracing -To run the server service locally with tracing enabled you just need to include the `quickstart-tracing.yml` file. +To run the fleetdb locally with tracing enabled you just need to include the `quickstart-tracing.yml` file. ```bash docker-compose -f quickstart.yml -f quickstart-tracing.yml up @@ -30,7 +30,7 @@ docker-compose -f quickstart.yml -f quickstart-tracing.yml up ### Running with local changes -The `quickstart.yml` compose file will run server service from released images and not the local code base. If you are doing development and want to run with your local code you can use the following command. +The `quickstart.yml` compose file will run fleetdb from released images and not the local code base. If you are doing development and want to run with your local code you can use the following command. ```bash docker-compose -f quickstart.yml -f quickstart-dev.yml up --build @@ -54,11 +54,11 @@ sqlboiler crdb --add-soft-deletes Export the DB URI required for integration tests. ```bash -export SERVERSERVICE_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=serverservice_test" +export FLEETDB_CRDB_URI="host=localhost port=26257 user=root sslmode=disable dbname=fleetdb_test" ``` Run test. ```bash -go test -timeout 30s -tags testtools -run ^TestIntegrationServerListComponents$ go.hollow.sh/serverservice/pkg/api/v1 -v +go test -timeout 30s -tags testtools -run ^TestIntegrationServerListComponents$ go.hollow.sh/fleetdb/pkg/api/v1 -v ``` diff --git a/cmd/doc.go b/cmd/doc.go index 17e275a..df5b504 100644 --- a/cmd/doc.go +++ b/cmd/doc.go @@ -1,2 +1,2 @@ // Package cmd provides our CLI interface for the hollow binary -package cmd // import "go.hollow.sh/serverservice/cmd" +package cmd // import "go.hollow.sh/fleetdb/cmd" diff --git a/cmd/root.go b/cmd/root.go index 9218767..0432440 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,20 +13,20 @@ import ( "go.infratographer.com/x/versionx" "go.uber.org/zap" - dbm "go.hollow.sh/serverservice/db" - "go.hollow.sh/serverservice/internal/config" + dbm "go.hollow.sh/fleetdb/db" + "go.hollow.sh/fleetdb/internal/config" ) var ( - appName = "serverservice" + appName = "fleetdb" cfgFile string logger *zap.SugaredLogger ) // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "serverservice", - Short: "Server Service for Hollow ecosystem", + Use: "fleetdb", + Short: "FleetDB for Hollow ecosystem", } // Execute adds all child commands to the root command and sets flags appropriately. @@ -69,7 +69,7 @@ func initConfig() { } viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) - viper.SetEnvPrefix("serverservice") + viper.SetEnvPrefix("fleetdb") viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. diff --git a/cmd/serve.go b/cmd/serve.go index 072a485..7c563cd 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -17,9 +17,9 @@ import ( // import gocdk secret drivers _ "gocloud.dev/secrets/localsecrets" - "go.hollow.sh/serverservice/internal/config" - "go.hollow.sh/serverservice/internal/dbtools" - "go.hollow.sh/serverservice/internal/httpsrv" + "go.hollow.sh/fleetdb/internal/config" + "go.hollow.sh/fleetdb/internal/dbtools" + "go.hollow.sh/fleetdb/internal/httpsrv" ) var ( @@ -77,10 +77,10 @@ func init() { rootCmd.PersistentFlags().String("nats-stream-name", appName, "prefix for NATS subjects") viperx.MustBindFlag(viper.GetViper(), "nats.stream.name", rootCmd.PersistentFlags().Lookup("nats-stream-name")) - rootCmd.PersistentFlags().String("nats-stream-prefix", "com.hollow.sh.serverservice.events", "NATS stream prefix") + rootCmd.PersistentFlags().String("nats-stream-prefix", "com.hollow.sh.fleetdb.events", "NATS stream prefix") viperx.MustBindFlag(viper.GetViper(), "nats.stream.prefix", rootCmd.PersistentFlags().Lookup("nats-stream-prefix")) - rootCmd.PersistentFlags().StringSlice("nats-stream-subjects", []string{"com.hollow.sh.serverservice.events.>"}, "NATS stream subject(s)") + rootCmd.PersistentFlags().StringSlice("nats-stream-subjects", []string{"com.hollow.sh.fleetdb.events.>"}, "NATS stream subject(s)") viperx.MustBindFlag(viper.GetViper(), "nats.stream.subjects", rootCmd.PersistentFlags().Lookup("nats-stream-subjects")) rootCmd.PersistentFlags().String("nats-stream-urn-ns", "hollow", "NATS stream URN namespace value") diff --git a/fleetdb b/fleetdb new file mode 100755 index 0000000..65bc02e Binary files /dev/null and b/fleetdb differ diff --git a/go.mod b/go.mod index d52a732..8249bf1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module go.hollow.sh/serverservice +module go.hollow.sh/fleetdb go 1.19 @@ -36,6 +36,7 @@ require ( require ( github.com/volatiletech/sqlboiler v3.7.1+incompatible + go.hollow.sh/serverservice v0.16.2 go.hollow.sh/toolbox v0.6.1 go.infratographer.com/x v0.3.7 gocloud.dev v0.33.0 @@ -122,7 +123,6 @@ require ( golang.org/x/text v0.12.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.137.0 // indirect - google.golang.org/genproto v0.0.0-20230815205213-6bfd019c3878 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230815205213-6bfd019c3878 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 // indirect google.golang.org/grpc v1.57.0 // indirect diff --git a/go.sum b/go.sum index c91a542..4e58756 100644 --- a/go.sum +++ b/go.sum @@ -683,6 +683,8 @@ go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dY go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.4/go.mod h1:Ud+VUwIi9/uQHOMA+4ekToJ12lTxlv0zB/+DHwTGEbU= go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= +go.hollow.sh/serverservice v0.16.2 h1:0wt0XJC/rm4OdovB6g8Fsx7BT2X71pG0keJiiLZaY+w= +go.hollow.sh/serverservice v0.16.2/go.mod h1:Zr99vSFO++ZlDjEf9rtPWi3TiMgMswJCW3D6LIFmMDM= go.hollow.sh/toolbox v0.6.1 h1:3E6JofImSCe63XayczbGfDxIXUjmBziMBBmbwook8WA= go.hollow.sh/toolbox v0.6.1/go.mod h1:nl+5RDDyYY/+wukOUzHHX2mOyWKRjlTOXUcGxny+tns= go.infratographer.com/x v0.3.7 h1:kkykoVtC8XrmvC4oZwHWa/15+dv9RhQHgSm8KoEb/Nc= @@ -1211,7 +1213,6 @@ google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20230815205213-6bfd019c3878 h1:Iveh6tGCJkHAjJgEqUQYGDGgbwmhjoAOz8kO/ajxefY= -google.golang.org/genproto v0.0.0-20230815205213-6bfd019c3878/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= google.golang.org/genproto/googleapis/api v0.0.0-20230815205213-6bfd019c3878 h1:WGq4lvB/mlicysM/dUT3SBvijH4D3sm/Ny1A4wmt2CI= google.golang.org/genproto/googleapis/api v0.0.0-20230815205213-6bfd019c3878/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 h1:lv6/DhyiFFGsmzxbsUUTOkN29II+zeWHxvT8Lpdxsv0= diff --git a/internal/dbtools/doc.go b/internal/dbtools/doc.go index d7e5d2a..5086e03 100644 --- a/internal/dbtools/doc.go +++ b/internal/dbtools/doc.go @@ -1,3 +1,3 @@ // Package dbtools provides tools to help with interacting with the database, // including all of our utilities for database integration testing -package dbtools // import "go.hollow.sh/serverservice/internal/dbtools" +package dbtools // import "go.hollow.sh/fleetdb/internal/dbtools" diff --git a/internal/dbtools/encryption_test.go b/internal/dbtools/encryption_test.go index 86347ff..15124ad 100644 --- a/internal/dbtools/encryption_test.go +++ b/internal/dbtools/encryption_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - "go.hollow.sh/serverservice/internal/dbtools" + "go.hollow.sh/fleetdb/internal/dbtools" ) func TestEncryptandDecrypt(t *testing.T) { diff --git a/internal/dbtools/fixtures.go b/internal/dbtools/fixtures.go index f256e2b..c0c885e 100644 --- a/internal/dbtools/fixtures.go +++ b/internal/dbtools/fixtures.go @@ -13,7 +13,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/types" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) //nolint:revive diff --git a/internal/dbtools/hooks.go b/internal/dbtools/hooks.go index 26ca26a..55b75b7 100644 --- a/internal/dbtools/hooks.go +++ b/internal/dbtools/hooks.go @@ -6,7 +6,7 @@ import ( "github.com/gosimple/slug" "github.com/volatiletech/sqlboiler/v4/boil" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // RegisterHooks adds any hooks that are configured to the models library diff --git a/internal/dbtools/testtools.go b/internal/dbtools/testtools.go index 10a25f7..3599e0c 100644 --- a/internal/dbtools/testtools.go +++ b/internal/dbtools/testtools.go @@ -23,11 +23,11 @@ import ( // import gocdk secret drivers _ "gocloud.dev/secrets/localsecrets" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // TestDBURI is the URI for the test database -var TestDBURI = os.Getenv("SERVERSERVICE_CRDB_URI") +var TestDBURI = os.Getenv("FLEETDB_CRDB_URI") var testDB *sqlx.DB var testKeeper *secrets.Keeper diff --git a/internal/dbtools/testtools_test.go b/internal/dbtools/testtools_test.go index 8169d2a..4328d3e 100644 --- a/internal/dbtools/testtools_test.go +++ b/internal/dbtools/testtools_test.go @@ -8,8 +8,8 @@ import ( "github.com/volatiletech/null/v8" "github.com/volatiletech/sqlboiler/v4/boil" - "go.hollow.sh/serverservice/internal/dbtools" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/dbtools" + "go.hollow.sh/fleetdb/internal/models" ) // TestDatabaseTest is used to force the test commands in this package to run during diff --git a/internal/httpsrv/doc.go b/internal/httpsrv/doc.go index df72ca9..1aca62f 100644 --- a/internal/httpsrv/doc.go +++ b/internal/httpsrv/doc.go @@ -1,3 +1,3 @@ // Package httpsrv provides the HTTP server to handle all -// requests for the serverservice. -package httpsrv // import go.hollow.sh/serverservice/internal/httpsrv +// requests for the fleetdb. +package httpsrv // import go.hollow.sh/fleetdb/internal/httpsrv diff --git a/internal/httpsrv/server.go b/internal/httpsrv/server.go index 8a605a6..ed50d3c 100644 --- a/internal/httpsrv/server.go +++ b/internal/httpsrv/server.go @@ -18,7 +18,7 @@ import ( "go.uber.org/zap" "gocloud.dev/secrets" - v1api "go.hollow.sh/serverservice/pkg/api/v1" + v1api "go.hollow.sh/fleetdb/pkg/api/v1" ) // Server implements the HTTP Server @@ -164,7 +164,7 @@ func (s *Server) readinessCheck(c *gin.Context) { }) } -// version returns the serverservice build information. +// version returns the fleetdb build information. func (s *Server) version(c *gin.Context) { c.JSON(http.StatusOK, versionx.BuildDetails().String()) } diff --git a/internal/httpsrv/server_test.go b/internal/httpsrv/server_test.go index 2f3e443..f2a5664 100644 --- a/internal/httpsrv/server_test.go +++ b/internal/httpsrv/server_test.go @@ -11,8 +11,8 @@ import ( "go.hollow.sh/toolbox/ginjwt" "go.uber.org/zap" - "go.hollow.sh/serverservice/internal/dbtools" - "go.hollow.sh/serverservice/internal/httpsrv" + "go.hollow.sh/fleetdb/internal/dbtools" + "go.hollow.sh/fleetdb/internal/httpsrv" ) var serverAuthConfig = ginjwt.AuthConfig{ diff --git a/main.go b/main.go index 899e4ad..6356bb0 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main //go:generate sqlboiler crdb --add-soft-deletes -import "go.hollow.sh/serverservice/cmd" +import "go.hollow.sh/fleetdb/cmd" func main() { cmd.Execute() diff --git a/pkg/api/v1/attribute_list_params.go b/pkg/api/v1/attribute_list_params.go index 0130297..f40d680 100644 --- a/pkg/api/v1/attribute_list_params.go +++ b/pkg/api/v1/attribute_list_params.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "fmt" diff --git a/pkg/api/v1/attribute_list_params_test.go b/pkg/api/v1/attribute_list_params_test.go index fb04f76..cffed11 100644 --- a/pkg/api/v1/attribute_list_params_test.go +++ b/pkg/api/v1/attribute_list_params_test.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "net/http" diff --git a/pkg/api/v1/attributes.go b/pkg/api/v1/attributes.go index b097fdb..cbf203b 100644 --- a/pkg/api/v1/attributes.go +++ b/pkg/api/v1/attributes.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "encoding/json" @@ -6,7 +6,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/types" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // Attributes provide the ability to apply namespaced settings to an entity. diff --git a/pkg/api/v1/bom.go b/pkg/api/v1/bom.go index d1fd595..4b8a848 100644 --- a/pkg/api/v1/bom.go +++ b/pkg/api/v1/bom.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "strings" @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" "github.com/volatiletech/null/v8" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // Bom provides a struct to map the bom_info table. diff --git a/pkg/api/v1/client.go b/pkg/api/v1/client.go index bdffa05..5d4f324 100644 --- a/pkg/api/v1/client.go +++ b/pkg/api/v1/client.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "context" @@ -9,7 +9,7 @@ import ( var apiVersion = "v1" -// Client has the ability to talk to a hollow server service api server running at the given URI +// Client has the ability to talk to a hollow fleetdb api server running at the given URI type Client struct { url string authToken string @@ -37,7 +37,7 @@ func NewClientWithToken(authToken, url string, doerClient Doer) (*Client, error) return c, nil } -// NewClient will return a server service client configured to talk to the given URL. +// NewClient will return a fleetdb client configured to talk to the given URL. // This client will not set the authorization header for you automatically and is left to be handled by the Doer that is provided. // // Example: @@ -53,7 +53,7 @@ func NewClientWithToken(authToken, url string, doerClient Doer) (*Client, error) // EndpointParams: url.Values{"audience": []string{"HOLLOW_AUDIENCE_VALUE"}}, // } // -// c, _ := serverservice.NewClient("HOLLOW_URI", oauthConfig.Client(ctx)) +// c, _ := fleetdb.NewClient("HOLLOW_URI", oauthConfig.Client(ctx)) func NewClient(url string, doerClient Doer) (*Client, error) { if url == "" { return nil, newClientError("failed to initialize: no hollow api url provided") diff --git a/pkg/api/v1/client_test.go b/pkg/api/v1/client_test.go index 5714eb4..3ee30c1 100644 --- a/pkg/api/v1/client_test.go +++ b/pkg/api/v1/client_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -8,8 +8,6 @@ import ( "time" "github.com/stretchr/testify/assert" - - serverservice "go.hollow.sh/serverservice/pkg/api/v1" ) var ( @@ -48,7 +46,7 @@ func TestNewClientWithToken(t *testing.T) { } for _, tt := range testCases { - c, err := serverservice.NewClientWithToken(tt.authToken, tt.url, nil) + c, err := fleetdb.NewClientWithToken(tt.authToken, tt.url, nil) if tt.expectError { assert.Error(t, err, tt.testName) diff --git a/pkg/api/v1/doc.go b/pkg/api/v1/doc.go index bb2986e..243a7c0 100644 --- a/pkg/api/v1/doc.go +++ b/pkg/api/v1/doc.go @@ -1,2 +1,2 @@ -// Package serverservice provides the v1 api for the server service -package serverservice +// Package fleetdb provides the v1 api for the fleetdb +package fleetdb diff --git a/pkg/api/v1/errors.go b/pkg/api/v1/errors.go index 53f9c09..44dffd8 100644 --- a/pkg/api/v1/errors.go +++ b/pkg/api/v1/errors.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "encoding/json" diff --git a/pkg/api/v1/firmware.go b/pkg/api/v1/firmware.go index b238c9b..e49d8a9 100644 --- a/pkg/api/v1/firmware.go +++ b/pkg/api/v1/firmware.go @@ -1,11 +1,11 @@ -package serverservice +package fleetdb import ( "time" "github.com/google/uuid" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ComponentFirmwareVersion represents a firmware file diff --git a/pkg/api/v1/firmware_list_params.go b/pkg/api/v1/firmware_list_params.go index 7ce4937..f1bbef8 100644 --- a/pkg/api/v1/firmware_list_params.go +++ b/pkg/api/v1/firmware_list_params.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "net/url" @@ -6,7 +6,7 @@ import ( "github.com/volatiletech/sqlboiler/types" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ComponentFirmwareVersionListParams allows you to filter the results diff --git a/pkg/api/v1/firmware_set.go b/pkg/api/v1/firmware_set.go index c67b8d9..24bff33 100644 --- a/pkg/api/v1/firmware_set.go +++ b/pkg/api/v1/firmware_set.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "encoding/json" @@ -7,7 +7,7 @@ import ( "github.com/google/uuid" "github.com/volatiletech/sqlboiler/v4/types" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ComponentFirmwareSet represents a group of firmwares diff --git a/pkg/api/v1/firmware_set_list_params.go b/pkg/api/v1/firmware_set_list_params.go index bac5d17..ae94101 100644 --- a/pkg/api/v1/firmware_set_list_params.go +++ b/pkg/api/v1/firmware_set_list_params.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "fmt" @@ -6,7 +6,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ComponentFirmwareSetListParams allows you to filter the results diff --git a/pkg/api/v1/messages.go b/pkg/api/v1/messages.go index dc46607..17aa522 100644 --- a/pkg/api/v1/messages.go +++ b/pkg/api/v1/messages.go @@ -1,5 +1,5 @@ //nolint:wsl,revive -package serverservice +package fleetdb import ( "encoding/json" @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" "github.com/volatiletech/null/v8" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) var ( diff --git a/pkg/api/v1/messages_test.go b/pkg/api/v1/messages_test.go index 9f96e1a..f1148b4 100644 --- a/pkg/api/v1/messages_test.go +++ b/pkg/api/v1/messages_test.go @@ -1,5 +1,5 @@ //nolint:wsl -package serverservice +package fleetdb import ( "testing" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/volatiletech/null/v8" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func TestSerialization(t *testing.T) { diff --git a/pkg/api/v1/mock_client_test.go b/pkg/api/v1/mock_client_test.go index fdecdc6..85c7c4b 100644 --- a/pkg/api/v1/mock_client_test.go +++ b/pkg/api/v1/mock_client_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "bytes" @@ -6,7 +6,7 @@ import ( "io" "net/http" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) // MockHTTPRequestDoer implements the standard http.Client interface. @@ -35,7 +35,7 @@ func (md *MockHTTPRequestDoer) Do(req *http.Request) (*http.Response, error) { } // mockClient that can be used for testing -func mockClient(body string, status int) *serverservice.Client { +func mockClient(body string, status int) *fleetdb.Client { mockDoer := &MockHTTPRequestDoer{ Response: &http.Response{ StatusCode: status, @@ -44,7 +44,7 @@ func mockClient(body string, status int) *serverservice.Client { Error: nil, } - c, err := serverservice.NewClientWithToken("mocked", "mocked", mockDoer) + c, err := fleetdb.NewClientWithToken("mocked", "mocked", mockDoer) if err != nil { return nil } diff --git a/pkg/api/v1/pagination.go b/pkg/api/v1/pagination.go index bd913ea..421ecde 100644 --- a/pkg/api/v1/pagination.go +++ b/pkg/api/v1/pagination.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "net/url" @@ -7,7 +7,7 @@ import ( "github.com/gin-gonic/gin" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) var ( diff --git a/pkg/api/v1/requests.go b/pkg/api/v1/requests.go index 4b86dbf..d97d10f 100644 --- a/pkg/api/v1/requests.go +++ b/pkg/api/v1/requests.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "bytes" diff --git a/pkg/api/v1/requests_test.go b/pkg/api/v1/requests_test.go index e1cceb3..645f50d 100644 --- a/pkg/api/v1/requests_test.go +++ b/pkg/api/v1/requests_test.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "context" diff --git a/pkg/api/v1/router.go b/pkg/api/v1/router.go index d058782..9ac22a6 100644 --- a/pkg/api/v1/router.go +++ b/pkg/api/v1/router.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "context" @@ -16,7 +16,7 @@ import ( "go.uber.org/zap" "gocloud.dev/secrets" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // Router provides a router for the v1 API diff --git a/pkg/api/v1/router_bom.go b/pkg/api/v1/router_bom.go index dd72c07..1e0eb53 100644 --- a/pkg/api/v1/router_bom.go +++ b/pkg/api/v1/router_bom.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "database/sql" @@ -8,7 +8,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) bomsUpload(c *gin.Context) { diff --git a/pkg/api/v1/router_bom_test.go b/pkg/api/v1/router_bom_test.go index 83ae579..6d7bc23 100644 --- a/pkg/api/v1/router_bom_test.go +++ b/pkg/api/v1/router_bom_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -6,21 +6,22 @@ import ( "strings" "testing" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationBomUpload(t *testing.T) { testCases := []struct { - testName string - uploadBoms []serverservice.Bom - expectedUploadErrorMsg string + testName string + uploadBoms []fleetdb.Bom + expectedUploadErrorMsg stri + ng expectedUploadErr bool aocMacAddress string expectedAocMacAddressError bool }{ { testName: "upload 1 bom and get by aoc mac address", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -37,7 +38,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload 2 boms and get by aoc mac address", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -62,7 +63,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload duplicate serial number", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -87,7 +88,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload duplicate AocMacAddress", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -112,7 +113,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload duplicate BmcMacAddress", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -137,7 +138,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload empty serial number", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -154,7 +155,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload empty AocMacAddress", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "", @@ -171,7 +172,7 @@ func TestIntegrationBomUpload(t *testing.T) { }, { testName: "upload empty BmcMacAddress", - uploadBoms: []serverservice.Bom{ + uploadBoms: []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -227,7 +228,7 @@ func TestIntegrationBomUpload(t *testing.T) { func TestUploadInOneTransaction(t *testing.T) { uploadBoms := - []serverservice.Bom{ + []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -266,7 +267,7 @@ func TestUploadInOneTransaction(t *testing.T) { func TestIntegrationGetBomByAocMacAddr(t *testing.T) { s := serverTest(t) - uploadBoms := []serverservice.Bom{ + uploadBoms := []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -296,7 +297,7 @@ func TestIntegrationGetBomByAocMacAddr(t *testing.T) { var testCases = []struct { testName string aocMacAddress string - expectedBom serverservice.Bom + expectedBom fleetdb.Bom expectedAocMacAddressError bool expectedAocMacAddressErrorMsg string }{ @@ -371,7 +372,7 @@ func TestIntegrationGetBomByAocMacAddr(t *testing.T) { func TestIntegrationGetBomByBmcMacAddr(t *testing.T) { s := serverTest(t) - uploadBoms := []serverservice.Bom{ + uploadBoms := []fleetdb.Bom{ { SerialNum: "fakeSerialNum1", AocMacAddress: "fakeAocMacAddress1,fakeAocMacAddress2", @@ -401,7 +402,7 @@ func TestIntegrationGetBomByBmcMacAddr(t *testing.T) { var testCases = []struct { testName string bmcMacAddress string - expectedBom serverservice.Bom + expectedBom fleetdb.Bom expectedBmcMacAddressError bool expectedBmcMacAddressErrorMsg string }{ diff --git a/pkg/api/v1/router_firmware.go b/pkg/api/v1/router_firmware.go index 59bcc5d..016dd2c 100644 --- a/pkg/api/v1/router_firmware.go +++ b/pkg/api/v1/router_firmware.go @@ -1,11 +1,11 @@ -package serverservice +package fleetdb import ( "github.com/gin-gonic/gin" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) serverComponentFirmwareList(c *gin.Context) { diff --git a/pkg/api/v1/router_firmware_set.go b/pkg/api/v1/router_firmware_set.go index 6673948..05a1869 100644 --- a/pkg/api/v1/router_firmware_set.go +++ b/pkg/api/v1/router_firmware_set.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "context" @@ -13,7 +13,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) var ( diff --git a/pkg/api/v1/router_firmware_set_test.go b/pkg/api/v1/router_firmware_set_test.go index 9168016..dcb826c 100644 --- a/pkg/api/v1/router_firmware_set_test.go +++ b/pkg/api/v1/router_firmware_set_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -11,13 +11,13 @@ import ( "golang.org/x/exp/maps" "golang.org/x/exp/slices" - "go.hollow.sh/serverservice/internal/dbtools" - "go.hollow.sh/serverservice/internal/models" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + "go.hollow.sh/fleetdb/internal/models" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) // r640FirmwareFixtureUUIDs returns firmware uuids based on the firmware hardware model attribute -func r640FirmwareFixtureUUIDs(t *testing.T, firmware []serverservice.ComponentFirmwareVersion) []string { +func r640FirmwareFixtureUUIDs(t *testing.T, firmware []fleetdb.ComponentFirmwareVersion) []string { t.Helper() ids := []string{} @@ -46,7 +46,7 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - var testFirmwareSet serverservice.ComponentFirmwareSetRequest + var testFirmwareSet fleetdb.ComponentFirmwareSetRequest if !expectError { // 2. retrieve component firmware fixture data for test @@ -62,7 +62,7 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { // expect two fixture firmware objects to be returned assert.Equal(t, 2, len(r640FirmwareIDs)) - testFirmwareSet = serverservice.ComponentFirmwareSetRequest{ + testFirmwareSet = fleetdb.ComponentFirmwareSetRequest{ Name: "test-firmware-set", ComponentFirmwareUUIDs: r640FirmwareIDs, } @@ -81,21 +81,21 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { var testCases = []struct { testName string - firmwareSetPayload *serverservice.ComponentFirmwareSetRequest + firmwareSetPayload *fleetdb.ComponentFirmwareSetRequest expectedError bool expectedResponse string errorMsg string }{ { "Name field required", - &serverservice.ComponentFirmwareSetRequest{}, + &fleetdb.ComponentFirmwareSetRequest{}, true, "400", "required attribute not set: Name", }, { "component firmware UUIDs required", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar", }, true, @@ -104,7 +104,7 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { }, { "valid UUIDs for the firmware ID expected", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar", ComponentFirmwareUUIDs: []string{ r640FirmwareIDs[0], @@ -117,7 +117,7 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { }, { "duplicate firmware UUIDs are not accepted", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar", ComponentFirmwareUUIDs: []string{ r640FirmwareIDs[0], @@ -130,7 +130,7 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { }, { "non-existing firmware UUID are not accepted", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar", ComponentFirmwareUUIDs: []string{ "d825bbeb-20fb-452e-9fe4-cdedacb2ca1f", @@ -142,10 +142,10 @@ func TestIntegrationServerComponentFirmwareSetCreate(t *testing.T) { }, { "firmware set added referencing firmware UUIDs", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar", ComponentFirmwareUUIDs: r640FirmwareIDs, - Attributes: []serverservice.Attributes{ + Attributes: []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.metadata", Data: json.RawMessage(`{"created by": "foobar"}`), @@ -190,7 +190,7 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { var err error - _, err = s.Client.UpdateComponentFirmwareSetRequest(ctx, firmwareSetID, serverservice.ComponentFirmwareSetRequest{}) + _, err = s.Client.UpdateComponentFirmwareSetRequest(ctx, firmwareSetID, fleetdb.ComponentFirmwareSetRequest{}) if !expectError { return nil } @@ -210,8 +210,8 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { var testCases = []struct { testName string - firmwareSetPayload *serverservice.ComponentFirmwareSetRequest - expectFirmwareSetAttributes []serverservice.Attributes + firmwareSetPayload *fleetdb.ComponentFirmwareSetRequest + expectFirmwareSetAttributes []fleetdb.Attributes expectedFirmwareCount int expectedError bool expectedResponse string @@ -219,7 +219,7 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }{ { "component firmware set UUID required", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar", }, nil, @@ -230,7 +230,7 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "valid UUIDs for the firmware ID expected", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ ID: firmwareSetID, Name: "foobar", ComponentFirmwareUUIDs: []string{ @@ -245,7 +245,7 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "duplicate firmware UUIDs are not accepted", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ ID: firmwareSetID, Name: "foobar", ComponentFirmwareUUIDs: []string{ @@ -261,7 +261,7 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "non-existing firmware UUID are not accepted", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ ID: firmwareSetID, Name: "foobar", ComponentFirmwareUUIDs: []string{ @@ -276,7 +276,7 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "update an existing firmware set - update name, referenced firmware", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar-updated", ID: firmwareSetID, ComponentFirmwareUUIDs: []string{dbtools.FixtureDellR640CPLD.ID}, @@ -289,17 +289,17 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "update an existing firmware set - update labels", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar-updated", ID: firmwareSetID, - Attributes: []serverservice.Attributes{ + Attributes: []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{"created by": "foobar"}`), }, }, }, - []serverservice.Attributes{ + []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{"created by": "foobar"}`), @@ -312,16 +312,16 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "update a firmware set with no attributes data does not overwrite existing attributes", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar-updated", ID: firmwareSetID, - Attributes: []serverservice.Attributes{ + Attributes: []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", }, }, }, - []serverservice.Attributes{ + []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{"created by": "foobar"}`), @@ -334,17 +334,17 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "update a firmware set with new attributes updates existing attributes", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar-updated", ID: firmwareSetID, - Attributes: []serverservice.Attributes{ + Attributes: []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{"updated by": "foo"}`), }, }, }, - []serverservice.Attributes{ + []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{"updated by": "foo"}`), @@ -357,11 +357,11 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "update an existing firmware set with empty attributes does not purge existing attributes", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar-updated-again", ID: firmwareSetID, }, - []serverservice.Attributes{ + []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{"updated by": "foo"}`), @@ -374,17 +374,17 @@ func TestIntegrationServerComponentFirmwareSetUpdate(t *testing.T) { }, { "update a firmware set attributes to be empty", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ Name: "foobar-updated", ID: firmwareSetID, - Attributes: []serverservice.Attributes{ + Attributes: []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{}`), }, }, }, - []serverservice.Attributes{ + []fleetdb.Attributes{ { Namespace: "sh.hollow.firmware_set.labels", Data: json.RawMessage(`{}`), @@ -523,7 +523,7 @@ func TestIntegrationServerComponentFirmwareSetGet(t *testing.T) { } } -func assertAttributesContains(t *testing.T, attrs []serverservice.Attributes, a []byte) bool { +func assertAttributesContains(t *testing.T, attrs []fleetdb.Attributes, a []byte) bool { for _, attr := range attrs { if assertAttributesEqual(t, a, attr.Data) { return true @@ -567,7 +567,7 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { testCases := []struct { testName string - params *serverservice.ComponentFirmwareSetListParams + params *fleetdb.ComponentFirmwareSetListParams expectedFirmwareSetAttribute []*models.AttributesFirmwareSet expectedFirmwareModels []string expectedTotalRecordCount int @@ -578,7 +578,7 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { { "list firmware set by name - r640", - &serverservice.ComponentFirmwareSetListParams{Name: "r640"}, + &fleetdb.ComponentFirmwareSetListParams{Name: "r640"}, []*models.AttributesFirmwareSet{dbtools.FixtureFirmwareSetR640Attribute}, []string{"R640"}, 1, @@ -588,7 +588,7 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { }, { "list firmware set by name - r6515", - &serverservice.ComponentFirmwareSetListParams{Name: "r6515"}, + &fleetdb.ComponentFirmwareSetListParams{Name: "r6515"}, []*models.AttributesFirmwareSet{dbtools.FixtureFirmwareSetR6515Attribute}, []string{"R6515"}, 1, @@ -598,8 +598,8 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { }, { "list with pagination Limit, Offset", - &serverservice.ComponentFirmwareSetListParams{ - Pagination: &serverservice.PaginationParams{ + &fleetdb.ComponentFirmwareSetListParams{ + Pagination: &fleetdb.PaginationParams{ Limit: 1, Page: 2, }, @@ -613,8 +613,8 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { }, { "list firmware set by attribute params", - &serverservice.ComponentFirmwareSetListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ComponentFirmwareSetListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: "sh.hollow.firmware_set.labels", Keys: []string{"vendor"}, @@ -638,8 +638,8 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { }, { "list firmware set by attribute params with OR on attribute", - &serverservice.ComponentFirmwareSetListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ComponentFirmwareSetListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: "sh.hollow.firmware_set.labels", Keys: []string{"model"}, @@ -651,7 +651,7 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { Keys: []string{"model"}, Operator: "eq", Value: "x11dph-t", - AttributeOperator: serverservice.AttributeLogicalOR, + AttributeOperator: fleetdb.AttributeLogicalOR, }, }, }, @@ -667,7 +667,7 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { }, { "list with incorrect firmware set Name attribute returns no records", - &serverservice.ComponentFirmwareSetListParams{ + &fleetdb.ComponentFirmwareSetListParams{ Name: "does-not-exist", }, nil, @@ -706,7 +706,7 @@ func TestIntegrationServerComponentFirmwareSetList(t *testing.T) { } } -func assertContainsFirmwareSetAttributes(t *testing.T, fwSetModelAttrs []*models.AttributesFirmwareSet, fwSets []serverservice.ComponentFirmwareSet) bool { +func assertContainsFirmwareSetAttributes(t *testing.T, fwSetModelAttrs []*models.AttributesFirmwareSet, fwSets []fleetdb.ComponentFirmwareSet) bool { t.Helper() expected := len(fwSetModelAttrs) @@ -724,7 +724,7 @@ func assertContainsFirmwareSetAttributes(t *testing.T, fwSetModelAttrs []*models return expected == got } -func assertFirmwareSetAttributeNSEqual(t *testing.T, fwSetModelAttrs []*models.AttributesFirmwareSet, fwSets []serverservice.ComponentFirmwareSet) bool { +func assertFirmwareSetAttributeNSEqual(t *testing.T, fwSetModelAttrs []*models.AttributesFirmwareSet, fwSets []fleetdb.ComponentFirmwareSet) bool { for _, fwSetModelAttr := range fwSetModelAttrs { for _, fwSet := range fwSets { for _, attr := range fwSet.Attributes { @@ -739,7 +739,7 @@ func assertFirmwareSetAttributeNSEqual(t *testing.T, fwSetModelAttrs []*models.A return true } -func firmwareSetContainsModel(t *testing.T, models []string, set []serverservice.ComponentFirmwareSet) bool { +func firmwareSetContainsModel(t *testing.T, models []string, set []fleetdb.ComponentFirmwareSet) bool { t.Helper() for _, model := range models { @@ -836,7 +836,7 @@ func TestIntegrationServerComponentFirmwareSetRemoveFirmware(t *testing.T) { var err error - _, err = s.Client.RemoveServerComponentFirmwareSetFirmware(ctx, firmwareSetID, serverservice.ComponentFirmwareSetRequest{}) + _, err = s.Client.RemoveServerComponentFirmwareSetFirmware(ctx, firmwareSetID, fleetdb.ComponentFirmwareSetRequest{}) if !expectError { return nil } @@ -861,21 +861,21 @@ func TestIntegrationServerComponentFirmwareSetRemoveFirmware(t *testing.T) { var testCases = []struct { testName string - firmwareSetPayload *serverservice.ComponentFirmwareSetRequest + firmwareSetPayload *fleetdb.ComponentFirmwareSetRequest expectedError bool errorMsg string expectedResponse string }{ { "component firmware set UUID required", - &serverservice.ComponentFirmwareSetRequest{}, + &fleetdb.ComponentFirmwareSetRequest{}, true, "", "expected a valid firmware set UUID", }, { "payload must include a non-nil firmware set UUID", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ ID: uuid.Nil, Name: "foobar", }, @@ -885,7 +885,7 @@ func TestIntegrationServerComponentFirmwareSetRemoveFirmware(t *testing.T) { }, { "firmware for removal must be part of firmware set", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ ID: firmwareSetID, ComponentFirmwareUUIDs: []string{uuid.NewString()}, }, @@ -895,7 +895,7 @@ func TestIntegrationServerComponentFirmwareSetRemoveFirmware(t *testing.T) { }, { "firmware removed from set", - &serverservice.ComponentFirmwareSetRequest{ + &fleetdb.ComponentFirmwareSetRequest{ ID: firmwareSetID, ComponentFirmwareUUIDs: []string{r640FirmwareIDs[0]}, }, diff --git a/pkg/api/v1/router_firmware_test.go b/pkg/api/v1/router_firmware_test.go index b1cfd97..7a79cd7 100644 --- a/pkg/api/v1/router_firmware_test.go +++ b/pkg/api/v1/router_firmware_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.hollow.sh/serverservice/internal/dbtools" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationFirmwareList(t *testing.T) { @@ -20,7 +20,7 @@ func TestIntegrationFirmwareList(t *testing.T) { scopedRealClientTests(t, scopes, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - params := serverservice.ComponentFirmwareVersionListParams{ + params := fleetdb.ComponentFirmwareVersionListParams{ Vendor: "", Model: nil, Version: "", @@ -42,14 +42,14 @@ func TestIntegrationFirmwareList(t *testing.T) { var testCases = []struct { testName string - params *serverservice.ComponentFirmwareVersionListParams + params *fleetdb.ComponentFirmwareVersionListParams expectedUUIDs []string expectError bool errorMsg string }{ { "search by vendor", - &serverservice.ComponentFirmwareVersionListParams{ + &fleetdb.ComponentFirmwareVersionListParams{ Vendor: "Dell", }, []string{ @@ -64,7 +64,7 @@ func TestIntegrationFirmwareList(t *testing.T) { }, { "search by model", - &serverservice.ComponentFirmwareVersionListParams{ + &fleetdb.ComponentFirmwareVersionListParams{ Model: []string{"X11DPH-T"}, }, []string{dbtools.FixtureSuperMicroX11DPHTBMC.ID}, @@ -73,7 +73,7 @@ func TestIntegrationFirmwareList(t *testing.T) { }, { "search by version", - &serverservice.ComponentFirmwareVersionListParams{ + &fleetdb.ComponentFirmwareVersionListParams{ Version: "2.6.6", }, []string{dbtools.FixtureDellR6515BIOS.ID}, @@ -82,7 +82,7 @@ func TestIntegrationFirmwareList(t *testing.T) { }, { "search by filename", - &serverservice.ComponentFirmwareVersionListParams{ + &fleetdb.ComponentFirmwareVersionListParams{ Filename: "BIOS_C4FT0_WN64_2.6.6.EXE", }, []string{dbtools.FixtureDellR6515BIOS.ID}, @@ -91,7 +91,7 @@ func TestIntegrationFirmwareList(t *testing.T) { }, { "search by checksum", - &serverservice.ComponentFirmwareVersionListParams{ + &fleetdb.ComponentFirmwareVersionListParams{ Checksum: "1ddcb3c3d0fc5925ef03a3dde768e9e245c579039dd958fc0f3a9c6368b6c5f4", }, []string{dbtools.FixtureDellR6515BIOS.ID}, @@ -100,9 +100,9 @@ func TestIntegrationFirmwareList(t *testing.T) { }, { "limit results", - &serverservice.ComponentFirmwareVersionListParams{ + &fleetdb.ComponentFirmwareVersionListParams{ Vendor: "Dell", - Pagination: &serverservice.PaginationParams{Limit: 1}, + Pagination: &fleetdb.PaginationParams{Limit: 1}, }, []string{dbtools.FixtureDellR640BIOS.ID}, false, @@ -151,7 +151,7 @@ func TestIntegrationServerComponentFirmwareCreate(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - testFirmware := serverservice.ComponentFirmwareVersion{ + testFirmware := fleetdb.ComponentFirmwareVersion{ UUID: uuid.New(), Vendor: "dell", Model: []string{"r615"}, @@ -177,14 +177,14 @@ func TestIntegrationServerComponentFirmwareCreate(t *testing.T) { var testCases = []struct { testName string - firmware *serverservice.ComponentFirmwareVersion + firmware *fleetdb.ComponentFirmwareVersion expectedError bool expectedResponse string errorMsg string }{ { "empty required parameters", - &serverservice.ComponentFirmwareVersion{ + &fleetdb.ComponentFirmwareVersion{ UUID: uuid.New(), Vendor: "dell", Model: nil, @@ -201,7 +201,7 @@ func TestIntegrationServerComponentFirmwareCreate(t *testing.T) { }, { "required lowercase parameters", - &serverservice.ComponentFirmwareVersion{ + &fleetdb.ComponentFirmwareVersion{ UUID: uuid.New(), Vendor: "DELL", Model: []string{"r615"}, @@ -218,7 +218,7 @@ func TestIntegrationServerComponentFirmwareCreate(t *testing.T) { }, { "filename allowed to be mixed case", - &serverservice.ComponentFirmwareVersion{ + &fleetdb.ComponentFirmwareVersion{ UUID: uuid.New(), Vendor: "dell", Model: []string{"r615"}, @@ -235,7 +235,7 @@ func TestIntegrationServerComponentFirmwareCreate(t *testing.T) { }, { "duplicate vendor/component/version/filename not allowed", - &serverservice.ComponentFirmwareVersion{ + &fleetdb.ComponentFirmwareVersion{ UUID: uuid.New(), Vendor: "dell", Model: []string{"r615"}, @@ -271,12 +271,12 @@ func TestIntegrationServerComponentFirmwareDelete(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - _, err := s.Client.DeleteServerComponentFirmware(ctx, serverservice.ComponentFirmwareVersion{UUID: uuid.MustParse(dbtools.FixtureDellR640CPLD.ID)}) + _, err := s.Client.DeleteServerComponentFirmware(ctx, fleetdb.ComponentFirmwareVersion{UUID: uuid.MustParse(dbtools.FixtureDellR640CPLD.ID)}) return err }) - _, err := s.Client.DeleteServerComponentFirmware(context.TODO(), serverservice.ComponentFirmwareVersion{UUID: uuid.MustParse(dbtools.FixtureDellR640BMC.ID)}) + _, err := s.Client.DeleteServerComponentFirmware(context.TODO(), fleetdb.ComponentFirmwareVersion{UUID: uuid.MustParse(dbtools.FixtureDellR640BMC.ID)}) assert.Contains(t, err.Error(), "violates foreign key constraint \"fk_firmware_id_ref_component_firmware_version\"") } @@ -286,7 +286,7 @@ func TestIntegrationServerComponentFirmwareUpdate(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - fw := serverservice.ComponentFirmwareVersion{ + fw := fleetdb.ComponentFirmwareVersion{ UUID: uuid.MustParse(dbtools.FixtureDellR640BMC.ID), Vendor: "dell", Model: []string{"r615"}, diff --git a/pkg/api/v1/router_int_test.go b/pkg/api/v1/router_int_test.go index 26c0055..7e29c72 100644 --- a/pkg/api/v1/router_int_test.go +++ b/pkg/api/v1/router_int_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "net/http" @@ -13,9 +13,9 @@ import ( "gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2/jwt" - "go.hollow.sh/serverservice/internal/dbtools" - "go.hollow.sh/serverservice/internal/httpsrv" - hollow "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + "go.hollow.sh/fleetdb/internal/httpsrv" + hollow "go.hollow.sh/fleetdb/pkg/api/v1" ) type integrationServer struct { diff --git a/pkg/api/v1/router_responses.go b/pkg/api/v1/router_responses.go index 36531b5..81d5a0c 100644 --- a/pkg/api/v1/router_responses.go +++ b/pkg/api/v1/router_responses.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "database/sql" diff --git a/pkg/api/v1/router_server.go b/pkg/api/v1/router_server.go index 7e1faa5..a845c99 100644 --- a/pkg/api/v1/router_server.go +++ b/pkg/api/v1/router_server.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "encoding/json" @@ -11,7 +11,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/types" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) serverList(c *gin.Context) { diff --git a/pkg/api/v1/router_server_attributes.go b/pkg/api/v1/router_server_attributes.go index 398ddfe..bf49bf6 100644 --- a/pkg/api/v1/router_server_attributes.go +++ b/pkg/api/v1/router_server_attributes.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "database/sql" @@ -8,7 +8,7 @@ import ( "github.com/gin-gonic/gin" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) serverAttributesList(c *gin.Context) { diff --git a/pkg/api/v1/router_server_attributes_test.go b/pkg/api/v1/router_server_attributes_test.go index 2e5754f..297bf59 100644 --- a/pkg/api/v1/router_server_attributes_test.go +++ b/pkg/api/v1/router_server_attributes_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.hollow.sh/serverservice/internal/dbtools" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationServerCreateAttributes(t *testing.T) { @@ -20,7 +20,7 @@ func TestIntegrationServerCreateAttributes(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - attrs := serverservice.Attributes{ + attrs := fleetdb.Attributes{ Namespace: "integration.tests", Data: json.RawMessage([]byte(`{"setting":"enabled"}`)), } diff --git a/pkg/api/v1/router_server_component_type.go b/pkg/api/v1/router_server_component_type.go index 3bb1a0f..d375188 100644 --- a/pkg/api/v1/router_server_component_type.go +++ b/pkg/api/v1/router_server_component_type.go @@ -1,10 +1,10 @@ -package serverservice +package fleetdb import ( "github.com/gin-gonic/gin" "github.com/volatiletech/sqlboiler/v4/boil" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) serverComponentTypeCreate(c *gin.Context) { diff --git a/pkg/api/v1/router_server_component_type_test.go b/pkg/api/v1/router_server_component_type_test.go index 94c0aff..d458901 100644 --- a/pkg/api/v1/router_server_component_type_test.go +++ b/pkg/api/v1/router_server_component_type_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.hollow.sh/serverservice/internal/dbtools" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationCreateServerComponentType(t *testing.T) { @@ -18,7 +18,7 @@ func TestIntegrationCreateServerComponentType(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - hct := serverservice.ServerComponentType{Name: "integration-test"} + hct := fleetdb.ServerComponentType{Name: "integration-test"} resp, err := s.Client.CreateServerComponentType(ctx, hct) if !expectError { diff --git a/pkg/api/v1/router_server_components.go b/pkg/api/v1/router_server_components.go index 4cbdad9..1e398bc 100644 --- a/pkg/api/v1/router_server_components.go +++ b/pkg/api/v1/router_server_components.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "database/sql" @@ -10,7 +10,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) var ( diff --git a/pkg/api/v1/router_server_components_test.go b/pkg/api/v1/router_server_components_test.go index 9ff092f..80c8afc 100644 --- a/pkg/api/v1/router_server_components_test.go +++ b/pkg/api/v1/router_server_components_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -10,18 +10,18 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.hollow.sh/serverservice/internal/dbtools" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) // zero values that change for each test run to enable object comparison -func zeroUUIDValues(sc *serverservice.ServerComponent) { +func zeroUUIDValues(sc *fleetdb.ServerComponent) { sc.ServerUUID = uuid.UUID{} sc.UUID = uuid.UUID{} sc.ComponentTypeID = "" } -func zeroTimeValues(sc *serverservice.ServerComponent) { +func zeroTimeValues(sc *fleetdb.ServerComponent) { sc.CreatedAt = time.Time{} sc.UpdatedAt = time.Time{} @@ -31,7 +31,7 @@ func zeroTimeValues(sc *serverservice.ServerComponent) { } } -func componentByNameVendorModelSerial(name, vendor, model, serial string, sc serverservice.ServerComponentSlice) *serverservice.ServerComponent { +func componentByNameVendorModelSerial(name, vendor, model, serial string, sc fleetdb.ServerComponentSlice) *fleetdb.ServerComponent { for _, c := range sc { if c.Name == name && c.Vendor == vendor && c.Model == model && c.Serial == serial { return &c @@ -58,15 +58,15 @@ func TestIntegrationServerListComponents(t *testing.T) { testCases := []struct { testName string - params *serverservice.ServerComponentListParams - expected serverservice.ServerComponentSlice + params *fleetdb.ServerComponentListParams + expected fleetdb.ServerComponentSlice errorMsg string }{ // TODO(joel): tests for unhappy paths { "by model", - &serverservice.ServerComponentListParams{Model: "Belly"}, - serverservice.ServerComponentSlice{ + &fleetdb.ServerComponentListParams{Model: "Belly"}, + fleetdb.ServerComponentSlice{ { Model: "Belly", Serial: "Up", @@ -78,9 +78,9 @@ func TestIntegrationServerListComponents(t *testing.T) { }, { "by model, versioned attributes", - &serverservice.ServerComponentListParams{ + &fleetdb.ServerComponentListParams{ Model: "Normal Fin", - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: "hollow.versioned", Keys: []string{"something"}, @@ -89,14 +89,14 @@ func TestIntegrationServerListComponents(t *testing.T) { }, }, }, - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { Model: "Normal Fin", Serial: "Left", Name: "Normal Fin", ComponentTypeName: "Fins", ComponentTypeSlug: "fins", - VersionedAttributes: []serverservice.VersionedAttributes{ + VersionedAttributes: []fleetdb.VersionedAttributes{ { Namespace: "hollow.versioned", Data: json.RawMessage(`{"something":"cool"}`), @@ -108,13 +108,13 @@ func TestIntegrationServerListComponents(t *testing.T) { }, { "pagination Limit", - &serverservice.ServerComponentListParams{ - Pagination: &serverservice.PaginationParams{ + &fleetdb.ServerComponentListParams{ + Pagination: &fleetdb.PaginationParams{ Limit: 1, }, Model: "Belly", }, - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { Model: "Belly", Serial: "Up", @@ -126,13 +126,13 @@ func TestIntegrationServerListComponents(t *testing.T) { }, { "pagination Limit, Offset", - &serverservice.ServerComponentListParams{ - Pagination: &serverservice.PaginationParams{ + &fleetdb.ServerComponentListParams{ + Pagination: &fleetdb.PaginationParams{ Limit: 1, Page: 2, }, }, - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { Name: "Normal Fin", Serial: "Right", @@ -202,7 +202,7 @@ func TestIntegrationServerGetComponents(t *testing.T) { assert.Len(t, componentTypeSlice, 1) // fixture to create a server components - csFixtureCreate := serverservice.ServerComponentSlice{ + csFixtureCreate := fleetdb.ServerComponentSlice{ { ServerUUID: servers[0].UUID, Name: "My Lucky Fin", @@ -212,7 +212,7 @@ func TestIntegrationServerGetComponents(t *testing.T) { ComponentTypeID: componentTypeSlice.ByName("Fins").ID, ComponentTypeName: componentTypeSlice.ByName("Fins").Name, ComponentTypeSlug: componentTypeSlice.ByName("Fins").Slug, - VersionedAttributes: []serverservice.VersionedAttributes{ + VersionedAttributes: []fleetdb.VersionedAttributes{ { Namespace: dbtools.FixtureNamespaceVersioned, Data: json.RawMessage(`{"version":"1.0"}`), @@ -235,21 +235,21 @@ func TestIntegrationServerGetComponents(t *testing.T) { testName string srvUUID uuid.UUID expectedCount int - expectedInSlice serverservice.ServerComponent + expectedInSlice fleetdb.ServerComponent errorMsg string }{ { "returns not found on missing server uuid", uuid.New(), 0, - serverservice.ServerComponent{}, + fleetdb.ServerComponent{}, "response code: 404", }, { "component Versioned Attributes is returned as expected", servers[0].UUID, 3, - serverservice.ServerComponent{ + fleetdb.ServerComponent{ ServerUUID: servers[0].UUID, Name: "My Lucky Fin", Vendor: "barracuda", @@ -258,7 +258,7 @@ func TestIntegrationServerGetComponents(t *testing.T) { ComponentTypeID: componentTypeSlice.ByName("Fins").ID, ComponentTypeName: componentTypeSlice.ByName("Fins").Name, ComponentTypeSlug: componentTypeSlice.ByName("Fins").Slug, - VersionedAttributes: []serverservice.VersionedAttributes{ + VersionedAttributes: []fleetdb.VersionedAttributes{ { Namespace: dbtools.FixtureNamespaceVersioned, Data: json.RawMessage(`{"version":"2.0"}`), @@ -306,15 +306,15 @@ func TestIntegrationServerCreateComponents(t *testing.T) { s := serverTest(t) // fixture objects - var servers []serverservice.Server + var servers []fleetdb.Server - var componentTypeSlice serverservice.ServerComponentTypeSlice + var componentTypeSlice fleetdb.ServerComponentTypeSlice // run default client tests realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - var sc serverservice.ServerComponentSlice + var sc fleetdb.ServerComponentSlice if !expectError { var err error @@ -329,7 +329,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { t.Fatal(err) } - sc = serverservice.ServerComponentSlice{ + sc = fleetdb.ServerComponentSlice{ { ServerUUID: servers[0].UUID, ComponentTypeID: componentTypeSlice[0].ID, @@ -357,7 +357,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { var testCases = []struct { testName string serverUUID uuid.UUID - components serverservice.ServerComponentSlice + components fleetdb.ServerComponentSlice responseMsg string errorMsg string }{ @@ -371,7 +371,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { { "create component and list by Name works", servers[0].UUID, - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { ServerUUID: servers[0].UUID, ComponentTypeID: componentTypeSlice[0].ID, @@ -388,7 +388,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { { "create component which violates unique constraint on ServerID, ComponentTypeID, Serial should return error", servers[0].UUID, - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { ServerUUID: servers[0].UUID, ComponentTypeID: componentTypeSlice[0].ID, @@ -414,7 +414,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { { "create component with unknown server UUID returns error", uuid.New(), - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { ServerUUID: uuid.New(), ComponentTypeID: componentTypeSlice[0].ID, @@ -431,7 +431,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { { "create component validates field constraints", servers[0].UUID, - serverservice.ServerComponentSlice{ + fleetdb.ServerComponentSlice{ { ServerUUID: servers[0].UUID, ComponentTypeID: "lala", @@ -446,7 +446,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { { "create component with empty slice returns error", servers[0].UUID, - serverservice.ServerComponentSlice{}, + fleetdb.ServerComponentSlice{}, "", "error in server component payload", }, @@ -466,7 +466,7 @@ func TestIntegrationServerCreateComponents(t *testing.T) { assert.NotNil(t, res) assert.Contains(t, res.Message, tt.responseMsg) - params := &serverservice.ServerComponentListParams{Name: tt.components[0].Name} + params := &fleetdb.ServerComponentListParams{Name: tt.components[0].Name} got, _, err := s.Client.ListComponents(context.TODO(), params) if err != nil { t.Error(err) @@ -487,13 +487,13 @@ func TestIntegrationServerCreateComponents(t *testing.T) { func TestIntegrationServerUpdateComponents(t *testing.T) { s := serverTest(t) // fixture objects - var servers []serverservice.Server + var servers []fleetdb.Server // run default client tests realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - var sc serverservice.ServerComponentSlice + var sc fleetdb.ServerComponentSlice if !expectError { var err error @@ -505,7 +505,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { } // update serial attribute for update to work - sc = serverservice.ServerComponentSlice{servers[0].Components[0]} + sc = fleetdb.ServerComponentSlice{servers[0].Components[0]} sc[0].Serial = "lala" } @@ -518,9 +518,9 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { }) // fixtures given to test cases below - var componentFixture []serverservice.ServerComponent + var componentFixture []fleetdb.ServerComponent - var serverFixture serverservice.Server + var serverFixture fleetdb.Server // The component fixture targeted in test cases below fixtureComponentName := "My Lucky Fin" @@ -538,8 +538,8 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { } // helper method to return fixture copy - componentFixtureCopy := func() []serverservice.ServerComponent { - var c []serverservice.ServerComponent + componentFixtureCopy := func() []fleetdb.ServerComponent { + var c []fleetdb.ServerComponent c = append(c, componentFixture...) @@ -567,7 +567,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { var testCases = []struct { testName string serverUUID uuid.UUID - components serverservice.ServerComponentSlice + components fleetdb.ServerComponentSlice change change responseMsg string errorMsg string @@ -671,11 +671,11 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { } } - var listParams *serverservice.ServerComponentListParams + var listParams *fleetdb.ServerComponentListParams // test case updates versioned attributes if len(tt.change.versionedAttributes) > 0 { - tt.components[0].VersionedAttributes = []serverservice.VersionedAttributes{ + tt.components[0].VersionedAttributes = []fleetdb.VersionedAttributes{ { Namespace: "hollow.metadata", Data: tt.change.versionedAttributes, @@ -685,7 +685,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { model := "testUpdatedVersionedAttributes" + time.Now().String() tt.components[0].Model = model - listParams = &serverservice.ServerComponentListParams{ + listParams = &fleetdb.ServerComponentListParams{ Name: fixtureComponentName, Serial: fixtureComponentSerial, Vendor: fixtureComponentVendor, @@ -695,7 +695,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { // test case updates attributes if len(tt.change.attributes) > 0 { - tt.components[0].Attributes = []serverservice.Attributes{ + tt.components[0].Attributes = []fleetdb.Attributes{ { Namespace: dbtools.FixtureNamespaceOtherdata, Data: tt.change.attributes, @@ -705,7 +705,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) { model := "testUpdatedAttributes" + time.Now().String() tt.components[0].Model = model - listParams = &serverservice.ServerComponentListParams{ + listParams = &fleetdb.ServerComponentListParams{ Name: fixtureComponentName, Serial: fixtureComponentSerial, Vendor: fixtureComponentVendor, diff --git a/pkg/api/v1/router_server_secret_types.go b/pkg/api/v1/router_server_secret_types.go index d650c38..e0c309d 100644 --- a/pkg/api/v1/router_server_secret_types.go +++ b/pkg/api/v1/router_server_secret_types.go @@ -1,10 +1,10 @@ -package serverservice +package fleetdb import ( "github.com/gin-gonic/gin" "github.com/volatiletech/sqlboiler/v4/boil" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) serverCredentialTypesList(c *gin.Context) { diff --git a/pkg/api/v1/router_server_secret_types_test.go b/pkg/api/v1/router_server_secret_types_test.go index 03b4e22..279fa6b 100644 --- a/pkg/api/v1/router_server_secret_types_test.go +++ b/pkg/api/v1/router_server_secret_types_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationServerCredentialTypesList(t *testing.T) { @@ -40,7 +40,7 @@ func TestIntegrationServerCredentialTypesCreate(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - resp, err := s.Client.CreateServerCredentialType(ctx, &serverservice.ServerCredentialType{Name: "Test Type"}) + resp, err := s.Client.CreateServerCredentialType(ctx, &fleetdb.ServerCredentialType{Name: "Test Type"}) if !expectError { require.NoError(t, err) assert.NotNil(t, resp.Links.Self) @@ -53,10 +53,10 @@ func TestIntegrationServerCredentialTypesCreate(t *testing.T) { s.Client.SetToken(validToken(adminScopes)) t.Run("creating a duplicate type fails", func(t *testing.T) { - slug := serverservice.ServerCredentialTypeBMC + slug := fleetdb.ServerCredentialTypeBMC // Make sure our server doesn't already have a BMC secret - _, err := s.Client.CreateServerCredentialType(ctx, &serverservice.ServerCredentialType{Name: "Test Type", Slug: slug}) + _, err := s.Client.CreateServerCredentialType(ctx, &fleetdb.ServerCredentialType{Name: "Test Type", Slug: slug}) assert.Error(t, err) require.Contains(t, err.Error(), "duplicate key") }) diff --git a/pkg/api/v1/router_server_secrets.go b/pkg/api/v1/router_server_secrets.go index 5408766..d0208b6 100644 --- a/pkg/api/v1/router_server_secrets.go +++ b/pkg/api/v1/router_server_secrets.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "fmt" @@ -9,8 +9,8 @@ import ( "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/dbtools" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/dbtools" + "go.hollow.sh/fleetdb/internal/models" ) func (r *Router) serverCredentialGet(c *gin.Context) { diff --git a/pkg/api/v1/router_server_secrets_test.go b/pkg/api/v1/router_server_secrets_test.go index 45d6d2c..c3e0fe7 100644 --- a/pkg/api/v1/router_server_secrets_test.go +++ b/pkg/api/v1/router_server_secrets_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.hollow.sh/serverservice/internal/dbtools" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationServerCredentialsUpsert(t *testing.T) { @@ -21,7 +21,7 @@ func TestIntegrationServerCredentialsUpsert(t *testing.T) { s.Client.SetToken(authToken) id := uuid.MustParse(dbtools.FixtureDory.ID) - slug := serverservice.ServerCredentialTypeBMC + slug := fleetdb.ServerCredentialTypeBMC path := fmt.Sprintf("http://test.hollow.com/api/v1/servers/%s/credentials/%s", id, slug) resp, err := s.Client.SetCredential(ctx, id, slug, "postgre", "something") @@ -38,7 +38,7 @@ func TestIntegrationServerCredentialsUpsert(t *testing.T) { t.Run("inserts when secret doesn't exist", func(t *testing.T) { uuid := uuid.MustParse(dbtools.FixtureMarlin.ID) - slug := serverservice.ServerCredentialTypeBMC + slug := fleetdb.ServerCredentialTypeBMC // Make sure our server doesn't already have a BMC secret secret, _, err := s.Client.GetCredential(ctx, uuid, slug) @@ -59,7 +59,7 @@ func TestIntegrationServerCredentialsUpsert(t *testing.T) { t.Run("updates when secret already exist", func(t *testing.T) { uuid := uuid.MustParse(dbtools.FixtureNemo.ID) - slug := serverservice.ServerCredentialTypeBMC + slug := fleetdb.ServerCredentialTypeBMC // Get the existing secret secret, _, err := s.Client.GetCredential(ctx, uuid, slug) @@ -83,7 +83,7 @@ func TestIntegrationServerCredentialsUpsert(t *testing.T) { t.Run("fails if server uuid not found", func(t *testing.T) { uuid := uuid.New() - slug := serverservice.ServerCredentialTypeBMC + slug := fleetdb.ServerCredentialTypeBMC // Make sure our server doesn't already have a BMC secret _, err := s.Client.SetCredential(ctx, uuid, slug, "postgre", "secret") @@ -108,7 +108,7 @@ func TestIntegrationServerSecretsDelete(t *testing.T) { s.Client.SetToken(authToken) id := uuid.MustParse(dbtools.FixtureNemo.ID) - slug := serverservice.ServerCredentialTypeBMC + slug := fleetdb.ServerCredentialTypeBMC _, err := s.Client.DeleteCredential(ctx, id, slug) if !expectError { diff --git a/pkg/api/v1/router_server_test.go b/pkg/api/v1/router_server_test.go index b6fb6a6..43eb5a2 100644 --- a/pkg/api/v1/router_server_test.go +++ b/pkg/api/v1/router_server_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/require" "github.com/volatiletech/null/v8" - "go.hollow.sh/serverservice/internal/dbtools" - serverservice "go.hollow.sh/serverservice/pkg/api/v1" + "go.hollow.sh/fleetdb/internal/dbtools" + fleetdb "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestIntegrationServerList(t *testing.T) { @@ -40,19 +40,19 @@ func TestIntegrationServerList(t *testing.T) { // These are the same test cases used in db/server_test.go var testCases = []struct { testName string - params *serverservice.ServerListParams + params *fleetdb.ServerListParams expectedUUIDs []string expectError bool errorMsg string }{ { "search by age less than 7", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceMetadata, Keys: []string{"age"}, - Operator: serverservice.OperatorLessThan, + Operator: fleetdb.OperatorLessThan, Value: "7", }, }, @@ -63,12 +63,12 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by age greater than 11 and facility code", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceMetadata, Keys: []string{"age"}, - Operator: serverservice.OperatorGreaterThan, + Operator: fleetdb.OperatorGreaterThan, Value: "11", }, }, @@ -80,7 +80,7 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by facility", - &serverservice.ServerListParams{ + &fleetdb.ServerListParams{ FacilityCode: "Ocean", }, []string{dbtools.FixtureDory.ID, dbtools.FixtureMarlin.ID}, @@ -89,18 +89,18 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by type and location from different attributes", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"type"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "blue-tang", }, { Namespace: dbtools.FixtureNamespaceMetadata, Keys: []string{"location"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "East Australian Current", }, }, @@ -111,12 +111,12 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by nested tag", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"nested", "tag"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "finding-nemo", }, }, @@ -127,12 +127,12 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by nested number greater than 1", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"nested", "number"}, - Operator: serverservice.OperatorGreaterThan, + Operator: fleetdb.OperatorGreaterThan, Value: "1", }, }, @@ -150,7 +150,7 @@ func TestIntegrationServerList(t *testing.T) { }, { "facility filter that doesn't match", - &serverservice.ServerListParams{ + &fleetdb.ServerListParams{ FacilityCode: "Neverland", }, []string{}, @@ -159,20 +159,20 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by type from attributes and name from versioned attributes", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"type"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "clown", }, }, - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"name"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "new", }, }, @@ -183,20 +183,20 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by type from attributes and name from versioned attributes, using the not current value, so nothing should return", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"type"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "clown", }, }, - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"name"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "old", }, }, @@ -207,8 +207,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by multiple components of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Model: "A Lucky Fin", Serial: "Right", @@ -225,8 +225,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "ensure both components have to match when searching by multiple components of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Name: "My Lucky Fin", Vendor: "Barracuda", @@ -245,18 +245,18 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by a single component and versioned attributes of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Model: "A Lucky Fin", Serial: "Right", }, }, - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"name"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "new", }, }, @@ -267,18 +267,18 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by a single component and versioned attributes of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Model: "A Lucky Fin", Serial: "Right", }, }, - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"name"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "new", }, }, @@ -289,15 +289,15 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by a single component and it's versioned attributes of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Model: "Normal Fin", - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"something"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "cool", }, }, @@ -310,25 +310,25 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by a component and server attributes of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Model: "Normal Fin", - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"something"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "cool", }, }, }, }, - AttributeListParams: []serverservice.AttributeListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"type"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "clown", }, }, @@ -339,25 +339,25 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by a component and server versioned attributes of the server", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { Model: "A Lucky Fin", - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"something"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "cool", }, }, }, }, - VersionedAttributeListParams: []serverservice.AttributeListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"name"}, - Operator: serverservice.OperatorEqual, + Operator: fleetdb.OperatorEqual, Value: "old", }, }, @@ -368,8 +368,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "search by a component slug", - &serverservice.ServerListParams{ - ComponentListParams: []serverservice.ServerComponentListParams{ + &fleetdb.ServerListParams{ + ComponentListParams: []fleetdb.ServerComponentListParams{ { ServerComponentType: dbtools.FixtureFinType.Slug, }, @@ -381,8 +381,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "search for devices with a versioned attributes in a namespace with key that exists", - &serverservice.ServerListParams{ - VersionedAttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"name"}, @@ -395,8 +395,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "search for devices with a versioned attributes in a namespace with key that doesn't exists", - &serverservice.ServerListParams{ - VersionedAttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, Keys: []string{"doesntExist"}, @@ -409,8 +409,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "search for devices that have versioned attributes in a namespace - no filters", - &serverservice.ServerListParams{ - VersionedAttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + VersionedAttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceVersioned, }, @@ -422,8 +422,8 @@ func TestIntegrationServerList(t *testing.T) { }, { "search for devices that have attributes in a namespace - no filters", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceMetadata, }, @@ -435,26 +435,26 @@ func TestIntegrationServerList(t *testing.T) { }, { "search for server without IncludeDeleted defined", - &serverservice.ServerListParams{}, + &fleetdb.ServerListParams{}, []string{dbtools.FixtureNemo.ID, dbtools.FixtureDory.ID, dbtools.FixtureMarlin.ID}, false, "", }, { "search for server with IncludeDeleted defined", - &serverservice.ServerListParams{IncludeDeleted: true}, + &fleetdb.ServerListParams{IncludeDeleted: true}, []string{dbtools.FixtureNemo.ID, dbtools.FixtureDory.ID, dbtools.FixtureMarlin.ID, dbtools.FixtureChuckles.ID}, false, "", }, { "search for devices by attributes that have a type like %lo%", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"type"}, - Operator: serverservice.OperatorLike, + Operator: fleetdb.OperatorLike, Value: "%lo%", }, }, @@ -465,12 +465,12 @@ func TestIntegrationServerList(t *testing.T) { }, { "search for devices by attributes that have a type like %lo", - &serverservice.ServerListParams{ - AttributeListParams: []serverservice.AttributeListParams{ + &fleetdb.ServerListParams{ + AttributeListParams: []fleetdb.AttributeListParams{ { Namespace: dbtools.FixtureNamespaceOtherdata, Keys: []string{"type"}, - Operator: serverservice.OperatorLike, + Operator: fleetdb.OperatorLike, Value: "%lo", }, }, @@ -506,7 +506,7 @@ func TestIntegrationServerListPagination(t *testing.T) { s := serverTest(t) s.Client.SetToken(validToken(adminScopes)) - p := &serverservice.ServerListParams{PaginationParams: &serverservice.PaginationParams{Limit: 2, Page: 1}} + p := &fleetdb.ServerListParams{PaginationParams: &fleetdb.PaginationParams{Limit: 2, Page: 1}} r, resp, err := s.Client.List(context.TODO(), p) assert.NoError(t, err) @@ -581,7 +581,7 @@ func TestIntegrationServerListPreload(t *testing.T) { s.Client.SetToken(validToken(adminScopes)) // should only return nemo - r, _, err := s.Client.List(context.TODO(), &serverservice.ServerListParams{FacilityCode: "Sydney"}) + r, _, err := s.Client.List(context.TODO(), &fleetdb.ServerListParams{FacilityCode: "Sydney"}) assert.NoError(t, err) assert.Len(t, r, 1) @@ -596,7 +596,7 @@ func TestIntegrationServerCreate(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - testServer := serverservice.Server{ + testServer := fleetdb.Server{ UUID: uuid.New(), Name: "test-server", FacilityCode: "int", @@ -616,12 +616,12 @@ func TestIntegrationServerCreate(t *testing.T) { var testCases = []struct { testName string - srv *serverservice.Server + srv *fleetdb.Server errorMsg string }{ { "fails on a duplicate uuid", - &serverservice.Server{ + &fleetdb.Server{ UUID: uuid.MustParse(dbtools.FixtureNemo.ID), FacilityCode: "int-test", }, @@ -643,7 +643,7 @@ func TestIntegrationServerDelete(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - _, err := s.Client.Delete(ctx, serverservice.Server{UUID: uuid.MustParse(dbtools.FixtureNemo.ID)}) + _, err := s.Client.Delete(ctx, fleetdb.Server{UUID: uuid.MustParse(dbtools.FixtureNemo.ID)}) return err }) @@ -674,11 +674,11 @@ func TestIntegrationServerDelete(t *testing.T) { for _, tt := range testCases { t.Run(tt.testName, func(t *testing.T) { if tt.create { - _, _, err := s.Client.Create(context.TODO(), serverservice.Server{UUID: tt.uuid}) + _, _, err := s.Client.Create(context.TODO(), fleetdb.Server{UUID: tt.uuid}) assert.NoError(t, err) } - _, err := s.Client.Delete(context.TODO(), serverservice.Server{UUID: tt.uuid}) + _, err := s.Client.Delete(context.TODO(), fleetdb.Server{UUID: tt.uuid}) if tt.expectErr { assert.Error(t, err) assert.Contains(t, err.Error(), tt.errorMsg) @@ -701,7 +701,7 @@ func TestIntegrationServerUpdate(t *testing.T) { realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - resp, err := s.Client.Update(ctx, uuid.MustParse(dbtools.FixtureDory.ID), serverservice.Server{Name: "The New Dory"}) + resp, err := s.Client.Update(ctx, uuid.MustParse(dbtools.FixtureDory.ID), fleetdb.Server{Name: "The New Dory"}) if !expectError { require.NoError(t, err) assert.NotNil(t, resp.Links.Self) @@ -712,13 +712,13 @@ func TestIntegrationServerUpdate(t *testing.T) { }) } -func TestIntegrationServerServiceCreateVersionedAttributes(t *testing.T) { +func TestIntegrationfleetdbCreateVersionedAttributes(t *testing.T) { s := serverTest(t) realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { s.Client.SetToken(authToken) - va := serverservice.VersionedAttributes{Namespace: "hollow.integegration.test", Data: json.RawMessage([]byte(`{"test":"integration"}`))} + va := fleetdb.VersionedAttributes{Namespace: "hollow.integegration.test", Data: json.RawMessage([]byte(`{"test":"integration"}`))} resp, err := s.Client.CreateVersionedAttributes(ctx, uuid.New(), va) if !expectError { @@ -729,15 +729,15 @@ func TestIntegrationServerServiceCreateVersionedAttributes(t *testing.T) { }) } -func TestIntegrationServerServiceCreateVersionedAttributesIncrementCounter(t *testing.T) { +func TestIntegrationfleetdbCreateVersionedAttributesIncrementCounter(t *testing.T) { s := serverTest(t) s.Client.SetToken(validToken(adminScopes)) u := uuid.New() ctx := context.TODO() - va := serverservice.VersionedAttributes{Namespace: "hollow.integegration.test", Data: json.RawMessage([]byte(`{"test":"integration"}`))} - newVA := serverservice.VersionedAttributes{Namespace: "hollow.integegration.test", Data: json.RawMessage([]byte(`{"test":"integration", "something":"else"}`))} + va := fleetdb.VersionedAttributes{Namespace: "hollow.integegration.test", Data: json.RawMessage([]byte(`{"test":"integration"}`))} + newVA := fleetdb.VersionedAttributes{Namespace: "hollow.integegration.test", Data: json.RawMessage([]byte(`{"test":"integration", "something":"else"}`))} _, err := s.Client.CreateVersionedAttributes(ctx, u, va) require.NoError(t, err) @@ -769,7 +769,7 @@ func TestIntegrationServerServiceCreateVersionedAttributesIncrementCounter(t *te assert.Equal(t, 1, r[1].Tally) } -func TestIntegrationServerServiceListVersionedAttributes(t *testing.T) { +func TestIntegrationfleetdbListVersionedAttributes(t *testing.T) { s := serverTest(t) realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { diff --git a/pkg/api/v1/server.go b/pkg/api/v1/server.go index fe74d96..c9d20eb 100644 --- a/pkg/api/v1/server.go +++ b/pkg/api/v1/server.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "time" @@ -7,7 +7,7 @@ import ( "github.com/google/uuid" "github.com/volatiletech/null/v8" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // Server represents a server in a facility diff --git a/pkg/api/v1/server_component.go b/pkg/api/v1/server_component.go index c8322b2..605f2c6 100644 --- a/pkg/api/v1/server_component.go +++ b/pkg/api/v1/server_component.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "time" @@ -8,7 +8,7 @@ import ( "github.com/volatiletech/null/v8" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ServerComponent represents a component of a server. These can be things like diff --git a/pkg/api/v1/server_component_list_params.go b/pkg/api/v1/server_component_list_params.go index c39a3f1..a878376 100644 --- a/pkg/api/v1/server_component_list_params.go +++ b/pkg/api/v1/server_component_list_params.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "fmt" diff --git a/pkg/api/v1/server_component_list_params_test.go b/pkg/api/v1/server_component_list_params_test.go index 36fce25..342377b 100644 --- a/pkg/api/v1/server_component_list_params_test.go +++ b/pkg/api/v1/server_component_list_params_test.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "net/http" diff --git a/pkg/api/v1/server_component_type.go b/pkg/api/v1/server_component_type.go index bb76813..a3d0de5 100644 --- a/pkg/api/v1/server_component_type.go +++ b/pkg/api/v1/server_component_type.go @@ -1,7 +1,7 @@ -package serverservice +package fleetdb import ( - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ServerComponentType provides a way to group server components by the type diff --git a/pkg/api/v1/server_component_type_list_params.go b/pkg/api/v1/server_component_type_list_params.go index f0f945b..fcb4192 100644 --- a/pkg/api/v1/server_component_type_list_params.go +++ b/pkg/api/v1/server_component_type_list_params.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import "net/url" diff --git a/pkg/api/v1/server_component_type_service.go b/pkg/api/v1/server_component_type_service.go index 3cf133f..529a357 100644 --- a/pkg/api/v1/server_component_type_service.go +++ b/pkg/api/v1/server_component_type_service.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "context" diff --git a/pkg/api/v1/server_component_type_service_test.go b/pkg/api/v1/server_component_type_service_test.go index f6144a5..5530c54 100644 --- a/pkg/api/v1/server_component_type_service_test.go +++ b/pkg/api/v1/server_component_type_service_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - hollow "go.hollow.sh/serverservice/pkg/api/v1" + hollow "go.hollow.sh/fleetdb/pkg/api/v1" ) func TestServerComponentTypeServiceCreate(t *testing.T) { diff --git a/pkg/api/v1/server_component_type_test.go b/pkg/api/v1/server_component_type_test.go index 9e190c6..1f4e5e7 100644 --- a/pkg/api/v1/server_component_type_test.go +++ b/pkg/api/v1/server_component_type_test.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "testing" diff --git a/pkg/api/v1/server_list_params.go b/pkg/api/v1/server_list_params.go index 81caff8..ce8480e 100644 --- a/pkg/api/v1/server_list_params.go +++ b/pkg/api/v1/server_list_params.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "fmt" @@ -7,7 +7,7 @@ import ( "github.com/volatiletech/null/v8" "github.com/volatiletech/sqlboiler/v4/queries/qm" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // ServerListParams allows you to filter the results diff --git a/pkg/api/v1/server_secret.go b/pkg/api/v1/server_secret.go index 8a4c0dd..1090e76 100644 --- a/pkg/api/v1/server_secret.go +++ b/pkg/api/v1/server_secret.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "time" diff --git a/pkg/api/v1/server_secret_type.go b/pkg/api/v1/server_secret_type.go index e55428b..f6fedb7 100644 --- a/pkg/api/v1/server_secret_type.go +++ b/pkg/api/v1/server_secret_type.go @@ -1,9 +1,9 @@ -package serverservice +package fleetdb import ( "time" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) const ( diff --git a/pkg/api/v1/server_service.go b/pkg/api/v1/server_service.go index 1c2bf07..99b4eee 100644 --- a/pkg/api/v1/server_service.go +++ b/pkg/api/v1/server_service.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "context" @@ -24,7 +24,7 @@ const ( bomByMacBMCAddressEndpoint = "bmc-mac-address" ) -// ClientInterface provides an interface for the expected calls to interact with a server service api +// ClientInterface provides an interface for the expected calls to interact with a fleetdb api type ClientInterface interface { Create(context.Context, Server) (*uuid.UUID, *ServerResponse, error) Delete(context.Context, Server) (*ServerResponse, error) diff --git a/pkg/api/v1/server_service_test.go b/pkg/api/v1/server_service_test.go index a467934..ee8c65c 100644 --- a/pkg/api/v1/server_service_test.go +++ b/pkg/api/v1/server_service_test.go @@ -1,4 +1,4 @@ -package serverservice_test +package fleetdb_test import ( "context" @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - hollow "go.hollow.sh/serverservice/pkg/api/v1" + hollow "go.hollow.sh/fleetdb/pkg/api/v1" ) -func TestServerServiceCreate(t *testing.T) { +func TestFleetDBCreate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { srv := hollow.Server{UUID: uuid.New(), FacilityCode: "Test1"} jsonResponse := json.RawMessage([]byte(`{"message": "resource created", "slug":"00000000-0000-0000-0000-000000001234"}`)) @@ -27,7 +27,7 @@ func TestServerServiceCreate(t *testing.T) { }) } -func TestServerServiceDelete(t *testing.T) { +func TestFleetDBDelete(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse := json.RawMessage([]byte(`{"message": "resource deleted"}`)) c := mockClient(string(jsonResponse), respCode) @@ -36,7 +36,7 @@ func TestServerServiceDelete(t *testing.T) { return err }) } -func TestServerServiceGet(t *testing.T) { +func TestFleetDBGet(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { srv := hollow.Server{UUID: uuid.New(), FacilityCode: "Test1"} jsonResponse, err := json.Marshal(hollow.ServerResponse{Record: srv}) @@ -53,7 +53,7 @@ func TestServerServiceGet(t *testing.T) { }) } -func TestServerServiceList(t *testing.T) { +func TestFleetDBList(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { srv := []hollow.Server{{UUID: uuid.New(), FacilityCode: "Test1"}} jsonResponse, err := json.Marshal(hollow.ServerResponse{Records: srv}) @@ -69,7 +69,7 @@ func TestServerServiceList(t *testing.T) { }) } -func TestServerServiceUpdate(t *testing.T) { +func TestFleetDBUpdate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(hollow.ServerResponse{Message: "resource updated"}) require.Nil(t, err) @@ -81,7 +81,7 @@ func TestServerServiceUpdate(t *testing.T) { }) } -func TestServerServiceCreateAttributes(t *testing.T) { +func TestFleetDBCreateAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { attr := hollow.Attributes{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))} jsonResponse := json.RawMessage([]byte(`{"message": "resource created"}`)) @@ -92,7 +92,7 @@ func TestServerServiceCreateAttributes(t *testing.T) { return err }) } -func TestServerServiceGetAttributes(t *testing.T) { +func TestFleetDBGetAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { attr := &hollow.Attributes{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))} jsonResponse, err := json.Marshal(hollow.ServerResponse{Record: attr}) @@ -108,7 +108,7 @@ func TestServerServiceGetAttributes(t *testing.T) { }) } -func TestServerServiceDeleteAttributes(t *testing.T) { +func TestFleetDBDeleteAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(hollow.ServerResponse{Message: "resource deleted"}) require.Nil(t, err) @@ -120,7 +120,7 @@ func TestServerServiceDeleteAttributes(t *testing.T) { }) } -func TestServerServiceListAttributes(t *testing.T) { +func TestFleetDBListAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { attrs := []hollow.Attributes{{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))}} jsonResponse, err := json.Marshal(hollow.ServerResponse{Records: attrs}) @@ -136,7 +136,7 @@ func TestServerServiceListAttributes(t *testing.T) { }) } -func TestServerServiceUpdateAttributes(t *testing.T) { +func TestFleetDBUpdateAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(hollow.ServerResponse{Message: "resource updated"}) require.Nil(t, err) @@ -148,7 +148,7 @@ func TestServerServiceUpdateAttributes(t *testing.T) { }) } -func TestServerServiceComponentsGet(t *testing.T) { +func TestFleetDBComponentsGet(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { sc := []hollow.ServerComponent{{Name: "unit-test", Serial: "1234"}} jsonResponse, err := json.Marshal(hollow.ServerResponse{Records: sc}) @@ -164,7 +164,7 @@ func TestServerServiceComponentsGet(t *testing.T) { }) } -func TestServerServiceComponentsList(t *testing.T) { +func TestFleetDBComponentsList(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { sc := []hollow.ServerComponent{{Name: "unit-test", Serial: "1234"}} jsonResponse, err := json.Marshal(hollow.ServerResponse{Records: sc}) @@ -180,7 +180,7 @@ func TestServerServiceComponentsList(t *testing.T) { }) } -func TestServerServiceComponentsCreate(t *testing.T) { +func TestFleetDBComponentsCreate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(hollow.ServerResponse{Message: "resource created"}) require.Nil(t, err) @@ -195,7 +195,7 @@ func TestServerServiceComponentsCreate(t *testing.T) { }) } -func TestServerServiceComponentsUpdate(t *testing.T) { +func TestFleetDBComponentsUpdate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(hollow.ServerResponse{Message: "resource updated"}) require.Nil(t, err) @@ -210,7 +210,7 @@ func TestServerServiceComponentsUpdate(t *testing.T) { }) } -func TestServerServiceVersionedAttributeCreate(t *testing.T) { +func TestFleetDBVersionedAttributeCreate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { va := hollow.VersionedAttributes{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))} jsonResponse := json.RawMessage([]byte(`{"message": "resource created", "slug":"the-namespace"}`)) @@ -225,7 +225,7 @@ func TestServerServiceVersionedAttributeCreate(t *testing.T) { }) } -func TestServerServiceGetVersionedAttributess(t *testing.T) { +func TestFleetDBGetVersionedAttributess(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { va := []hollow.VersionedAttributes{{Namespace: "test", Data: json.RawMessage([]byte(`{}`))}} jsonResponse, err := json.Marshal(hollow.ServerResponse{Records: va}) @@ -241,7 +241,7 @@ func TestServerServiceGetVersionedAttributess(t *testing.T) { }) } -func TestServerServiceListVersionedAttributess(t *testing.T) { +func TestFleetDBListVersionedAttributess(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { va := []hollow.VersionedAttributes{{Namespace: "test", Data: json.RawMessage([]byte(`{}`))}} jsonResponse, err := json.Marshal(hollow.ServerResponse{Records: va}) @@ -257,7 +257,7 @@ func TestServerServiceListVersionedAttributess(t *testing.T) { }) } -func TestServerServiceCreateServerComponentFirmware(t *testing.T) { +func TestFleetDBCreateServerComponentFirmware(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { firmware := hollow.ComponentFirmwareVersion{ UUID: uuid.New(), @@ -277,7 +277,7 @@ func TestServerServiceCreateServerComponentFirmware(t *testing.T) { }) } -func TestServerServiceServerComponentFirmwareDelete(t *testing.T) { +func TestFleetDBServerComponentFirmwareDelete(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse := json.RawMessage([]byte(`{"message": "resource deleted"}`)) c := mockClient(string(jsonResponse), respCode) @@ -286,7 +286,7 @@ func TestServerServiceServerComponentFirmwareDelete(t *testing.T) { return err }) } -func TestServerServiceServerComponentFirmwareGet(t *testing.T) { +func TestFleetDBServerComponentFirmwareGet(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { firmware := hollow.ComponentFirmwareVersion{ UUID: uuid.New(), @@ -310,7 +310,7 @@ func TestServerServiceServerComponentFirmwareGet(t *testing.T) { }) } -func TestServerServiceServerComponentFirmwareList(t *testing.T) { +func TestFleetDBServerComponentFirmwareList(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { firmware := []hollow.ComponentFirmwareVersion{{ UUID: uuid.New(), @@ -331,7 +331,7 @@ func TestServerServiceServerComponentFirmwareList(t *testing.T) { }) } -func TestServerServiceServerComponentFirmwareUpdate(t *testing.T) { +func TestFleetDBServerComponentFirmwareUpdate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(hollow.ServerResponse{Message: "resource updated"}) require.Nil(t, err) diff --git a/pkg/api/v1/versioned_attributes.go b/pkg/api/v1/versioned_attributes.go index 07f8486..7a27a64 100644 --- a/pkg/api/v1/versioned_attributes.go +++ b/pkg/api/v1/versioned_attributes.go @@ -1,4 +1,4 @@ -package serverservice +package fleetdb import ( "encoding/json" @@ -6,7 +6,7 @@ import ( "github.com/volatiletech/sqlboiler/v4/types" - "go.hollow.sh/serverservice/internal/models" + "go.hollow.sh/fleetdb/internal/models" ) // VersionedAttributes represents a set of attributes of an entity at a given time diff --git a/quickstart-dev.yml b/quickstart-dev.yml index 14b1c39..a594ddd 100644 --- a/quickstart-dev.yml +++ b/quickstart-dev.yml @@ -1,12 +1,12 @@ version: "3.9" services: - serverservice: + fleetdb: build: context: . dockerfile: Dockerfile.dev - serverservice-migrate: + fleetdb-migrate: build: context: . dockerfile: Dockerfile.dev diff --git a/quickstart-tracing.yml b/quickstart-tracing.yml index 7f5666d..dca5242 100644 --- a/quickstart-tracing.yml +++ b/quickstart-tracing.yml @@ -1,14 +1,14 @@ version: '3.7' services: - serverservice: + fleetdb: depends_on: - jaeger environment: - - SERVERSERVICE_TRACING_ENABLED=true - - SERVERSERVICE_TRACING_ENVIRONMENT=dev-dockercompose - - SERVERSERVICE_TRACING_PROVIDER=jaeger - - SERVERSERVICE_TRACING_JAEGER_ENDPOINT=http://jaeger:14268/api/traces + - FLEETDB_TRACING_ENABLED=true + - FLEETDB_TRACING_ENVIRONMENT=dev-dockercompose + - FLEETDB_TRACING_PROVIDER=jaeger + - FLEETDB_TRACING_JAEGER_ENDPOINT=http://jaeger:14268/api/traces jaeger: image: jaegertracing/all-in-one:1.48.0 diff --git a/quickstart.yml b/quickstart.yml index 276106e..4382648 100644 --- a/quickstart.yml +++ b/quickstart.yml @@ -1,29 +1,29 @@ version: "3.9" services: - serverservice: - image: ghcr.io/metal-toolbox/hollow-serverservice:v0.16.0 + fleetdb: + image: ghcr.io/metal-toolbox/fleetdb:v0.16.0 depends_on: - crdb - - serverservice-migrate + - fleetdb-migrate environment: - - SERVERSERVICE_OIDC_ENABLED=false - - SERVERSERVICE_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable - - SERVERSERVICE_DB_ENCRYPTION_DRIVER=base64key://smGbjm71Nxd1Ig5FS0wj9SlbzAIrnolCz9bQQ6uAhl4= + - FLEETDB_OIDC_ENABLED=false + - FLEETDB_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable + - FLEETDB_DB_ENCRYPTION_DRIVER=base64key://smGbjm71Nxd1Ig5FS0wj9SlbzAIrnolCz9bQQ6uAhl4= ports: - "8000:8000" restart: unless-stopped networks: - hollow - serverservice-migrate: - image: ghcr.io/metal-toolbox/hollow-serverservice:v0.16.0 + fleetdb-migrate: + image: ghcr.io/metal-toolbox/fleetdb:v0.16.0 command: migrate up depends_on: - crdb environment: - - SERVERSERVICE_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable + - FLEETDB_CRDB_URI=postgresql://root@crdb:26257/defaultdb?sslmode=disable restart: on-failure networks: - hollow diff --git a/sqlboiler.toml b/sqlboiler.toml index 321931c..1a57a8d 100644 --- a/sqlboiler.toml +++ b/sqlboiler.toml @@ -3,7 +3,7 @@ pkgname = "models" output = "internal/models" [crdb] -dbname = "serverservice_test" +dbname = "fleetdb_test" host = "localhost" port = 26257 user = "root"