mirror of
https://github.com/containers/podman.git
synced 2025-12-07 14:20:44 +08:00
rework system connection and farm storage
We now no longer write containers.conf, instead system connections and farms are written to a new file called podman-connections.conf. This is a major rework and I had to change a lot of things to get this to compile again with my c/common changes. It is a breaking change for users as connections/farms added before this commit can now no longer be removed or modified directly. However because the logic keeps reading from containers.conf the old connections can still be used to connect to a remote host. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
51
vendor/github.com/containers/common/pkg/config/new.go
generated
vendored
51
vendor/github.com/containers/common/pkg/config/new.go
generated
vendored
@@ -21,7 +21,6 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
// FIXME: update code base and tests to use the two constants below.
|
||||
containersConfEnv = "CONTAINERS_CONF"
|
||||
containersConfOverrideEnv = containersConfEnv + "_OVERRIDE"
|
||||
)
|
||||
@@ -79,15 +78,34 @@ func newLocked(options *Options) (*Config, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("finding config on system: %w", err)
|
||||
}
|
||||
// connectionsPath, err := connectionsConfigFile()
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
for _, path := range configs {
|
||||
// var dests []*Destination
|
||||
// if path == connectionsPath {
|
||||
// // Store the dest pointers so we know after the load if there are new pointers
|
||||
// // the connection changed and thus is read write.
|
||||
// dests = maps.Values(config.Engine.ServiceDestinations)
|
||||
// }
|
||||
|
||||
// Merge changes in later configs with the previous configs.
|
||||
// Each config file that specified fields, will override the
|
||||
// previous fields.
|
||||
if err = readConfigFromFile(path, config); err != nil {
|
||||
if err = readConfigFromFile(path, config, true); err != nil {
|
||||
return nil, fmt.Errorf("reading system config %q: %w", path, err)
|
||||
}
|
||||
logrus.Debugf("Merged system config %q", path)
|
||||
logrus.Tracef("%+v", config)
|
||||
|
||||
// // if there is a new dest now we know it is read write as it was in the connections.conf file
|
||||
// for _, dest := range config.Engine.ServiceDestinations {
|
||||
// if !slices.Contains(dests, dest) {
|
||||
// dest.ReadWrite = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
modules, err := options.modules()
|
||||
@@ -115,7 +133,7 @@ func newLocked(options *Options) (*Config, error) {
|
||||
}
|
||||
// readConfigFromFile reads in container config in the specified
|
||||
// file and then merge changes with the current default.
|
||||
if err := readConfigFromFile(add, config); err != nil {
|
||||
if err := readConfigFromFile(add, config, false); err != nil {
|
||||
return nil, fmt.Errorf("reading additional config %q: %w", add, err)
|
||||
}
|
||||
logrus.Debugf("Merged additional config %q", add)
|
||||
@@ -157,12 +175,8 @@ func systemConfigs() (configs []string, finalErr error) {
|
||||
}
|
||||
return append(configs, path), nil
|
||||
}
|
||||
if _, err := os.Stat(DefaultContainersConfig); err == nil {
|
||||
configs = append(configs, DefaultContainersConfig)
|
||||
}
|
||||
if _, err := os.Stat(OverrideContainersConfig); err == nil {
|
||||
configs = append(configs, OverrideContainersConfig)
|
||||
}
|
||||
configs = append(configs, DefaultContainersConfig)
|
||||
configs = append(configs, OverrideContainersConfig)
|
||||
|
||||
var err error
|
||||
configs, err = addConfigs(OverrideContainersConfig+".d", configs)
|
||||
@@ -170,18 +184,14 @@ func systemConfigs() (configs []string, finalErr error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path, err := ifRootlessConfigPath()
|
||||
path, err := userConfigPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if path != "" {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
configs = append(configs, path)
|
||||
}
|
||||
configs, err = addConfigs(path+".d", configs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
configs = append(configs, path)
|
||||
configs, err = addConfigs(path+".d", configs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return configs, nil
|
||||
}
|
||||
@@ -225,10 +235,13 @@ func addConfigs(dirPath string, configs []string) ([]string, error) {
|
||||
// unmarshal its content into a Config. The config param specifies the previous
|
||||
// default config. If the path, only specifies a few fields in the Toml file
|
||||
// the defaults from the config parameter will be used for all other fields.
|
||||
func readConfigFromFile(path string, config *Config) error {
|
||||
func readConfigFromFile(path string, config *Config, ignoreErrNotExist bool) error {
|
||||
logrus.Tracef("Reading configuration file %q", path)
|
||||
meta, err := toml.DecodeFile(path, config)
|
||||
if err != nil {
|
||||
if ignoreErrNotExist && errors.Is(err, fs.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("decode configuration %v: %w", path, err)
|
||||
}
|
||||
keys := meta.Undecoded()
|
||||
|
||||
Reference in New Issue
Block a user