Help us shape the future of Go! Take the 2026 Go Developer Survey

docli

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2015 License: BSD-3-Clause Imports: 14 Imported by: 0

README

DOCLI

Travis Build Status Coverage Status

DigitalOcean CLI client

NAME:
   docli - DigitalOcean API CLI

USAGE:
   docli [global options] command [command options] [arguments...]

COMMANDS:
   account              account commands
   action               action commands
   domain               domain commands
   droplet              droplet commands
   droplet-action       droplet action commands
   image-action         image action commands
   image                image commands
   region               region commands
   size                 size commands
   key                  ssh key commands
   help, h              Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --token              DigitalOcean API V2 Token [$DO_TOKEN]
   --debug              Debug
   --help, -h           show help
   --version, -v        print the version

Documentation

Index

Constants

View Source
const (
	ArgActionID          = "action-id"
	ArgDropletID         = "droplet-id"
	ArgDomainName        = "domain-name"
	ArgKernelID          = "kernel-id"
	ArgImage             = "image"
	ArgImageID           = "image-id"
	ArgImageSlug         = "image-slug"
	ArgIPAddress         = "ip-address"
	ArgDropletName       = "droplet-name"
	ArgResizeDisk        = "resize-disk"
	ArgSnapshotName      = "snapshot-name"
	ArgBackups           = "enable-backups"
	ArgIPv6              = "enable-ipv6"
	ArgPrivateNetworking = "enable-private-networking"
	ArgRecordData        = "record-data"
	ArgRecordID          = "record-id"
	ArgRecordName        = "record-name"
	ArgRecordPort        = "record-port"
	ArgRecordPriority    = "record-priority"
	ArgRecordType        = "record-type"
	ArgRecordWeight      = "record-weight"
	ArgRegionSlug        = "region"
	ArgSizeSlug          = "size"
	ArgSSHKeys           = "ssh-keys"
	ArgUserData          = "user-data"
	ArgImageName         = "image-name"
	ArgKey               = "key"
	ArgKeyName           = "key-name"
	ArgKeyPublicKey      = "public-key"
)

Variables

View Source
var (
	Bail func(err error, msg string)
)

Functions

func AccountGet

func AccountGet(c *cli.Context)

func ActionGet

func ActionGet(c *cli.Context)

func ActionList

func ActionList(c *cli.Context)

func DomainCreate

func DomainCreate(c *cli.Context)

func DomainDelete

func DomainDelete(c *cli.Context)

func DomainGet

func DomainGet(c *cli.Context)

func DomainList

func DomainList(c *cli.Context)

List lists all domains.

func DropletActionChangeKernel

func DropletActionChangeKernel(c *cli.Context)

ChangeKernel changes the kernel for a droplet.

func DropletActionDisableBackups

func DropletActionDisableBackups(c *cli.Context)

DisableBackups disables backups for a droplet.

func DropletActionEnableIPv6

func DropletActionEnableIPv6(c *cli.Context)

EnableIPv6 enables IPv6 for a droplet.

func DropletActionEnablePrivateNetworking

func DropletActionEnablePrivateNetworking(c *cli.Context)

EnablePrivateNetworking enables private networking for a droplet.

func DropletActionGet

func DropletActionGet(c *cli.Context)

Get returns a droplet action by id.

func DropletActionPasswordReset

func DropletActionPasswordReset(c *cli.Context)

PasswordReset resets the droplet root password.

func DropletActionPowerCycle

func DropletActionPowerCycle(c *cli.Context)

PowerCycle power cycles a droplet.

func DropletActionPowerOff

func DropletActionPowerOff(c *cli.Context)

PowerOff turns droplet power off.

func DropletActionPowerOn

func DropletActionPowerOn(c *cli.Context)

PowerOn turns droplet power on.

func DropletActionReboot

func DropletActionReboot(c *cli.Context)

Reboot reboots a droplet.

func DropletActionRebuild

func DropletActionRebuild(c *cli.Context)

Rebuild rebuilds a droplet using an image id or slug.

func DropletActionRename

func DropletActionRename(c *cli.Context)

Rename renames a droplet.

func DropletActionResize

func DropletActionResize(c *cli.Context)

Resize resizesx a droplet giving a size slug and optionally expands the disk.

func DropletActionRestore

func DropletActionRestore(c *cli.Context)

Restore restores a droplet using an image id.

func DropletActionShutdown

func DropletActionShutdown(c *cli.Context)

Shutdown shuts a droplet down.

func DropletActionSnapshot

func DropletActionSnapshot(c *cli.Context)

Snapshot creates a snapshot for a droplet.

func DropletActionUpgrade

func DropletActionUpgrade(c *cli.Context)

Upgrade upgrades a droplet.

func DropletActions

func DropletActions(c *cli.Context)

Actions returns a list of actions for a droplet.

func DropletBackups

func DropletBackups(c *cli.Context)

Backups returns a list of backup images for a droplet.

func DropletCreate

func DropletCreate(c *cli.Context)

Create creates a droplet.

func DropletDelete

func DropletDelete(c *cli.Context)

Delete destroy a droplet by id.

func DropletGet

func DropletGet(c *cli.Context)

Get returns a droplet.

func DropletKernels

func DropletKernels(c *cli.Context)

Kernels returns a list of available kernels for a droplet.

func DropletList

func DropletList(c *cli.Context)

List returns a list of droplets.

func DropletNeighbors

func DropletNeighbors(c *cli.Context)

Neighbors returns a list of droplet neighbors.

func DropletSnapshots

func DropletSnapshots(c *cli.Context)

Snapshots returns a list of available kernels for a droplet.

func ErrWithUsage

func ErrWithUsage(c *cli.Context, msg string)

func ImageActionsGet

func ImageActionsGet(c *cli.Context)

Get retrieves an action for an image.

func ImageActionsTransfer

func ImageActionsTransfer(c *cli.Context)

Tranfer an image.

func ImagesDelete

func ImagesDelete(c *cli.Context)

func ImagesGet

func ImagesGet(c *cli.Context)

Get retrieves an image by id or slug.

func ImagesList

func ImagesList(c *cli.Context)

List images.

func ImagesListApplication

func ImagesListApplication(c *cli.Context)

ListApplication lists application iamges.

func ImagesListDistribution

func ImagesListDistribution(c *cli.Context)

ListDistribution lists distributions that are available.

func ImagesListUser

func ImagesListUser(c *cli.Context)

ListUser lists user images.

func ImagesUpdate

func ImagesUpdate(c *cli.Context)

Update updates an image.

func KeyCreate

func KeyCreate(c *cli.Context)

Create uploads a SSH key.

func KeyDelete

func KeyDelete(c *cli.Context)

func KeyGet

func KeyGet(c *cli.Context)

func KeyList

func KeyList(c *cli.Context)

func KeyUpdate

func KeyUpdate(c *cli.Context)

func NewClient

func NewClient(c *cli.Context, cs Config) *godo.Client

NewClient creates a Client.

func PaginateResp

func PaginateResp(gen Generator, opts *Opts) ([]interface{}, error)

PaginateResp paginates a Response.

func RecordCreate

func RecordCreate(c *cli.Context)

func RecordDelete

func RecordDelete(c *cli.Context)

func RecordGet

func RecordGet(c *cli.Context)

Retrieve a domain record.

func RecordList

func RecordList(c *cli.Context)

List records for a domain.

func RecordUpdate

func RecordUpdate(c *cli.Context)

func RegionList

func RegionList(c *cli.Context)

List all regions.

func SSH

func SSH(c *cli.Context)

SSH finds a droplet to ssh to given input parameters (name or id).

func SizeList

func SizeList(c *cli.Context)

List all sizes.

func WithinTest

func WithinTest(cs Config, fs *flag.FlagSet, fn func(*cli.Context))

func WriteJSON

func WriteJSON(item interface{}, w io.Writer) error

Types

type AccountServiceMock

type AccountServiceMock struct {
	GetFn func() (*godo.Account, *godo.Response, error)
}

func (*AccountServiceMock) Get

type ActionsServiceMock

type ActionsServiceMock struct {
	GetFn  func(id int) (*godo.Action, *godo.Response, error)
	ListFn func(opts *godo.ListOptions) ([]godo.Action, *godo.Response, error)
}

func (*ActionsServiceMock) Get

func (s *ActionsServiceMock) Get(id int) (*godo.Action, *godo.Response, error)

func (*ActionsServiceMock) List

type Config

type Config interface {
	NewClient(token string) *godo.Client
	SSH(user, host string) error
}

Config holds configuration values for commands. It currently contains a godo Client and a method for running SSH.

var DefaultConfig Config = &LiveConfig{}

DefaultConfig is the current configuration for the commands.

type DomainsServiceMock

type DomainsServiceMock struct {
	ListFn   func(opts *godo.ListOptions) ([]godo.Domain, *godo.Response, error)
	GetFn    func(string) (*godo.Domain, *godo.Response, error)
	CreateFn func(*godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error)
	DeleteFn func(string) (*godo.Response, error)

	RecordsFn      func(string, *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error)
	RecordFn       func(string, int) (*godo.DomainRecord, *godo.Response, error)
	DeleteRecordFn func(string, int) (*godo.Response, error)
	EditRecordFn   func(string, int, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error)
	CreateRecordFn func(string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error)
}

func (*DomainsServiceMock) Create

func (*DomainsServiceMock) CreateRecord

func (*DomainsServiceMock) Delete

func (s *DomainsServiceMock) Delete(name string) (*godo.Response, error)

func (*DomainsServiceMock) DeleteRecord

func (s *DomainsServiceMock) DeleteRecord(name string, id int) (*godo.Response, error)

func (*DomainsServiceMock) EditRecord

func (*DomainsServiceMock) Get

func (s *DomainsServiceMock) Get(name string) (*godo.Domain, *godo.Response, error)

func (*DomainsServiceMock) List

func (*DomainsServiceMock) Record

func (s *DomainsServiceMock) Record(name string, id int) (*godo.DomainRecord, *godo.Response, error)

func (*DomainsServiceMock) Records

func (s *DomainsServiceMock) Records(name string, opts *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error)

type DropletActionsServiceMock

type DropletActionsServiceMock struct {
	ChangeKernelFn            func(id, kernelID int) (*godo.Action, *godo.Response, error)
	DisableBackupsFn          func(id int) (*godo.Action, *godo.Response, error)
	EnableIPv6Fn              func(id int) (*godo.Action, *godo.Response, error)
	EnablePrivateNetworkingFn func(id int) (*godo.Action, *godo.Response, error)
	GetFn                     func(dropletID, actionID int) (*godo.Action, *godo.Response, error)
	GetByURIFn                func(rawurl string) (*godo.Action, *godo.Response, error)
	PasswordResetFn           func(id int) (*godo.Action, *godo.Response, error)
	PowerCycleFn              func(id int) (*godo.Action, *godo.Response, error)
	PowerOffFn                func(id int) (*godo.Action, *godo.Response, error)
	PowerOnFn                 func(id int) (*godo.Action, *godo.Response, error)
	RebootFn                  func(id int) (*godo.Action, *godo.Response, error)
	RebuildByImageIDFn        func(id, imageID int) (*godo.Action, *godo.Response, error)
	RebuildByImageSlugFn      func(id int, slug string) (*godo.Action, *godo.Response, error)
	RenameFn                  func(id int, name string) (*godo.Action, *godo.Response, error)
	ResizeFn                  func(id int, sizeSlug string, resizeDisk bool) (*godo.Action, *godo.Response, error)
	RestoreFn                 func(id, imageID int) (*godo.Action, *godo.Response, error)
	ShutdownFn                func(id int) (*godo.Action, *godo.Response, error)
	SnapshotFn                func(id int, name string) (*godo.Action, *godo.Response, error)
	UpgradeFn                 func(id int) (*godo.Action, *godo.Response, error)
}

func (*DropletActionsServiceMock) ChangeKernel

func (s *DropletActionsServiceMock) ChangeKernel(id, kernelID int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) DisableBackups

func (s *DropletActionsServiceMock) DisableBackups(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) EnableIPv6

func (s *DropletActionsServiceMock) EnableIPv6(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) EnablePrivateNetworking

func (s *DropletActionsServiceMock) EnablePrivateNetworking(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Get

func (s *DropletActionsServiceMock) Get(dropletID, actionID int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) GetByURI

func (s *DropletActionsServiceMock) GetByURI(rawurl string) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) PasswordReset

func (s *DropletActionsServiceMock) PasswordReset(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) PowerCycle

func (s *DropletActionsServiceMock) PowerCycle(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) PowerOff

func (s *DropletActionsServiceMock) PowerOff(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) PowerOn

func (*DropletActionsServiceMock) Reboot

func (*DropletActionsServiceMock) RebuildByImageID

func (s *DropletActionsServiceMock) RebuildByImageID(id, imageID int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) RebuildByImageSlug

func (s *DropletActionsServiceMock) RebuildByImageSlug(id int, slug string) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Rename

func (s *DropletActionsServiceMock) Rename(id int, name string) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Resize

func (s *DropletActionsServiceMock) Resize(id int, sizeSlug string, resizeDisk bool) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Restore

func (s *DropletActionsServiceMock) Restore(id, imageID int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Shutdown

func (s *DropletActionsServiceMock) Shutdown(id int) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Snapshot

func (s *DropletActionsServiceMock) Snapshot(id int, name string) (*godo.Action, *godo.Response, error)

func (*DropletActionsServiceMock) Upgrade

type DropletsServiceMock

type DropletsServiceMock struct {
	ActionsFn   func(dropletID int, opt *godo.ListOptions) ([]godo.Action, *godo.Response, error)
	BackupsFn   func(dropletID int, opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)
	CreateFn    func(createRequest *godo.DropletCreateRequest) (*godo.Droplet, *godo.Response, error)
	DeleteFn    func(dropletID int) (*godo.Response, error)
	GetFn       func(dropletID int) (*godo.Droplet, *godo.Response, error)
	KernelsFn   func(dropletID int, opt *godo.ListOptions) ([]godo.Kernel, *godo.Response, error)
	ListFn      func(opt *godo.ListOptions) ([]godo.Droplet, *godo.Response, error)
	NeighborsFn func(dropletID int) ([]godo.Droplet, *godo.Response, error)
	SnapshotsFn func(dropletID int, opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)
}

func (*DropletsServiceMock) Actions

func (s *DropletsServiceMock) Actions(dropletID int, opt *godo.ListOptions) ([]godo.Action, *godo.Response, error)

func (*DropletsServiceMock) Backups

func (s *DropletsServiceMock) Backups(dropletID int, opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)

func (*DropletsServiceMock) Create

func (s *DropletsServiceMock) Create(createRequest *godo.DropletCreateRequest) (*godo.Droplet, *godo.Response, error)

func (*DropletsServiceMock) Delete

func (s *DropletsServiceMock) Delete(dropletID int) (*godo.Response, error)

func (*DropletsServiceMock) Get

func (s *DropletsServiceMock) Get(dropletID int) (*godo.Droplet, *godo.Response, error)

func (*DropletsServiceMock) Kernels

func (s *DropletsServiceMock) Kernels(dropletID int, opt *godo.ListOptions) ([]godo.Kernel, *godo.Response, error)

func (*DropletsServiceMock) List

func (*DropletsServiceMock) Neighbors

func (s *DropletsServiceMock) Neighbors(dropletID int) ([]godo.Droplet, *godo.Response, error)

func (*DropletsServiceMock) Snapshots

func (s *DropletsServiceMock) Snapshots(dropletID int, opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)

type Generator

type Generator func(*godo.ListOptions) ([]interface{}, *godo.Response, error)

Generator is a function that generates the list to be paginated.

type ImageActionsServiceMock

type ImageActionsServiceMock struct {
	GetFn      func(imageID, actionID int) (*godo.Action, *godo.Response, error)
	TransferFn func(imageID int, transferRequest *godo.ActionRequest) (*godo.Action, *godo.Response, error)
}

func (*ImageActionsServiceMock) Get

func (s *ImageActionsServiceMock) Get(imageID, actionID int) (*godo.Action, *godo.Response, error)

func (*ImageActionsServiceMock) Transfer

func (s *ImageActionsServiceMock) Transfer(imageID int, transferRequest *godo.ActionRequest) (*godo.Action, *godo.Response, error)

type ImagesServiceMock

type ImagesServiceMock struct {
	ListFn             func(*godo.ListOptions) ([]godo.Image, *godo.Response, error)
	ListDistributionFn func(opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)
	ListApplicationFn  func(opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)
	ListUserFn         func(opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)
	GetByIDFn          func(int) (*godo.Image, *godo.Response, error)
	GetBySlugFn        func(string) (*godo.Image, *godo.Response, error)
	UpdateFn           func(int, *godo.ImageUpdateRequest) (*godo.Image, *godo.Response, error)
	DeleteFn           func(int) (*godo.Response, error)
}

func (*ImagesServiceMock) Delete

func (s *ImagesServiceMock) Delete(id int) (*godo.Response, error)

func (*ImagesServiceMock) GetByID

func (s *ImagesServiceMock) GetByID(id int) (*godo.Image, *godo.Response, error)

func (*ImagesServiceMock) GetBySlug

func (s *ImagesServiceMock) GetBySlug(slug string) (*godo.Image, *godo.Response, error)

func (*ImagesServiceMock) List

func (*ImagesServiceMock) ListApplication

func (s *ImagesServiceMock) ListApplication(opts *godo.ListOptions) ([]godo.Image, *godo.Response, error)

func (*ImagesServiceMock) ListDistribution

func (s *ImagesServiceMock) ListDistribution(opts *godo.ListOptions) ([]godo.Image, *godo.Response, error)

func (*ImagesServiceMock) ListUser

func (s *ImagesServiceMock) ListUser(opts *godo.ListOptions) ([]godo.Image, *godo.Response, error)

func (*ImagesServiceMock) Update

type KeysServiceMock

type KeysServiceMock struct {
	ListFn                func(*godo.ListOptions) ([]godo.Key, *godo.Response, error)
	GetByIDFn             func(int) (*godo.Key, *godo.Response, error)
	GetByFingerprintFn    func(string) (*godo.Key, *godo.Response, error)
	CreateFn              func(*godo.KeyCreateRequest) (*godo.Key, *godo.Response, error)
	UpdateByIDFn          func(int, *godo.KeyUpdateRequest) (*godo.Key, *godo.Response, error)
	UpdateByFingerprintFn func(string, *godo.KeyUpdateRequest) (*godo.Key, *godo.Response, error)
	DeleteByIDFn          func(int) (*godo.Response, error)
	DeleteByFingerprintFn func(string) (*godo.Response, error)
}

func (*KeysServiceMock) Create

func (*KeysServiceMock) DeleteByFingerprint

func (s *KeysServiceMock) DeleteByFingerprint(fingerprint string) (*godo.Response, error)

func (*KeysServiceMock) DeleteByID

func (s *KeysServiceMock) DeleteByID(id int) (*godo.Response, error)

func (*KeysServiceMock) GetByFingerprint

func (s *KeysServiceMock) GetByFingerprint(fingerprint string) (*godo.Key, *godo.Response, error)

func (*KeysServiceMock) GetByID

func (s *KeysServiceMock) GetByID(id int) (*godo.Key, *godo.Response, error)

func (*KeysServiceMock) List

func (s *KeysServiceMock) List(opts *godo.ListOptions) ([]godo.Key, *godo.Response, error)

func (*KeysServiceMock) UpdateByFingerprint

func (s *KeysServiceMock) UpdateByFingerprint(fingerprint string, req *godo.KeyUpdateRequest) (*godo.Key, *godo.Response, error)

func (*KeysServiceMock) UpdateByID

func (s *KeysServiceMock) UpdateByID(id int, req *godo.KeyUpdateRequest) (*godo.Key, *godo.Response, error)

type LiveConfig

type LiveConfig struct{}

LiveConfig

func (*LiveConfig) NewClient

func (cs *LiveConfig) NewClient(token string) *godo.Client

NewClient creates creates a godo.Client givent a token.

func (*LiveConfig) SSH

func (cs *LiveConfig) SSH(user, host string) error

SSH runs the ssh binary given a user and a host. It preserves stdin, stdout, and stderr.

type Opts

type Opts struct {
	Debug bool
}

func LoadOpts

func LoadOpts(c *cli.Context) *Opts

type RegionsServiceMock

type RegionsServiceMock struct {
	ListFn func(opts *godo.ListOptions) ([]godo.Region, *godo.Response, error)
}

func (*RegionsServiceMock) List

type SizesServiceMock

type SizesServiceMock struct {
	ListFn func(opts *godo.ListOptions) ([]godo.Size, *godo.Response, error)
}

func (*SizesServiceMock) List

func (s *SizesServiceMock) List(opts *godo.ListOptions) ([]godo.Size, *godo.Response, error)

type TestConfig

type TestConfig struct {
	Client *godo.Client
	SSHFn  func(user, host string) error
}

TestConfig is an implemenation of Config that can be inspected during tests.

func NewTestConfig

func NewTestConfig(client *godo.Client) *TestConfig

NewTestConfig creates a TestConfig.

func (*TestConfig) NewClient

func (cs *TestConfig) NewClient(_ string) *godo.Client

NewClient returns the specified godo.Client.

func (*TestConfig) SSH

func (cs *TestConfig) SSH(user, host string) error

SSH allows the developer to inspect the status of the ssh connection during tests.

type TokenSource

type TokenSource struct {
	AccessToken string
}

func (*TokenSource) Token

func (t *TokenSource) Token() (*oauth2.Token, error)

Directories

Path Synopsis
cmd
docli command

Jump to

Keyboard shortcuts

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