backend.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. package volume // import "github.com/docker/docker/api/server/router/volume"
  2. import (
  3. "context"
  4. "github.com/docker/docker/volume/service/opts"
  5. // TODO return types need to be refactored into pkg
  6. "github.com/docker/docker/api/types"
  7. "github.com/docker/docker/api/types/filters"
  8. "github.com/docker/docker/api/types/volume"
  9. )
  10. // Backend is the methods that need to be implemented to provide
  11. // volume specific functionality
  12. type Backend interface {
  13. List(ctx context.Context, filter filters.Args) ([]*volume.Volume, []string, error)
  14. Get(ctx context.Context, name string, opts ...opts.GetOption) (*volume.Volume, error)
  15. Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*volume.Volume, error)
  16. Remove(ctx context.Context, name string, opts ...opts.RemoveOption) error
  17. Prune(ctx context.Context, pruneFilters filters.Args) (*types.VolumesPruneReport, error)
  18. }
  19. // ClusterBackend is the backend used for Swarm Cluster Volumes. Regular
  20. // volumes go through the volume service, but to avoid across-dependency
  21. // between the cluster package and the volume package, we simply provide two
  22. // backends here.
  23. type ClusterBackend interface {
  24. GetVolume(nameOrID string) (volume.Volume, error)
  25. GetVolumes(options volume.ListOptions) ([]*volume.Volume, error)
  26. CreateVolume(volume volume.CreateOptions) (*volume.Volume, error)
  27. RemoveVolume(nameOrID string, force bool) error
  28. UpdateVolume(nameOrID string, version uint64, volume volume.UpdateOptions) error
  29. IsManager() bool
  30. }