// NewConfig creates a new Config. It starts with an empty config and, if
// specified, merges the config at `userConfigPath` path.  Depending if we're
// running as root or rootless, we then merge the system configuration followed
// by merging the default config (hard-coded default in memory).
// Note that the OCI runtime is hard-set to `crun` if we're running on a system
// with cgroupsv2. Other OCI runtimes are not yet supporting cgroupsv2. This
// might change in the future.
NewConfig creates a new Config. It starts with an empty config and, if
specified, merges the config at `userConfigPath` path.  Depending if we're
running as root or rootless, we then merge the system configuration followed
by merging the default config (hard-coded default in memory).
Note that the OCI runtime is hard-set to `crun` if we're running on a system
with cgroupsv2. Other OCI runtimes are not yet supporting cgroupsv2. This
might change in the future.
// NewConfig creates a new Config . It starts with an empty config and if // specified merges the config at ` userConfigPath ` path . Depending if we ' re // running as root or rootless we then merge the system configuration followed // by merging the default config ( hard - coded default in memory ) . // Note that the OCI runtime is hard - set to ` crun ` if we ' re running on a system // with cgroupsv2 . Other OCI runtimes are not yet supporting cgroupsv2 . This // might change in the future .
func NewConfig(userConfigPath string) (*Config, error) {
	config, err := DefaultConfig()
	if err != nil {
		return nil, err
	}
	if err = newLibpodConfig(config); err != nil && !os.IsNotExist(err) {
		logrus.Errorf("error reading libpod.conf: %v", err)
	}
	configs, err := systemConfigs()
	if err != nil {
		return nil, errors.Wrapf(err, "error finding config on system")
	}
	for _, path := range configs {
		config, err := readConfigFromFile(path, config)
		if err != nil {
			return nil, errors.Wrapf(err, "error reading system config %q", path)
		}
		logrus.Debugf("Merged system config %q: %v", path, config)
	}
	if userConfigPath != "" {
		var err error
		config, err = readConfigFromFile(userConfigPath, config)
		if err != nil {
			return nil, errors.Wrapf(err, "error reading user config %q", userConfigPath)
		}
		logrus.Debugf("Merged user config %q: %v", userConfigPath, config)
	}
	config.addCAPPrefix()
	if err := config.Validate(); err != nil {
		return nil, err
	}
	return config, nil
}
func NewConfig ( userConfigPath string ) ( * Config , error ) { config , err := DefaultConfig ( ) if err != nil { return nil , err } if err = newLibpodConfig ( config ) ; err != nil && ! os . IsNotExist ( err ) { logrus . Errorf ( " " , err ) } configs , err := systemConfigs ( ) if err != nil { return nil , errors . Wrapf ( err , " " ) } for _ , path := range configs { config , err := readConfigFromFile ( path , config ) if err != nil { return nil , errors . Wrapf ( err , " " , path ) } logrus . Debugf ( " " , path , config ) } if userConfigPath != " " { var err error config , err = readConfigFromFile ( userConfigPath , config ) if err != nil { return nil , errors . Wrapf ( err , " " , userConfigPath ) } logrus . Debugf ( " " , userConfigPath , config ) } config . addCAPPrefix ( ) if err := config . Validate ( ) ; err != nil { return nil , err } return config , nil }
NewConfig creates a new Config.
NewConfig creates a new Config .
// Generate the default config for the system // read libpod.conf and convert the config to *Config // Now, gather the system configs and merge them as needed. // Merge changes in later configs with the previous configs. // Each config file that specified fields, will override the // previous fields. // If the caller specified a config path to use, then we read it to // override the system defaults. // readConfigFromFile reads in container config in the specified // file and then merge changes with the current default.