Documentation
¶
Overview ¶
Package config is a helper package to facilitate getting and setting config values using Viper.
This package provides functions to read and write configuration settings for the eng CLI tool. It supports various configuration file formats and allows for easy management of local configuration settings.
Key features: - Load configuration from JSON, YAML, TOML, and other formats. - Set and get configuration values programmatically. - Support for environment variable overrides. - Easy integration with the Viper library.
These are local configs related to the eng CLI, not deployment configs.
Index ¶
- Variables
- func BareRepoPath() string
- func Branch() string
- func DisableAllProxies() error
- func DotfilesRepo() string
- func Email() string
- func GetActiveProxy() (string, bool)
- func GetBareRepoPath()
- func GetBranch()
- func GetDotfilesRepo()
- func GetEmail()
- func GetRepoURL()
- func GetVerbose()
- func GitDevPath() string
- func RepoURL() string
- func SaveProxyConfigsImpl(proxies []ProxyConfig) error
- func SelectProxy(proxies []ProxyConfig) (int, error)
- func SetProxyEnvVars(proxyValue string)
- func UnsetProxyEnvVars()
- func Verbose() bool
- type ProxyConfig
- type SaveProxyConfigsFunc
Constants ¶
This section is empty.
Variables ¶
var SaveProxyConfigs = SaveProxyConfigsImpl
SaveProxyConfigs is a variable that holds the function to save proxy configurations This can be overridden in tests
Functions ¶
func BareRepoPath ¶ added in v0.28.0
func BareRepoPath() string
BareRepoPath checks for the bare repository path in the configuration and prompts the user to confirm it. If the path is not found or the user does not confirm it, the function will call updateBareRepoPath() to update the path. It logs the start and success of the path checking process and returns the confirmed path as a string.
func Branch ¶ added in v0.28.0
func Branch() string
Branch checks for the dotfiles branch in the configuration and prompts the user to confirm it. If the branch is not found or the user does not confirm it, the function will call updateBranch() to update the branch. It logs the start and success of the branch checking process and returns the confirmed branch as a string.
func DisableAllProxies ¶ added in v0.17.12
func DisableAllProxies() error
DisableAllProxies disables all proxy configurations and unsets environment variables
func DotfilesRepo ¶ added in v0.14.3
func DotfilesRepo() string
DotfilesRepo checks for the dotfiles repository path in the configuration and prompts the user to confirm it. If the path is not found or the user does not confirm it, the function will call updateDotfilesRepo() to update the path. It logs the start and success of the path checking process and returns the confirmed path as a string.
func Email ¶
func Email() string
Email checks for the user's email in the configuration and prompts the user to confirm it. If the email is not found or the user does not confirm it, the function will call updateEmail() to update the email. It logs the start and success of the email checking process and returns the confirmed email as a string.
func GetActiveProxy ¶ added in v0.17.12
GetActiveProxy returns the currently active proxy value and true if any proxy is enabled If no proxy is enabled, returns the first proxy value and false If no proxies exist, returns an empty string and false
func GetBareRepoPath ¶ added in v0.28.0
func GetBareRepoPath()
GetBareRepoPath retrieves the bare repository path from the configuration. If the path is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the path.
func GetBranch ¶ added in v0.28.0
func GetBranch()
GetBranch retrieves the dotfiles branch from the configuration. If the branch is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the branch.
func GetDotfilesRepo ¶ added in v0.14.3
func GetDotfilesRepo()
GetDotfilesRepo retrieves the dotfiles repository path from the configuration. If the path is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the path.
func GetEmail ¶
func GetEmail()
GetEmail retrieves the user's email from the configuration. If the email is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the email.
func GetRepoURL ¶ added in v0.28.0
func GetRepoURL()
GetRepoURL retrieves the dotfiles repository URL from the configuration. If the URL is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the URL.
func GetVerbose ¶ added in v0.28.13
func GetVerbose()
GetVerbose retrieves the verbose setting from the configuration. If the verbose setting is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the verbose setting.
func GitDevPath ¶ added in v0.22.0
func GitDevPath() string
GitDevPath checks for the development folder path in the configuration and prompts the user to confirm it. If the path is not found or the user does not confirm it, the function will call updateGitDevPath() to update the path. It logs the start and success of the path checking process and returns the confirmed path as a string.
func RepoURL ¶ added in v0.28.0
func RepoURL() string
RepoURL checks for the dotfiles repository URL in the configuration and prompts the user to confirm it. If the URL is not found or the user does not confirm it, the function will call updateRepoURL() to update the URL. It logs the start and success of the URL checking process and returns the confirmed URL as a string.
func SaveProxyConfigsImpl ¶ added in v0.20.0
func SaveProxyConfigsImpl(proxies []ProxyConfig) error
SaveProxyConfigsImpl is the actual implementation of saving proxy configurations to viper config
func SelectProxy ¶ added in v0.17.12
func SelectProxy(proxies []ProxyConfig) (int, error)
SelectProxy prompts the user to select a proxy from the list and returns the index
func SetProxyEnvVars ¶ added in v0.17.12
func SetProxyEnvVars(proxyValue string)
SetProxyEnvVars sets all proxy-related environment variables to the provided value and handles custom no_proxy settings
func UnsetProxyEnvVars ¶ added in v0.17.12
func UnsetProxyEnvVars()
UnsetProxyEnvVars unsets all proxy-related environment variables
func Verbose ¶ added in v0.28.13
func Verbose() bool
Verbose checks for the verbose setting in the configuration and prompts the user to confirm it. If the verbose setting is not found or the user does not confirm it, the function will call updateVerbose() to update the setting. It logs the start and success of the verbose checking process and returns the confirmed verbose setting as a bool.
Types ¶
type ProxyConfig ¶ added in v0.17.0
ProxyConfig represents a single proxy configuration
func AddOrUpdateProxy ¶ added in v0.17.12
func AddOrUpdateProxy() ([]ProxyConfig, int)
AddOrUpdateProxy adds a new proxy or updates an existing one
func EnableProxy ¶ added in v0.17.12
func EnableProxy(index int, proxies []ProxyConfig) ([]ProxyConfig, error)
EnableProxy enables the proxy at the given index and disables all others
func GetProxyConfigs ¶ added in v0.17.12
func GetProxyConfigs() ([]ProxyConfig, int)
GetProxyConfigs checks for proxy settings in the configuration and returns the current proxies and the index of the active proxy (-1 if none are active)
type SaveProxyConfigsFunc ¶ added in v0.20.0
type SaveProxyConfigsFunc func(proxies []ProxyConfig) error
SaveProxyConfigsFunc defines the function type for saving proxy configs