Package mdocker is a mistify subagent that manages guest docker containers, exposed via JSON-RPC over HTTP.
/_mistify_RPC_
* GET - Run a specified method
{
"method": "MDocker.RPC_METHOD",
"params": [
DATA_STRUCT
],
"id": 0
}
Where RPC_METHOD is the desired method and DATA_STRUCTURE is one of the request structs defined in http://godoc.org/github.com/mistifyio/mistify-agent/rpc .
{
"result": {
KEY: RESPONSE_STRUCT
},
"error": null,
"id": 0
}
Where KEY is a string (e.g. "snapshot") and DATA is one of the response structs defined in http://godoc.org/github.com/mistifyio/mistify-agent/rpc .
ListContainers
GetContainer
DeleteContainer
SaveContainer
CreateContainer
StartContainer
StopContainer
RestartContainer
RebootContainer
PauseContainer
UnpauseContainer
ListImages
GetImages
LoadImage
DeleteImage
See the godocs and function signatures for each method's purpose and expected request/response structs.
type ErrorHTTPCode struct {
Expected int
Code int
Source string
}
ErrorHTTPCode should be used for errors resulting from an http response code not matching the expected code
func (e ErrorHTTPCode) Error() string
Error returns a string error message
type MDocker struct {
}
MDocker is the Mistify Docker subagent service
func New(endpoint, imageService, tlsCertPath string) (*MDocker, error)
New creates a new MDocker with a docker client
func (md *MDocker) CreateContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
CreateContainer creates a new Docker container
func (md *MDocker) DeleteContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
DeleteContainer deletes a Docker container
func (md *MDocker) DeleteImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error
DeleteImage deletes a Docker image
func (md *MDocker) GetContainer(h *http.Request, request *rpc.ContainerRequest, response *rpc.ContainerResponse) error
GetContainer retrieves information about a specific Docker container
func (md *MDocker) GetImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error
GetImage retrieves information about a specific Docker image
func (md *MDocker) GetInfo(h *http.Request, request *struct{}, response *docker.DockerInfo) error
GetInfo provides general information about the system from Docker
func (md *MDocker) ListContainers(h *http.Request, request *rpc.ContainerRequest, response *rpc.ContainerResponse) error
ListContainers retrieves a list of Docker containers
func (md *MDocker) ListImages(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error
ListImages retrieves a list of Docker images
func (md *MDocker) LoadImage(h *http.Request, request *rpc.ImageRequest, response *rpc.ImageResponse) error
LoadImage downloads a new container image from the image service and imports it into Docker
func (md *MDocker) PauseContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
PauseContainer pauses a Docker container
func (md *MDocker) RebootContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
RebootContainer restarts a Docker container
func (md *MDocker) RequestOpts(req RPCRequest, opts interface{}) error
RequestOpts extracts the request opts into an appropriate struct Nested structs stored in interface{} don't convert directly, so use JSON as an intermediate
func (md *MDocker) RestartContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
RestartContainer restarts a Docker container
func (md *MDocker) RunHTTP(port uint) (*graceful.Server, error)
RunHTTP creates and runs the RPC HTTP server
func (md *MDocker) SaveContainer(h *http.Request, request *rpc.ContainerRequest, response *rpc.ImageResponse) error
SaveContainer saves a Docker container
func (md *MDocker) StartContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
StartContainer starts a Docker container
func (md *MDocker) StopContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
StopContainer stops a Docker container or kills it after a timeout
func (md *MDocker) UnpauseContainer(h *http.Request, request *rpc.GuestRequest, response *rpc.GuestResponse) error
UnpauseContainer restarts a Docker container
type RPCRequest interface {
GetOpts() interface{}
}
RPCRequest is an interface for incoming RPC requests
-- Generated with godocdown