config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig added in v0.2.0

type AuthConfig struct {
	KeysURL      string `split_words:"true" default:"https://auth.rotational.app/.well-known/jwks.json"`
	Audience     string `default:"https://rotational.app"`
	Issuer       string `default:"https://auth.rotational.app"`
	CookieDomain string `split_words:"true" default:"rotational.app"`
}

Configures the authentication and authorization for the Tenant API.

func (AuthConfig) Validate added in v0.2.0

func (c AuthConfig) Validate() error

type Config

type Config struct {
	Maintenance  bool                `default:"false"`                                    // $TENANT_MAINTENANCE
	BindAddr     string              `split_words:"true" default:":8088"`                 // $TENANT_BIND_ADDR
	Mode         string              `default:"release"`                                  // $TENANT_MODE
	LogLevel     logger.LevelDecoder `split_words:"true" default:"info"`                  // $TENANT_LOG_LEVEL
	ConsoleLog   bool                `split_words:"true" default:"false"`                 // $TENANT_CONSOLE_LOG
	AllowOrigins []string            `split_words:"true" default:"http://localhost:3000"` // $TENANT_ALLOW_ORIGINS
	Auth         AuthConfig          `split_words:"true"`
	Database     DatabaseConfig      `split_words:"true"`
	Ensign       SDKConfig           `split_words:"true"`
	MetaTopic    MetaTopicConfig     `split_words:"true"`
	Quarterdeck  QuarterdeckConfig   `split_words:"true"`
	SendGrid     emails.Config       `split_words:"false"`
	Sentry       sentry.Config
	// contains filtered or unexported fields
}

Config uses confire to load required settings from the environment, parses and validates them, and loads defaults where necessary in preparation for running the Tenant API service. This is the top-level config, any sub configurations will need to be defined as properties of this Config.

func New

func New() (conf Config, err error)

New loads and parses the config from the environment and validates it, marking it as processed so that external users can determine if the config is ready for use. This should be the only way Config objects are created for use in the application.

func (Config) AllowAllOrigins

func (c Config) AllowAllOrigins() bool

Returns true if the allow origins slice contains one entry that is a "*"

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

func (Config) IsZero

func (c Config) IsZero() bool

Returns true if the config has not been correctly processed from the environment.

func (Config) Mark

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

Mark a manually constructed config as processed as long as it is valid.

func (Config) Validate

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

Custom validations are added here, particularly validations that require one or more fields to be processed before the validation occurs. NOTE: ensure that all nested config validation methods are called here.

type DatabaseConfig added in v0.1.1

type DatabaseConfig struct {
	URL      string `default:"trtl://localhost:4436"`
	Insecure bool   `default:"true"`
	CertPath string `split_words:"true"`
	PoolPath string `split_words:"true"`
	Testing  bool   `default:"false"`
}

Configures the connection to trtl for replicated data storage.

func (DatabaseConfig) Endpoint added in v0.1.1

func (c DatabaseConfig) Endpoint() (_ string, err error)

func (DatabaseConfig) Validate added in v0.1.1

func (c DatabaseConfig) Validate() (err error)

If not insecure, the cert and pool paths are required.

type MetaTopicConfig added in v0.8.0

type MetaTopicConfig struct {
	SDKConfig
	TopicName string `split_words:"true" default:"ensign.metatopic.topics"`
}

Configures an SDK connection to Ensign for subscribing to a meta topic.

type QuarterdeckConfig added in v0.2.0

type QuarterdeckConfig struct {
	URL          string        `default:"https://auth.rotational.app"`
	WaitForReady time.Duration `default:"5m" split_words:"true"`
}

Configures the client connection to Quarterdeck.

func (QuarterdeckConfig) Client added in v0.2.0

func (c QuarterdeckConfig) Client() (_ qd.QuarterdeckClient, err error)

func (QuarterdeckConfig) Validate added in v0.2.0

func (c QuarterdeckConfig) Validate() (err error)

type SDKConfig added in v0.5.0

type SDKConfig struct {
	Enabled          bool          `default:"true" yaml:"enabled"`
	ClientID         string        `split_words:"true"`
	ClientSecret     string        `split_words:"true"`
	Endpoint         string        `default:"ensign.rotational.app:443"`
	AuthURL          string        `split_words:"true" default:"https://auth.rotational.app"`
	Insecure         bool          `default:"false"`
	NoAuthentication bool          `split_words:"true" default:"false"`
	WaitForReady     time.Duration `default:"5m" split_words:"true"`
	Testing          bool          `default:"false"`
}

Configures an SDK connection to Ensign, primarily so Tenant can manage topics on the user's behalf.

func (SDKConfig) ClientOptions added in v0.7.0

func (c SDKConfig) ClientOptions() []sdk.Option

func (SDKConfig) Validate added in v0.5.0

func (c SDKConfig) Validate() error

Jump to

Keyboard shortcuts

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