config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0, EPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvToBool

func EnvToBool(key string, value bool) bool

EnvToBool check if an ENV variable is set and returns its value as a bool. If not set, the default value is returned.

func EnvToInt

func EnvToInt(key string, value int64) int64

EnvToInt check if an ENV variable is set and returns its value as an integer. If not set or value is not an integer, the default value is returned.

func EnvToString

func EnvToString(key string, value string) string

EnvToString check if an ENV variable is set and returns its value as a string. If not set, the default value is returned.

func LoadConfigFromFile

func LoadConfigFromFile(filePath string, config interface{}) error

LoadConfigFromFile reads the file contents and unmarshal them into the given config structure.

func ParseConfigFilePath

func ParseConfigFilePath() string

ParseConfigFilePath returns the value for configuration file path if set.

func SetupAllUpdateManagerFlags

func SetupAllUpdateManagerFlags(flagSet *flag.FlagSet, cfg *Config)

SetupAllUpdateManagerFlags adds all flags for the configuration of the update manager

func SetupFlags

func SetupFlags(flagSet *flag.FlagSet, cfg *BaseConfig)

SetupFlags adds common flags for the configuration of all update agents

Types

type BaseConfig

type BaseConfig struct {
	Log           *logger.LogConfig      `json:"log,omitempty"`
	MQTT          *mqtt.ConnectionConfig `json:"connection,omitempty"`
	Domain        string                 `json:"domain,omitempty"`
	ThingsEnabled bool                   `json:"thingsEnabled,omitempty"`
}

BaseConfig represents the common, reusable configuration that holds logger options and MQTT connection parameters.

func DefaultDomainConfig

func DefaultDomainConfig(domain string) *BaseConfig

DefaultDomainConfig creates a new configuration filled with default values for all config properties and domain name set to the given parameter.

type Config

type Config struct {
	*BaseConfig
	Agents                 map[string]*api.UpdateManagerConfig `json:"agents,omitempty"`
	RebootEnabled          bool                                `json:"rebootEnabled"`
	RebootAfter            string                              `json:"rebootAfter"`
	ReportFeedbackInterval string                              `json:"reportFeedbackInterval"`
	CurrentStateDelay      string                              `json:"currentStateDelay"`
	PhaseTimeout           string                              `json:"phaseTimeout"`
	OwnerConsentCommands   []types.CommandType                 `json:"ownerConsentCommands"`
	OwnerConsentTimeout    string                              `json:"ownerConsentTimeout"`
}

Config represents the Update Manager configuration.

func LoadConfig

func LoadConfig(version string) (*Config, error)

LoadConfig loads a new configuration instance using flags and config file (if set).

Jump to

Keyboard shortcuts

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