utils

package
v0.0.0-...-af40d72 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemoryBackend = "memory"
	MySQLBackend  = "mysql"
	SqliteBackend = "sqlite3"
)

Specifies the list of recognized backends

Variables

This section is empty.

Functions

func ConfigureClientTLS

func ConfigureClientTLS(opts *ClientTLSOpts) (*tls.Config, error)

ConfigureClientTLS generates a tls configuration for clients using the provided parameters. / Note that if the root CA file contains invalid data, behavior is not guaranteed. Currently (as of Go 1.5.1) only the valid certificates up to the bad data will be parsed and added the root CA pool.

func ConfigureServerTLS

func ConfigureServerTLS(opts *ServerTLSOpts) (*tls.Config, error)

ConfigureServerTLS specifies a set of ciphersuites, the server cert and key, and optionally client authentication. Note that a tls configuration is constructed that either requires and verifies client authentication or doesn't deal with client certs at all. Nothing in the middle.

Also note that if the client CA file contains invalid data, behavior is not guaranteed. Currently (as of Go 1.5.1) only the valid certificates up to the bad data will be parsed and added the client CA pool.

func GetPathRelativeToConfig

func GetPathRelativeToConfig(configuration *viper.Viper, key string) string

GetPathRelativeToConfig gets a configuration key which is a path, and if it is not empty or an absolute path, returns the absolute path relative to the configuration file

func ParseBugsnag

func ParseBugsnag(configuration *viper.Viper) (*bugsnag.Configuration, error)

ParseBugsnag tries to parse out a Bugsnag Configuration from a Viper. If no values are provided, returns a nil pointer.

func ParseLogLevel

func ParseLogLevel(configuration *viper.Viper, defaultLevel logrus.Level) (
	logrus.Level, error)

ParseLogLevel tries to parse out a log level from a Viper. If there is no configuration, defaults to the provided error level

func ParseViper

func ParseViper(v *viper.Viper, configFile string) error

ParseViper tries to parse out a Viper from a configuration file.

func RootHandlerFactory

func RootHandlerFactory(auth auth.AccessController, ctx context.Context, trust signed.CryptoService) func(contextHandler, ...string) *rootHandler

RootHandlerFactory creates a new rootHandler factory using the given Context creator and authorizer. The returned factory allows creating new rootHandlers from the alternate http handler contextHandler and a scope.

func SetUpBugsnag

func SetUpBugsnag(config *bugsnag.Configuration) error

SetUpBugsnag configures bugsnag and sets up a logrus hook

func SetupViper

func SetupViper(configuration *viper.Viper, envPrefix string)

SetupViper sets up an instance of viper to also look at environment variables

Types

type ClientTLSOpts

type ClientTLSOpts struct {
	RootCAFile         string
	ServerName         string
	InsecureSkipVerify bool
	ClientCertFile     string
	ClientKeyFile      string
}

ClientTLSOpts is a struct that contains options to pass to ConfigureClientTLS

type ServerTLSOpts

type ServerTLSOpts struct {
	ServerCertFile string
	ServerKeyFile  string
	ClientCAFile   string
}

ServerTLSOpts generates a tls configuration for servers using the provided parameters.

func ParseServerTLS

func ParseServerTLS(configuration *viper.Viper, tlsRequired bool) (*ServerTLSOpts, error)

ParseServerTLS tries to parse out a valid ServerTLSOpts from a Viper:

  • If TLS is required, both the cert and key must be provided
  • If TLS is not requried, either both the cert and key must be provided or neither must be provided

The files are relative to the config file used to populate the instance of viper.

type Storage

type Storage struct {
	Backend string
	Source  string
}

Storage is a configuration about what storage backend a server should use

func ParseStorage

func ParseStorage(configuration *viper.Viper, allowedBackends []string) (*Storage, error)

ParseStorage tries to parse out Storage from a Viper. If backend and URL are not provided, returns a nil pointer. Storage is required (if a backend is not provided, an error will be returned.)

Jump to

Keyboard shortcuts

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