Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Container List API call to return mount info #12735

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/api/handlers/compat/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,15 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
return nil, err
}

m, err := json.Marshal(inspect.Mounts)
if err != nil {
return nil, err
}
mounts := []types.MountPoint{}
if err := json.Unmarshal(m, &mounts); err != nil {
return nil, err
}

return &handlers.Container{Container: types.Container{
ID: l.ID(),
Names: []string{fmt.Sprintf("/%s", l.Name())},
Expand All @@ -374,7 +383,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
}{
"host"},
NetworkSettings: &networkSettings,
Mounts: nil,
Mounts: mounts,
},
ContainerCreateConfig: types.ContainerCreateConfig{},
}, nil
Expand Down
4 changes: 3 additions & 1 deletion test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ podman rm -a -f &>/dev/null

t GET "libpod/containers/json (at start: clean slate)" 200 length=0

podman run $IMAGE true
podman run -v /tmp:/tmp $IMAGE true

t GET libpod/containers/json 200 length=0

Expand All @@ -33,6 +33,7 @@ t GET libpod/containers/json?all=true 200 \
.[0].Command[0]="true" \
.[0].State~\\\(exited\\\|stopped\\\) \
.[0].ExitCode=0 \
.[0].Mounts~.*/tmp \
.[0].IsInfra=false

# Test compat API for Network Settings (.Network is N/A when rootless)
Expand All @@ -44,6 +45,7 @@ t GET /containers/json?all=true 200 \
length=1 \
.[0].Id~[0-9a-f]\\{64\\} \
.[0].Image=$IMAGE \
.[0].Mounts~.*/tmp \
$network_expect

# compat API imageid with sha256: prefix
Expand Down