doctl

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

README

doctl

Travis Build Status

doctl is a command line interface for the DigitalOcean API.

Usage:
  doctl [command]

Available Commands:
  account     account commands
  auth        auth commands
  compute     compute commands
  version     show the current version

Flags:
  -t, --access-token string   DigitalOcean API V2 Access Token
  -h, --help                  help for doctl
  -o, --output string         output format [text|json] (default "text")
  -v, --verbose               verbose output

Use "doctl [command] --help" for more information about a command.

Installation

Option 1 - Use a Package Manager (preferred method)
OS X

You can use Homebrew to install doctl on Mac OS X by using the command below:

brew install doctl
Windows and GNU/Linux

Integrations with package managers for GNU/Linux and Windows are to come.

Option 2 – Download a Release from GitHub

Visit the Releases page for the doctl GitHub project, and find the appropriate archive for your operating system and architecture. (For OS X systems, remember to use the darwin archive.)

OS X and GNU/Linux

You can download the archive from your browser, or copy its URL and retrieve it to your home directory with wget or curl:

cd ~

# OS X
curl -L https://github.com/digitalocean/doctl/releases/download/v1.5.0/doctl-1.5.0-darwin-10.6-amd64.tar.gz | tar xz

# linux (with wget)
wget -qO- https://github.com/digitalocean/doctl/releases/download/v1.5.0/doctl-1.5.0-linux-amd64.tar.gz  | tar xz
# linux (with curl)
curl -L https://github.com/digitalocean/doctl/releases/download/v1.5.0/doctl-1.5.0-linux-amd64.tar.gz  | tar xz

Move the doctl binary to somewhere in your path. For example:

sudo mv ./doctl /usr/local/bin
Windows

On Windows systems, you should be able to download the Windows release, and then double-click the zip archive to extract the doctl.exe executable.

Option 3 – Build From Source

Alternatively, if you have a Go environment configured, you can install the development version of doctl from the command line like so:

go get github.com/digitalocean/doctl/cmd/doctl

Initialization

To use doctl, a DigitalOcean access token is required. Generate a new token and run doctl auth init, or set the environment variable, DIGITALOCEAN_ACCESS_TOKEN, with your new token.

Configuration

By default, doctl will load a configuration file from $XDG_CONFIG_HOME/doctl/config.yaml if found. If the XDG_CONFIG_HOME environment variable is not, the path will default to $HOME/.config/doctl/config.yaml on Unix like systems, and %APPDATA%/doctl/config/config.yaml on Windows.

The configuration file has changed locations in recent versions, and a warning will be displayed if your configuration exists at the legacy location.

Configuration OPTIONS
  • access-token - The DigitalOcean access token. You can generate a token in the Apps & API section of the DigitalOcean control panel or use doctl auth login.
  • output - Type of output to display results in. Choices are json or text. If not supplied, doctl will default to text.

Example:

access-token: MY_TOKEN
output: text

Examples

doctl is able to interact with all of your DigitalOcean resources. Below are a few common usage examples. To learn more about the features available, see the full tutorial on the DigitalOcean community site.

  • List all Droplets on your account:

    doctl compute droplet list

  • Create a Droplet:

    doctl compute droplet create <name> --region <region-slug> --image <image-slug> --size <size-slug>

  • Assign a Floating IP to a Droplet:

    doctl compute floating-ip-action assign <ip-addr> <droplet-id>

  • Create a new A record for an existing domain:

    doctl compute domain records create --record-type A --record-name www --record-data <ip-addr> <domain-name>

doctl also simplifies actions without an API endpoint. For instance, it allows you to SSH to your Droplet by name:

doctl compute ssh <droplet-name>

By default, it assumes you are using the root user. If you want to SSH as a specific user, you can do that as well:

doctl compute ssh <user>@<droplet-name>

Building and dependencies

doctl's dependencies are managed by gvt. To add dependencies, use gvt fetch.

Releasing

To build doctl for all its platforms, run script/build.sh <version>. To upload doctl to Github, run script/release.sh <version>. A valid GITHUB_TOKEN environment variable with access to the bryanl/doctl repository is required.

Documentation

Index

Constants

View Source
const (
	// ArgActionID is an action id argument.
	ArgActionID = "action-id"
	// ArgActionAfter is an action after argument.
	ArgActionAfter = "after"
	// ArgActionBefore is an action before argument.
	ArgActionBefore = "before"
	// ArgActionResourceType is an action resource type argument.
	ArgActionResourceType = "resource-type"
	// ArgActionRegion is an action region argument.
	ArgActionRegion = "region"
	// ArgActionStatus is an action status argument.
	ArgActionStatus = "status"
	// ArgActionType is an action type argument.
	ArgActionType = "action-type"
	// ArgCommandWait is a wait for a droplet to be created argument.
	ArgCommandWait = "wait"
	// ArgDomainName is a domain name argument.
	ArgDomainName = "domain-name"
	// ArgDropletID is a droplet id argument.
	ArgDropletID = "droplet-id"
	// ArgKernelID is a ekrnel id argument.
	ArgKernelID = "kernel-id"
	// ArgImage is an image argument.
	ArgImage = "image"
	// ArgImageID is an image id argument.
	ArgImageID = "image-id"
	// ArgImagePublic is a public image argument.
	ArgImagePublic = "public"
	// ArgImageSlug is an image slug argment.
	ArgImageSlug = "image-slug"
	// ArgIPAddress is an IP address argument.
	ArgIPAddress = "ip-address"
	// ArgDropletName is a droplet name argument.
	ArgDropletName = "droplet-name"
	// ArgResizeDisk is a resize disk argument.
	ArgResizeDisk = "resize-disk"
	// ArgSnapshotName is a snapshot name arugment.
	ArgSnapshotName = "snapshot-name"
	// ArgBackups is an enable backups argument.
	ArgBackups = "enable-backups"
	// ArgIPv6 is an enable IPv6 argument.
	ArgIPv6 = "enable-ipv6"
	// ArgPrivateNetworking is an enable private networking argument.
	ArgPrivateNetworking = "enable-private-networking"
	// ArgRecordData is a record data argument.
	ArgRecordData = "record-data"
	// ArgRecordID is a record id argument.
	ArgRecordID = "record-id"
	// ArgRecordName is a record name argument.
	ArgRecordName = "record-name"
	// ArgRecordPort is a record port argument.
	ArgRecordPort = "record-port"
	// ArgRecordPriority is a record priority argument.
	ArgRecordPriority = "record-priority"
	// ArgRecordType is a record type argument.
	ArgRecordType = "record-type"
	// ArgRecordWeight is a record weight argument.
	ArgRecordWeight = "record-weight"
	// ArgRegionSlug is a region slug argument.
	ArgRegionSlug = "region"
	// ArgSizeSlug is a size slug argument.
	ArgSizeSlug = "size"
	// ArgsSSHKeyPath is a ssh argument.
	ArgsSSHKeyPath = "ssh-key-path"
	// ArgSSHKeys is a ssh key argument.
	ArgSSHKeys = "ssh-keys"
	// ArgsSSHPort is a ssh argument.
	ArgsSSHPort = "ssh-port"
	// ArgsSSHAgentForwarding is a ssh argument.
	ArgsSSHAgentForwarding = "ssh-agent-forwarding"
	// ArgsSSHPrivateIP is a ssh argument.
	ArgsSSHPrivateIP = "ssh-private-ip"
	// ArgUserData is a user data argument.
	ArgUserData = "user-data"
	// ArgUserDataFile is a user data file location argument.
	ArgUserDataFile = "user-data-file"
	// ArgImageName name is an image name argument.
	ArgImageName = "image-name"
	// ArgKey is a key argument.
	ArgKey = "key"
	// ArgKeyName is a key name argument.
	ArgKeyName = "key-name"
	// ArgKeyPublicKey is a public key argument.
	ArgKeyPublicKey = "public-key"
	// ArgKeyPublicKeyFile is a public key file argument.
	ArgKeyPublicKeyFile = "public-key-file"
	// ArgSSHUser is a SSH user argument.
	ArgSSHUser = "ssh-user"
	// ArgFormat is columns to include in output argment.
	ArgFormat = "format"
	// ArgNoHeader hides the output header.
	ArgNoHeader = "no-header"
	// ArgPollTime is how long before the next poll argument.
	ArgPollTime = "poll-timeout"
	// ArgTagName is a tag name
	ArgTagName = "tag-name"

	// ArgOutput is an output type argument.
	ArgOutput = "output"

	// ArgVolumeSize is the size of a volume.
	ArgVolumeSize = "size"
	// ArgVolumeDesc is the description of a volume.
	ArgVolumeDesc = "desc"
	// ArgVolumeRegion is the region of a volume.
	ArgVolumeRegion = "region"
	// ArgVolumeList is the IDs of many volumes.
	ArgVolumeList = "volumes"

	// ArgDeleteForce forces deletion actions
	ArgDeleteForce = "force"
)
View Source
const (
	// NSRoot is a configuration key that signifies this value is at the root.
	NSRoot = "doctl"

	// LatestReleaseURL is the latest release URL endpoint.
	LatestReleaseURL = "https://api.github.com/repos/digitalocean/doctl/releases/latest"
)

Variables

View Source
var (
	// DoitConfig holds the app's current configuration.
	DoitConfig Config = &LiveConfig{}

	// DoitVersion is doit's version.
	DoitVersion = Version{
		Major: 1,
		Minor: 0,
		Patch: 0,
		Label: "dev",
	}

	// Build is doit's build tag.
	Build string

	// Major is doctl's major version.
	Major string

	// Minor is doctl's minor version.
	Minor string

	// Patch is doctl's patch version.
	Patch string

	// Label is doctl's label.
	Label string

	// TraceHTTP traces http connections.
	TraceHTTP bool
)

Functions

This section is empty.

Types

type Command added in v0.5.0

type Command interface {
	Run(args ...string) ([]byte, error)
	Start(args ...string) error
	Stop() error
}

Command runs commands.

type Config

type Config interface {
	GetGodoClient(trace bool) (*godo.Client, error)
	SSH(user, host, keyPath string, port int, opts ssh.Options) runner.Runner
	Set(ns, key string, val interface{})
	GetString(ns, key string) (string, error)
	GetBool(ns, key string) (bool, error)
	GetInt(ns, key string) (int, error)
	GetStringSlice(ns, key string) ([]string, error)
}

Config is an interface that represent doit's config.

type GithubLatestVersioner added in v1.0.0

type GithubLatestVersioner struct{}

GithubLatestVersioner retrieves the latest version from Github.

func (*GithubLatestVersioner) LatestVersion added in v1.0.0

func (glv *GithubLatestVersioner) LatestVersion() (string, error)

LatestVersion retrieves the latest version from Github or returns an error.

type LatestVersioner added in v1.0.0

type LatestVersioner interface {
	LatestVersion() (string, error)
}

LatestVersioner an interface for detecting the latest version.

type LiveCommand added in v0.5.0

type LiveCommand struct {
	// contains filtered or unexported fields
}

LiveCommand is a live implementation of Command.

func NewLiveCommand added in v0.5.0

func NewLiveCommand(path string) *LiveCommand

NewLiveCommand creates a LiveCommand.

func (*LiveCommand) Run added in v0.5.0

func (c *LiveCommand) Run(args ...string) ([]byte, error)

Run runs a LiveCommand with args and returns stdout and an error if there was one.

func (*LiveCommand) Start added in v0.5.0

func (c *LiveCommand) Start(args ...string) error

Start runs a LiveCommand with args and starts it. This would most likely block, so you should call it in a goroutine.

func (*LiveCommand) Stop added in v0.5.0

func (c *LiveCommand) Stop() error

Stop stops an existing LiveCommand.

type LiveConfig

type LiveConfig struct {
	// contains filtered or unexported fields
}

LiveConfig is an implementation of Config for live values.

func (*LiveConfig) GetBool added in v0.5.0

func (c *LiveConfig) GetBool(ns, key string) (bool, error)

GetBool returns a config value as a bool.

func (*LiveConfig) GetGodoClient added in v0.5.0

func (c *LiveConfig) GetGodoClient(trace bool) (*godo.Client, error)

GetGodoClient returns a GodoClient.

func (*LiveConfig) GetInt added in v0.5.0

func (c *LiveConfig) GetInt(ns, key string) (int, error)

GetInt returns a config value as an int.

func (*LiveConfig) GetString added in v0.5.0

func (c *LiveConfig) GetString(ns, key string) (string, error)

GetString returns a config value as a string.

func (*LiveConfig) GetStringSlice added in v0.5.0

func (c *LiveConfig) GetStringSlice(ns, key string) ([]string, error)

GetStringSlice returns a config value as a string slice.

func (*LiveConfig) SSH

func (c *LiveConfig) SSH(user, host, keyPath string, port int, opts ssh.Options) runner.Runner

SSH creates a ssh connection to a host.

func (*LiveConfig) Set added in v0.5.0

func (c *LiveConfig) Set(ns, key string, val interface{})

Set sets a config key.

type MissingArgsErr added in v0.5.0

type MissingArgsErr struct {
	Command string
}

MissingArgsErr is an error returned when their are too few arguments for a command.

func NewMissingArgsErr added in v0.5.0

func NewMissingArgsErr(cmd string) *MissingArgsErr

NewMissingArgsErr creates a MissingArgsErr instance.

func (*MissingArgsErr) Error added in v0.5.0

func (e *MissingArgsErr) Error() string

type MockCommand added in v0.5.0

type MockCommand struct {
	// contains filtered or unexported fields
}

MockCommand is a mock command implementation. It allows you simulate running an external command.

func NewMockCommand added in v0.5.0

func NewMockCommand(path string) *MockCommand

NewMockCommand createsd a MockCommand.

func (*MockCommand) Run added in v0.5.0

func (c *MockCommand) Run(args ...string) ([]byte, error)

Run simulates the running of a command.

func (*MockCommand) Start added in v0.5.0

func (c *MockCommand) Start(args ...string) error

Start simulates starting a command.

func (*MockCommand) Stop added in v0.5.0

func (c *MockCommand) Stop() error

Stop simulates stoping a command.

type MockRunner added in v0.5.0

type MockRunner struct {
	Err error
}

MockRunner is an implemenation of Runner for mocking.

func (*MockRunner) Run added in v0.5.0

func (tr *MockRunner) Run() error

Run mock runs things.

type Version added in v1.0.0

type Version struct {
	Major, Minor, Patch int
	Name, Build, Label  string
}

Version is the version info for doit.

func (Version) Complete added in v1.0.0

func (v Version) Complete(lv LatestVersioner) string

Complete is the complete version for doit.

func (Version) String added in v1.0.0

func (v Version) String() string

Directories

Path Synopsis
cmd
do
pkg
ssh
units
Package units provides helper function to parse and print size and time units in human-readable format.
Package units provides helper function to parse and print size and time units in human-readable format.

Jump to

Keyboard shortcuts

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