volume

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

Docker volume extension api.

Go handler to create external volume extensions for Docker.

Usage

This library is designed to be integrated in your program.

  1. Implement the volume.Driver interface.
  2. Initialize a volume.Handler with your implementation.
  3. Call either ServeTCP or ServeUnix from the volume.Handler.
Example using TCP sockets:
  d := MyVolumeDriver{}
  h := volume.NewHandler(d)
  h.ServeTCP("test_volume", ":8080")
Example using Unix sockets:
  d := MyVolumeDriver{}
  h := volume.NewHandler(d)
  u, _ := user.Lookup("root")
  gid, _ := strconv.Atoi(u.Gid)
  h.ServeUnix("test_volume", gid)

Full example plugins

Documentation

Index

Constants

View Source
const (
	// DefaultDockerRootDirectory is the default directory where volumes will be created.
	DefaultDockerRootDirectory = "/var/lib/docker-volumes"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CapabilitiesResponse

type CapabilitiesResponse struct {
	Capabilities Capability
}

CapabilitiesResponse structure for a volume capability response

type Capability

type Capability struct {
	Scope string
}

Capability represents the list of capabilities a volume driver can return

type CreateRequest

type CreateRequest struct {
	Name    string
	Options map[string]string `json:"Opts,omitempty"`
}

CreateRequest is the structure that docker's requests are deserialized to.

type Driver

type Driver interface {
	Create(*CreateRequest) error
	List() (*ListResponse, error)
	Get(*GetRequest) (*GetResponse, error)
	Remove(*RemoveRequest) error
	Path(*PathRequest) (*PathResponse, error)
	Mount(*MountRequest) (*MountResponse, error)
	Unmount(*UnmountRequest) error
	Capabilities() *CapabilitiesResponse
}

Driver represent the interface a driver must fulfill.

type ErrorResponse

type ErrorResponse struct {
	Err string
}

ErrorResponse is a formatted error message that docker can understand

func NewErrorResponse

func NewErrorResponse(msg string) *ErrorResponse

NewErrorResponse creates an ErrorResponse with the provided message

type GetRequest

type GetRequest struct {
	Name string
}

GetRequest structure for a volume get request

type GetResponse

type GetResponse struct {
	Volume *Volume
}

GetResponse structure for a volume get response

type Handler

type Handler struct {
	sdk.Handler
	// contains filtered or unexported fields
}

Handler forwards requests and responses between the docker daemon and the plugin.

func NewHandler

func NewHandler(driver Driver) *Handler

NewHandler initializes the request handler with a driver implementation.

type ListResponse

type ListResponse struct {
	Volumes []*Volume
}

ListResponse structure for a volume list response

type MountRequest

type MountRequest struct {
	Name string
	ID   string
}

MountRequest structure for a volume mount request

type MountResponse

type MountResponse struct {
	Mountpoint string
}

MountResponse structure for a volume mount response

type PathRequest

type PathRequest struct {
	Name string
}

PathRequest structure for a volume path request

type PathResponse

type PathResponse struct {
	Mountpoint string
}

PathResponse structure for a volume path response

type RemoveRequest

type RemoveRequest struct {
	Name string
}

RemoveRequest structure for a volume remove request

type UnmountRequest

type UnmountRequest struct {
	Name string
	ID   string
}

UnmountRequest structure for a volume unmount request

type Volume

type Volume struct {
	Name       string
	Mountpoint string                 `json:",omitempty"`
	CreatedAt  string                 `json:",omitempty"`
	Status     map[string]interface{} `json:",omitempty"`
}

Volume represents a volume object for use with `Get` and `List` requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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