base

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	BaseCobraCommand func(hcapi2.Client) *cobra.Command
	Run              func(context.Context, hcapi2.Client, state.ActionWaiter, *cobra.Command, []string) error
}

Cmd allows defining commands for generic resource-based commands

func (*Cmd) CobraCommand

func (gc *Cmd) CobraCommand(
	ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer, actionWaiter state.ActionWaiter,
) *cobra.Command

CobraCommand creates a command that can be registered with cobra.

type DescribeCmd

type DescribeCmd struct {
	ResourceNameSingular string // e.g. "server"
	ShortDescription     string
	// key in API response JSON to use for extracting object from response body for JSON output.
	JSONKeyGetByID   string // e.g. "server"
	JSONKeyGetByName string // e.g. "servers"
	NameSuggestions  func(client hcapi2.Client) func() []string
	Fetch            func(ctx context.Context, client hcapi2.Client, idOrName string) (interface{}, *hcloud.Response, error)
	PrintText        func(ctx context.Context, client hcapi2.Client, resource interface{}) error
}

DescribeCmd allows defining commands for describing a resource.

func (*DescribeCmd) CobraCommand

func (dc *DescribeCmd) CobraCommand(
	ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer,
) *cobra.Command

CobraCommand creates a command that can be registered with cobra.

func (*DescribeCmd) Run

func (dc *DescribeCmd) Run(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, args []string) error

Run executes a describe command.

type LabelCmds

type LabelCmds struct {
	ResourceNameSingular   string
	ShortDescriptionAdd    string
	ShortDescriptionRemove string
	NameSuggestions        func(client hcapi2.Client) func() []string
	LabelKeySuggestions    func(client hcapi2.Client) func(idOrName string) []string
	FetchLabels            func(ctx context.Context, client hcapi2.Client, idOrName string) (map[string]string, int, error)
	SetLabels              func(ctx context.Context, client hcapi2.Client, id int, labels map[string]string) error
}

LabelCmds allows defining commands for adding labels to resources.

func (*LabelCmds) AddCobraCommand

func (lc *LabelCmds) AddCobraCommand(
	ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer,
) *cobra.Command

AddCobraCommand creates a command that can be registered with cobra.

func (*LabelCmds) RemoveCobraCommand

func (lc *LabelCmds) RemoveCobraCommand(
	ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer,
) *cobra.Command

RemoveCobraCommand creates a command that can be registered with cobra.

func (*LabelCmds) RunAdd

func (lc *LabelCmds) RunAdd(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, args []string) error

RunAdd executes an add label command

func (*LabelCmds) RunRemove

func (lc *LabelCmds) RunRemove(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, args []string) error

RunRemove executes a remove label command

type ListCmd

type ListCmd struct {
	ResourceNamePlural string // e.g. "servers"
	DefaultColumns     []string
	Fetch              func(context.Context, hcapi2.Client, hcloud.ListOpts) ([]interface{}, error)
	OutputTable        func(client hcapi2.Client) *output.Table
	JSONSchema         func([]interface{}) interface{}
}

ListCmd allows defining commands for listing resources

func (*ListCmd) CobraCommand

func (lc *ListCmd) CobraCommand(
	ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer,
) *cobra.Command

CobraCommand creates a command that can be registered with cobra.

func (*ListCmd) Run

func (lc *ListCmd) Run(ctx context.Context, client hcapi2.Client, cmd *cobra.Command) error

Run executes a list command

Jump to

Keyboard shortcuts

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