dockervolume: go.pedge.io/dockervolume Index | Files | Directories

package dockervolume

import "go.pedge.io/dockervolume"

Package dockervolume is a library taking care of the generic code for docker volume plugins written in go.

Also see https://go.pedge.io/dockerplugin.

Your volume plugin must implement the VolumeDriver interface.

The API in this package exposes additional functionality on top of the docker volume plugin API. See the protocol buffers file for details.

To launch your plugin using Unix sockets, do:

func launch(volumeDriver dockervolume.VolumeDriver) error {
  return dockervolume.NewUnixServer(
	volumeDriver,
	"volume_driver_name",
	"root",
	dockerplugin.ServerOptions{},
  ).Serve()
}

To launch your plugin using TCP, do:

func launch(volumeDriver dockervolume.VolumeDriver) error {
  return dockervolume.NewTCPServer(
	volumeDriver,
	"volume_driver_name",
	"address",
	dockerplugin.ServerOptions{},
  ).Serve()
}

Example:

https://github.com/peter-edge/dockervolume-go/tree/master/example/cmd/dockervolume-example

Index

Package Files

api_server.go dockervolume.go dockervolume.pb.go dockervolume.pb.gw.go volume_driver_client.go

func NewTCPServer Uses

func NewTCPServer(
    volumeDriver VolumeDriver,
    volumeDriverName string,
    address string,
    opts dockerplugin.ServerOptions,
) dockerplugin.Server

NewTCPServer returns a new Server for TCP.

func NewUnixServer Uses

func NewUnixServer(
    volumeDriver VolumeDriver,
    volumeDriverName string,
    group string,
    opts dockerplugin.ServerOptions,
) dockerplugin.Server

NewUnixServer returns a new Server for Unix sockets.

func RegisterAPIHandler Uses

func RegisterAPIHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterAPIHandler registers the http handlers for service API to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterAPIHandlerFromEndpoint Uses

func RegisterAPIHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterAPIHandlerFromEndpoint is same as RegisterAPIHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterAPIServer Uses

func RegisterAPIServer(s *grpc.Server, srv APIServer)

type APIClient Uses

type APIClient interface {
    // Create is the create function call for the docker volume plugin API.
    Create(ctx context.Context, in *NameOptsRequest, opts ...grpc.CallOption) (*ErrResponse, error)
    // Remove is the remove function call for the docker volume plugin API.
    Remove(ctx context.Context, in *NameRequest, opts ...grpc.CallOption) (*ErrResponse, error)
    // Path is the path function call for the docker volume plugin API.
    Path(ctx context.Context, in *NameRequest, opts ...grpc.CallOption) (*MountpointErrResponse, error)
    // Mount is the mount function call for the docker volume plugin API.
    Mount(ctx context.Context, in *NameRequest, opts ...grpc.CallOption) (*MountpointErrResponse, error)
    // Unmount is the unmount function call for the docker volume plugin API.
    Unmount(ctx context.Context, in *NameRequest, opts ...grpc.CallOption) (*ErrResponse, error)
    // Cleanup attempts to remove all volumes managed by the API. If any volume
    // cannot be removed, for example if it is still attached to a container, this
    // function will error. This function returns all volumes that were attempted
    // to be removed.
    Cleanup(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*Volumes, error)
    // GetVolume returns the volume managed by the API.
    GetVolume(ctx context.Context, in *NameRequest, opts ...grpc.CallOption) (*Volume, error)
    // ListVolumes returns all volumes managed by the API.
    ListVolumes(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*Volumes, error)
}

func NewAPIClient Uses

func NewAPIClient(cc *grpc.ClientConn) APIClient

type APIServer Uses

type APIServer interface {
    // Create is the create function call for the docker volume plugin API.
    Create(context.Context, *NameOptsRequest) (*ErrResponse, error)
    // Remove is the remove function call for the docker volume plugin API.
    Remove(context.Context, *NameRequest) (*ErrResponse, error)
    // Path is the path function call for the docker volume plugin API.
    Path(context.Context, *NameRequest) (*MountpointErrResponse, error)
    // Mount is the mount function call for the docker volume plugin API.
    Mount(context.Context, *NameRequest) (*MountpointErrResponse, error)
    // Unmount is the unmount function call for the docker volume plugin API.
    Unmount(context.Context, *NameRequest) (*ErrResponse, error)
    // Cleanup attempts to remove all volumes managed by the API. If any volume
    // cannot be removed, for example if it is still attached to a container, this
    // function will error. This function returns all volumes that were attempted
    // to be removed.
    Cleanup(context.Context, *google_protobuf1.Empty) (*Volumes, error)
    // GetVolume returns the volume managed by the API.
    GetVolume(context.Context, *NameRequest) (*Volume, error)
    // ListVolumes returns all volumes managed by the API.
    ListVolumes(context.Context, *google_protobuf1.Empty) (*Volumes, error)
}

func NewAPIServer Uses

func NewAPIServer(volumeDriver VolumeDriver, volumeDriverName string) APIServer

NewAPIServer returns a new APIServer for the given VolumeDriver and name.

type ErrResponse Uses

type ErrResponse struct {
    Err string `protobuf:"bytes,1,opt,name=err" json:"err,omitempty"`
}

ErrResponse is a response for the docker volume plugin API with a potential error.

func (*ErrResponse) Descriptor Uses

func (*ErrResponse) Descriptor() ([]byte, []int)

func (*ErrResponse) ProtoMessage Uses

func (*ErrResponse) ProtoMessage()

func (*ErrResponse) Reset Uses

func (m *ErrResponse) Reset()

func (*ErrResponse) String Uses

func (m *ErrResponse) String() string

type MountpointErrResponse Uses

type MountpointErrResponse struct {
    Mountpoint string `protobuf:"bytes,1,opt,name=mountpoint" json:"mountpoint,omitempty"`
    Err        string `protobuf:"bytes,2,opt,name=err" json:"err,omitempty"`
}

MountpointErrResponse is a response for the docker volume plugin API with a mountpoint and a potential error.

func (*MountpointErrResponse) Descriptor Uses

func (*MountpointErrResponse) Descriptor() ([]byte, []int)

func (*MountpointErrResponse) ProtoMessage Uses

func (*MountpointErrResponse) ProtoMessage()

func (*MountpointErrResponse) Reset Uses

func (m *MountpointErrResponse) Reset()

func (*MountpointErrResponse) String Uses

func (m *MountpointErrResponse) String() string

type NameOptsRequest Uses

type NameOptsRequest struct {
    Name string            `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
    Opts map[string]string `protobuf:"bytes,2,rep,name=opts" json:"opts,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
}

NameOptsRequest is a request with a volume name and opts.

func (*NameOptsRequest) Descriptor Uses

func (*NameOptsRequest) Descriptor() ([]byte, []int)

func (*NameOptsRequest) GetOpts Uses

func (m *NameOptsRequest) GetOpts() map[string]string

func (*NameOptsRequest) ProtoMessage Uses

func (*NameOptsRequest) ProtoMessage()

func (*NameOptsRequest) Reset Uses

func (m *NameOptsRequest) Reset()

func (*NameOptsRequest) String Uses

func (m *NameOptsRequest) String() string

type NameRequest Uses

type NameRequest struct {
    Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}

NameRequest is a request with a volume name.

func (*NameRequest) Descriptor Uses

func (*NameRequest) Descriptor() ([]byte, []int)

func (*NameRequest) ProtoMessage Uses

func (*NameRequest) ProtoMessage()

func (*NameRequest) Reset Uses

func (m *NameRequest) Reset()

func (*NameRequest) String Uses

func (m *NameRequest) String() string

type Volume Uses

type Volume struct {
    Name       string            `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
    Opts       map[string]string `protobuf:"bytes,2,rep,name=opts" json:"opts,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
    Mountpoint string            `protobuf:"bytes,3,opt,name=mountpoint" json:"mountpoint,omitempty"`
}

Volume represents a volume managed by the dockervolume package.

func (*Volume) Descriptor Uses

func (*Volume) Descriptor() ([]byte, []int)

func (*Volume) GetOpts Uses

func (m *Volume) GetOpts() map[string]string

func (*Volume) ProtoMessage Uses

func (*Volume) ProtoMessage()

func (*Volume) Reset Uses

func (m *Volume) Reset()

func (*Volume) String Uses

func (m *Volume) String() string

type VolumeDriver Uses

type VolumeDriver interface {
    // Create a volume with the given name and opts.
    Create(name string, opts pkgmap.StringStringMap) (err error)
    // Remove the volume with the given name. opts and mountpoint were the opts
    // given when created, and mountpoint when mounted, if ever mounted.
    Remove(name string, opts pkgmap.StringStringMap, mountpoint string) (err error)
    // Mount the given volume and return the mountpoint. opts were the opts
    // given when created.
    Mount(name string, opts pkgmap.StringStringMap) (mountpoint string, err error)
    // Unmount the given volume. opts were the opts and mountpoint were the
    // opts given when created, and mountpoint when mounted.
    Unmount(name string, opts pkgmap.StringStringMap, mountpoint string) (err error)
}

VolumeDriver is the interface that should be implemented for custom volume drivers.

type VolumeDriverClient Uses

type VolumeDriverClient interface {
    // Create a volume with the given name and opts.
    Create(name string, opts map[string]string) (err error)
    // Remove the volume with the given name.
    Remove(name string) (err error)
    // Get the path of the mountpoint for the given name.
    Path(name string) (mountpoint string, err error)
    // Mount the given volume and return the mountpoint.
    Mount(name string) (mountpoint string, err error)
    // Unmount the given volume.
    Unmount(name string) (err error)
    // Cleanup all volumes.
    Cleanup() ([]*Volume, error)
    // Get a volume by name.
    GetVolume(name string) (*Volume, error)
    // List all volumes.
    ListVolumes() ([]*Volume, error)
}

VolumeDriverClient is a wrapper for APIClient.

func NewVolumeDriverClient Uses

func NewVolumeDriverClient(apiClient APIClient) VolumeDriverClient

NewVolumeDriverClient creates a new VolumeDriverClient for the given APIClient.

type Volumes Uses

type Volumes struct {
    Volume []*Volume `protobuf:"bytes,1,rep,name=volume" json:"volume,omitempty"`
}

Volumes is the plural of Volume.

func (*Volumes) Descriptor Uses

func (*Volumes) Descriptor() ([]byte, []int)

func (*Volumes) GetVolume Uses

func (m *Volumes) GetVolume() []*Volume

func (*Volumes) ProtoMessage Uses

func (*Volumes) ProtoMessage()

func (*Volumes) Reset Uses

func (m *Volumes) Reset()

func (*Volumes) String Uses

func (m *Volumes) String() string

Directories

PathSynopsis
cmd/dockervolumePackage main contains a CLI binary for the dockervolume API functionality not contained within the docker volume plugin API.
example/cmd/dockervolume-examplePackage main contains an example implementation of a dockervolume VolumeDriver and binary.

Package dockervolume imports 20 packages (graph) and is imported by 2 packages. Updated 2016-07-17. Refresh now. Tools for package owners.