provisioning-backend

module
v0.0.0-...-4263410 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: GPL-3.0

README

provisioning-backend

Provisioning backend service for cloud.redhat.com.

Components

  • pbackend api - API backend service
  • pbackend worker - backend job processing worker
  • pbackend statuser - backend sources processing worker (single instance)
  • pbackend migrate - database migration tool with embedded SQL scripts

Building

Particular version of Go and tools are required for successful build. The install-go make target will use already installed version of go to perform go download commend to install Go into $HOME/sdk.

make install-go
make install-tools
make build

Configuration

Configuration is done via configuration files in config/ directory, see config/api.env.example file for list of options with documentation. The application expects config/app.env file to be present, other programs from this git repo also look up additional file which will override values:

  • worker looks up config/worker.env
  • migrate looks up config/migrate.env
  • typesctl looks up config/typesctl.env
  • integration (DAO) tests look up config/test.env

Environmental variables always override any values from configuration files, or can be used for complete configuration of the application without any .env file.

Finally, when running the app in Clowder environment, some configuration values are overwritten by those from Clowder. See consoleDot shared library for more details.

Development setup

To run all the components from this repository, you will need:

  • Go compiler
  • PostgreSQL server with UUID module
  • GNU Makefile * Backend services
dnf install postgresql-server postgresql-contrib
make run

Code style

We run go fmt, goimports, go vet and golangci-lint lint suite via GitHub Actions. To run them locally do:

make install-tools
make fmt lint

Make sure to set your editor to use goimports formatting style of code.

Migrations

Migrations can be found in internal/db/migrations in SQL format, the only supported database platform is PostgreSQL. To create a new migration:

make generate-migration MIGRATION_NAME=add_new_column

We currently do not allow down migrations, so delete the down.sql file and do not commit it into git (it will fail build).

To apply migrations, build and run pbmigrate binary. This is exactly what application performs during startup. The pbmigrate utility also supports seeding initial data. There are files available in internal/db/seeds with various seed configurations. Feel free to create your own configuration which you may or may not want to commit into git. When you set DB_SEED_SCRIPT configuration variable, the migration tool will execute all statements from that file. By default, the variable is empty, meaning no data will be seeded.

Building container

podman build -t pb .
podman run --name pb1 --rm -ti -p 8000:8000 -p 5000:5000 pb
curl http://localhost:8000
curl http://localhost:5000/metrics

Contributing

Check out CONTRIBUTING.md

License

GNU GPL 3.0, see LICENSE

Directories

Path Synopsis
cmd
internal
background
Background jobs responsible for queueing batch operations (availability checks) or other operations (cleanups etc).
Background jobs responsible for queueing batch operations (availability checks) or other operations (cleanups etc).
cache
Package cache provides application cache based on Redis.
Package cache provides application cache based on Redis.
clients/http/image_builder
Package image_builder provides primitives to interact with the openapi HTTP API.
Package image_builder provides primitives to interact with the openapi HTTP API.
clients/http/rbac
Package rbac provides primitives to interact with the openapi HTTP API.
Package rbac provides primitives to interact with the openapi HTTP API.
clients/http/sources
Package sources provides primitives to interact with the openapi HTTP API.
Package sources provides primitives to interact with the openapi HTTP API.
dao
Package dao provides a Database Access Object interface to stored data.
Package dao provides a Database Access Object interface to stored data.
db
ptr
Package ptr provides value to pointer and pointer to value functions.
Package ptr provides value to pointer and pointer to value functions.
queue/stub
Import this package in all Go tests which need to enqueue a job.
Import this package in all Go tests which need to enqueue a job.
ssh
testing/initialization
The package initializes logging and all stubs for use in tests.
The package initializes logging and all stubs for use in tests.
userdata
Package init provides functions for integration with virtual machine initialization frameworks like cloud-init.
Package init provides functions for integration with virtual machine initialization frameworks like cloud-init.
usrerr
Package usrerr provides error type and predefined values for user-facing HTTP errors.
Package usrerr provides error type and predefined values for user-facing HTTP errors.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL