mirror of
https://github.com/containers/podman.git
synced 2025-05-20 08:36:23 +08:00

We added the concept of image volumes in 2.2.0, to support inspecting an image from within a container. However, this is a strictly read-only mount, with no modification allowed. By contrast, the new `image` volume driver creates a c/storage container as its underlying storage, so we have a read/write layer. This, in and of itself, is not especially interesting, but what it will enable in the future is. If we add a new command to allow these image volumes to be committed, we can now distribute volumes - and changes to them - via a standard OCI image registry (which is rather new and quite exciting). Future work in this area: - Add support for `podman volume push` (commit volume changes and push resulting image to OCI registry). - Add support for `podman volume pull` (currently, we require that the image a volume is created from be already pulled; it would be simpler if we had a dedicated command that did the pull and made a volume from it) - Add support for scratch images (make an empty image on demand to use as the base of the volume) - Add UOR support to `podman volume push` and `podman volume pull` to enable both with non-image volume drivers Signed-off-by: Matthew Heon <matthew.heon@pm.me>
77 lines
1.9 KiB
Go
77 lines
1.9 KiB
Go
package libpod
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/containers/podman/v4/libpod/define"
|
|
pluginapi "github.com/docker/go-plugins-helpers/volume"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Inspect provides detailed information about the configuration of the given
|
|
// volume.
|
|
func (v *Volume) Inspect() (*define.InspectVolumeData, error) {
|
|
if !v.valid {
|
|
return nil, define.ErrVolumeRemoved
|
|
}
|
|
|
|
v.lock.Lock()
|
|
defer v.lock.Unlock()
|
|
|
|
if err := v.update(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
data := new(define.InspectVolumeData)
|
|
|
|
data.Mountpoint = v.config.MountPoint
|
|
if v.UsesVolumeDriver() {
|
|
logrus.Debugf("Querying volume plugin %s for status", v.config.Driver)
|
|
data.Mountpoint = v.state.MountPoint
|
|
|
|
if v.plugin == nil {
|
|
return nil, fmt.Errorf("volume %s uses volume plugin %s but it is not available, cannot inspect: %w", v.Name(), v.config.Driver, define.ErrMissingPlugin)
|
|
}
|
|
|
|
// Retrieve status for the volume.
|
|
// Need to query the volume driver.
|
|
req := new(pluginapi.GetRequest)
|
|
req.Name = v.Name()
|
|
resp, err := v.plugin.GetVolume(req)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("retrieving volume %s information from plugin %s: %w", v.Name(), v.Driver(), err)
|
|
}
|
|
if resp != nil {
|
|
data.Status = resp.Status
|
|
}
|
|
}
|
|
|
|
data.Name = v.config.Name
|
|
data.Driver = v.config.Driver
|
|
data.CreatedAt = v.config.CreatedTime
|
|
data.Labels = make(map[string]string)
|
|
for k, v := range v.config.Labels {
|
|
data.Labels[k] = v
|
|
}
|
|
data.Scope = v.Scope()
|
|
data.Options = make(map[string]string)
|
|
for k, v := range v.config.Options {
|
|
data.Options[k] = v
|
|
}
|
|
data.UID = v.uid()
|
|
data.GID = v.gid()
|
|
data.Anonymous = v.config.IsAnon
|
|
data.MountCount = v.state.MountCount
|
|
data.NeedsCopyUp = v.state.NeedsCopyUp
|
|
data.NeedsChown = v.state.NeedsChown
|
|
data.StorageID = v.config.StorageID
|
|
|
|
if v.config.Timeout != nil {
|
|
data.Timeout = *v.config.Timeout
|
|
} else if v.UsesVolumeDriver() {
|
|
data.Timeout = v.runtime.config.Engine.VolumePluginTimeout
|
|
}
|
|
|
|
return data, nil
|
|
}
|