mirror of
https://github.com/containers/podman.git
synced 2025-05-21 09:05:56 +08:00
fix lint - drop else block
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -451,45 +451,47 @@ func NewConfig(userConfigPath string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now, check if the user can access system configs and merge them if needed.
|
// Now, check if the user can access system configs and merge them if needed.
|
||||||
if configs, err := systemConfigs(); err != nil {
|
configs, err := systemConfigs()
|
||||||
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error finding config on system")
|
return nil, errors.Wrapf(err, "error finding config on system")
|
||||||
} else {
|
}
|
||||||
migrated := false
|
|
||||||
for _, path := range configs {
|
migrated := false
|
||||||
systemConfig, err := readConfigFromFile(path)
|
for _, path := range configs {
|
||||||
if err != nil {
|
systemConfig, err := readConfigFromFile(path)
|
||||||
return nil, errors.Wrapf(err, "error reading system config %q", path)
|
if err != nil {
|
||||||
}
|
return nil, errors.Wrapf(err, "error reading system config %q", path)
|
||||||
// Handle CGroups v2 configuration migration.
|
|
||||||
// Migrate only the first config, and do it before
|
|
||||||
// merging.
|
|
||||||
if !migrated {
|
|
||||||
if err := cgroupV2Check(path, systemConfig); err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "error rewriting configuration file %s", userConfigPath)
|
|
||||||
}
|
|
||||||
migrated = true
|
|
||||||
}
|
|
||||||
// Merge the it into the config. Any unset field in config will be
|
|
||||||
// over-written by the systemConfig.
|
|
||||||
if err := config.mergeConfig(systemConfig); err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "error merging system config")
|
|
||||||
}
|
|
||||||
logrus.Debugf("Merged system config %q: %v", path, config)
|
|
||||||
}
|
}
|
||||||
|
// Handle CGroups v2 configuration migration.
|
||||||
|
// Migrate only the first config, and do it before
|
||||||
|
// merging.
|
||||||
|
if !migrated {
|
||||||
|
if err := cgroupV2Check(path, systemConfig); err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error rewriting configuration file %s", userConfigPath)
|
||||||
|
}
|
||||||
|
migrated = true
|
||||||
|
}
|
||||||
|
// Merge the it into the config. Any unset field in config will be
|
||||||
|
// over-written by the systemConfig.
|
||||||
|
if err := config.mergeConfig(systemConfig); err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error merging system config")
|
||||||
|
}
|
||||||
|
logrus.Debugf("Merged system config %q: %v", path, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, create a default config from memory and forcefully merge it into
|
// Finally, create a default config from memory and forcefully merge it into
|
||||||
// the config. This way we try to make sure that all fields are properly set
|
// the config. This way we try to make sure that all fields are properly set
|
||||||
// and that user AND system config can partially set.
|
// and that user AND system config can partially set.
|
||||||
if defaultConfig, err := defaultConfigFromMemory(); err != nil {
|
defaultConfig, err := defaultConfigFromMemory()
|
||||||
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error generating default config from memory")
|
return nil, errors.Wrapf(err, "error generating default config from memory")
|
||||||
} else {
|
}
|
||||||
// Check if we need to switch to cgroupfs and logger=file on rootless.
|
|
||||||
defaultConfig.checkCgroupsAndLogger()
|
|
||||||
|
|
||||||
if err := config.mergeConfig(defaultConfig); err != nil {
|
// Check if we need to switch to cgroupfs and logger=file on rootless.
|
||||||
return nil, errors.Wrapf(err, "error merging default config from memory")
|
defaultConfig.checkCgroupsAndLogger()
|
||||||
}
|
|
||||||
|
if err := config.mergeConfig(defaultConfig); err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error merging default config from memory")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relative paths can cause nasty bugs, because core paths we use could
|
// Relative paths can cause nasty bugs, because core paths we use could
|
||||||
|
@ -26,11 +26,12 @@ const (
|
|||||||
// config is different for root and rootless. It also parses the storage.conf.
|
// config is different for root and rootless. It also parses the storage.conf.
|
||||||
func defaultConfigFromMemory() (*Config, error) {
|
func defaultConfigFromMemory() (*Config, error) {
|
||||||
c := new(Config)
|
c := new(Config)
|
||||||
if tmp, err := defaultTmpDir(); err != nil {
|
tmp, err := defaultTmpDir()
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
c.TmpDir = tmp
|
|
||||||
}
|
}
|
||||||
|
c.TmpDir = tmp
|
||||||
|
|
||||||
c.EventsLogFilePath = filepath.Join(c.TmpDir, "events", "events.log")
|
c.EventsLogFilePath = filepath.Join(c.TmpDir, "events", "events.log")
|
||||||
|
|
||||||
storeOpts, err := storage.DefaultStoreOptions(rootless.IsRootless(), rootless.GetRootlessUID())
|
storeOpts, err := storage.DefaultStoreOptions(rootless.IsRootless(), rootless.GetRootlessUID())
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// NameRegex is a regular expression to validate container/pod names.
|
// NameRegex is a regular expression to validate container/pod names.
|
||||||
NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
|
NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
|
||||||
// RegexError is thrown in presence of an invalid container/pod name.
|
// RegexError is thrown in presence of an invalid container/pod name.
|
||||||
RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
|
RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
|
||||||
)
|
)
|
||||||
|
@ -213,11 +213,11 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) {
|
|||||||
// Sets up containers/storage, state store, OCI runtime
|
// Sets up containers/storage, state store, OCI runtime
|
||||||
func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
|
func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
|
||||||
// Find a working conmon binary
|
// Find a working conmon binary
|
||||||
if cPath, err := runtime.config.FindConmon(); err != nil {
|
cPath, err := runtime.config.FindConmon()
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
runtime.conmonPath = cPath
|
|
||||||
}
|
}
|
||||||
|
runtime.conmonPath = cPath
|
||||||
|
|
||||||
// Make the static files directory if it does not exist
|
// Make the static files directory if it does not exist
|
||||||
if err := os.MkdirAll(runtime.config.StaticDir, 0700); err != nil {
|
if err := os.MkdirAll(runtime.config.StaticDir, 0700); err != nil {
|
||||||
|
Reference in New Issue
Block a user