config

package
v0.0.0-...-695f612 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvRegionName = "RADIO_REGION_NAME"
	EnvRegion     = "RADIO_REGION" // legacy
)

Top level common ENVs

View Source
const EnvCertPassword = "RADIO_CERT_PASSWD"

EnvCertPassword is the environment variable which contains the password used to decrypt the TLS private key. It must be set if the TLS private key is password protected.

View Source
const (
	ValueSeparator = ","
)

Config value separator

Variables

View Source
var (
	ErrInvalidCacheDrivesValue = newErrFn(
		"Invalid cache drive value",
		"Please check the value in your config.yml",
		"Mounted drives or directories are wrong",
	)

	ErrInvalidCacheExcludesValue = newErrFn(
		"Invalid cache excludes value",
		"Please check the passed value in your config.yml",
		"Cache exclusion patterns are incorrect please refer to documentation",
	)

	ErrInvalidCacheExpiryValue = newErrFn(
		"Invalid cache expiry value",
		"Please check the passed value in your config.yml",
		"Valid cache expiry duration must be in days",
	)

	ErrInvalidCacheQuota = newErrFn(
		"Invalid cache quota value",
		"Please check the passed value in your config.yml",
		" Valid cache quota value must be between 0-100",
	)

	ErrInvalidCacheAfter = newErrFn(
		"Invalid cache after value",
		"Please check the passed value",
		"RADIO_CACHE_AFTER: Valid cache after value must be 0 or greater",
	)

	ErrInvalidCacheWatermarkLow = newErrFn(
		"Invalid cache low watermark value",
		"Please check the passed value",
		"RADIO_CACHE_WATERMARK_LOW: Valid cache low watermark value must be between 0-100",
	)

	ErrInvalidCacheWatermarkHigh = newErrFn(
		"Invalid cache high watermark value",
		"Please check the passed value",
		"RADIO_CACHE_WATERMARK_HIGH: Valid cache high watermark value must be between 0-100",
	)

	ErrInvalidAddressFlag = newErrFn(
		"--address input is invalid",
		"Please check --address parameter",
		`--address binds to a specific ADDRESS:PORT, ADDRESS can be an IPv4/IPv6 address or hostname (default port is ':9000')
	Examples: --address ':443'
		  --address '172.16.34.31:9000'
		  --address '[fe80::da00:a6c8:e3ae:ddd7]:9000'`,
	)

	ErrConfigInvalid = newErrFn(
		"--config input is invalid",
		"Please provide the correct path to your config",
		`--config or -c is path to your config.yml (default path is 'config.yml' in current directory)
        Examples: --config /etc/radio/config.yml
                  --config config.yml
                  --config /opt/radio/config.yml`,
	)

	ErrPortAlreadyInUse = newErrFn(
		"Port is already in use",
		"Please ensure no other program uses the same address/port",
		"",
	)

	ErrPortAccess = newErrFn(
		"Unable to use specified port",
		"Please ensure Radio binary has 'cap_net_bind_service=+ep' permissions",
		`Use 'sudo setcap cap_net_bind_service=+ep /path/to/radio' to provide sufficient permissions`,
	)

	ErrSSLUnexpectedError = newErrFn(
		"Invalid TLS certificate",
		"Please check the content of your certificate data",
		`Only PEM (x.509) format is accepted as valid public & private certificates`,
	)

	ErrSSLUnexpectedData = newErrFn(
		"Invalid TLS certificate",
		"Please check your certificate",
		"",
	)

	ErrSSLNoPassword = newErrFn(
		"Missing TLS password",
		"Please set the password to environment variable `RADIO_CERT_PASSWD` so that the private key can be decrypted",
		"",
	)

	ErrNoCertsAndHTTPSEndpoints = newErrFn(
		"HTTPS specified in endpoints, but no TLS certificate is found on the local machine",
		"Please add TLS certificate or use HTTP endpoints only",
		"Refer to https://docs.min.io/docs/how-to-secure-access-to-minio-server-with-tls for information about how to load a TLS certificate in your server",
	)

	ErrCertsAndHTTPEndpoints = newErrFn(
		"HTTP specified in endpoints, but the server in the local machine is configured with a TLS certificate",
		"Please remove the certificate in the configuration directory or switch to HTTPS",
		"",
	)

	ErrSSLWrongPassword = newErrFn(
		"Unable to decrypt the private key using the provided password",
		"Please set the correct password in environment variable `RADIO_CERT_PASSWD`",
		"",
	)

	ErrInvalidRadioEndpoints = newErrFn(
		"Unable to initialize endpoint(s)",
		"Please check the specified value in your config.yml",
		"Please provide correct combination of remote servers",
	)
)

UI errors

Functions

func ErrorToErr

func ErrorToErr(err error) error

ErrorToErr inspects the passed error and transforms it to the appropriate UI error.

func Errorf

func Errorf(errKind ErrorKind, format string, a ...interface{}) error

Errorf - formats according to a format specifier and returns the string as a value that satisfies error of type config.Error

func FmtError

func FmtError(introMsg string, err error, jsonFlag bool) string

FmtError converts a fatal error message to a more clear error using some colors

func GetRootCAs

func GetRootCAs(certsCAsDir string) (*x509.CertPool, error)

GetRootCAs - returns all the root CAs into certPool at the input certsCADir

func LoadX509KeyPair

func LoadX509KeyPair(certFile, keyFile string) (tls.Certificate, error)

LoadX509KeyPair - load an X509 key pair (private key , certificate) from the provided paths. The private key may be encrypted and is decrypted using the ENV_VAR: RADIO_CERT_PASSWD.

func LookupRegion

func LookupRegion() (string, error)

LookupRegion - get current region.

func ParsePublicCertFile

func ParsePublicCertFile(certFile string) (x509Certs []*x509.Certificate, err error)

ParsePublicCertFile - parses public cert into its *x509.Certificate equivalent.

Types

type Err

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

Err is a structure which contains all information to print a fatal error message in json or pretty mode Err implements error so we can use it anywhere

func (*Err) Clone

func (u *Err) Clone() *Err

Clone returns a new Err struct with the same information

func (*Err) Error

func (u *Err) Error() string

Return the error message

func (*Err) Hint

func (u *Err) Hint(m string, args ...interface{}) *Err

Hint - Replace the current error's message

func (*Err) Msg

func (u *Err) Msg(m string, args ...interface{}) *Err

Msg - Replace the current error's message

type ErrFn

type ErrFn func(err error) *Err

ErrFn function wrapper

type Error

type Error struct {
	Kind ErrorKind
	Err  string
}

Error config error type

func (Error) Error

func (e Error) Error() string

type ErrorKind

type ErrorKind int8

ErrorKind config error kind

const (
	ContinueKind ErrorKind = iota + 1
	SafeModeKind
)

Various error kinds.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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