Report bad entries in storage.conf to the user
Currently if a user puts a typo into a storage.conf or puts the keys in the wrong section, then tools using container/storage ignore them. This patch will print them as warnings, so that the user has some idea what is going on. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
e159777f1e
commit
d65940d8a0
|
|
@ -2,7 +2,6 @@ package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -272,21 +271,21 @@ func ReloadConfigurationFileIfNeeded(configFile string, storeOptions *StoreOptio
|
||||||
// ReloadConfigurationFile parses the specified configuration file and overrides
|
// ReloadConfigurationFile parses the specified configuration file and overrides
|
||||||
// the configuration in storeOptions.
|
// the configuration in storeOptions.
|
||||||
func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
|
func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
|
||||||
data, err := ioutil.ReadFile(configFile)
|
config := new(tomlConfig)
|
||||||
if err != nil {
|
|
||||||
|
meta, err := toml.DecodeFile(configFile, &config)
|
||||||
|
if err == nil {
|
||||||
|
keys := meta.Undecoded()
|
||||||
|
if len(keys) > 0 {
|
||||||
|
logrus.Warningf("Failed to decode the keys %q from %q.", keys, configFile)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
fmt.Printf("Failed to read %s %v\n", configFile, err.Error())
|
fmt.Printf("Failed to read %s %v\n", configFile, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config := new(tomlConfig)
|
|
||||||
|
|
||||||
if _, err := toml.Decode(string(data), config); err != nil {
|
|
||||||
fmt.Printf("Failed to parse %s %v\n", configFile, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear storeOptions of previos settings
|
// Clear storeOptions of previos settings
|
||||||
*storeOptions = StoreOptions{}
|
*storeOptions = StoreOptions{}
|
||||||
if config.Storage.Driver != "" {
|
if config.Storage.Driver != "" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue