mirror of
https://github.com/containers/podman.git
synced 2025-10-19 12:12:36 +08:00
Fix inspect --format '{{.Mounts}}.
Go templating is incapable of dealing with pointers, so when we moved to Docker compatible mounts JSON, we broke it. The solution is to not use pointers in this part of inspect. Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
@ -46,7 +46,7 @@ type InspectContainerData struct {
|
|||||||
GraphDriver *driver.Data `json:"GraphDriver"`
|
GraphDriver *driver.Data `json:"GraphDriver"`
|
||||||
SizeRw int64 `json:"SizeRw,omitempty"`
|
SizeRw int64 `json:"SizeRw,omitempty"`
|
||||||
SizeRootFs int64 `json:"SizeRootFs,omitempty"`
|
SizeRootFs int64 `json:"SizeRootFs,omitempty"`
|
||||||
Mounts []*InspectMount `json:"Mounts"`
|
Mounts []InspectMount `json:"Mounts"`
|
||||||
Dependencies []string `json:"Dependencies"`
|
Dependencies []string `json:"Dependencies"`
|
||||||
NetworkSettings *InspectNetworkSettings `json:"NetworkSettings"` //TODO
|
NetworkSettings *InspectNetworkSettings `json:"NetworkSettings"` //TODO
|
||||||
ExitCommand []string `json:"ExitCommand"`
|
ExitCommand []string `json:"ExitCommand"`
|
||||||
@ -359,8 +359,8 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data)
|
|||||||
// Get inspect-formatted mounts list.
|
// Get inspect-formatted mounts list.
|
||||||
// Only includes user-specified mounts. Only includes bind mounts and named
|
// Only includes user-specified mounts. Only includes bind mounts and named
|
||||||
// volumes, not tmpfs volumes.
|
// volumes, not tmpfs volumes.
|
||||||
func (c *Container) getInspectMounts(ctrSpec *spec.Spec) ([]*InspectMount, error) {
|
func (c *Container) getInspectMounts(ctrSpec *spec.Spec) ([]InspectMount, error) {
|
||||||
inspectMounts := []*InspectMount{}
|
inspectMounts := []InspectMount{}
|
||||||
|
|
||||||
// No mounts, return early
|
// No mounts, return early
|
||||||
if len(c.config.UserVolumes) == 0 {
|
if len(c.config.UserVolumes) == 0 {
|
||||||
@ -384,7 +384,7 @@ func (c *Container) getInspectMounts(ctrSpec *spec.Spec) ([]*InspectMount, error
|
|||||||
// We need to look up the volumes.
|
// We need to look up the volumes.
|
||||||
// First: is it a named volume?
|
// First: is it a named volume?
|
||||||
if volume, ok := namedVolumes[vol]; ok {
|
if volume, ok := namedVolumes[vol]; ok {
|
||||||
mountStruct := new(InspectMount)
|
mountStruct := InspectMount{}
|
||||||
mountStruct.Type = "volume"
|
mountStruct.Type = "volume"
|
||||||
mountStruct.Dst = volume.Dest
|
mountStruct.Dst = volume.Dest
|
||||||
mountStruct.Name = volume.Name
|
mountStruct.Name = volume.Name
|
||||||
@ -398,7 +398,7 @@ func (c *Container) getInspectMounts(ctrSpec *spec.Spec) ([]*InspectMount, error
|
|||||||
mountStruct.Driver = volFromDB.Driver()
|
mountStruct.Driver = volFromDB.Driver()
|
||||||
mountStruct.Src = volFromDB.MountPoint()
|
mountStruct.Src = volFromDB.MountPoint()
|
||||||
|
|
||||||
parseMountOptionsForInspect(volume.Options, mountStruct)
|
parseMountOptionsForInspect(volume.Options, &mountStruct)
|
||||||
|
|
||||||
inspectMounts = append(inspectMounts, mountStruct)
|
inspectMounts = append(inspectMounts, mountStruct)
|
||||||
} else if mount, ok := mounts[vol]; ok {
|
} else if mount, ok := mounts[vol]; ok {
|
||||||
@ -408,12 +408,12 @@ func (c *Container) getInspectMounts(ctrSpec *spec.Spec) ([]*InspectMount, error
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
mountStruct := new(InspectMount)
|
mountStruct := InspectMount{}
|
||||||
mountStruct.Type = "bind"
|
mountStruct.Type = "bind"
|
||||||
mountStruct.Src = mount.Source
|
mountStruct.Src = mount.Source
|
||||||
mountStruct.Dst = mount.Destination
|
mountStruct.Dst = mount.Destination
|
||||||
|
|
||||||
parseMountOptionsForInspect(mount.Options, mountStruct)
|
parseMountOptionsForInspect(mount.Options, &mountStruct)
|
||||||
|
|
||||||
inspectMounts = append(inspectMounts, mountStruct)
|
inspectMounts = append(inspectMounts, mountStruct)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user