mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
e2e: fix full path support when reading viper config file
Something changed in Viper such that it now returns the ConfigFileNotFound error when the config file is not found, for example when it is specified including the .yaml or .json suffix. When the code was originally was written, it returned "Unsupported Config Type". Found when adding a unit test for this code (separate commit because it depends on the flag changes).
This commit is contained in:
parent
7340b6341a
commit
3630cfca2b
@ -25,10 +25,6 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
viperFileNotFound = "Unsupported Config Type \"\""
|
||||
)
|
||||
|
||||
// ViperizeFlags checks whether a configuration file was specified, reads it, and updates
|
||||
// the configuration variables accordingly. Must be called after framework.HandleFlags()
|
||||
// and before framework.AfterReadingAllFlags().
|
||||
@ -68,7 +64,7 @@ func ViperizeFlags(requiredConfig, optionalConfig string) error {
|
||||
// of file suffices. Therefore try once more without
|
||||
// suffix.
|
||||
ext := filepath.Ext(viperConfig)
|
||||
if ext != "" && err.Error() == viperFileNotFound {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok && ext != "" {
|
||||
viper.SetConfigName(filepath.Base(viperConfig[0 : len(viperConfig)-len(ext)]))
|
||||
err = viper.ReadInConfig()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user