resourcemgr

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: 24 Imported by: 0

Documentation

Overview

Package resourcemgr implements generic resource handling methods. This includes:

  • a mechanism for creating specific resources from a JSON or YAML input.
  • an untyped resource management interface for each resource type
  • table template data for each resource type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateResourcesFromFile

func CreateResourcesFromFile(f string) ([]runtime.Object, error)

CreateResourcesFromFile creates the Resource from the specified file f.

  • The file format may be JSON or YAML encoding of either a single resource or list of resources as defined by the API objects in /api.
  • A filename of "-" means "Read from stdin".

The returned Resource will either be a single Resource or a List containing zero or more Resources. If the file does not contain any valid Resources this function returns an error.

Types

type ResourceListObject

type ResourceListObject interface {
	runtime.Object
	v1.ListMetaAccessor
}

ResourceListObject is implemented by all Calico resources lists

type ResourceManager

type ResourceManager interface {
	GetTableDefaultHeadings(wide bool) []string
	GetTableTemplate(columns []string, printNamespace bool) (string, error)
	GetObjectType() reflect.Type
	IsNamespaced() bool
	Apply(ctx context.Context, client client.Interface, resource ResourceObject) (ResourceObject, error)
	Create(ctx context.Context, client client.Interface, resource ResourceObject) (ResourceObject, error)
	Update(ctx context.Context, client client.Interface, resource ResourceObject) (ResourceObject, error)
	Delete(ctx context.Context, client client.Interface, resource ResourceObject) (ResourceObject, error)
	GetOrList(ctx context.Context, client client.Interface, resource ResourceObject) (runtime.Object, error)
	Patch(ctx context.Context, client client.Interface, resource ResourceObject, patch string) (ResourceObject, error)
}

ResourceManager provides a useful function for each resource type. This includes:

  • Commands to assist with generation of table output format of resources
  • Commands to manage resource instances through an un-typed interface.

func GetResourceManager

func GetResourceManager(resource runtime.Object) ResourceManager

GetResourceManager returns the Resource Manager for a particular resource type.

type ResourceObject

type ResourceObject interface {
	runtime.Object
	v1.ObjectMetaAccessor
}

ResourceObject is implemented by all Calico resources

func GetResourcesFromArgs

func GetResourcesFromArgs(args map[string]interface{}) ([]ResourceObject, error)

GetResourcesFromArgs gets resources from arguments. This function also inserts resource name, namespace if specified. Example "calicoctl get bgppeer peer123" will return a BGPPeer resource with name field populated to "peer123".

Jump to

Keyboard shortcuts

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