config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config provides configuration loading and validation for the nstance-agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug            bool          `env:"DEBUG" envDefault:"false"`
	Environment      string        `env:"ENVIRONMENT" envDefault:"development"`
	RegistrationAddr string        `env:"SERVER_REGISTRATION_ADDR" validate:"required,addr"`
	AgentAddr        string        `env:"SERVER_AGENT_ADDR" validate:"required,addr"`
	IdentityDir      string        `env:"IDENTITY_DIR" envDefault:"/opt/nstance-agent/identity" validate:"required,dirpath,dirwriteable"`
	KeysDir          string        `env:"KEYS_DIR" envDefault:"/opt/nstance-agent/keys" validate:"required,dirpath,dirwriteable"`
	RecvDir          string        `env:"RECV_DIR" envDefault:"/opt/nstance-agent/recv" validate:"required,dirpath,dirwriteable"`
	IdentityMode     string        `env:"IDENTITY_MODE" envDefault:"0600"`
	KeysMode         string        `env:"KEYS_MODE" envDefault:"0640"`
	RecvMode         string        `env:"RECV_MODE" envDefault:"0640"`
	InstanceKind     string        `env:"INSTANCE_KIND"`
	InstanceID       string        `env:"INSTANCE_ID" validate:"required,puidv7"`
	InstanceHostname string        `env:"INSTANCE_HOSTNAME" validate:"omitempty,hostname"`
	InstanceFQDN     string        `env:"INSTANCE_FQDN" validate:"omitempty,fqdn"`
	InstanceIPv4     string        `env:"INSTANCE_IPV4" validate:"omitempty,ipv4"`
	InstanceIPv6     string        `env:"INSTANCE_IPV6" validate:"omitempty,ipv6"`
	MetricsInterval  time.Duration `env:"METRICS_INTERVAL" envDefault:"60s" validate:"gte=0"`
	SpotPollInterval time.Duration `env:"SPOT_POLL_INTERVAL" envDefault:"2s" validate:"gte=0"`
}

Config defines the agent runtime configuration. Each field is populated from environment variables.

func Load

func Load() (Config, error)

Load builds a Config from environment variables, applies defaults, normalises values, and validates the result.

func (Config) IdentityFileMode

func (c Config) IdentityFileMode() os.FileMode

IdentityFileMode returns the IdentityMode as os.FileMode

func (Config) KeysFileMode

func (c Config) KeysFileMode() os.FileMode

KeysFileMode returns the KeysMode as os.FileMode

func (Config) RecvFileMode

func (c Config) RecvFileMode() os.FileMode

RecvFileMode returns the RecvMode as os.FileMode

Jump to

Keyboard shortcuts

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