config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config defines the application's configuration structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineAndBindFlags

func DefineAndBindFlags(v *viper.Viper, fs *pflag.FlagSet) error

DefineAndBindFlags defines the application's command-line flags on the provided FlagSet and binds them to Viper configuration keys.

Parameters:

  • v: The Viper instance to bind flags to.
  • fs: The pflag.FlagSet instance on which to define the flags.

Returns:

  • error: An error if any flag binding operation fails.

func LoadViperConfig

func LoadViperConfig(configFilePathOverride string) (*viper.Viper, string, error)

LoadViperConfig initializes a new Viper instance, sets up configuration paths, and attempts to read a TOML configuration file. This is the reverted pre-xdg version.

Parameters:

  • configFilePathOverride: If not empty, this path will be used directly to load the config file.

Returns:

  • *viper.Viper: The configured Viper instance.
  • string: The path of the configuration file that was successfully loaded. Empty if no file was loaded.
  • error: An error if one occurred during config file loading (unless it's a 'file not found' error when searching default paths, which is not treated as an error).

Types

type AppConfig

type AppConfig struct {
	// Listen is the socket path or address for the multiplexer to listen on.
	// If empty, "<directory of ConfigFilePathUsed or current dir>/agent.sock" is used.
	Listen string

	// Targets is a list of paths to target SSH agents to proxy for read-only operations.
	Targets []string

	// AddTargets is a list of paths to target SSH agents that can handle adding keys via ssh-add.
	AddTargets []string

	// SelectTargetCommand is the command to execute to select a target agent
	// when multiple AddTargets are specified and an ssh-add operation occurs.
	SelectTargetCommand string

	// Debug enables debug logging.
	Debug bool

	// ConfigFilePathUsed stores the path of the configuration file that was loaded.
	// This will be empty if no configuration file was used.
	ConfigFilePathUsed string
}

AppConfig holds the application's configuration values, typically populated from command-line flags and a configuration file.

func GetAppConfig

func GetAppConfig(v *viper.Viper, configFileUsedPath string) *AppConfig

GetAppConfig populates and returns an AppConfig struct from a Viper instance. This function should be called *after* pflag.Parse() has been executed, so that Viper reflects any command-line overrides.

Parameters:

  • v: The Viper instance, which has been updated by parsed command-line flags.
  • configFileUsedPath: The path of the configuration file that was loaded, if any.

Returns:

  • *AppConfig: The populated application configuration.

func (*AppConfig) MarshalZerologObject

func (a *AppConfig) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog.LogObjectMarshaler.

Jump to

Keyboard shortcuts

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