digitalocean / doctl
- суббота, 7 мая 2016 г. в 03:13:36
Go
A command line tool for DigitalOcean services
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 formt [text|json] (default "text")
-v, --verbose verbose output
Use "doctl [command] --help" for more information about a command.
Currently, you can use Homebrew to install doctl
on Mac OS X by using the command below:
brew install doctl
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.)
You can download the archive from from your browser, or copy its URL and retrieve it to your home directory with wget
or curl
:
cd ~
wget https://github.com/digitalocean/doctl/releases/download/v1.0.0/doctl-1.0.0-linux-amd64.tar.gz
Or:
cd ~
curl -OL https://github.com/digitalocean/doctl/releases/download/v1.0.0/doctl-1.0.0-linux-amd64.tar.gz
Extract the binary. On GNU/Linux or OS X systems, you can use tar
:
tar xf doctl-1.0.0-linux-amd64.tar.gz
On Windows systems, you should be able to double-click the zip archive to extract the doctl
executable.
Move the doctl
binary to somewhere in your path. For example, on GNU/Linux and OS X systems:
sudo mv ./doctl /usr/local/bin
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
To automatically retrieve your access token from DigitalOcean, run doctl auth login
. This process will authenticate
you with DigitalOcean and retrieve an access token. If your shell does not have access to a web browser
(because of a remote Linux shell with no DISPLAY environment variable or you've specified the CLIAUTH=1 flag), doctl
will give you a link for offline authentication.
By default, doctl
will load a configuration file from $HOME/.doctlcfg
if found.
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
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>
doctl
's dependencies are managed by gvt. To add dependencies, use gvt fetch
.
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.