common

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionApply action = iota
	ActionCreate
	ActionUpdate
	ActionDelete
	ActionGetOrList
	ActionPatch
)

Variables

View Source
var VERSION string

Functions

func CheckLocked

func CheckLocked(ctx context.Context, c client.Interface) (bool, error)

CheckLocked checks if the datastore is locked. This is important for datastore migrations and splitting up IP pools so that the underlying data is not changed while the operations are being carried out.

func CheckVersionMismatch

func CheckVersionMismatch(configArg, allowMismatchArg interface{}) error

func ExecuteResourceAction

func ExecuteResourceAction(args map[string]interface{}, client client.Interface, resource resourcemgr.ResourceObject, action action) ([]runtime.Object, error)

ExecuteResourceAction fans out the specific resource action to the appropriate method on the ResourceManager for the specific resource.

Types

type CommandResults

type CommandResults struct {
	// Whether the input file was invalid.
	FileInvalid bool

	// The number of resources that are being configured.
	NumResources int

	// The number of resources that were actually configured.  This will
	// never be 0 without an associated error.
	NumHandled int

	// The associated error.
	Err error

	// The single type of resource that is being configured, or blank
	// if multiple resource types are being configured in a single shot.
	SingleKind string

	// The results returned from each invocation
	Resources []runtime.Object

	// Errors associated with individual resources
	ResErrs []error

	// The Calico API client used for the requests (useful if required
	// again).
	Client client.Interface
}

CommandResults contains the results from executing a CLI command

func ExecuteConfigCommand

func ExecuteConfigCommand(args map[string]interface{}, action action) CommandResults

ExecuteConfigCommand is main function called by all of the resource management commands in calicoctl (apply, create, replace, get, delete and patch). This provides common function for all these commands:

  • Load resources from file (or if not specified determine the resource from the command line options).
  • Convert the loaded resources into a list of resources (easier to handle)
  • Process each resource individually, fanning out to the appropriate methods on the client interface, collate results and exit on the first error.

type ResourcePrinter

type ResourcePrinter interface {
	Print(client client.Interface, resources []runtime.Object) error
}

type ResourcePrinterJSON

type ResourcePrinterJSON struct{}

ResourcePrinterJSON implements the ResourcePrinter interface and is used to display a slice of resources in JSON format.

func (ResourcePrinterJSON) Print

func (r ResourcePrinterJSON) Print(client client.Interface, resources []runtime.Object) error

type ResourcePrinterTable

type ResourcePrinterTable struct {
	// The headings to display in the table.  If this is nil, the default headings for the
	// resource are used instead (in which case the `wide` boolean below is used to specify
	// whether wide or narrow format is required.
	Headings []string

	// Wide format.  When headings have not been explicitly specified, this is used to
	// determine whether to the resource-specific default wide or narrow headings.
	Wide bool

	// Namespace included. When a resource being printed is namespaced, this is used
	// to determine if the namespace column should be printed or not.
	PrintNamespace bool
}

ResourcePrinterTable implements the ResourcePrinter interface and is used to display a slice of resources in ps table format.

func (ResourcePrinterTable) Print

func (r ResourcePrinterTable) Print(client client.Interface, resources []runtime.Object) error

type ResourcePrinterTemplate

type ResourcePrinterTemplate struct {
	Template string
}

ResourcePrinterTemplate implements the ResourcePrinter interface and is used to display a slice of resources using a user-defined go-lang template string.

func (ResourcePrinterTemplate) Print

func (r ResourcePrinterTemplate) Print(client client.Interface, resources []runtime.Object) error

type ResourcePrinterTemplateFile

type ResourcePrinterTemplateFile struct {
	TemplateFile string
}

ResourcePrinterTemplateFile implements the ResourcePrinter interface and is used to display a slice of resources using a user-defined go-lang template specified in a file.

func (ResourcePrinterTemplateFile) Print

func (r ResourcePrinterTemplateFile) Print(client client.Interface, resources []runtime.Object) error

type ResourcePrinterYAML

type ResourcePrinterYAML struct{}

ResourcePrinterYAML implements the ResourcePrinter interface and is used to display a slice of resources in YAML format.

func (ResourcePrinterYAML) Print

func (r ResourcePrinterYAML) Print(client client.Interface, resources []runtime.Object) error

Jump to

Keyboard shortcuts

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