config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 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.

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.

Functions

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 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 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 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 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