cmd

package
Version: v0.0.0-...-6eee230 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MPL-2.0 Imports: 28 Imported by: 54

Documentation

Overview

This package provides utilities that underlie the specific commands.

Index

Constants

This section is empty.

Variables

View Source
var ErrDurationMustBeString = errors.New("cannot JSON unmarshal something other than a string into a ConfigDuration")

ErrDurationMustBeString is returned when a non-string value is presented to be deserialized as a ConfigDuration

Functions

func CatchSignals

func CatchSignals(logger blog.Logger, callback func())

CatchSignals catches SIGTERM, SIGINT, SIGHUP and executes a callback method before exiting

func Clock

func Clock() clock.Clock

Clock functions similarly to clock.New(), but the returned value can be changed using the FAKECLOCK environment variable if the 'integration' build flag is set.

This function returns the default Clock.

func Fail

func Fail(msg string)

Fail exits and prints an error message to stderr and the logger audit log.

func FailOnError

func FailOnError(err error, msg string)

FailOnError exits and prints an error message, but only if we encountered a problem and err != nil

func FilterShutdownErrors

func FilterShutdownErrors(err error) error

FilterShutdownErrors returns the input error, with the exception of "use of closed network connection," on which it returns nil Per https://github.com/grpc/grpc-go/issues/1017, a gRPC server's `Serve()` will always return an error, even when GracefulStop() is called. We don't want to log graceful stops as errors, so we filter out the meaningless error we get in that situation.

func NewLogger

func NewLogger(logConf SyslogConfig) blog.Logger

func ReadConfigFile

func ReadConfigFile(filename string, out interface{}) error

ReadConfigFile takes a file path as an argument and attempts to unmarshal the content of the file into a struct containing a configuration of a boulder component.

func StatsAndLogging

func StatsAndLogging(logConf SyslogConfig, addr string) (prometheus.Registerer, blog.Logger)

StatsAndLogging constructs a prometheus registerer and an AuditLogger based on its config parameters, and return them both. It also spawns off an HTTP server on the provided port to report the stats and provide pprof profiling handlers. NewLogger and newStatsRegistry will call os.Exit on errors. Also sets the constructed AuditLogger as the default logger, and configures the mysql and grpc packages to use our logger. This must be called before any gRPC code is called, because gRPC's SetLogger doesn't use any locking.

func VersionString

func VersionString() string

VersionString produces a friendly Application version string.

Types

type BeelineConfig

type BeelineConfig struct {
	// WriteKey is the API key needed to send data Honeycomb. This can be given
	// directly in the JSON config for local development, or as a path to a
	// separate file for production deployment.
	WriteKey PasswordConfig
	// Dataset is the event collection, e.g. Staging or Prod.
	Dataset string
	// SampleRate is the (positive integer) denominator of the sample rate.
	// Default: 1 (meaning all traces are sent). Set higher to send fewer traces.
	SampleRate uint32
	// Mute disables honeycomb entirely; useful in test environments.
	Mute bool
}

BeelineConfig provides config options for the Honeycomb beeline-go library, which are passed to its beeline.Init() method.

func (*BeelineConfig) Load

func (bc *BeelineConfig) Load() (beeline.Config, error)

Load converts a BeelineConfig to a beeline.Config, loading the api WriteKey and setting the ServiceName automatically.

type ConfigDuration

type ConfigDuration struct {
	time.Duration
}

ConfigDuration is just an alias for time.Duration that allows serialization to YAML as well as JSON.

func (ConfigDuration) MarshalJSON

func (d ConfigDuration) MarshalJSON() ([]byte, error)

MarshalJSON returns the string form of the duration, as a byte array.

func (*ConfigDuration) UnmarshalJSON

func (d *ConfigDuration) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a string into a ConfigDuration using time.ParseDuration. If the input does not unmarshal as a string, then UnmarshalJSON returns ErrDurationMustBeString.

func (*ConfigDuration) UnmarshalYAML

func (d *ConfigDuration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML uses the same format as JSON, but is called by the YAML parser (vs. the JSON parser).

type DBConfig

type DBConfig struct {
	DBConnect string
	// A file containing a connect URL for the DB.
	DBConnectFile string

	// MaxOpenConns sets the maximum number of open connections to the
	// database. If MaxIdleConns is greater than 0 and MaxOpenConns is
	// less than MaxIdleConns, then MaxIdleConns will be reduced to
	// match the new MaxOpenConns limit. If n < 0, then there is no
	// limit on the number of open connections.
	MaxOpenConns int

	// MaxIdleConns sets the maximum number of connections in the idle
	// connection pool. If MaxOpenConns is greater than 0 but less than
	// MaxIdleConns, then MaxIdleConns will be reduced to match the
	// MaxOpenConns limit. If n < 0, no idle connections are retained.
	MaxIdleConns int

	// ConnMaxLifetime sets the maximum amount of time a connection may
	// be reused. Expired connections may be closed lazily before reuse.
	// If d < 0, connections are not closed due to a connection's age.
	ConnMaxLifetime ConfigDuration

	// ConnMaxIdleTime sets the maximum amount of time a connection may
	// be idle. Expired connections may be closed lazily before reuse.
	// If d < 0, connections are not closed due to a connection's idle
	// time.
	ConnMaxIdleTime ConfigDuration
}

DBConfig defines how to connect to a database. The connect string may be stored in a file separate from the config, because it can contain a password, which we want to keep out of configs.

func (*DBConfig) URL

func (d *DBConfig) URL() (string, error)

URL returns the DBConnect URL represented by this DBConfig object, either loading it from disk or returning a default value. Leading and trailing whitespace is stripped.

type GRPCClientConfig

type GRPCClientConfig struct {
	ServerAddress string
	Timeout       ConfigDuration
}

GRPCClientConfig contains the information needed to talk to the gRPC service

type GRPCServerConfig

type GRPCServerConfig struct {
	Address string `json:"address"`
	// ClientNames is a list of allowed client certificate subject alternate names
	// (SANs). The server will reject clients that do not present a certificate
	// with a SAN present on the `ClientNames` list.
	ClientNames []string `json:"clientNames"`
	// MaxConnectionAge specifies how long a connection may live before the server sends a GoAway to the
	// client. Because gRPC connections re-resolve DNS after a connection close,
	// this controls how long it takes before a client learns about changes to its
	// backends.
	// https://pkg.go.dev/google.golang.org/grpc/keepalive#ServerParameters
	MaxConnectionAge ConfigDuration
}

GRPCServerConfig contains the information needed to run a gRPC service

type HostnamePolicyConfig

type HostnamePolicyConfig struct {
	HostnamePolicyFile string
}

HostnamePolicyConfig specifies a file from which to load a policy regarding what hostnames to issue for.

type PAConfig

type PAConfig struct {
	DBConfig
	Challenges map[core.AcmeChallenge]bool
}

PAConfig specifies how a policy authority should connect to its database, what policies it should enforce, and what challenges it should offer.

func (PAConfig) CheckChallenges

func (pc PAConfig) CheckChallenges() error

CheckChallenges checks whether the list of challenges in the PA config actually contains valid challenge names

type PasswordConfig

type PasswordConfig struct {
	PasswordFile string
}

PasswordConfig contains a path to a file containing a password.

func (*PasswordConfig) Pass

func (pc *PasswordConfig) Pass() (string, error)

Pass returns a password, extracted from the PasswordConfig's PasswordFile

type PortConfig

type PortConfig struct {
	HTTPPort  int
	HTTPSPort int
	TLSPort   int
}

PortConfig specifies what ports the VA should call to on the remote host when performing its checks.

type RPCServerConfig

type RPCServerConfig struct {
	Server     string // Queue name where the server receives requests
	RPCTimeout ConfigDuration
}

RPCServerConfig contains configuration particular to a specific RPC server type (e.g. RA, SA, etc)

type SMTPConfig

type SMTPConfig struct {
	PasswordConfig
	Server   string
	Port     string
	Username string
}

type ServiceConfig

type ServiceConfig struct {
	// DebugAddr is the address to run the /debug handlers on.
	DebugAddr string
	GRPC      *GRPCServerConfig
	TLS       TLSConfig
}

ServiceConfig contains config items that are common to all our services, to be embedded in other config structs.

type SyslogConfig

type SyslogConfig struct {
	StdoutLevel int
	SyslogLevel int
}

SyslogConfig defines the config for syslogging.

type TLSConfig

type TLSConfig struct {
	CertFile   *string
	KeyFile    *string
	CACertFile *string
}

TLSConfig represents certificates and a key for authenticated TLS.

func (*TLSConfig) Load

func (t *TLSConfig) Load() (*tls.Config, error)

Load reads and parses the certificates and key listed in the TLSConfig, and returns a *tls.Config suitable for either client or server use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to