config: Create function to check config options

Moved the checking routines in `LoadConfiguration()` to a new
`checkConfig()` function for clarity.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2018-11-29 08:28:14 +00:00
parent 70e4dc550a
commit fe784c1e36

View File

@ -659,17 +659,27 @@ func LoadConfiguration(configPath string, ignoreLogging, builtIn bool) (resolved
}
config.DisableNewNetNs = tomlConf.Runtime.DisableNewNetNs
if err := checkNetNsConfig(config); err != nil {
return "", config, err
}
if err := checkHypervisorConfig(config.HypervisorConfig); err != nil {
if err := checkConfig(config); err != nil {
return "", config, err
}
return resolved, config, nil
}
// checkConfig checks the validity of the specified config.
func checkConfig(config oci.RuntimeConfig) error {
if err := checkNetNsConfig(config); err != nil {
return err
}
if err := checkHypervisorConfig(config.HypervisorConfig); err != nil {
return err
}
return nil
}
func updateConfig(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
if err := updateRuntimeConfig(configPath, tomlConf, config); err != nil {