config

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const HeaderKeyPrefix = "header."

HeaderKeyPrefix prefixes INI keys used to store custom HTTP headers (e.g. "header.X-Routing-Key = abc123") in a profile or endpoint section.

Variables

View Source
var (
	ConfigPaths = []string{

		"/etc/ovh.conf",

		"~/.ovh.conf",

		"./ovh.conf",
	}

	ConfigurableFields = map[string]string{
		"endpoint":              "default",
		"default_cloud_project": "ovh-cli",
	}
)
View Source
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.

View Source
var CredentialKeys = []string{"application_key", "application_secret", "consumer_key"}

CredentialKeys are the INI keys holding OVHcloud API credentials.

Functions

func DeleteConfigValue added in v0.14.0

func DeleteConfigValue(cfg *ini.File, path, sectionName, keyName string) error

DeleteConfigValue removes a key from the given section. If sectionName is empty, it is resolved via ConfigurableFields like SetConfigValue does.

func DeleteCredentials added in v0.13.0

func DeleteCredentials(cfg *ini.File, path, sectionName string) error

DeleteCredentials removes the API credential keys (application_key, application_secret, consumer_key)

func DeleteProfile added in v0.10.0

func DeleteProfile(cfg *ini.File, path, profileName string) error

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 DeleteProfileConfigValue added in v0.14.0

func DeleteProfileConfigValue(cfg *ini.File, path, profileName, keyName string) error

DeleteProfileConfigValue removes a key from a profile section.

func ExpandConfigPaths

func ExpandConfigPaths() []string

configPaths returns configPaths, with ~/ prefix expanded.

func GetActiveProfileName added in v0.10.0

func GetActiveProfileName(cfg *ini.File, flagOverride string) string

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 GetConfigValue(cfg *ini.File, sectionName, keyName string) (string, error)

func GetCustomHeaders added in v0.14.0

func GetCustomHeaders(cfg *ini.File, sectionName string) map[string]string

GetCustomHeaders returns the custom HTTP headers configured in the given section (an endpoint-named legacy section), stored as "header.<Name>" INI keys. Returns an empty map if cfg is nil, sectionName is empty, or the section has no such keys.

func GetProfileConfigValue added in v0.10.0

func GetProfileConfigValue(cfg *ini.File, profileName, keyName string) string

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 GetProfileCustomHeaders added in v0.14.0

func GetProfileCustomHeaders(cfg *ini.File, profileName string) map[string]string

GetProfileCustomHeaders returns the custom HTTP headers configured for the given profile, stored as "header.<Name>" INI keys in its profile section.

func GetProfileSection added in v0.10.0

func GetProfileSection(cfg *ini.File, profileName string) (*ini.Section, error)

GetProfileSection returns the [profile:<name>] INI section for the given profile.

func IsDefaultProfile added in v0.10.0

func IsDefaultProfile(name string) bool

IsDefaultProfile returns true if the given name is the reserved default profile.

func IsProfileMode added in v0.10.0

func IsProfileMode(cfg *ini.File, flagOverride string) bool

IsProfileMode returns true if a profile is active (either from flag, env, or config).

func ListProfiles added in v0.10.0

func ListProfiles(cfg *ini.File) []string

ListProfiles returns the names of all profiles found in the INI config.

func LoadINI

func LoadINI() (*ini.File, string)

loadINI builds a ini.File from the configuration paths provided in configPaths. It's a helper for loadConfig.

func ProfileSectionName added in v0.13.0

func ProfileSectionName(profileName string) string

func SetActiveProfile added in v0.10.0

func SetActiveProfile(cfg *ini.File, path, profileName string) error

SetActiveProfile sets the active profile in the [default] section.

func SetConfigValue

func SetConfigValue(cfg *ini.File, path, sectionName, keyName, value string) error

func SetProfileConfigValue added in v0.10.0

func SetProfileConfigValue(cfg *ini.File, path, profileName, keyName, value string) error

SetProfileConfigValue sets a configuration value in a profile section, creating the section if it does not exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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