common

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProfilesFolderName is the name of the folder where individual configuration profiles are stored
	ProfilesFolderName = "profiles"
	// BindPlaneDirectoryName TODO(doc)
	BindPlaneDirectoryName = ".bindplane"
	// BoldDatabaseName is the name of the bbolt database file
	BoldDatabaseName = "storage"
	// DownloadsDirectoryName is the name of the directory where downloads are cached
	DownloadsDirectoryName = "downloads"
	// BindPlaneLogName returns the name of the BindPlane log file
	BindPlaneLogName = "bindplane.log"
	// DefaultProfileName is the name of the default profile
	DefaultProfileName = "default"
)
View Source
const (
	// StoreTypeMap uses an in-memory store
	StoreTypeMap = "map"
	// StoreTypeBbolt uses go.etcd.io/bbolt for storage
	StoreTypeBbolt = "bbolt"
	// StoreTypeGoogleCloud uses Google Cloud Datastore for storage
	StoreTypeGoogleCloud = "googlecloud"
)

Variables

This section is empty.

Functions

func DefaultBindPlaneHomePath

func DefaultBindPlaneHomePath() string

DefaultBindPlaneHomePath returns the default value of the bindplane home path

func NewFileLogger

func NewFileLogger(level zapcore.Level, path string) (*zap.Logger, error)

NewFileLogger takes a logging level and log file path and returns a zip.Logger

func NewLogger

func NewLogger(config Common, level zapcore.Level) (*zap.Logger, error)

NewLogger returns a new Logger for the specified config and level

func NewStdoutLogger

func NewStdoutLogger(level zapcore.Level) (*zap.Logger, error)

NewStdoutLogger returns a new Logger with the specified level, writing to stdout

Types

type Client

type Client struct {
	Common
}

Client TODO(doc)

type Command

type Command struct {
	// TODO(doc)
	Output string `mapstructure:"output" yaml:"output"`
}

Command TODO(doc)

type Common

type Common struct {
	// Env is one of
	Env Env `mapstructure:"env" yaml:"env,omitempty"`

	// 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"`

	// ServerURL is the URL that clients should use to contact the server.
	ServerURL string `mapstructure:"serverURL" yaml:"serverURL,omitempty"`

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

	// TLSConfig is an optional TLS configuration for communication between client and server.
	TLSConfig `yaml:",inline" mapstructure:",squash"`

	// LogFilePath is the path of the bindplane log file, defaulting to $HOME/.bindplane/bindplane.log
	LogFilePath string `mapstructure:"logFilePath" yaml:"logFilePath,omitempty"`

	// LogOutput indicates where logs should be written, defaulting to "file"
	LogOutput LogOutput `mapstructure:"logOutput" yaml:"logOutput,omitempty"`

	// GoogleCloudTracing enables and configures tracing to Google Cloud
	GoogleCloudTracing *GoogleCloudTracing `mapstructure:"tracing,omitempty" yaml:"tracing,omitempty"`
	// contains filtered or unexported fields
}

Common TODO(doc)

func (*Common) BindPlaneEnv

func (c *Common) BindPlaneEnv() Env

BindPlaneEnv ensures that Env has a valid value and defaults to EnvProduction

func (*Common) BindPlaneHomePath

func (c *Common) BindPlaneHomePath() string

BindPlaneHomePath returns the path to the BindPlane home where files are stored by default

func (*Common) BindPlaneLogFilePath

func (c *Common) BindPlaneLogFilePath() string

BindPlaneLogFilePath returns the path to the log file for bindplane

func (*Common) BindPlaneURL

func (c *Common) BindPlaneURL() string

BindPlaneURL returns the configured server url. If one is not configured, a url derived from the configured host and port is used.

func (*Common) EnableTLS

func (c *Common) EnableTLS() bool

EnableTLS returns true if TLS is enabled

func (*Common) ServerScheme

func (c *Common) ServerScheme() string

ServerScheme returns http or https

func (*Common) WebsocketScheme

func (c *Common) WebsocketScheme() string

WebsocketScheme returns ws or wss

type Config

type Config struct {
	// Server TODO(doc)
	Server `mapstructure:"server" yaml:"server,omitempty"`
	// Client TODO(doc)
	Client `mapstructure:"client" yaml:"client,omitempty"`
	// Command TODO(doc)
	Command `mapstructure:"command" yaml:"command,omitempty"`
}

Config TODO(doc)

func InitConfig

func InitConfig(bindplaneHomePath string) *Config

InitConfig returns a Config struct with zero values, which will be assigned during Command's PersistentPreRun

func (*Config) Validate

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

Validate checks the runtime configuration for issues and returns all errors, if any.

type Env

type Env string

Env is an enum indicating the environment in which BindPlane is running.

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

	// EnvTest should be used for tests and uses debug logging with json gin request logging to the log file.
	EnvTest Env = "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 Env = "production"
)

type GoogleCloudDatastore

type GoogleCloudDatastore struct {
	ProjectID       string `mapstructure:"projectID,omitempty" yaml:"projectID,omitempty"`
	Endpoint        string `mapstructure:"endpoint,omitempty" yaml:"endpoint,omitempty"`
	CredentialsFile string `mapstructure:"credentialsFile,omitempty" yaml:"credentialsFile,omitempty"`
}

GoogleCloudDatastore contains the configuration for google cloud datastore

type GoogleCloudPubSub

type GoogleCloudPubSub struct {
	ProjectID       string `mapstructure:"projectID,omitempty" yaml:"projectID,omitempty"`
	Endpoint        string `mapstructure:"endpoint,omitempty" yaml:"endpoint,omitempty"`
	CredentialsFile string `mapstructure:"credentialsFile,omitempty" yaml:"credentialsFile,omitempty"`
	Topic           string `mapstructure:"topic,omitempty" yaml:"topic,omitempty"`

	// Subscription is the name of the subscription that this node should use. In production this will be generated but it
	// is useful to specify in development.
	Subscription string `mapstructure:"subscription,omitempty" yaml:"subscription,omitempty"`
}

GoogleCloudPubSub is configuration for a server's Pub/Sub subscriber and publisher

type GoogleCloudTracing

type GoogleCloudTracing struct {
	Enabled         bool   `mapstructure:"enabled" yaml:"enabled"`
	ProjectID       string `mapstructure:"projectID,omitempty" yaml:"projectID,omitempty"`
	CredentialsFile string `mapstructure:"credentialsFile,omitempty" yaml:"credentialsFile,omitempty"`
}

GoogleCloudTracing is configuration for tracing to Google Cloud Monitoring

type LogOutput

type LogOutput string

LogOutput is an enum of possible values for the LogOutput configuration setting

const (
	// LogOutputFile will write logs to the file specified by LogFilePath
	LogOutputFile LogOutput = "file"

	// LogOutputStdout will write logs to stdout
	LogOutputStdout LogOutput = "stdout"
)

type Server

type Server struct {
	// StoreType indicates the type of store to use. "map", "bbolt", and "googlecloud" are currently supported.
	StoreType string `mapstructure:"storeType,omitempty" yaml:"storeType,omitempty"`

	// GoogleCloudDatastore contains configuration for contacting Google Could Datastore and is used if StoreType == "googlecloud"
	GoogleCloudDatastore *GoogleCloudDatastore `mapstructure:"datastore,omitempty" yaml:"datastore,omitempty"`

	// GoogleCloudPubSub contains configuration for contacting Google Could Pub/Sub and is used if StoreType == "googlecloud"
	GoogleCloudPubSub *GoogleCloudPubSub `yaml:"pubsub,omitempty" mapstructure:"pubsub,omitempty"`

	// StorageFilePath TODO(doc)
	StorageFilePath string `mapstructure:"storageFilePath,omitempty" yaml:"storageFilePath,omitempty"`

	// 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"`

	// RemoteURL is the URL that agents should use to contact the server
	RemoteURL string `mapstructure:"remoteURL,omitempty" yaml:"remoteURL,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"`

	// AgentsServiceURL is the url of the Agent Versions server which manages the release of the agent. This service will
	// be contacted to determine the most recent agent version and to identify the location of artifacts for each version
	// of the agent.
	AgentsServiceURL string `mapstructure:"agentsServiceURL,omitempty" yaml:"agentsServiceURL,omitempty"`

	// DownloadsFolderPath is the path to the folder where agent versions are stored for upgrading agents
	DownloadsFolderPath string `mapstructure:"downloadsFolderPath,omitempty" yaml:"downloadsFolderPath,omitempty"`
	// DisableDownloadsCache TODO(doc)
	DisableDownloadsCache bool `mapstructure:"disableDownloadsCache,omitempty" yaml:"disableDownloadsCache,omitempty"`

	// SessionSecret is used to encode the user sessions cookies.  It should be a uuid.
	SessionsSecret string `mapstructure:"sessionsSecret,omitempty" yaml:"sessionsSecret,omitempty"`

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

Server TODO(doc)

func (*Server) BindAddress

func (c *Server) BindAddress() string

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

func (*Server) BindPlaneDownloadsPath

func (c *Server) BindPlaneDownloadsPath() string

BindPlaneDownloadsPath returns the path to the directory where downloads are cached

func (*Server) BoltDatabasePath

func (c *Server) BoltDatabasePath() string

BoltDatabasePath returns the path to the bolt database file

func (*Server) WebsocketURL

func (c *Server) WebsocketURL() string

WebsocketURL is the URL that should be used for agents connecting to the server

type TLSConfig

type TLSConfig 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"`
}

TLSConfig contains configuration for connecting over TLS and mTLS.

Jump to

Keyboard shortcuts

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