config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "rtnl"

All environment variables will have this Prefix unless otherwise defined in struct tags. For example, the conf.LogLevel environment variable will be RTNL_LOG_LEVEL because of this Prefix and the split_words struct tag in the conf below.

Variables

View Source
var (
	ErrInvalidEnsignCredentials = errors.New("invalid configuration: must specify either path to ensign credentials or the client id and api key")
)

Functions

This section is empty.

Types

type AuthConfig added in v1.2.0

type AuthConfig struct {
	GoogleClientID  string            `split_words:"true" required:"true" desc:"the Google oauth claims client id and audience"`
	HDClaim         string            `split_words:"true" default:"rotational.io" desc:"the email domain to allow to authenticate"`
	CookieDomain    string            `split_words:"true" default:"rtnl.link" desc:"the domain to assign cookies to"`
	Keys            map[string]string `required:"false" desc:"rsa keys for signing access tokens (generated if omitted)"`
	Audience        string            `default:"https://rtnl.link" desc:"audience to add to rtnl jwt claims"`
	Issuer          string            `default:"https://rtnl.link" desc:"issuer to add to rtnl jwt claims"`
	AccessDuration  time.Duration     `split_words:"true" default:"1h" desc:"amount of time access tokens are valid"`
	RefreshDuration time.Duration     `split_words:"true" default:"2h" desc:"amount of time refresh tokens are valid"`
	RefreshOverlap  time.Duration     `split_words:"true" default:"-15m" desc:"validity period of refresh token while access token is"`
}

type Config

type Config struct {
	Maintenance  bool                `default:"false" yaml:"maintenance"`
	Mode         string              `default:"release"`
	LogLevel     logger.LevelDecoder `split_words:"true" default:"info" yaml:"log_level"`
	ConsoleLog   bool                `split_words:"true" default:"false" yaml:"console_log"`
	BindAddr     string              `split_words:"true" default:":8765" yaml:"bind_addr"`
	AllowOrigins []string            `split_words:"true" default:"http://localhost:8765"`
	Origin       string              `default:"https://rtnl.link"`
	AltOrigin    string              `split_words:"true" default:"https://r8l.co"`
	Storage      StorageConfig
	Auth         AuthConfig
	Ensign       EnsignConfig
	// contains filtered or unexported fields
}

Config contains all of the configuration parameters for an rtnl server and is loaded from the environment or a configuration file with reasonable defaults for values that are omitted. The Config should be validated in preparation for running the server to ensure that all server operations work as expected.

func New

func New() (conf Config, err error)

New creates and processes a Config from the environment ready for use. If the configuration is invalid or it cannot be processed an error is returned.

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

Parse and return the zerolog log level for configuring global logging.

func (Config) IsZero

func (c Config) IsZero() bool

A Config is zero-valued if it hasn't been processed by a file or the environment.

func (*Config) MakeOriginURLs added in v1.0.0

func (c *Config) MakeOriginURLs(sid string) (link string, alt string)

func (Config) Mark

func (c Config) Mark() (Config, error)

Mark a manually constructed config as processed as long as its valid.

func (Config) Validate

func (c Config) Validate() (err error)

Validates the config is ready for use in the application and that configuration semantics such as requiring multiple required configuration parameters are enforced.

type EnsignConfig added in v1.1.0

type EnsignConfig struct {
	Maintenance  bool   `env:"RTNL_MAINTENANCE"`
	Path         string `required:"false"`
	ClientID     string `split_words:"true"`
	ClientSecret string `split_words:"true"`
	Topic        string `default:"shortcrust-production"`
}

func (EnsignConfig) Options added in v1.1.0

func (c EnsignConfig) Options() ensign.Option

func (EnsignConfig) Validate added in v1.1.0

func (c EnsignConfig) Validate() error

type StorageConfig added in v0.2.0

type StorageConfig struct {
	ReadOnly bool   `split_words:"true" default:"false"`
	DataPath string `split_words:"true" required:"true"`
}

Jump to

Keyboard shortcuts

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