base

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENDPOINT      = "https://api.servers.com/v1"
	ErrNoContexts = "" /* 155-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func AddFormatFlags added in v0.3.0

func AddFormatFlags(cmd *cobra.Command)

func AddGlobalFlags

func AddGlobalFlags(cmd *cobra.Command)

func CheckEmptyContexts

func CheckEmptyContexts(cmdContext *CmdContext) func(cmd *cobra.Command, args []string) error

CheckEmptyContexts returns error if no contexts found

func CheckFormatterFlags added in v0.2.0

func CheckFormatterFlags(cmdContext *CmdContext, entities map[string]entities.EntityInterface) func(cmd *cobra.Command, args []string) error

CheckFormatterFlags checks flags related to formatter

func CombinePreRunE added in v0.2.0

func CombinePreRunE(funcs ...func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error

CombinePreRunE combines multiple pre-run functions into one

func InitCmdContext

func InitCmdContext(cmdContext *CmdContext) func(cmd *cobra.Command, args []string) error

InitCmdContext inits cmd context and sets up necessary dependencies

func NewListCmd

func NewListCmd[T any](use string, entityName string, colFactory CollectionFactory[T], cmdContext *CmdContext, opts ...ListOptions[T]) *cobra.Command

NewListCmd base list command for different collections

func NoArgs added in v0.3.2

func NoArgs(cmd *cobra.Command, args []string) error

func ParseLabels

func ParseLabels(labels []string) (map[string]string, error)

ParseLabels parses slice of labels and returns map expects that slice element would be: "foo=bar"

func ReadInputJSON

func ReadInputJSON(path string, in io.Reader, input any) error

ReadInputJSON reads input from file and unmarshals it into the given struct. If path is "-", it reads from stdin.

func SetupContext

func SetupContext(cmd *cobra.Command, manager *config.Manager) (context.Context, context.CancelFunc)

SetupContext returns context with timeout based on 'http-timeout' from config or cli flag

func SetupProxy

func SetupProxy(cmd *cobra.Command, manager *config.Manager)

SetupProxy setup proxy envs for client based on 'proxy' defined in config or cli flag

func SkeletonOrExactArgs added in v0.10.2

func SkeletonOrExactArgs(n int) cobra.PositionalArgs

func UsageRun added in v0.3.2

func UsageRun(cmd *cobra.Command, args []string)

func ValidateFlags added in v0.10.0

func ValidateFlags(cmd *cobra.Command, required []string) error

Types

type AdditionalOption added in v0.6.0

type AdditionalOption[T any] struct {
	// contains filtered or unexported fields
}

func (*AdditionalOption[T]) AddFlags added in v0.6.0

func (o *AdditionalOption[T]) AddFlags(cmd *cobra.Command)

func (*AdditionalOption[T]) ApplyToCollection added in v0.6.0

func (o *AdditionalOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type AllPager added in v0.4.0

type AllPager interface {
	AllPages() bool
}

type AttachedSubnetworksOption added in v0.6.0

type AttachedSubnetworksOption[T any] struct {
	// contains filtered or unexported fields
}

func (*AttachedSubnetworksOption[T]) AddFlags added in v0.6.0

func (o *AttachedSubnetworksOption[T]) AddFlags(cmd *cobra.Command)

func (*AttachedSubnetworksOption[T]) ApplyToCollection added in v0.6.0

func (o *AttachedSubnetworksOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type BandwidthTypeOption added in v0.6.0

type BandwidthTypeOption[T any] struct {
	// contains filtered or unexported fields
}

bandwidth type option

func (*BandwidthTypeOption[T]) AddFlags added in v0.6.0

func (o *BandwidthTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*BandwidthTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *BandwidthTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type BaseListOptions added in v0.3.0

type BaseListOptions[T any] struct {
	// contains filtered or unexported fields
}

BaseListOptions is a base options struct for list commands

func (*BaseListOptions[T]) AddFlags added in v0.3.0

func (o *BaseListOptions[T]) AddFlags(cmd *cobra.Command)

AddFlags adds common list flags to the command

func (*BaseListOptions[T]) AllPages added in v0.3.0

func (o *BaseListOptions[T]) AllPages() bool

AllPages returns true if all pages should be retrieved

func (*BaseListOptions[T]) ApplyToCollection added in v0.3.0

func (o *BaseListOptions[T]) ApplyToCollection(collection serverscom.Collection[T])

ApplyToCollection applies the options to a collection

type ClusterIDOption added in v0.4.0

type ClusterIDOption[T any] struct {
	// contains filtered or unexported fields
}

cluster id option

func (*ClusterIDOption[T]) AddFlags added in v0.4.0

func (o *ClusterIDOption[T]) AddFlags(cmd *cobra.Command)

func (*ClusterIDOption[T]) ApplyToCollection added in v0.4.0

func (o *ClusterIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type CmdContext

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

CmdContext represents the context for a command

func NewCmdContext

func NewCmdContext(manager *config.Manager, client *client.Client) *CmdContext

NewCmdContext creates new cmd context with specified manager and client

func (*CmdContext) GetClient

func (c *CmdContext) GetClient() *client.Client

GetClient returns the client from cmd context

func (*CmdContext) GetManager

func (c *CmdContext) GetManager() *config.Manager

GetManager returns the manager from cmd context

func (*CmdContext) GetOrCreateFormatter added in v0.2.0

func (c *CmdContext) GetOrCreateFormatter(cmd *cobra.Command) *output.Formatter

GetOrCreateFormatter returns formatter for the command

func (*CmdContext) SetManagerConfig

func (c *CmdContext) SetManagerConfig(config *config.Config)

SetManagerConfig sets manager config

type CollectionFactory

type CollectionFactory[T any] func(verbose bool, args ...string) serverscom.Collection[T]

CollectionFactory is a function type that creates a typed resource collection with configurable verbosity level type CollectionFactory[T any] func(verbose bool) serverscom.Collection[T]

type CurrencyOption added in v0.4.0

type CurrencyOption[T any] struct {
	// contains filtered or unexported fields
}

currency option

func (*CurrencyOption[T]) AddFlags added in v0.4.0

func (o *CurrencyOption[T]) AddFlags(cmd *cobra.Command)

func (*CurrencyOption[T]) ApplyToCollection added in v0.4.0

func (o *CurrencyOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type DistributionMethodOption added in v0.6.0

type DistributionMethodOption[T any] struct {
	// contains filtered or unexported fields
}

func (*DistributionMethodOption[T]) AddFlags added in v0.6.0

func (o *DistributionMethodOption[T]) AddFlags(cmd *cobra.Command)

func (*DistributionMethodOption[T]) ApplyToCollection added in v0.6.0

func (o *DistributionMethodOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type DriveInterfaceOption added in v0.6.0

type DriveInterfaceOption[T any] struct {
	// contains filtered or unexported fields
}

func (*DriveInterfaceOption[T]) AddFlags added in v0.6.0

func (o *DriveInterfaceOption[T]) AddFlags(cmd *cobra.Command)

func (*DriveInterfaceOption[T]) ApplyToCollection added in v0.6.0

func (o *DriveInterfaceOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type DriveMediaTypeOption added in v0.6.0

type DriveMediaTypeOption[T any] struct {
	// contains filtered or unexported fields
}

func (*DriveMediaTypeOption[T]) AddFlags added in v0.6.0

func (o *DriveMediaTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*DriveMediaTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *DriveMediaTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type EndDateOption added in v0.4.0

type EndDateOption[T any] struct {
	// contains filtered or unexported fields
}

end date option

func (*EndDateOption[T]) AddFlags added in v0.4.0

func (o *EndDateOption[T]) AddFlags(cmd *cobra.Command)

func (*EndDateOption[T]) ApplyToCollection added in v0.4.0

func (o *EndDateOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type FamilyOption added in v0.6.0

type FamilyOption[T any] struct {
	// contains filtered or unexported fields
}

func (*FamilyOption[T]) AddFlags added in v0.6.0

func (o *FamilyOption[T]) AddFlags(cmd *cobra.Command)

func (*FamilyOption[T]) ApplyToCollection added in v0.6.0

func (o *FamilyOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type HasRaidControllerOption added in v0.6.0

type HasRaidControllerOption[T any] struct {
	// contains filtered or unexported fields
}

func (*HasRaidControllerOption[T]) AddFlags added in v0.6.0

func (o *HasRaidControllerOption[T]) AddFlags(cmd *cobra.Command)

func (*HasRaidControllerOption[T]) ApplyToCollection added in v0.6.0

func (o *HasRaidControllerOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type HiddenTypeOption added in v0.6.0

type HiddenTypeOption[T any] struct{}

HiddenTypeOption adds hidden type flag. Used in commands that determine type from sub command rather than user input

func (*HiddenTypeOption[T]) AddFlags added in v0.6.0

func (o *HiddenTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*HiddenTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *HiddenTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type InstanceIDOption added in v0.10.0

type InstanceIDOption[T any] struct {
	// contains filtered or unexported fields
}

func (*InstanceIDOption[T]) AddFlags added in v0.10.0

func (o *InstanceIDOption[T]) AddFlags(cmd *cobra.Command)

func (*InstanceIDOption[T]) ApplyToCollection added in v0.10.0

func (o *InstanceIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type InterfaceTypeOption added in v0.6.0

type InterfaceTypeOption[T any] struct {
	// contains filtered or unexported fields
}

func (*InterfaceTypeOption[T]) AddFlags added in v0.6.0

func (o *InterfaceTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*InterfaceTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *InterfaceTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type InvoiceStatusOption added in v0.6.0

type InvoiceStatusOption[T any] struct {
	// contains filtered or unexported fields
}

invoice status option

func (*InvoiceStatusOption[T]) AddFlags added in v0.6.0

func (o *InvoiceStatusOption[T]) AddFlags(cmd *cobra.Command)

func (*InvoiceStatusOption[T]) ApplyToCollection added in v0.6.0

func (o *InvoiceStatusOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type InvoiceTypeOption added in v0.4.0

type InvoiceTypeOption[T any] struct {
	// contains filtered or unexported fields
}

invoice type option

func (*InvoiceTypeOption[T]) AddFlags added in v0.4.0

func (o *InvoiceTypeOption[T]) AddFlags(cmd *cobra.Command)

use itype instead of type to avoid conflict with baseList 'type' hidden flag which we use for subcommands

func (*InvoiceTypeOption[T]) ApplyToCollection added in v0.4.0

func (o *InvoiceTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type IsBackupOption added in v0.10.0

type IsBackupOption[T any] struct {
	// contains filtered or unexported fields
}

func (*IsBackupOption[T]) AddFlags added in v0.10.0

func (o *IsBackupOption[T]) AddFlags(cmd *cobra.Command)

func (*IsBackupOption[T]) ApplyToCollection added in v0.10.0

func (o *IsBackupOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type L2SegmentGroupTypeOption added in v0.6.0

type L2SegmentGroupTypeOption[T any] struct {
	// contains filtered or unexported fields
}

func (*L2SegmentGroupTypeOption[T]) AddFlags added in v0.6.0

func (o *L2SegmentGroupTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*L2SegmentGroupTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *L2SegmentGroupTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type LabelSelectorOption added in v0.4.0

type LabelSelectorOption[T any] struct {
	// contains filtered or unexported fields
}

label selector option

func (*LabelSelectorOption[T]) AddFlags added in v0.4.0

func (o *LabelSelectorOption[T]) AddFlags(cmd *cobra.Command)

func (*LabelSelectorOption[T]) ApplyToCollection added in v0.4.0

func (o *LabelSelectorOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type ListOptions added in v0.3.0

type ListOptions[T any] interface {
	AddFlags(*cobra.Command)
	ApplyToCollection(serverscom.Collection[T])
}

func NewListOptions added in v0.4.0

func NewListOptions[T any](opts ...ListOptions[T]) []ListOptions[T]

type LocationCodeOption added in v0.10.3

type LocationCodeOption[T any] struct {
	// contains filtered or unexported fields
}

location code option

func (*LocationCodeOption[T]) AddFlags added in v0.10.3

func (o *LocationCodeOption[T]) AddFlags(cmd *cobra.Command)

func (*LocationCodeOption[T]) ApplyToCollection added in v0.10.3

func (o *LocationCodeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type LocationIDOption added in v0.4.0

type LocationIDOption[T any] struct {
	// contains filtered or unexported fields
}

location id option

func (*LocationIDOption[T]) AddFlags added in v0.4.0

func (o *LocationIDOption[T]) AddFlags(cmd *cobra.Command)

func (*LocationIDOption[T]) ApplyToCollection added in v0.4.0

func (o *LocationIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type NetworkPoolTypeOption added in v0.6.0

type NetworkPoolTypeOption[T any] struct {
	// contains filtered or unexported fields
}

network pool type option

func (*NetworkPoolTypeOption[T]) AddFlags added in v0.6.0

func (o *NetworkPoolTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*NetworkPoolTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *NetworkPoolTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type OperatingSystemIDOption added in v0.6.0

type OperatingSystemIDOption[T any] struct {
	// contains filtered or unexported fields
}

operating system id option

func (*OperatingSystemIDOption[T]) AddFlags added in v0.6.0

func (o *OperatingSystemIDOption[T]) AddFlags(cmd *cobra.Command)

func (*OperatingSystemIDOption[T]) ApplyToCollection added in v0.6.0

func (o *OperatingSystemIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type ParentIDOption added in v0.4.0

type ParentIDOption[T any] struct {
	// contains filtered or unexported fields
}

parent id option

func (*ParentIDOption[T]) AddFlags added in v0.4.0

func (o *ParentIDOption[T]) AddFlags(cmd *cobra.Command)

func (*ParentIDOption[T]) ApplyToCollection added in v0.4.0

func (o *ParentIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type RackIDOption added in v0.7.0

type RackIDOption[T any] struct {
	// contains filtered or unexported fields
}

func (*RackIDOption[T]) AddFlags added in v0.7.0

func (o *RackIDOption[T]) AddFlags(cmd *cobra.Command)

func (*RackIDOption[T]) ApplyToCollection added in v0.7.0

func (o *RackIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type RedundancyOption added in v0.6.0

type RedundancyOption[T any] struct {
	// contains filtered or unexported fields
}

redundancy option

func (*RedundancyOption[T]) AddFlags added in v0.6.0

func (o *RedundancyOption[T]) AddFlags(cmd *cobra.Command)

func (*RedundancyOption[T]) ApplyToCollection added in v0.6.0

func (o *RedundancyOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type RegionCodeOption added in v0.10.3

type RegionCodeOption[T any] struct {
	// contains filtered or unexported fields
}

func (*RegionCodeOption[T]) AddFlags added in v0.10.3

func (o *RegionCodeOption[T]) AddFlags(cmd *cobra.Command)

func (*RegionCodeOption[T]) ApplyToCollection added in v0.10.3

func (o *RegionCodeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type RegionIDOption added in v0.10.0

type RegionIDOption[T any] struct {
	// contains filtered or unexported fields
}

func (*RegionIDOption[T]) AddFlags added in v0.10.0

func (o *RegionIDOption[T]) AddFlags(cmd *cobra.Command)

func (*RegionIDOption[T]) ApplyToCollection added in v0.10.0

func (o *RegionIDOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type SBMFlavorsShowAllOption added in v0.6.0

type SBMFlavorsShowAllOption[T any] struct {
	// contains filtered or unexported fields
}

func (*SBMFlavorsShowAllOption[T]) AddFlags added in v0.6.0

func (o *SBMFlavorsShowAllOption[T]) AddFlags(cmd *cobra.Command)

func (*SBMFlavorsShowAllOption[T]) ApplyToCollection added in v0.6.0

func (o *SBMFlavorsShowAllOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type SearchPatternOption added in v0.4.0

type SearchPatternOption[T any] struct {
	// contains filtered or unexported fields
}

search pattern option

func (*SearchPatternOption[T]) AddFlags added in v0.4.0

func (o *SearchPatternOption[T]) AddFlags(cmd *cobra.Command)

func (*SearchPatternOption[T]) ApplyToCollection added in v0.4.0

func (o *SearchPatternOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type StartDateOption added in v0.4.0

type StartDateOption[T any] struct {
	// contains filtered or unexported fields
}

start date option

func (*StartDateOption[T]) AddFlags added in v0.4.0

func (o *StartDateOption[T]) AddFlags(cmd *cobra.Command)

func (*StartDateOption[T]) ApplyToCollection added in v0.4.0

func (o *StartDateOption[T]) ApplyToCollection(collection serverscom.Collection[T])

type UplinkTypeOption added in v0.6.0

type UplinkTypeOption[T any] struct {
	// contains filtered or unexported fields
}

uplink type option

func (*UplinkTypeOption[T]) AddFlags added in v0.6.0

func (o *UplinkTypeOption[T]) AddFlags(cmd *cobra.Command)

func (*UplinkTypeOption[T]) ApplyToCollection added in v0.6.0

func (o *UplinkTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T])

Jump to

Keyboard shortcuts

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