Categorygithub.com/redhatinsights/module-update-router
modulepackage
0.0.0-20240923033952-3d30e6c6c5ca
Repository: https://github.com/redhatinsights/module-update-router.git
Documentation: pkg.go.dev

# README

PkgGoDev Go Report Card codecov

module-update-router is a microservice that determines whether a client should fetch a testing/prerelease module or a released/production module. It maintains a list of account IDs internally and will respond to GET requests to /api/v1/channel?module=<module-name> (for example, insights-core) with an appropriate URL fragment (either /testing or /release). It is worth noting that this service does not serve the module itself; the client must know where to retrieve the module. This service simply tells the client which module to retrieve.

Building

go build

Testing

go test

Running

go run .

Configuring

Configuration is done through environment variables.

  • ADDR: Address on which the HTTP server should listen (default: ":8080")
  • MADDR: Address on which the metrics HTTP server should listen (default: ":2112")
  • LOG_FORMAT: Format of log output (either "json" or "text") (default: "text")
  • DB_DRIVER: Database driver to use (either "pgx" or "sqlite") (default: "sqlite")
  • DATABASE_URL: A URL forming a database connection string (i.e. "file::memory:")
  • DB_HOST: Address of the database server (default: "localhost")
  • DB_PORT: TCP port of the database server (default: "5432")
  • DB_NAME: Name of the database (default: "postgres")
  • DB_USER: Username on the database server (default: "postgres")
  • DB_PASS: Password of the database user

# Functions

DefaultEnv retrieves the value of the environment variable named by the key.
NewNullString creates a sql.NullString from s, returning an empty NullString if s is nil or a zero-value string.
NewServer creates a new instance of the application, configured with the provided addr, API roots and database handle.
Open opens a database specified by dataSourceName.

# Structs

DB wraps a sql.DB handle, providing an application-specific, higher-level API around the standard sql.DB interface.
Server is the application's HTTP server.