config

package
v0.0.0-...-d17e12a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstallationModeEnv = "INSTALLATION_MODE"
	InstallationModeCMC = "CHILD_MANAGED_CHILD"
	InstallationModePMC = "PARENT_MANAGED_CHILD"
	InstallationModeP   = "PARENT"
	InstallationModeS   = "STANDALONE"

	SecVerPrefix = "_v1_"
)

Variables

View Source
var (
	// AllowFlags defines processing the cli arguments
	// true by default
	// false on init of C-shared library libtransit
	AllowFlags = true
	// EnvPrefix defines name prefix for environment variables
	// with struct-path selector and value, for example:
	//    TCG_GWCONNECTIONS_0_PASSWORD=TOK_EN
	EnvPrefix = "TCG_"
	// ConfigEnv defines environment variable for config file path, overrides the ConfigName
	ConfigEnv = "TCG_CONFIG"
	// ConfigName defines default filename for look in work directory if ConfigEnv is empty
	ConfigName = "tcg_config.yaml"
	// SecKeyEnv defines environment variable for
	SecKeyEnv = "TCG_SECKEY"
)

Functions

func Decrypt

func Decrypt(message, secret []byte) ([]byte, error)

Decrypt decrypts small messages golang.org/x/crypto/nacl/secretbox

func Encrypt

func Encrypt(message, secret []byte) ([]byte, error)

Encrypt encrypts small messages golang.org/x/crypto/nacl/secretbox

Types

type BuildInfo

type BuildInfo struct {
	Tag  string `json:"tag"`
	Time string `json:"time"`
}

BuildInfo describes the build properties

func GetBuildInfo

func GetBuildInfo() BuildInfo

GetBuildInfo returns the build properties

type Config

type Config struct {
	Connector     Connector     `yaml:"connector"`
	DSConnection  DSConnection  `yaml:"dsConnection"`
	GWConnections GWConnections `yaml:"gwConnections"`
}

Config defines TCG Agent configuration

func GetConfig

func GetConfig() *Config

GetConfig implements Singleton pattern

func (Config) ConfigPath

func (cfg Config) ConfigPath() string

ConfigPath returns config file path

func (Config) InitTracerProvider

func (cfg Config) InitTracerProvider() (*tracesdk.TracerProvider, error)

InitTracerProvider inits provider

func (*Config) IsConfiguringPMC

func (cfg *Config) IsConfiguringPMC() bool

IsConfiguringPMC checks configuration stage

func (*Config) LoadConnectorDTO

func (cfg *Config) LoadConnectorDTO(data []byte) (*ConnectorDTO, error)

LoadConnectorDTO loads ConnectorDTO into Config

type Connector

type Connector struct {
	transit.AgentIdentity `yaml:",inline"`

	BatchEvents   time.Duration `yaml:"batchEvents"`
	BatchMetrics  time.Duration `yaml:"batchMetrics"`
	BatchMaxBytes int           `yaml:"batchMaxBytes"`

	// ControllerAddr accepts value for combined "host:port"
	// used as `http.Server{Addr}`
	ControllerAddr     string `yaml:"controllerAddr"`
	ControllerCertFile string `yaml:"controllerCertFile"`
	ControllerKeyFile  string `yaml:"controllerKeyFile"`
	// ControllerPin accepts value from environment
	// provides local access for debug
	ControllerPin string `yaml:"-"`
	// Custom HTTP configuration
	ControllerReadTimeout  time.Duration `yaml:"-"`
	ControllerWriteTimeout time.Duration `yaml:"-"`
	ControllerStartTimeout time.Duration `yaml:"-"`
	ControllerStopTimeout  time.Duration `yaml:"-"`

	Enabled            bool   `yaml:"enabled"`
	InstallationMode   string `yaml:"installationMode,omitempty"`
	IsDynamicInventory bool   `yaml:"-"`
	// GWEncode defines using HTTPEncode in Groundwork client: child|force|off
	// enabled for child by default
	GWEncode string `yaml:"-"`

	// LogCondense accepts time duration for condensing similar records
	// if 0 turn off condensing
	LogCondense time.Duration `yaml:"logCondense"`
	// LogFile accepts file path to log in addition to stdout
	LogFile        string `yaml:"logFile"`
	LogFileMaxSize int64  `yaml:"logFileMaxSize"`
	// Log files are rotated count times before being removed.
	// If count is 0, old versions are removed rather than rotated.
	LogFileRotate int      `yaml:"logFileRotate"`
	LogLevel      LogLevel `yaml:"logLevel"`
	LogColors     bool     `yaml:"logColors"`
	LogTimeFormat string   `yaml:"logTimeFormat"`

	// NatsAckWait is the time the NATS server will wait before resending a message
	// Should be greater then the GWClient request duration
	NatsAckWait time.Duration `yaml:"-"`
	// designates the maximum number of outstanding acknowledgements
	// (messages that have been delivered but not acknowledged)
	// that NATS Streaming will allow for a given subscription.
	// When this limit is reached, NATS Streaming will suspend delivery of messages
	// to this subscription until the number of unacknowledged messages falls below the specified limit
	NatsMaxInflight int `yaml:"-"`
	// NatsMaxPubAcksInflight accepts number of unacknowledged messages
	// that a publisher may have in-flight at any given time.
	// When this maximum is reached, further async publish calls will block
	// until the number of unacknowledged messages falls below the specified limit
	NatsMaxPubAcksInflight int   `yaml:"-"`
	NatsMaxPayload         int32 `yaml:"-"`
	// NatsMonitorPort enables monitoring on http port useful for debug
	// curl 'localhost:8222/streaming/channelsz?limit=0&offset=0&subs=1'
	// More info: https://docs.nats.io/nats-streaming-concepts/monitoring
	NatsMonitorPort int    `yaml:"-"`
	NatsStoreDir    string `yaml:"natsFilestoreDir"`
	// NatsStoreType accepts "FILE"|"MEMORY"
	NatsStoreType string `yaml:"natsStoreType"`
	// How long messages are kept
	NatsStoreMaxAge time.Duration `yaml:"natsStoreMaxAge"`
	// How many bytes are allowed per-channel
	NatsStoreMaxBytes int64 `yaml:"natsStoreMaxBytes"`
	// How many messages are allowed per-channel
	NatsStoreMaxMsgs int64 `yaml:"natsStoreMaxMsgs"`
	// NatsServerConfigFile is used to override yaml values for
	// NATS server configuration (debug only).
	NatsServerConfigFile string `yaml:"natsServerConfigFile"`

	TransportStartRndDelay int `yaml:"-"`
}

Connector defines TCG Connector configuration see GetConfig() for defaults

type ConnectorDTO

type ConnectorDTO struct {
	AgentID       string        `json:"agentId"`
	AppName       string        `json:"appName"`
	AppType       string        `json:"appType"`
	TcgURL        string        `json:"tcgUrl"`
	LogLevel      LogLevel      `json:"logLevel"`
	Enabled       bool          `json:"enabled"`
	DSConnection  DSConnection  `json:"dalekservicesConnection"`
	GWConnections GWConnections `json:"groundworkConnections"`
}

ConnectorDTO defines TCG Connector configuration

type DSConnection

type DSConnection clients.DSConnection

DSConnection defines DalekServices Connection configuration

type GWConnection

type GWConnection clients.GWConnection

GWConnection defines Groundwork Connection configuration

func (GWConnection) MarshalYAML

func (con GWConnection) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler interface overrides the password field

func (*GWConnection) UnmarshalYAML

func (con *GWConnection) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface. overrides the password field

type GWConnections

type GWConnections []*GWConnection

GWConnections defines a set of configurations

func (*GWConnections) UnmarshalYAML

func (cc *GWConnections) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface. Applies decode to items in collection for setting only fields present in yaml. Note (as for gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b):

if yaml defines an empty set this method is not called but target is truncated.

type LogLevel

type LogLevel int

LogLevel defines levels in logrus-style

const (
	Error LogLevel = iota
	Warn
	Info
	Debug
)

Enum levels

func (LogLevel) String

func (l LogLevel) String() string

Jump to

Keyboard shortcuts

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