func LoadAndValidateFromViper() (*BinnacleConfig, error) {
	var config BinnacleConfig

	if err := viper.Unmarshal(&config); err != nil {
		return nil, err
	}

	// Set general defaults
	if len(config.Context) == 0 {
		config.Context = "default"
	}

	// Set defaults for charts
	for idx := range config.Charts {
		chart := &config.Charts[idx]

		if len(chart.Repo) == 0 {
			chart.Repo = ""
		}

		if len(chart.State) == 0 {
			chart.State = StatePresent
		}

		for k, v := range chart.Values {
			chart.Values[k] = cleanupMapValue(v)
		}
	}

	// Set defaults for repos
	for idx, repo := range config.Repositories {
		if len(repo.State) == 0 {
			config.Repositories[idx].State = StatePresent
		}
	}

	if err := validateConfig(&config); err != nil {
		return nil, err
	}

	return &config, nil
}
// LoadAndValidateFromViper creates a BinnacleConfig object from Viper
LoadAndValidateFromViper creates a BinnacleConfig object from Viper
// LoadAndValidateFromViper creates a BinnacleConfig object from Viper
func LoadAndValidateFromViper() (*BinnacleConfig, error) {
	var config BinnacleConfig
	if err := viper.Unmarshal(&config); err != nil {
		return nil, err
	}
	if len(config.Context) == 0 {
		config.Context = "default"
	}
	for idx := range config.Charts {
		chart := &config.Charts[idx]
		if len(chart.Repo) == 0 {
			chart.Repo = ""
		}
		if len(chart.State) == 0 {
			chart.State = StatePresent
		}
		for k, v := range chart.Values {
			chart.Values[k] = cleanupMapValue(v)
		}
	}
	for idx, repo := range config.Repositories {
		if len(repo.State) == 0 {
			config.Repositories[idx].State = StatePresent
		}
	}
	if err := validateConfig(&config); err != nil {
		return nil, err
	}
	return &config, nil
}
func LoadAndValidateFromViper ( ) ( * BinnacleConfig , error ) { var config BinnacleConfig if err := viper . Unmarshal ( & config ) ; err != nil { return nil , err } if len ( config . Context ) == 0 { config . Context = " " } for idx := range config . Charts { chart := & config . Charts [ idx ] if len ( chart . Repo ) == 0 { chart . Repo = " " } if len ( chart . State ) == 0 { chart . State = StatePresent } for k , v := range chart . Values { chart . Values [ k ] = cleanupMapValue ( v ) } } for idx , repo := range config . Repositories { if len ( repo . State ) == 0 { config . Repositories [ idx ] . State = StatePresent } } if err := validateConfig ( & config ) ; err != nil { return nil , err } return & config , nil }
LoadAndValidateFromViper creates a BinnacleConfig object from Viper
LoadAndValidateFromViper creates a BinnacleConfig object from Viper
// Set general defaults // Set defaults for charts // Set defaults for repos