config

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Package config contains the top level configuration structures and logic

Index

Constants

View Source
const (
	// DefaultUsername is the default username used for communication between client and server.
	DefaultUsername = "admin"

	// DefaultPassword is the default password used for communication between client and server.
	DefaultPassword = "admin"
)
View Source
const (
	// DefaultOutput is the default output format of the CLI
	DefaultOutput = "table"

	// EnvDevelopment should be used for development and uses debug logging and normal gin request logging to stdout.
	EnvDevelopment = "development"

	// EnvTest should be used for tests and uses debug logging with json gin request logging to the log file.
	EnvTest = "test"

	// EnvProduction the the default and should be used in production and uses info logging with json gin request logging to the log file.
	EnvProduction = "production"

	// DefaultRolloutsInterval is the interval at which rollouts are updated
	DefaultRolloutsInterval = 5 * time.Second

	// DefaultMetricsInterval is the interval at which metrics are exported
	DefaultMetricsInterval = 1 * time.Minute
)
View Source
const (
	// LoggingOutputFile will write logs to the file specified by LogFilePath
	LoggingOutputFile = "file"

	// LoggingOutputStdout will write logs to stdout
	LoggingOutputStdout = "stdout"
)
View Source
const (
	// MetricsTypeOTLP is the OTLP metrics type
	MetricsTypeOTLP = "otlp"
	// MetricsTypeNop is the metrics type that does nothing
	MetricsTypeNop = ""
)
View Source
const (
	// DefaultHost is the default host to which the server will bind.
	DefaultHost = "127.0.0.1"

	// DefaultPort is the default port on which the server will serve.
	DefaultPort = "3001"
)
View Source
const (
	// DefaultMaxEvents is the default maximum number of events to merge into a single event.
	DefaultMaxEvents = 100

	// StoreTypeMap is the type of store that uses an in-memory store.
	StoreTypeMap = "map"

	// StoreTypeBBolt is the type of store that uses bbolt.
	StoreTypeBBolt = "bbolt"
)
View Source
const (
	// TracerTypeGoogleCloud is the type of tracer that sends traces to Google Cloud Monitoring
	TracerTypeGoogleCloud = "google"

	// TracerTypeOTLP is the type of tracer that sends traces to an OTLP endpoint
	TracerTypeOTLP = "otlp"

	// TracerTypeNop is the type of tracer that does nothing
	TracerTypeNop = ""
)
View Source
const DefaultSyncInterval = 1 * time.Hour

DefaultSyncInterval is the default interval at which agent-versions will be synchronized with GitHub.

Variables

View Source
var (
	// DefaultSecretKey is the default value for secret key.
	// Having this be hard coded allows us to determine if a user has changed from defaults.
	DefaultSecretKey = "38f6b093-ed43-457d-9564-1b55006f66b2"

	// DefaultSessionSecret is the default value for session secret.
	// Having this be hard coded allows us to determine if a user has changed from defaults.
	DefaultSessionSecret = "5cdd2530-c4ee-4294-ad8f-217a9406eaf2"
)

#nosec G101 -- these credentials are use to detect if we need to replace them and are only valid for first install

View Source
var DefaultBBoltPath = filepath.Join(common.GetHome(), "storage")

DefaultBBoltPath is the default path to the bbolt file.

View Source
var DefaultLoggingFilePath = filepath.Join(common.GetHome(), "bindplane.log")

DefaultLoggingFilePath is the default path for the bindplane log file

Functions

This section is empty.

Types

type AgentVersions

type AgentVersions struct {
	SyncInterval time.Duration `mapstructure:"syncInterval,omitempty" yaml:"syncInterval,omitempty"`
}

AgentVersions is the configuration for serving and checking agent versions.

func (*AgentVersions) Validate

func (c *AgentVersions) Validate() error

Validate validates the agent versions configuration.

type Auth

type Auth struct {
	// SecretKey is a shared secret between the server and the agent to ensure agents are authorized to communicate with the server.
	SecretKey string `mapstructure:"secretKey,omitempty" yaml:"secretKey,omitempty"`

	// Username is the basic auth username used for communication between client and server.
	Username string `mapstructure:"username" yaml:"username,omitempty"`

	// Password is the basic auth password used for communication between client and server.
	Password string `mapstructure:"password" yaml:"password,omitempty"`

	// SessionSecret is the secret used to sign the session cookie.
	SessionSecret string `mapstructure:"sessionSecret" yaml:"sessionSecret,omitempty"`
}

Auth is the configuration for authentication

func (*Auth) Validate

func (c *Auth) Validate() error

Validate validates the auth configuration.

type BBolt

type BBolt struct {
	// Path is the path to the bbolt file.
	Path string `mapstructure:"path,omitempty" yaml:"path,omitempty"`
}

BBolt is the configuration for a bbolt store.

func (*BBolt) Validate

func (b *BBolt) Validate() error

Validate validates the bbolt configuration.

type Config

type Config struct {
	// ProfileName is the name of the profile associated with this config file if there is one
	ProfileName string `mapstructure:"name,omitempty" yaml:"name,omitempty"`

	// APIVersion is the version of the configuration file
	APIVersion string `mapstructure:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`

	// Env is the environment of the service
	Env string `mapstructure:"env,omitempty" yaml:"env,omitempty"`

	// Output is the output format of the CLI
	Output string `mapstructure:"output,omitempty" yaml:"output,omitempty"`

	// Offline mode indicates if the server should be considered offline. An offline server will not attempt to contact
	// any other services. It will still allow agents to connect and serve api requests.
	Offline bool `mapstructure:"offline,omitempty" yaml:"offline,omitempty"`

	// RolloutsInterval is the interval at which rollouts' progress is updated.
	RolloutsInterval time.Duration `mapstructure:"rolloutsInterval" yaml:"rolloutsInterval,omitempty"`

	// Auth is the configuration for authentication
	Auth Auth `mapstructure:"auth,omitempty" yaml:"auth,omitempty"`

	// Network is the configuration for networking
	Network Network `mapstructure:"network" yaml:"network,omitempty"`

	// AgentVersions is the configuration for agent versions
	AgentVersions AgentVersions `mapstructure:"agentVersions,omitempty" yaml:"agentVersions,omitempty"`

	// Store is the configuration for storage
	Store Store `mapstructure:"store,omitempty" yaml:"store,omitempty"`

	// Tracing is the tracer configuration for the server
	Tracing Tracing `mapstructure:"tracing,omitempty" yaml:"tracing,omitempty"`

	// Logging configuration for the logger
	Logging Logging `yaml:"logging,omitempty" mapstructure:"logging,omitempty"`

	// Metrics is the configuration for sending APM metrics
	Metrics Metrics `yaml:"metrics,omitempty" mapstructure:"metrics,omitempty"`
}

Config is the configuration of BindPlane

func NewConfig

func NewConfig() *Config

NewConfig returns a new config

func (*Config) BindPlaneInsecureSkipVerify

func (c *Config) BindPlaneInsecureSkipVerify() bool

BindPlaneInsecureSkipVerify returns the BindPlane InsecureSkipVerify

func (*Config) BindPlaneURL

func (c *Config) BindPlaneURL() string

BindPlaneURL returns the BindPlane URL

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type GoogleCloudTracing

type GoogleCloudTracing struct {
	// ProjectID is the Google Cloud project ID to use when sending traces.
	ProjectID string `mapstructure:"projectID,omitempty" yaml:"projectID,omitempty"`

	// CredentialsFile is the path to the Google Cloud credentials file to use when sending traces.
	CredentialsFile string `mapstructure:"credentialsFile,omitempty" yaml:"credentialsFile,omitempty"`
}

GoogleCloudTracing is the configuration for tracing to Google Cloud Monitoring

func (*GoogleCloudTracing) Validate

func (t *GoogleCloudTracing) Validate() error

Validate validates the Google Cloud tracing configuration.

type Logging

type Logging struct {
	// FilePath is the path of the bindplane log file, defaulting to $HOME/.bindplane/bindplane.log
	FilePath string `mapstructure:"filePath" yaml:"filePath,omitempty"`

	// Output indicates where logs should be written, defaulting to "file"
	Output string `mapstructure:"output" yaml:"output,omitempty"`
}

Logging contains configuration for logging.

func (*Logging) Validate

func (l *Logging) Validate() error

Validate validates the logging configuration.

type Metrics added in v1.25.0

type Metrics struct {
	// Type is the type of metrics to send
	Type string `mapstructure:"type,omitempty" yaml:"type,omitempty"`

	// Interval is the interval to send metrics at
	Interval time.Duration `mapstructure:"interval,omitempty" yaml:"interval,omitempty"`

	// OTLP is the config for sending OTLP metrics
	OTLP OTLPMetrics `mapstructure:"otlp,omitempty" yaml:"otlp,omitempty"`
}

Metrics is the config for sending APM metrics

func (*Metrics) Validate added in v1.25.0

func (m *Metrics) Validate() error

Validate validates the metrics config

type Network

type Network struct {
	// Host is the Host to which the server will bind.
	Host string `mapstructure:"host" yaml:"host,omitempty"`

	// Port is the Port on which the server will serve.
	Port string `mapstructure:"port" yaml:"port,omitempty"`

	// RemoteURL is the remote URL of the server. If not provided, this will be constructed from the Host and Port.
	RemoteURL string `mapstructure:"remoteURL" yaml:"remoteURL,omitempty"`

	TLS `mapstructure:",squash" yaml:",inline"`
}

Network is the configuration for networking in BindPlane

func (*Network) BindAddress

func (n *Network) BindAddress() string

BindAddress is the address (host:port) to which the server will bind

func (*Network) ServerScheme

func (n *Network) ServerScheme() string

ServerScheme returns http or https

func (*Network) ServerURL

func (n *Network) ServerURL() string

ServerURL returns the server URL of the server. This will be the RemoteURL if provided, otherwise it will be constructed from the Host and Port.

func (*Network) Validate

func (n *Network) Validate() error

Validate validates the TLS configuration

func (*Network) WebsocketScheme

func (n *Network) WebsocketScheme() string

WebsocketScheme returns ws or wss

func (*Network) WebsocketURL

func (n *Network) WebsocketURL() string

WebsocketURL returns the websocket URL of the server. This will be the RemoteURL if provided, otherwise it will be constructed from the Host and Port.

type OTLPMetrics added in v1.25.0

type OTLPMetrics struct {
	// Endpoint is the gRPC endpoint to send metrics to
	Endpoint string `mapstructure:"endpoint,omitempty" yaml:"endpoint,omitempty"`

	// Insecure is whether to use an insecure connection
	Insecure bool `mapstructure:"insecure,omitempty" yaml:"insecure,omitempty"`
}

OTLPMetrics is the config for sending OTLP metrics

type OTLPTracing

type OTLPTracing struct {
	// Endpoint is the OTLP endpoint to send traces to.
	Endpoint string `mapstructure:"endpoint,omitempty" yaml:"endpoint,omitempty"`

	// Insecure disables TLS verification
	Insecure bool `mapstructure:"insecure,omitempty" yaml:"insecure,omitempty"`
}

OTLPTracing is the configuration for tracing to an OTLP endpoint

func (*OTLPTracing) Validate

func (t *OTLPTracing) Validate() error

Validate validates the OTLP tracing configuration.

type Override

type Override struct {
	// Field is the config field to override
	Field string
	// Flag is the flag that will override the field
	Flag string
	// Env is the environment variable that will override the field
	Env string
	// Usage is the usage for the override
	Usage string
	// Default is the default value for the override
	Default any
	// ShortHand is the shorthand for the flag
	ShortHand string

	// Hidden signals if the cli flag should be hidden in the help menu
	Hidden bool
}

Override is a configuration override

func DefaultOverrides

func DefaultOverrides() []*Override

DefaultOverrides returns the default overrides

func NewHiddenOverride

func NewHiddenOverride(field, usage string, def any) *Override

NewHiddenOverride creates a new override that is hidden

func NewOverride

func NewOverride(field, usage string, def any) *Override

NewOverride creates a new override

func NewOverrideWithShortHand

func NewOverrideWithShortHand(field, shorthand, usage string, def any) *Override

NewOverrideWithShortHand creates a new override with a shorthand

func NewOverrideWithoutPrefix

func NewOverrideWithoutPrefix(field, usage string, def any) *Override

NewOverrideWithoutPrefix creates a new override without the original field prefix for the flag and env

func (*Override) Bind

func (o *Override) Bind(flags *pflag.FlagSet) error

Bind binds the override to the viper instance

type Store

type Store struct {
	// Type is the type of store.
	Type string `mapstructure:"type,omitempty" yaml:"type,omitempty"`

	// MaxEvents is the maximum number of events to merge into a single event.
	MaxEvents int `mapstructure:"maxEvents,omitempty" yaml:"maxEvents,omitempty"`

	// BBolt is the configuration for a bbolt store.
	BBolt BBolt `mapstructure:"bbolt,omitempty" yaml:"bbolt,omitempty"`
}

Store is the configuration for a store.

func (*Store) Validate

func (s *Store) Validate() error

Validate validates the store configuration.

type TLS

type TLS struct {
	// Certificate is the path to the x509 PEM encoded certificate file that will be used to
	// establish TLS connections.
	//
	// When operating in server mode, this certificate is presented to clients.
	// When operating in client mode with mTLS, this certificate is used for authentication
	// against the server.
	Certificate string `mapstructure:"tlsCert" yaml:"tlsCert,omitempty"`

	// PrivateKey is the matching x509 PEM encoded private key for the Certificate.
	PrivateKey string `mapstructure:"tlsKey" yaml:"tlsKey,omitempty"`

	// CertificateAuthority is one or more file paths to x509 PEM encoded certificate authority chains.
	// These certificate authorities are used for trusting incoming client mTLS connections.
	CertificateAuthority []string `mapstructure:"tlsCa" yaml:"tlsCa,omitempty"`

	// InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name. If
	// InsecureSkipVerify is true, crypto/tls accepts any certificate presented by the server and any host name in that
	// certificate.
	//
	// It is also used to signal that clients, like the agent metrics pipeline, should connect to the server with
	// tls.insecure set to true.
	//
	// In this mode, TLS is susceptible to machine-in-the-middle attacks. This should be used only for testing only.
	InsecureSkipVerify bool `mapstructure:"tlsSkipVerify" yaml:"tlsSkipVerify,omitempty"`
}

TLS is the configuration for TLS connections

func (TLS) Convert

func (t TLS) Convert() (*tls.Config, error)

Convert converts a TLS config to a *tls.Config

func (*TLS) TLSEnabled

func (t *TLS) TLSEnabled() bool

TLSEnabled returns true if TLS is configured

func (*TLS) Validate

func (t *TLS) Validate() error

Validate validates the TLS configuration

type Tracing

type Tracing struct {
	// Type specifies the type of tracing to use.
	Type string `mapstructure:"type,omitempty" yaml:"type,omitempty"`

	// SamplingRate is the rate at which traces are sampled. Valid values are between 0 and 1.
	SamplingRate float64 `mapstructure:"samplingRate,omitempty" yaml:"samplingRate,omitempty"`

	// GoogleCloud is used to send traces to Google Cloud when TraceType is set to "google".
	GoogleCloud GoogleCloudTracing `mapstructure:"googleCloud,omitempty" yaml:"googleCloud,omitempty"`

	// OTLP is used to send traces to an Open Telemetry OTLP receiver when TraceType is set to "otlp".
	OTLP OTLPTracing `mapstructure:"otlp,omitempty" yaml:"otlp,omitempty"`
}

Tracing is the configuration for tracing

func (*Tracing) Validate

func (t *Tracing) Validate() error

Validate validates the tracing configuration.

Jump to

Keyboard shortcuts

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