config

package
v0.0.0-...-161c778 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultServerAddress  = "0.0.0.0:3000"
	DefaultDataDir        = "./"
	DefaultDataRetention  = "1d"
	DefaultLogLevel       = "info"
	DefaultConfigFilename = "httpe.conf"
	EnvPrefix             = "httpe"
)

Variables

View Source
var (
	ErrAddressIncludesScheme  = errors.New("server address must not include scheme")
	ErrUnableToAccessCertFile = errors.New("failed to open/access cert_file")
	ErrUnableToAccessKeyFile  = errors.New("failed to open/access key_file")
	ErrCertOrKeyMissing       = errors.New("to activate TLS you must provide cert AND key")
	ErrNoRulesFile            = errors.New("no rules file specified")
	ErrRulesFileNotReadable   = errors.New("rules file not found or not readable")
	ErrBadSMTPServer          = errors.New("SMTP server is not a valid hostname or IP address")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	S    *SvrConfig  `mapstructure:"server"`
	SMTP *SMTPConfig `mapstructure:"smtp"`
	// contains filtered or unexported fields
}

Config is used for managing the license server config values

func New

func New(pFlags *pflag.FlagSet) (cfg *Config)

New returns a new Config with the specified pFlags

func (*Config) Load

func (c *Config) Load(cfgPath *string, cfgReader io.Reader) (cfg *Config, err error)

Load reads the config from the reader (if non nil) or a file (if the reader isn't specified). If not using the reader, then the file will either be the one specified via the config flag or the default config filename.

func (*Config) LoadAndValidate

func (c *Config) LoadAndValidate(cfgPath *string, cfgReader io.Reader) (err error)

LoadAndValidate loads and validates configuration values from either the path or reader specified

func (*Config) Setup

func (c *Config) Setup()

Setup configures viper for reading the config values

func (*Config) Validate

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

Validate validates the loaded config

type SMTPConfig

type SMTPConfig struct {
	Server   string `mapstructure:"server"`
	Port     int    `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	From     string `mapstructure:"from"`
}

type SvrConfig

type SvrConfig struct {
	Address       string `mapstructure:"address"`
	DataDir       string `mapstructure:"data_dir"`
	DataRetention string `mapstructure:"data_retention"`
	CertFile      string `mapstructure:"cert_file"`
	KeyFile       string `mapstructure:"key_file"`
	AccessLogFile string `mapstructure:"access_log_file"`
	LogFile       string `mapstructure:"log_file"`
	LogLevel      string `mapstructure:"log_level"`
	RulesFile     string `mapstructure:"rules_file"`
	ValidateOnly  bool   `mapstructure:"validate"`
	DumpRules     bool   `mapstructure:"dump_rules"`
}

SvrConfig represents the config settings for the server

Jump to

Keyboard shortcuts

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