app

package
v0.0.0-...-dcf9213 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCollectInterval = 72 * time.Hour
	DefaultCollectSplay    = 4 * time.Hour
)

Variables

View Source
var (
	ErrAppInit = errors.New("error initializing app")
)
View Source
var (
	ErrConfig = errors.New("configuration error")
)

Functions

func NewLogrusEntryFromLogger

func NewLogrusEntryFromLogger(fields logrus.Fields, logger *logrus.Logger) *logrus.Entry

NewLogrusEntryFromLogger returns a logger contextualized with the given logrus fields.

Types

type App

type App struct {

	// App configuration.
	Config *Configuration

	// TermCh is the channel to terminate the app based on a signal
	TermCh chan os.Signal

	// Sync waitgroup to wait for running go routines on termination.
	SyncWg *sync.WaitGroup

	// Logger is the app logger
	Logger *logrus.Logger

	// Kind is the type of application - inband/outofband
	Kind model.AppKind
	// contains filtered or unexported fields
}

App holds attributes for running alloy.

func New

func New(appKind model.AppKind, storeKind model.StoreKind, cfgFile string, loglevel model.LogLevel) (app *App, err error)

New returns a new alloy application object with the configuration loaded

func (*App) LoadConfiguration

func (a *App) LoadConfiguration(cfgFile string, storeKind model.StoreKind) error

LoadConfiguration loads application configuration

Reads in the cfgFile when available and overrides from environment variables.

type Configuration

type Configuration struct {
	// LogLevel is the app verbose logging level.
	// one of - info, debug, trace
	LogLevel string `mapstructure:"log_level"`

	// AppKind is either inband or outofband
	AppKind model.AppKind `mapstructure:"app_kind"`

	// StoreKind declares the type of storage repository that holds asset inventory data.
	StoreKind model.StoreKind `mapstructure:"store_kind"`

	// CSV file path when StoreKind is set to csv.
	CsvFile string `mapstructure:"csv_file"`

	// FacilityCode limits this alloy to events in a facility.
	FacilityCode string `mapstructure:"facility_code"`

	// FleetDBAPIOptions defines the fleetdb API client configuration parameters
	//
	// This parameter is required when StoreKind is set to fleetdb.
	FleetDBAPIOptions *FleetDBAPIOptions `mapstructure:"fleetdb"`

	// Controller Out of band collector concurrency
	Concurrency int `mapstructure:"concurrency"`

	CollectInterval time.Duration `mapstructure:"collect_interval"`

	CollectIntervalSplay time.Duration `mapstructure:"collect_interval_splay"`

	// EventsBrokerKind indicates the kind of event broker configuration to enable,
	//
	// Supported parameter value - nats
	EventsBorkerKind string `mapstructure:"events_broker_kind"`

	// NatsOptions defines the NATs events broker configuration parameters.
	//
	// This parameter is required when EventsBrokerKind is set to nats.
	NatsOptions *events.NatsOptions `mapstructure:"nats"`
}

Configuration holds application configuration read from a YAML or set by env variables.

nolint:govet // prefer readability over field alignment optimization for this case.

type FleetDBAPIOptions

type FleetDBAPIOptions struct {
	EndpointURL          *url.URL
	FacilityCode         string   `mapstructure:"facility_code"`
	Endpoint             string   `mapstructure:"endpoint"`
	OidcIssuerEndpoint   string   `mapstructure:"oidc_issuer_endpoint"`
	OidcAudienceEndpoint string   `mapstructure:"oidc_audience_endpoint"`
	OidcClientSecret     string   `mapstructure:"oidc_client_secret"`
	OidcClientID         string   `mapstructure:"oidc_client_id"`
	OidcClientScopes     []string `mapstructure:"oidc_client_scopes"`
	DisableOAuth         bool     `mapstructure:"disable_oauth"`
}

FleetDBAPIOptions defines configuration for the fleetdb client. https://github.com/metal-automata/fleetdb

Jump to

Keyboard shortcuts

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