Documentation ¶
Index ¶
- Constants
- func BindFullyQualifiedFlag(cmd *cobra.Command) func(flag *pflag.Flag)
- func SetupConfig()
- func SetupConfigSources(configFile string, defaultConfigFile bool) error
- func SupportedExtensions() []string
- func SyncFullyQualifiedFlag(cmd *cobra.Command, flagName string) error
- func SyncFullyQualifiedFlags(cmd *cobra.Command) error
Constants ¶
const ( EnvImageRepository = "IKE_DOCKER_REPOSITORY" EnvImageDevRepository = "IKE_DOCKER_DEV_REPOSITORY" EnvImageRegistry = "IKE_DOCKER_REGISTRY" EnvTestImage = "IKE_TEST_IMAGE_NAME" EnvImageTag = "IKE_IMAGE_TAG" )
These consts are used across the project to load corresponding env variables.
Variables ¶
This section is empty.
Functions ¶
func BindFullyQualifiedFlag ¶
BindFullyQualifiedFlag ensures that each flag used in commands is bound to a key using fully qualified name which has a following form:
commandName.flagName
This lets us keep structure of yaml file:
commandName: flagName: value
func SetupConfig ¶
func SetupConfig()
SetupConfig defines Viper env var prefixes and type handling when inferring key value.
func SetupConfigSources ¶
SetupConfigSources sets up Viper configuration sources.
If specific file path is provided but fails when loading it will return an error.
In case of default config location it will not fail if file does not exist, but will in any other case such as parse error.
Config precedence (each item takes precedence over the item below it): . Flags . Env variables . Config file
Environment variables are prefixed with `IKE` and have fully qualified names, for example in case of `develop` command and its `port` flag corresponding environment variable is `IKE_DEVELOP_PORT`.
func SupportedExtensions ¶
func SupportedExtensions() []string
SupportedExtensions returns a slice of all supported config format (as file extensions).
func SyncFullyQualifiedFlag ¶
SyncFullyQualifiedFlag ensures that if configuration provides a value for a given cmd.flag it will be set back to the flag itself, but only if the flag was not set through CLI.
This way we can make flags required but still have their values provided by the configuration source.
func SyncFullyQualifiedFlags ¶
SyncFullyQualifiedFlags ensures that if configuration provide a value for any of defined flags it will be set back to the flag itself.
This function iterates over all flags defined for cobra.Command and accumulates errors if they occur while calling SyncFullyQualifiedFlag for every flag.
Types ¶
This section is empty.