dm

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

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

Go to latest
Published: Jun 16, 2016 License: Apache-2.0 Imports: 8 Imported by: 1

README

go-docker-machine: Go binding for Docker Machine

GoDoc Build Status Go Report Card

go-docker-machine provides a Go binding for Docker Machine. Inspired by python-docker-machine.

Currently, go-docker-machine is tested with Docker Machine 0.6.0.

Example

example/main.go:

package main

import (
	"fmt"
	"os"

	"golang.org/x/net/context"

	dm "github.com/AkihiroSuda/go-docker-machine"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Fprintf(os.Stderr, "Usage: %s MACHINENAME\n", os.Args[0])
		os.Exit(1)
	}
	mname := os.Args[1]

	dockerMachine := dm.NewDockerMachine()

	// client is github.com/docker/engine-api/client.(*Client)
	client, err := dockerMachine.Client(mname)
	if err != nil {
		panic(err)
	}
	info, err := client.Info(context.Background())
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s(%s) has %d containers\n",
		info.Name, info.ServerVersion, info.Containers)
}
$ docker-machine create -d virtualbox dm1
$ go run example/main.go dm1
dm1(1.11.1) has 0 containers

Documentation

Overview

Package dm provides a binding for Docker Machine

Index

Constants

View Source
const (
	// DefaultDockerMachinePath is the default path to `docker-machine`
	DefaultDockerMachinePath = "docker-machine"
)

Variables

View Source
var (
	// ExepctedMachineConfigVersions are expected, but not mandatory
	ExepctedMachineConfigVersions = []int{3}
)

Functions

This section is empty.

Types

type AuthOptions

type AuthOptions struct {
	CaCertPath     string `json:"CaCertPath"`
	ClientCertPath string `json:"ClientCertPath"`
	ClientKeyPath  string `json:"ClientKeyPath"`
	StorePath      string `json:"StorePath"`
}

AuthOptions is included in a result of `docker-machine inspect`

type DockerMachine

type DockerMachine struct {
	Path string
	// contains filtered or unexported fields
}

DockerMachine is an instance of `docker-machine`

func NewDockerMachine

func NewDockerMachine() *DockerMachine

NewDockerMachine instantiates DockerMachine

func (*DockerMachine) Client

func (dm *DockerMachine) Client(name string) (*client.Client, error)

Client returns docker/engine-api/client.(*Client) for the machine. The API version is set to client.DefaultVersion. You can update the version later by calling (*Client).UpdateClientVersion.

func (*DockerMachine) Env

func (dm *DockerMachine) Env(name string) (map[string]string, error)

Env returns string map that contains DOCKER_{TLS_VERIFY,HOST,CERT_PATH,MACHINE_NAME}

func (*DockerMachine) Inspect

func (dm *DockerMachine) Inspect(name string) (MachineConfig, error)

Inspect inspects the machine (`docker-machine inspect`)

func (*DockerMachine) Machine

func (dm *DockerMachine) Machine(name string) (Machine, error)

Machine returns the machine (`docker-machine ls`)

func (*DockerMachine) Machines

func (dm *DockerMachine) Machines() ([]Machine, error)

Machines returns the list of machines (`docker-machine ls`)

func (*DockerMachine) RawCommandResult

func (dm *DockerMachine) RawCommandResult(arg ...string) ([]byte, error)

RawCommandResult returns a raw `docker-machine` command result with arg

type EngineOptions

type EngineOptions struct {
	TLSVerify bool `json:"TlsVerify"`
}

EngineOptions is included in a result of `docker-machine inspect`

type HostOptions

type HostOptions struct {
	EngineOptions EngineOptions `json:"EngineOptions"`
	AuthOptions   AuthOptions   `json:"AuthOptions"`
}

HostOptions is included in a result of `docker-machine inspect`

type Machine

type Machine struct {
	Name  string       `json:"Name"`
	State MachineState `json:"State"`
	URL   string       `json:"URL"`
}

Machine is a result of `docker-machine ls`

type MachineConfig

type MachineConfig struct {
	ConfigVersion int         `json:"ConfigVersion"`
	HostOptions   HostOptions `json:"HostOptions"`
}

MachineConfig is a result of `docker-machine inspect`

type MachineState

type MachineState string

MachineState is a state of a machine

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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