Fix podman info with multiple imagestores

The command `podman info` returned only one imagestore in
`store.graphOptions.<driver>.imagestore` even if multiple
image stores were configured.

This change replaces the field `<driver>.imagestore` with
the field `<driver>.additionalImageStores`, that instead
of a string is an array of strings and that includes all
the configured additional image stores.

Fix https://github.com/containers/storage/issues/2094

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
This commit is contained in:
Mario Loriedo
2024-11-29 16:28:47 +00:00
parent b3c02684fd
commit 0d3a653c30
2 changed files with 26 additions and 2 deletions

View File

@ -250,7 +250,8 @@ func (r *Runtime) storeInfo() (*define.StoreInfo, error) {
graphOptions := map[string]interface{}{}
for _, o := range r.store.GraphOptions() {
split := strings.SplitN(o, "=", 2)
if strings.HasSuffix(split[0], "mount_program") {
switch {
case strings.HasSuffix(split[0], "mount_program"):
ver, err := version.Program(split[1])
if err != nil {
logrus.Warnf("Failed to retrieve program version for %s: %v", split[1], err)
@ -260,7 +261,17 @@ func (r *Runtime) storeInfo() (*define.StoreInfo, error) {
program["Version"] = ver
program["Package"] = version.Package(split[1])
graphOptions[split[0]] = program
} else {
case strings.HasSuffix(split[0], "imagestore"):
key := strings.ReplaceAll(split[0], "imagestore", "additionalImageStores")
if graphOptions[key] == nil {
graphOptions[key] = []string{split[1]}
} else {
graphOptions[key] = append(graphOptions[key].([]string), split[1])
}
// Fallthrough to include the `imagestore` key to avoid breaking
// Podman v5 API. Should be removed in Podman v6.0.0.
fallthrough
default:
graphOptions[split[0]] = split[1]
}
}