config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package config defines the application's configuration structure.

Index

Constants

View Source
const (
	DefaultSelectTargetCommand = "ssh-agent-mux-select"
)

Variables

This section is empty.

Functions

func DefaultConfigFilePath added in v0.6.0

func DefaultConfigFilePath() (string, error)

func DefineAndBindFlags

func DefineAndBindFlags(fs *pflag.FlagSet) error

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

Parameters:

  • 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) (string, error)

func ResolveConfigFilePath added in v0.6.0

func ResolveConfigFilePath(configFilePathOverride string) (string, 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 `toml:"listen"`

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

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

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

	// Debug enables debug logging.
	Debug bool `toml:"debug"`

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

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

func DefaultAppConfig added in v0.6.0

func DefaultAppConfig() *AppConfig

func GetAppConfig

func GetAppConfig(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