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 ¶
Create 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 ResourceActionCommand ¶
type ResourceActionCommand func(context.Context, client.Interface, ResourceObject) (ResourceObject, error)
type ResourceListActionCommand ¶
type ResourceListActionCommand func(context.Context, client.Interface, ResourceObject) (ResourceListObject, error)
type ResourceListObject ¶
type ResourceListObject interface { runtime.Object v1.ListMetaAccessor }
All Calico resources list implement the resource interface.
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) }
The ResourceManager interface provides 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
Return the Resource Manager for a particular resource type.
type ResourceObject ¶
type ResourceObject interface { runtime.Object v1.ObjectMetaAccessor }
All Calico resources implement the resource interface.
func GetResourceFromArgs ¶
func GetResourceFromArgs(args map[string]interface{}) (ResourceObject, error)
Gets resource 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".