Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteProfile(cfg *ini.File, path, profileName string) error
- func ExpandConfigPaths() []string
- func GetActiveProfileName(cfg *ini.File, flagOverride string) string
- func GetConfigValue(cfg *ini.File, sectionName, keyName string) (string, error)
- func GetProfileConfigValue(cfg *ini.File, profileName, keyName string) string
- func GetProfileCredentials(cfg *ini.File, profileName string) (endpoint, appKey, appSecret, consumerKey string, err error)
- func GetProfileSection(cfg *ini.File, profileName string) (*ini.Section, error)
- func IsDefaultProfile(name string) bool
- func IsProfileMode(cfg *ini.File, flagOverride string) bool
- func ListProfiles(cfg *ini.File) []string
- func LoadINI() (*ini.File, string)
- func SetActiveProfile(cfg *ini.File, path, profileName string) error
- func SetConfigValue(cfg *ini.File, path, sectionName, keyName, value string) error
- func SetProfileConfigValue(cfg *ini.File, path, profileName, keyName, value string) error
Constants ¶
const DefaultProfileName = "default"
DefaultProfileName is the reserved name for the legacy/default configuration. It does not map to a [profile:default] section — instead it represents the standard go-ovh configuration from [default] + [ovh-<endpoint>] sections.
Variables ¶
var ( ConfigPaths = []string{ "/etc/ovh.conf", "~/.ovh.conf", "./ovh.conf", } ConfigurableFields = map[string]string{ "endpoint": "default", "default_cloud_project": "ovh-cli", } )
var ActiveProfileOverride string
ActiveProfileOverride is set from the --profile CLI flag by the root command's PersistentPreRun. It allows GetConfigValue to respect the --profile flag without the config package needing to import the flags package.
Functions ¶
func DeleteProfile ¶ added in v0.10.0
DeleteProfile removes a profile section from the config. If the deleted profile was the active one, the "profile" key is removed from [default] (falling back to legacy mode).
func ExpandConfigPaths ¶
func ExpandConfigPaths() []string
configPaths returns configPaths, with ~/ prefix expanded.
func GetActiveProfileName ¶ added in v0.10.0
GetActiveProfileName returns the active profile name by checking (in order): 1. The flagOverride parameter (from --profile CLI flag) 2. The OVH_PROFILE environment variable 3. The "profile" key in the [default] INI section Returns "" if no profile is configured (legacy mode).
func GetConfigValue ¶
func GetProfileConfigValue ¶ added in v0.10.0
GetProfileConfigValue reads a configuration value from a profile section.
func GetProfileCredentials ¶ added in v0.10.0
func GetProfileCredentials(cfg *ini.File, profileName string) (endpoint, appKey, appSecret, consumerKey string, err error)
GetProfileCredentials reads OVHcloud API credentials from a profile section. Environment variables (OVH_ENDPOINT, OVH_APPLICATION_KEY, etc.) take precedence.
func GetProfileSection ¶ added in v0.10.0
GetProfileSection returns the [profile:<name>] INI section for the given profile.
func IsDefaultProfile ¶ added in v0.10.0
IsDefaultProfile returns true if the given name is the reserved default profile.
func IsProfileMode ¶ added in v0.10.0
IsProfileMode returns true if a profile is active (either from flag, env, or config).
func ListProfiles ¶ added in v0.10.0
ListProfiles returns the names of all profiles found in the INI config.
func LoadINI ¶
loadINI builds a ini.File from the configuration paths provided in configPaths. It's a helper for loadConfig.
func SetActiveProfile ¶ added in v0.10.0
SetActiveProfile sets the active profile in the [default] section.
func SetConfigValue ¶
Types ¶
This section is empty.