Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ func checkConfigFile(requireToken bool) error {
if err != nil {
return fmt.Errorf("could not open the config file " + viper.ConfigFileUsed() + ". Have you called the login command? ")
}
// make sure the config file is parsable
err = viper.ReadInConfig()
if err != nil {
return fmt.Errorf("%w: could not parse the config file "+viper.ConfigFileUsed()+". Have you called the login command? ", err)
}

fmeflowUrl := viper.GetString("url")

// check the fme server URL is valid
Expand Down
1 change: 1 addition & 0 deletions cmd/login_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ token: 5ba5e0fd15c2403bc8b2e3aa1dfb975ca2197fbe
url: %s
`, mainHttpServerLogin.URL),
},
omitConfig: true,
},
{
name: "login with token",
Expand Down
5 changes: 1 addition & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ func initConfig() {
//viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
err := viper.ReadInConfig()
if err != nil { // Handle errors reading the config file
cobra.CheckErr(err)
}
viper.ReadInConfig()

}

Expand Down
2 changes: 1 addition & 1 deletion cmd/testFunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func runTests(tcs []testCase, t *testing.T) {
}

// if a config file isn't specified, generate a random file and set the config file flag
if !configFlagExists(tc.args) {
if !configFlagExists(tc.args) && !tc.omitConfig {
f, err := os.CreateTemp("", "config-file*.yaml")
require.NoError(t, err)
defer os.Remove(f.Name()) // clean up
Expand Down