service

package
v27.0.0-rc.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
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

func IsInUse(err error) bool

IsInUse returns a boolean indicating whether the error indicates that a volume is in use

func IsNameConflict

func IsNameConflict(err error) bool

IsNameConflict returns a boolean indicating whether the error indicates that a volume name is already taken

func IsNotExist

func IsNotExist(err error) bool

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.

func And

func And(bys ...By) By

And creates a `By` combining all the passed in bys using AND logic.

func ByDriver

func ByDriver(drivers ...string) By

ByDriver is `By` that filters based on the driver names that are passed in

func FromList

func FromList(ls *[]volume.Volume, by By) By

FromList returns a By which sets the initial list of volumes to use

func Or

func Or(bys ...By) By

Or creates a `By` combining all the passed in bys using OR logic.

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.

func (*OpErr) Cause

func (e *OpErr) Cause() error

Cause returns the error the caused this error

func (*OpErr) Error

func (e *OpErr) Error() string

Error satisfies the built-in error interface type.

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 string, action events.Action, 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 NewStore

func NewStore(rootPath string, drivers *drivers.Store, opts ...StoreOpt) (*VolumeStore, error)

NewStore creates a new volume store at the given path

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) Release

func (s *VolumeStore) Release(ctx context.Context, name string, ref string) error

Release releases the specified reference to the volume

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

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) Release

func (s *VolumesService) Release(ctx context.Context, name string, ref string) error

Release releases a volume reference

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL