in cmd/hub/cmd/root.go [93:150]
func initConfig() {
home, err := homedir.Dir()
if err != nil {
util.Warn("Unable to determine HOME directory: %v", err)
}
if config.ConfigFile != "" {
// Use config file from the flag.
viper.SetConfigFile(config.ConfigFile)
} else {
if err == nil {
// Search config in home directory with name ".hub-config" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".hub-config")
}
}
if config.CacheFile == "" && err == nil {
config.CacheFile = fmt.Sprintf("%s/.hub-cache.yaml", home)
}
viper.SetEnvPrefix("hub")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err = viper.ReadInConfig(); err == nil {
if config.Verbose {
log.Printf("Using config file %s", viper.ConfigFileUsed())
}
}
if viper.GetBool("force") {
config.Force = true
}
if viper.GetBool("debug") {
config.Debug = true
}
if viper.GetBool("trace") {
config.Trace = true
}
if tty := viper.GetString("tty"); tty != "" {
config.TtyMode = tty
}
if pass := viper.GetString("crypto-password"); pass != "" {
config.CryptoPassword = pass
}
if key := viper.GetString("crypto-aws-kms-key-arn"); key != "" {
config.CryptoAwsKmsKeyArn = key
}
if key := viper.GetString("crypto-azure-keyvault-key-id"); key != "" {
config.CryptoAzureKeyVaultKeyId = key
}
if key := viper.GetString("crypto-gcp-kms-key-name"); key != "" {
config.CryptoGcpKmsKeyName = key
}
for _, initializer := range initializers {
initializer()
}
}