Documentation ¶
Index ¶
- Constants
- func IsInUse(err error) bool
- func IsNameConflict(err error) bool
- func IsNotExist(err error) bool
- type By
- type ByReferenced
- type CustomFilter
- type OpErr
- type StoreOpt
- type VolumeEventLogger
- type VolumeStore
- func (s *VolumeStore) CountReferences(v volume.Volume) int
- func (s *VolumeStore) Create(ctx context.Context, name, driverName string, createOpts ...opts.CreateOption) (volume.Volume, error)
- func (s *VolumeStore) Find(ctx context.Context, by By) (vols []volume.Volume, warnings []string, err error)
- func (s *VolumeStore) Get(ctx context.Context, name string, getOptions ...opts.GetOption) (volume.Volume, error)
- func (s *VolumeStore) Release(ctx context.Context, name string, ref string) error
- func (s *VolumeStore) Remove(ctx context.Context, v volume.Volume, rmOpts ...opts.RemoveOption) error
- func (s *VolumeStore) Shutdown() error
- type VolumesService
- func (s *VolumesService) Create(ctx context.Context, name, driverName string, options ...opts.CreateOption) (*volumetypes.Volume, error)
- func (s *VolumesService) Get(ctx context.Context, name string, getOpts ...opts.GetOption) (*volumetypes.Volume, error)
- func (s *VolumesService) GetDriverList() []string
- func (s *VolumesService) List(ctx context.Context, filter filters.Args) (volumesOut []*volumetypes.Volume, warnings []string, err error)
- func (s *VolumesService) LiveRestoreVolume(ctx context.Context, vol *volumetypes.Volume, ref string) error
- func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*volumetypes.Volume, error)
- func (s *VolumesService) Mount(ctx context.Context, vol *volumetypes.Volume, ref string) (string, error)
- func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types.VolumesPruneReport, error)
- func (s *VolumesService) Release(ctx context.Context, name string, ref string) error
- func (s *VolumesService) Remove(ctx context.Context, name string, rmOpts ...opts.RemoveOption) error
- func (s *VolumesService) Shutdown() error
- func (s *VolumesService) Unmount(ctx context.Context, vol *volumetypes.Volume, ref string) error
Constants ¶
const AnonymousLabel = "com.docker.volume.anonymous"
AnonymousLabel is the label used to indicate that a volume is anonymous This is set automatically on a volume when a volume is created without a name specified, and as such an id is generated for it.
Variables ¶
This section is empty.
Functions ¶
func IsInUse ¶
IsInUse returns a boolean indicating whether the error indicates that a volume is in use
func IsNameConflict ¶
IsNameConflict returns a boolean indicating whether the error indicates that a volume name is already taken
func IsNotExist ¶
IsNotExist returns a boolean indicating whether the error indicates that the volume does not exist
Types ¶
type By ¶
type By interface {
// contains filtered or unexported methods
}
By is an interface which is used to implement filtering on volumes.
type ByReferenced ¶
type ByReferenced bool
ByReferenced is a `By` that filters based on if the volume has references
type CustomFilter ¶
type CustomFilter filterFunc
CustomFilter is a `By` that is used by callers to provide custom filtering logic.
type OpErr ¶
type OpErr struct { // Err is the error that occurred during the operation. Err error // Op is the operation which caused the error, such as "create", or "list". Op string // Name is the name of the resource being requested for this op, typically the volume name or the driver name. Name string // Refs is the list of references associated with the resource. Refs []string }
OpErr is the error type returned by functions in the store package. It describes the operation, volume name, and error.
type StoreOpt ¶
type StoreOpt func(store *VolumeStore) error
StoreOpt sets options for a VolumeStore
func WithEventLogger ¶
func WithEventLogger(logger VolumeEventLogger) StoreOpt
WithEventLogger configures the VolumeStore with the given VolumeEventLogger
type VolumeEventLogger ¶
type VolumeEventLogger interface { // LogVolumeEvent generates an event related to a volume. LogVolumeEvent(volumeID, action string, attributes map[string]string) }
VolumeEventLogger interface provides methods to log volume-related events
type VolumeStore ¶
type VolumeStore struct {
// contains filtered or unexported fields
}
VolumeStore is responsible for storing and reference counting volumes.
func (*VolumeStore) CountReferences ¶
func (s *VolumeStore) CountReferences(v volume.Volume) int
CountReferences gives a count of all references for a given volume.
func (*VolumeStore) Create ¶
func (s *VolumeStore) Create(ctx context.Context, name, driverName string, createOpts ...opts.CreateOption) (volume.Volume, error)
Create creates a volume with the given name and driver If the volume needs to be created with a reference to prevent race conditions with volume cleanup, make sure to use the `CreateWithReference` option.
func (*VolumeStore) Find ¶
func (s *VolumeStore) Find(ctx context.Context, by By) (vols []volume.Volume, warnings []string, err error)
Find lists volumes filtered by the past in filter. If a driver returns a volume that has name which conflicts with another volume from a different driver, the first volume is chosen and the conflicting volume is dropped.
func (*VolumeStore) Get ¶
func (s *VolumeStore) Get(ctx context.Context, name string, getOptions ...opts.GetOption) (volume.Volume, error)
Get looks if a volume with the given name exists and returns it if so
func (*VolumeStore) Remove ¶
func (s *VolumeStore) Remove(ctx context.Context, v volume.Volume, rmOpts ...opts.RemoveOption) error
Remove removes the requested volume. A volume is not removed if it has any refs
func (*VolumeStore) Shutdown ¶
func (s *VolumeStore) Shutdown() error
Shutdown releases all resources used by the volume store It does not make any changes to volumes, drivers, etc.
type VolumesService ¶
type VolumesService struct {
// contains filtered or unexported fields
}
VolumesService manages access to volumes This is used as the main access point for volumes to higher level services and the API.
func NewVolumeService ¶
func NewVolumeService(root string, pg plugingetter.PluginGetter, rootIDs idtools.Identity, logger VolumeEventLogger) (*VolumesService, error)
NewVolumeService creates a new volume service
func (*VolumesService) Create ¶
func (s *VolumesService) Create(ctx context.Context, name, driverName string, options ...opts.CreateOption) (*volumetypes.Volume, error)
Create creates a volume If the caller is creating this volume to be consumed immediately, it is expected that the caller specifies a reference ID. This reference ID will protect this volume from removal.
A good example for a reference ID is a container's ID. When whatever is going to reference this volume is removed the caller should defeference the volume by calling `Release`.
func (*VolumesService) Get ¶
func (s *VolumesService) Get(ctx context.Context, name string, getOpts ...opts.GetOption) (*volumetypes.Volume, error)
Get returns details about a volume
func (*VolumesService) GetDriverList ¶
func (s *VolumesService) GetDriverList() []string
GetDriverList gets the list of registered volume drivers
func (*VolumesService) List ¶
func (s *VolumesService) List(ctx context.Context, filter filters.Args) (volumesOut []*volumetypes.Volume, warnings []string, err error)
List gets the list of volumes which match the past in filters If filters is nil or empty all volumes are returned.
func (*VolumesService) LiveRestoreVolume ¶
func (s *VolumesService) LiveRestoreVolume(ctx context.Context, vol *volumetypes.Volume, ref string) error
LiveRestoreVolume passes through the LiveRestoreVolume call to the volume if it is implemented otherwise it is a no-op.
func (*VolumesService) LocalVolumesSize ¶
func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*volumetypes.Volume, error)
LocalVolumesSize gets all local volumes and fetches their size on disk Note that this intentionally skips volumes which have mount options. Typically volumes with mount options are not really local even if they are using the local driver.
func (*VolumesService) Mount ¶
func (s *VolumesService) Mount(ctx context.Context, vol *volumetypes.Volume, ref string) (string, error)
Mount mounts the volume Callers should specify a uniqe reference for each Mount/Unmount pair.
Example: ```go mountID := "randomString" s.Mount(ctx, vol, mountID) s.Unmount(ctx, vol, mountID) ```
func (*VolumesService) Prune ¶
func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types.VolumesPruneReport, error)
Prune removes (local) volumes which match the past in filter arguments. Note that this intentionally skips volumes with mount options as there would be no space reclaimed in this case.
func (*VolumesService) Remove ¶
func (s *VolumesService) Remove(ctx context.Context, name string, rmOpts ...opts.RemoveOption) error
Remove removes a volume An error is returned if the volume is still referenced.
func (*VolumesService) Shutdown ¶
func (s *VolumesService) Shutdown() error
Shutdown shuts down the image service and dependencies
func (*VolumesService) Unmount ¶
func (s *VolumesService) Unmount(ctx context.Context, vol *volumetypes.Volume, ref string) error
Unmount unmounts the volume. Note that depending on the implementation, the volume may still be mounted due to other resources using it.
The reference specified here should be the same reference specified during `Mount` and should be unique for each mount/unmount pair. See `Mount` documentation for an example.