dkvolume

package module
v0.0.0-...-d8fba18 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2015 License: MIT Imports: 8 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 dkvolume.Driver interface.
  2. Initialize a dkvolume.Hander with your implementation.
  3. Call either ServeTCP or ServeUnix from the dkvolume.Handler.
Example using TCP sockets:
  d := MyVolumeDriver{}
  h := dkvolume.NewHandler(d)
  h.ServeTCP("test_volume", ":8080")
Example using Unix sockets:
  d := MyVolumeDriver{}
  h := dkvolume.NewHandler(d)
  h.ServeUnix("root", "test_volume")

Full example plugins

License

MIT

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 Driver

type Driver interface {
	Create(Request) Response
	Remove(Request) Response
	Path(Request) Response
	Mount(Request) Response
	Unmount(Request) Response
}

Driver represent the interface a driver must fulfill.

type Handler

type Handler struct {
	// 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.

func (*Handler) ServeTCP

func (h *Handler) ServeTCP(pluginName, addr string) error

ServeTCP makes the handler to listen for request in a given TCP address. It also writes the spec file on the right directory for docker to read.

func (*Handler) ServeUnix

func (h *Handler) ServeUnix(systemGroup, addr string) error

ServeUnix makes the handler to listen for requests in a unix socket. It also creates the socket file on the right directory for docker to read.

type Request

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

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

type Response

type Response struct {
	Mountpoint string
	Err        string
}

Response is the strucutre that the plugin's responses are serialized to.

Jump to

Keyboard shortcuts

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