app

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogFactGathered

func LogFactGathered(fact Fact, c system.Command)

LogFactGathered logs the details of a fact that has been gathered.

Types

type Action

type Action struct {
	Command string   `validate:"required"` // action command
	Rules   []string // action rules
}

Format provides a data format for the actions defined in the configuration file.

type Config

type Config struct {
	Daemon  Daemon           `validate:"dive"`
	Logging system.LogConfig `validate:"dive"`
	Facts   []Fact           `validate:"dive"`          // facts slice
	Actions []Action         `validate:"required,dive"` // actions slice
	Hash    uint32
}

Config provides a data format for the configuration file.

func LoadConfigFile

func LoadConfigFile(file string) Config

LoadConfigFile loads a configuration file, validates it, and returns the resulting Config.

func Run

func Run(configFile string, configArgs Config) Config

Run executes all the actions defined in the configuration file. It loads the configuration from the specified file and merges it with the provided merge configuration. It initializes logging and gathers facts before executing the actions.

Parameters: - configFile: The path to the configuration file. - merge: The merge configuration to combine with the loaded configuration.

notest

func (*Config) CalculateHash

func (c *Config) CalculateHash()

CalculateHash calculates a Adler-32 hash from the Config struct

func (*Config) Merge

func (c *Config) Merge(m Config)

Merge merges the fields of the provided Config into the receiver Config.

type Daemon

type Daemon struct {
	Interval string `validate:"duration"`
}

Daemon provides a data format for daemon settings defined in the configuration file.

type DurationValidator

type DurationValidator struct {
	// contains filtered or unexported fields
}

DurationValidator is a custom validator for duration strings.

func (*DurationValidator) Validate

func (v *DurationValidator) Validate(fl validator.FieldLevel) bool

Validate is the validation method for duration strings. It checks if the duration string is valid by attempting to parse it using time.ParseDuration().

type Fact

type Fact struct {
	Name    string `validate:"required"` // fact name
	Command string `validate:"required"` // fact command
}

Fact provides a data format for the facts defined in the configuration file.

type Facts

type Facts map[string]string

Facts represents a map of fact names to their corresponding values.

Jump to

Keyboard shortcuts

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