docker

package
v1.59.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 38 Imported by: 1

Documentation

Overview

Package docker serves a remote suitable for use with docker volume api

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVolumeNotFound   = errors.New("volume not found")
	ErrVolumeExists     = errors.New("volume already exists")
	ErrMountpointExists = errors.New("non-empty mountpoint already exists")
)

Errors

View Source
var Command = &cobra.Command{
	Use:   "docker",
	Short: `Serve any remote on docker's volume plugin API.`,
	Long:  strings.ReplaceAll(longHelp, "|", "`") + vfs.Help,

	Run: func(command *cobra.Command, args []string) {
		cmd.CheckArgs(0, 0, command, args)
		cmd.Run(false, false, command, func() error {
			ctx := context.Background()
			drv, err := NewDriver(ctx, baseDir, nil, nil, false, forgetState)
			if err != nil {
				return err
			}
			srv := NewServer(drv)
			if socketAddr == "" {

				return srv.ServeUnix(pluginName, socketGid)
			}
			if filepath.IsAbs(socketAddr) {

				return srv.ServeUnix(socketAddr, socketGid)
			}
			return srv.ServeTCP(socketAddr, "", nil, noSpec)
		})
	},
}

Command definition for cobra

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 struct {
	// contains filtered or unexported fields
}

Driver implements docker driver api

func NewDriver

func NewDriver(ctx context.Context, root string, mntOpt *mountlib.Options, vfsOpt *vfscommon.Options, dummy, forgetState bool) (*Driver, error)

NewDriver makes a new docker driver

func (*Driver) Create

func (drv *Driver) Create(req *CreateRequest) error

Create volume To use subpath we are limited to defining a new volume definition via alias

func (*Driver) Exit

func (drv *Driver) Exit()

Exit will unmount all currently mounted volumes

func (*Driver) Get

func (drv *Driver) Get(req *GetRequest) (*GetResponse, error)

Get volume info

func (*Driver) List

func (drv *Driver) List() (*ListResponse, error)

List volumes handled by the driver

func (*Driver) Mount

func (drv *Driver) Mount(req *MountRequest) (*MountResponse, error)

Mount volume

func (*Driver) Path

func (drv *Driver) Path(req *PathRequest) (*PathResponse, error)

Path returns path of the requested volume

func (*Driver) Remove

func (drv *Driver) Remove(req *RemoveRequest) error

Remove volume

func (*Driver) Unmount

func (drv *Driver) Unmount(req *UnmountRequest) error

Unmount volume

type ErrorResponse

type ErrorResponse struct {
	Err string
}

ErrorResponse is a formatted error message that docker can understand

type GetRequest

type GetRequest struct {
	Name string
}

GetRequest structure for a volume get request

type GetResponse

type GetResponse struct {
	Volume *VolInfo
}

GetResponse structure for a volume get response

type ListResponse

type ListResponse struct {
	Volumes []*VolInfo
}

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 Server

type Server http.Server

Server connects plugin with docker daemon by protocol

func NewServer

func NewServer(drv *Driver) *Server

NewServer creates new docker plugin server

func (*Server) ServeTCP

func (s *Server) ServeTCP(addr, specDir string, tlsConfig *tls.Config, noSpec bool) error

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

func (*Server) ServeUnix

func (s *Server) ServeUnix(path string, gid int) error

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

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown the server

type UnmountRequest

type UnmountRequest struct {
	Name string
	ID   string
}

UnmountRequest structure for a volume unmount request

type VolInfo

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

VolInfo represents a volume for Get and List requests

type VolOpts

type VolOpts map[string]string

VolOpts keeps volume options

type Volume

type Volume struct {
	Name       string    `json:"name"`
	MountPoint string    `json:"mountpoint"`
	CreatedAt  time.Time `json:"created"`
	Fs         string    `json:"fs"`             // remote[,connectString]:path
	Type       string    `json:"type,omitempty"` // same as ":backend:"
	Path       string    `json:"path,omitempty"` // for "remote:path" or ":backend:path"
	Options    VolOpts   `json:"options"`        // all options together
	Mounts     []string  `json:"mounts"`         // mountReqs as a string list
	// contains filtered or unexported fields
}

Volume keeps volume runtime state Public members get persisted in saved state

Jump to

Keyboard shortcuts

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