commands

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//DoitCmd is the root level bl command that all other commands attach to
	DoitCmd = &Command{
		Command: &cobra.Command{
			Use:   "bl",
			Short: "bl is a command line interface (CLI) for the BinaryLane API.",
		},
	}

	//Writer wires up stdout for all commands to write to
	Writer = os.Stdout
	//APIURL customize API base URL
	APIURL string
	//Context current auth context
	Context string
	//Output global output format
	Output string
	//Token global authorization token
	Token string
	//Trace toggles http tracing output
	Trace bool
)
View Source
var (
	ErrUnknownTerminal = errors.New("unknown terminal")
)

ErrUnknownTerminal signifies an unknown terminal. It is returned when doit can't ascertain the current terminal type with requesting an auth token.

Functions

func AddBoolFlag

func AddBoolFlag(cmd *Command, name, shorthand string, def bool, desc string, opts ...flagOpt)

AddBoolFlag adds a boolean flag to a command.

func AddIntFlag

func AddIntFlag(cmd *Command, name, shorthand string, def int, desc string, opts ...flagOpt)

AddIntFlag adds an integr flag to a command.

func AddStringFlag

func AddStringFlag(cmd *Command, name, shorthand, dflt, desc string, opts ...flagOpt)

AddStringFlag adds a string flag to a command.

func AddStringMapStringFlag

func AddStringMapStringFlag(cmd *Command, name, shorthand string, def map[string]string, desc string, opts ...flagOpt)

AddStringMapStringFlag adds a map of strings by strings flag to a command.

func AddStringSliceFlag

func AddStringSliceFlag(cmd *Command, name, shorthand string, def []string, desc string, opts ...flagOpt)

AddStringSliceFlag adds a string slice flag to a command.

func AskForConfirm

func AskForConfirm(message string) error

AskForConfirm parses and verifies user input for confirmation.

func AskForConfirmDelete

func AskForConfirmDelete(resourceType string, count int) error

AskForConfirmDelete builds a message to ask the user to confirm deleteing one or multiple resources and then sends it through to AskForConfirm to parses and verifies user input.

func Execute

func Execute()

Execute executes the current command using DoitCmd.

func RunAccountGet

func RunAccountGet(c *CmdConfig) error

RunAccountGet runs account get.

func RunAccountRateLimit

func RunAccountRateLimit(c *CmdConfig) error

RunAccountRateLimit retrieves API rate limits for the account.

func RunAuthInit

func RunAuthInit(retrieveUserTokenFunc func() (string, error)) func(c *CmdConfig) error

RunAuthInit initializes the bl config. Configuration is stored in $XDG_CONFIG_HOME/bl. On Unix, if XDG_CONFIG_HOME is not set, use $HOME/.config. On Windows use %APPDATA%/bl/config.

func RunAuthList

func RunAuthList(c *CmdConfig) error

RunAuthList lists all available auth contexts from the user's bl config.

func RunAuthSwitch

func RunAuthSwitch(c *CmdConfig) error

RunAuthSwitch changes the default context and writes it to the configuration.

func RunBalanceGet

func RunBalanceGet(c *CmdConfig) error

RunBalanceGet runs balance get.

func RunBillingHistoryList

func RunBillingHistoryList(c *CmdConfig) error

RunBillingHistoryList runs invoice list.

func RunCmdActionGet

func RunCmdActionGet(c *CmdConfig) error

RunCmdActionGet runs action get.

func RunCmdActionList

func RunCmdActionList(c *CmdConfig) error

RunCmdActionList run action list.

func RunCmdActionWait

func RunCmdActionWait(c *CmdConfig) error

RunCmdActionWait waits for an action to complete or error.

func RunCmdTagCreate

func RunCmdTagCreate(c *CmdConfig) error

RunCmdTagCreate runs tag create.

func RunCmdTagDelete

func RunCmdTagDelete(c *CmdConfig) error

RunCmdTagDelete runs tag delete.

func RunCmdTagGet

func RunCmdTagGet(c *CmdConfig) error

RunCmdTagGet runs tag get.

func RunCmdTagList

func RunCmdTagList(c *CmdConfig) error

RunCmdTagList runs tag list.

func RunCompletionBash

func RunCompletionBash(c *CmdConfig) error

RunCompletionBash outputs completion code for bash.

func RunCompletionZsh

func RunCompletionZsh(c *CmdConfig) error

RunCompletionZsh outputs completion code for zsh shell.

func RunDomainCreate

func RunDomainCreate(c *CmdConfig) error

RunDomainCreate runs domain create.

func RunDomainDelete

func RunDomainDelete(c *CmdConfig) error

RunDomainDelete deletes a domain by name.

func RunDomainGet

func RunDomainGet(c *CmdConfig) error

RunDomainGet retrieves a domain by name.

func RunDomainList

func RunDomainList(c *CmdConfig) error

RunDomainList runs domain create.

func RunFirewallAddRules

func RunFirewallAddRules(c *CmdConfig) error

RunFirewallAddRules adds rules to a Firewall.

func RunFirewallAddServers

func RunFirewallAddServers(c *CmdConfig) error

RunFirewallAddServers adds servers to a Firewall.

func RunFirewallAddTags

func RunFirewallAddTags(c *CmdConfig) error

RunFirewallAddTags adds tags to a Firewall.

func RunFirewallCreate

func RunFirewallCreate(c *CmdConfig) error

RunFirewallCreate creates a new Firewall with a given configuration.

func RunFirewallDelete

func RunFirewallDelete(c *CmdConfig) error

RunFirewallDelete deletes a Firewall by its identifier.

func RunFirewallGet

func RunFirewallGet(c *CmdConfig) error

RunFirewallGet retrieves an existing Firewall by its identifier.

func RunFirewallList

func RunFirewallList(c *CmdConfig) error

RunFirewallList lists Firewalls.

func RunFirewallListByServer

func RunFirewallListByServer(c *CmdConfig) error

RunFirewallListByServer lists Firewalls for a given Server.

func RunFirewallRemoveRules

func RunFirewallRemoveRules(c *CmdConfig) error

RunFirewallRemoveRules removes rules from a Firewall.

func RunFirewallRemoveServers

func RunFirewallRemoveServers(c *CmdConfig) error

RunFirewallRemoveServers removes servers from a Firewall.

func RunFirewallRemoveTags

func RunFirewallRemoveTags(c *CmdConfig) error

RunFirewallRemoveTags removes tags from a Firewall.

func RunFirewallUpdate

func RunFirewallUpdate(c *CmdConfig) error

RunFirewallUpdate updates an existing Firewall with new configuration.

func RunFloatingIPActionsAssign

func RunFloatingIPActionsAssign(c *CmdConfig) error

RunFloatingIPActionsAssign assigns a floating IP to a server.

func RunFloatingIPActionsGet

func RunFloatingIPActionsGet(c *CmdConfig) error

RunFloatingIPActionsGet retrieves an action for a floating IP.

func RunFloatingIPActionsUnassign

func RunFloatingIPActionsUnassign(c *CmdConfig) error

RunFloatingIPActionsUnassign unassigns a floating IP to a server.

func RunFloatingIPCreate

func RunFloatingIPCreate(c *CmdConfig) error

RunFloatingIPCreate runs floating IP create.

func RunFloatingIPDelete

func RunFloatingIPDelete(c *CmdConfig) error

RunFloatingIPDelete runs floating IP delete.

func RunFloatingIPGet

func RunFloatingIPGet(c *CmdConfig) error

RunFloatingIPGet retrieves a floating IP's details.

func RunFloatingIPList

func RunFloatingIPList(c *CmdConfig) error

RunFloatingIPList runs floating IP create.

func RunImageActionsGet

func RunImageActionsGet(c *CmdConfig) error

RunImageActionsGet retrieves an action for an image.

func RunImageActionsTransfer

func RunImageActionsTransfer(c *CmdConfig) error

RunImageActionsTransfer an image.

func RunImagesCreate

func RunImagesCreate(c *CmdConfig) error

RunImagesCreate creates a new custom image.

func RunImagesDelete

func RunImagesDelete(c *CmdConfig) error

RunImagesDelete deletes an image.

func RunImagesGet

func RunImagesGet(c *CmdConfig) error

RunImagesGet retrieves an image by id or slug.

func RunImagesList

func RunImagesList(c *CmdConfig) error

RunImagesList images.

func RunImagesListApplication

func RunImagesListApplication(c *CmdConfig) error

RunImagesListApplication lists application iamges.

func RunImagesListDistribution

func RunImagesListDistribution(c *CmdConfig) error

RunImagesListDistribution lists distributions that are available.

func RunImagesListUser

func RunImagesListUser(c *CmdConfig) error

RunImagesListUser lists user images.

func RunImagesUpdate

func RunImagesUpdate(c *CmdConfig) error

RunImagesUpdate updates an image.

func RunInvoicesGet

func RunInvoicesGet(c *CmdConfig) error

RunInvoicesGet runs invoice get.

func RunInvoicesGetCSV

func RunInvoicesGetCSV(c *CmdConfig) error

RunInvoicesGetCSV runs an invoice get csv.

func RunInvoicesGetPDF

func RunInvoicesGetPDF(c *CmdConfig) error

RunInvoicesGetPDF runs an invoice get pdf.

func RunInvoicesList

func RunInvoicesList(c *CmdConfig) error

RunInvoicesList runs invoice list.

func RunInvoicesSummary

func RunInvoicesSummary(c *CmdConfig) error

RunInvoicesSummary runs an invoice summary.

func RunKeyCreate

func RunKeyCreate(c *CmdConfig) error

RunKeyCreate uploads a SSH key.

func RunKeyDelete

func RunKeyDelete(c *CmdConfig) error

RunKeyDelete deletes a key.

func RunKeyGet

func RunKeyGet(c *CmdConfig) error

RunKeyGet retrieves a key.

func RunKeyImport

func RunKeyImport(c *CmdConfig) error

RunKeyImport imports a key from a file

func RunKeyList

func RunKeyList(c *CmdConfig) error

RunKeyList lists keys.

func RunKeyUpdate

func RunKeyUpdate(c *CmdConfig) error

RunKeyUpdate updates a key.

func RunLoadBalancerAddForwardingRules

func RunLoadBalancerAddForwardingRules(c *CmdConfig) error

RunLoadBalancerAddForwardingRules adds forwarding rules to a load balancer.

func RunLoadBalancerAddServers

func RunLoadBalancerAddServers(c *CmdConfig) error

RunLoadBalancerAddServers adds servers to a load balancer.

func RunLoadBalancerCreate

func RunLoadBalancerCreate(c *CmdConfig) error

RunLoadBalancerCreate creates a new load balancer with a given configuration.

func RunLoadBalancerDelete

func RunLoadBalancerDelete(c *CmdConfig) error

RunLoadBalancerDelete deletes a load balancer by its identifier.

func RunLoadBalancerGet

func RunLoadBalancerGet(c *CmdConfig) error

RunLoadBalancerGet retrieves an existing load balancer by its identifier.

func RunLoadBalancerList

func RunLoadBalancerList(c *CmdConfig) error

RunLoadBalancerList lists load balancers.

func RunLoadBalancerRemoveForwardingRules

func RunLoadBalancerRemoveForwardingRules(c *CmdConfig) error

RunLoadBalancerRemoveForwardingRules removes forwarding rules from a load balancer.

func RunLoadBalancerRemoveServers

func RunLoadBalancerRemoveServers(c *CmdConfig) error

RunLoadBalancerRemoveServers removes servers from a load balancer.

func RunLoadBalancerUpdate

func RunLoadBalancerUpdate(c *CmdConfig) error

RunLoadBalancerUpdate updates an existing load balancer with new configuration.

func RunPluginList

func RunPluginList(c *CmdConfig) error

RunPluginList is a command for listing available plugins.

func RunPluginRun

func RunPluginRun(c *CmdConfig) error

RunPluginRun is a command for running a plugin.

func RunProjectResourcesAssign

func RunProjectResourcesAssign(c *CmdConfig) error

RunProjectResourcesAssign assigns a Project Resource.

func RunProjectResourcesGet

func RunProjectResourcesGet(c *CmdConfig) error

RunProjectResourcesGet retrieves a Project Resource.

func RunProjectResourcesList

func RunProjectResourcesList(c *CmdConfig) error

RunProjectResourcesList lists the Projects.

func RunProjectsCreate

func RunProjectsCreate(c *CmdConfig) error

RunProjectsCreate creates a new Project with a given configuration.

func RunProjectsDelete

func RunProjectsDelete(c *CmdConfig) error

RunProjectsDelete deletes a Project with a given configuration.

func RunProjectsGet

func RunProjectsGet(c *CmdConfig) error

RunProjectsGet retrieves an existing Project by its identifier. Use "default" as an identifier to retrieve your default project.

func RunProjectsList

func RunProjectsList(c *CmdConfig) error

RunProjectsList lists Projects.

func RunProjectsUpdate

func RunProjectsUpdate(c *CmdConfig) error

RunProjectsUpdate updates an existing Project with a given configuration.

func RunRecordCreate

func RunRecordCreate(c *CmdConfig) error

RunRecordCreate creates a domain record.

func RunRecordDelete

func RunRecordDelete(c *CmdConfig) error

RunRecordDelete deletes a domain record.

func RunRecordList

func RunRecordList(c *CmdConfig) error

RunRecordList list records for a domain.

func RunRecordUpdate

func RunRecordUpdate(c *CmdConfig) error

RunRecordUpdate updates a domain record.

func RunRegionList

func RunRegionList(c *CmdConfig) error

RunRegionList all regions.

func RunSSH

func RunSSH(c *CmdConfig) error

RunSSH finds a server to ssh to given input parameters (name or id).

func RunServerActionChangeKernel

func RunServerActionChangeKernel(c *CmdConfig) error

RunServerActionChangeKernel changes the kernel for a server.

func RunServerActionDisableBackups

func RunServerActionDisableBackups(c *CmdConfig) error

RunServerActionDisableBackups disables backups for a server.

func RunServerActionEnableBackups

func RunServerActionEnableBackups(c *CmdConfig) error

RunServerActionEnableBackups disables backups for a server.

func RunServerActionEnableIPv6

func RunServerActionEnableIPv6(c *CmdConfig) error

RunServerActionEnableIPv6 enables IPv6 for a server.

func RunServerActionEnablePrivateNetworking

func RunServerActionEnablePrivateNetworking(c *CmdConfig) error

RunServerActionEnablePrivateNetworking enables private networking for a server.

func RunServerActionGet

func RunServerActionGet(c *CmdConfig) error

RunServerActionGet returns a server action by id.

func RunServerActionPasswordReset

func RunServerActionPasswordReset(c *CmdConfig) error

RunServerActionPasswordReset resets the server root password.

func RunServerActionPowerCycle

func RunServerActionPowerCycle(c *CmdConfig) error

RunServerActionPowerCycle power cycles a server.

func RunServerActionPowerOff

func RunServerActionPowerOff(c *CmdConfig) error

RunServerActionPowerOff turns server power off.

func RunServerActionPowerOn

func RunServerActionPowerOn(c *CmdConfig) error

RunServerActionPowerOn turns server power on.

func RunServerActionReboot

func RunServerActionReboot(c *CmdConfig) error

RunServerActionReboot reboots a server.

func RunServerActionRebuild

func RunServerActionRebuild(c *CmdConfig) error

RunServerActionRebuild rebuilds a server using an image id or slug.

func RunServerActionRename

func RunServerActionRename(c *CmdConfig) error

RunServerActionRename renames a server.

func RunServerActionResize

func RunServerActionResize(c *CmdConfig) error

RunServerActionResize resizes a server giving a size slug and optionally expands the disk.

func RunServerActionRestore

func RunServerActionRestore(c *CmdConfig) error

RunServerActionRestore restores a server using an image id.

func RunServerActionShutdown

func RunServerActionShutdown(c *CmdConfig) error

RunServerActionShutdown shuts a server down.

func RunServerActionSnapshot

func RunServerActionSnapshot(c *CmdConfig) error

RunServerActionSnapshot creates a snapshot for a server.

func RunServerActions

func RunServerActions(c *CmdConfig) error

RunServerActions returns a list of actions for a server.

func RunServerBackups

func RunServerBackups(c *CmdConfig) error

RunServerBackups returns a list of backup images for a server.

func RunServerCreate

func RunServerCreate(c *CmdConfig) error

RunServerCreate creates a server.

func RunServerDelete

func RunServerDelete(c *CmdConfig) error

RunServerDelete destroy a server by id.

func RunServerGet

func RunServerGet(c *CmdConfig) error

RunServerGet returns a server.

func RunServerKernels

func RunServerKernels(c *CmdConfig) error

RunServerKernels returns a list of available kernels for a server.

func RunServerList

func RunServerList(c *CmdConfig) error

RunServerList returns a list of servers.

func RunServerNeighbors

func RunServerNeighbors(c *CmdConfig) error

RunServerNeighbors returns a list of server neighbors.

func RunServerSnapshots

func RunServerSnapshots(c *CmdConfig) error

RunServerSnapshots returns a list of available snapshots for a server.

func RunServerTag

func RunServerTag(c *CmdConfig) error

RunServerTag adds a tag to a server.

func RunServerUntag

func RunServerUntag(c *CmdConfig) error

RunServerUntag untags a server.

func RunSizeList

func RunSizeList(c *CmdConfig) error

RunSizeList all sizes.

func RunSnapshotDelete

func RunSnapshotDelete(c *CmdConfig) error

RunSnapshotDelete destroys snapshot(s) by id

func RunSnapshotGet

func RunSnapshotGet(c *CmdConfig) error

RunSnapshotGet returns a snapshot

func RunSnapshotList

func RunSnapshotList(c *CmdConfig) error

RunSnapshotList returns a list of snapshots

func RunVPCCreate

func RunVPCCreate(c *CmdConfig) error

RunVPCCreate creates a new VPC with a given configuration.

func RunVPCDelete

func RunVPCDelete(c *CmdConfig) error

RunVPCDelete deletes a VPC by its identifier.

func RunVPCGet

func RunVPCGet(c *CmdConfig) error

RunVPCGet retrieves an existing VPC by its identifier.

func RunVPCList

func RunVPCList(c *CmdConfig) error

RunVPCList lists VPCs.

func RunVPCUpdate

func RunVPCUpdate(c *CmdConfig) error

RunVPCUpdate updates an existing VPC with new configuration.

Types

type CmdConfig

type CmdConfig struct {
	NS   string
	Doit blcli.Config
	Out  io.Writer
	Args []string

	// services
	Keys              func() bl.KeysService
	Sizes             func() bl.SizesService
	Regions           func() bl.RegionsService
	Images            func() bl.ImagesService
	ImageActions      func() bl.ImageActionsService
	LoadBalancers     func() bl.LoadBalancersService
	FloatingIPs       func() bl.FloatingIPsService
	FloatingIPActions func() bl.FloatingIPActionsService
	Servers           func() bl.ServersService
	ServerActions     func() bl.ServerActionsService
	Domains           func() bl.DomainsService
	Actions           func() bl.ActionsService
	Account           func() bl.AccountService
	Balance           func() bl.BalanceService
	BillingHistory    func() bl.BillingHistoryService
	Invoices          func() bl.InvoicesService
	Tags              func() bl.TagsService
	Snapshots         func() bl.SnapshotsService
	Firewalls         func() bl.FirewallsService
	Projects          func() bl.ProjectsService
	VPCs              func() bl.VPCsService
	// contains filtered or unexported fields
}

CmdConfig is a command configuration.

func NewCmdConfig

func NewCmdConfig(ns string, dc blcli.Config, out io.Writer, args []string, initClient bool) (*CmdConfig, error)

NewCmdConfig creates an instance of a CmdConfig.

func (*CmdConfig) Display

func (c *CmdConfig) Display(d displayers.Displayable) error

Display displays the output from a command.

type CmdRunner

type CmdRunner func(*CmdConfig) error

CmdRunner runs a command and passes in a cmdConfig.

type Command

type Command struct {
	*cobra.Command
	// contains filtered or unexported fields
}

Command is a wrapper around cobra.Command that adds bl specific functionality.

func Account

func Account() *Command

Account creates the account commands hierarchy.

func Actions

func Actions() *Command

Actions creates the action commands hierarchy.

func Auth

func Auth() *Command

Auth creates auth commands for bl-cli.

func Balance

func Balance() *Command

Balance creates the balance commands hierarchy.

func BillingHistory

func BillingHistory() *Command

BillingHistory creates the BillingHistory commands hierarchy.

func CmdBuilder

func CmdBuilder(parent *Command, cr CmdRunner, cliText, shortdesc string, longdesc string, out io.Writer, options ...cmdOption) *Command

CmdBuilder builds a new command.

func Completion

func Completion() *Command

Completion creates the completion command

func Domain

func Domain() *Command

Domain creates the domain commands hierarchy.

func Firewall

func Firewall() *Command

Firewall creates the firewall command.

func FloatingIP

func FloatingIP() *Command

FloatingIP creates the command hierarchy for floating ips.

func FloatingIPAction

func FloatingIPAction() *Command

FloatingIPAction creates the floating IP action command.

func ImageAction

func ImageAction() *Command

ImageAction creates the image action command.

func Images

func Images() *Command

Images creates an image command.

func Invoices

func Invoices() *Command

Invoices creates the invoices commands hierarchy.

func LoadBalancer

func LoadBalancer() *Command

LoadBalancer creates the load balancer command.

func Plugin

func Plugin() *Command

Plugin creates the plugin commands hierarchy.

func ProjectResourcesCmd

func ProjectResourcesCmd() *Command

ProjectResourcesCmd creates the project resources commands hierarchy.

func Projects

func Projects() *Command

Projects creates the projects commands hierarchy.

func Region

func Region() *Command

Region creates the region commands hierarchy.

func SSH

func SSH(parent *Command) *Command

SSH creates the ssh commands hierarchy

func SSHKeys

func SSHKeys() *Command

SSHKeys creates the ssh key commands hierarchy.

func Server

func Server() *Command

Server creates the server command.

func ServerAction

func ServerAction() *Command

ServerAction creates the server-action command.

func Size

func Size() *Command

Size creates the size commands hierarchy.

func Snapshot

func Snapshot() *Command

Snapshot creates the snapshot command

func Tags

func Tags() *Command

Tags creates the tag commands hierarchy.

func VPCs

func VPCs() *Command

VPCs creates the vpcs command.

func Version

func Version() *Command

Version creates a version command.

func (*Command) AddCommand

func (c *Command) AddCommand(commands ...*Command)

AddCommand adds child commands and adds child commands for cobra as well.

func (*Command) ChildCommands

func (c *Command) ChildCommands() []*Command

ChildCommands returns the child commands.

type UnknownSchemeError

type UnknownSchemeError struct {
	Scheme string
}

UnknownSchemeError signifies an unknown HTTP scheme.

func (*UnknownSchemeError) Error

func (use *UnknownSchemeError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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