config

package
v0.0.0-...-6c12179 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load[T any](conf *T, confFiles fs.FS) error

Load resolves the configuration into the provided conf object. Config is merged in order from the following sources:

  1. config.yaml embedded in this package. These are the curiostack defaults where applicable.
  2. config.yaml at the base of the repository, identified by being next to go.work, if present.
  3. config.yaml in the provided fs.FS if present.
  4. config-local.yaml in the provided fs.FS if present and CONFIG_ENV is unset (local development).
  5. config-nonlocal.yaml in the provided fs.FS if present and CONFIG_ENV is set.
  6. config-${CONFIG_ENV}.yaml in the provided fs.FS if present and CONFIG_ENV is set.
  7. Environment variables, where the config key is capitalized with '.' replaced with '_'.

Types

type Common

type Common struct {
	// Server holds the configuration for the server.
	Server Server `koanf:"server"`

	// Google holds the configruation for using common GCP functionality.
	Google Google `koanf:"google"`

	// Logging holds the configuration for logging.
	Logging Logging `koanf:"logging"`
}

Common holds curiostack standard configuration objects. Server configuration objects should embed this and define their own fields on top of it.

type Google

type Google struct {
	// Project is the GCP project ID.
	Project string `koanf:"project"`

	// Region is the default region development resources are deployed to.
	Region string `koanf:"region"`
}

Google holds the configuration for using common GCP functionality.

type Logging

type Logging struct {
	// Level is the [slog.Level] to use. Defaults to "info".
	Level string `koanf:"level"`

	// JSON indicates if logs should be output in JSON format.
	JSON bool `koanf:"json"`
}

Logging holds the configuration for logging.

type Server

type Server struct {
	// Address is the address the server will listen on, e.g. ":9080".
	// Defaults to ":8080".
	Address string `koanf:"address"`
}

Server holds the configuration for the server.

Jump to

Keyboard shortcuts

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