config

package
v0.0.0-...-2205d8a Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPopulatedMissing = errors.New("populated missing secrets")

ErrPopulatedMissing can be returned by New to signal that missing values have been populated and persisted.

View Source
var (
	// EventRetention defines the duration for which events are expected to
	//  be kept before expired. This value can be overridden by setting OFFEN_APP_RETENTION_DAYS
	EventRetention = time.Hour * 24 * 6 * 31
)
View Source
var Revision string

Revision will be set by ldflags on build time

Functions

func ExpandString

func ExpandString(s string) string

ExpandString expands all environment variables in the given string

Types

type Bytes

type Bytes []byte

Bytes is a byte slice.

func (*Bytes) Bytes

func (b *Bytes) Bytes() []byte

Bytes unwraps b and returns its value as a byte slice.

func (*Bytes) Decode

func (b *Bytes) Decode(v string) error

Decode decodes a base64 encoded string into b.

func (*Bytes) IsZero

func (b *Bytes) IsZero() bool

IsZero checks whether the underlying byte slice is empty

type Config

type Config struct {
	Server struct {
		Port             int  `default:"3000"`
		ReverseProxy     bool `default:"false"`
		SSLCertificate   EnvString
		SSLKey           EnvString
		AutoTLS          []string
		LetsEncryptEmail string
		CertificateCache EnvString `default:"/var/www/.cache"`
	}
	Database struct {
		Dialect           Dialect   `default:"sqlite3"`
		ConnectionString  EnvString `default:"/var/opt/offen/offen.db"`
		ConnectionRetries int       `default:"0"`
	}
	App struct {
		Development  bool     `default:"false"`
		LogLevel     LogLevel `default:"info"`
		SingleNode   bool     `default:"true"`
		Locale       Locale   `default:"en"`
		RootAccount  string
		DemoAccount  string `ignored:"true"`
		DeployTarget DeployTarget
		Retention    Retention `default:"6months"`
	}
	Secret Bytes
	SMTP   struct {
		Authtype string `default:"LOGIN"`
		User     string
		Password string
		Host     string
		Port     int    `default:"587"`
		Sender   string `default:"no-reply@offen.dev"`
	}
}

Config contains all runtime configuration needed for running offen as and also defines the desired defaults. Package envconfig is used to source values from the application environment at runtime.

func New

func New(populateMissing bool, override string) (*Config, error)

New returns a new runtime configuration

func (*Config) NewMailer

func (c *Config) NewMailer() (mailer.Mailer, error)

NewMailer returns a new mailer that is suitable for the given config. In development, mail content will be printed to stdout. In production, SMTP is preferred and falls back to sendmail if no SMTP credentials are given.

func (*Config) SMTPConfigured

func (c *Config) SMTPConfigured() bool

SMTPConfigured returns true if a SMTP Host is configured

type DeployTarget

type DeployTarget string

DeployTarget identifies a known deploy target.

const (
	DeployTargetHeroku DeployTarget = "heroku"
)

this defines all the known deploy targets that have defined exceptions for generating a runtime config.

func (*DeployTarget) Decode

func (d *DeployTarget) Decode(v string) error

Decode validates and assigns v.

func (*DeployTarget) String

func (d *DeployTarget) String() string

type Dialect

type Dialect string

Dialect identifies a SQL dialect.

func (*Dialect) Decode

func (d *Dialect) Decode(v string) error

Decode validates and assigns v.

func (*Dialect) String

func (d *Dialect) String() string

type EnvString

type EnvString string

EnvString is a string that expands environemt variables

func (*EnvString) Decode

func (e *EnvString) Decode(v string) error

Decode validates and assigns v.

func (*EnvString) RawString

func (e *EnvString) RawString() string

RawString returns the original value without any interpolation.

func (*EnvString) String

func (e *EnvString) String() string

type Locale

type Locale string

Locale is a language used throughout the application's interface.

func (*Locale) Decode

func (l *Locale) Decode(s string) error

Decode validates and assigns l.

func (*Locale) String

func (l *Locale) String() string

type LogLevel

type LogLevel logrus.Level

LogLevel is a wrapped logrus log level

func (*LogLevel) Decode

func (l *LogLevel) Decode(v string) error

Decode parses a string into l.

func (*LogLevel) LogLevel

func (l *LogLevel) LogLevel() logrus.Level

LogLevel unwraps l.

type Retention

type Retention struct {
	// contains filtered or unexported fields
}

Retention defines a data retention period.

func (*Retention) Decode

func (r *Retention) Decode(v string) error

Decode validates and assigns v.

func (*Retention) String

func (r *Retention) String() string

Jump to

Keyboard shortcuts

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