resources

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource struct {
	Status            ResourceStatus
	Metadata          ResourceMetadata
	Conditions        []map[string]string
	ReadyRequirements []ResourceConditionReadyRequirements
}

Represents a k8s resource in a type-neutral way We used to have lots of repeated code because we needed to perform the same operations on different resources, which are represented by the go k8s sdk as different types. This type provides a single type that can represent any kind of resource and perform common actions

func MakeResource

func MakeResource(source unstructured.Unstructured) Resource

Make a resource from an unstructured, parse it, and return it

func (*Resource) AddReadyRequirements

func (r *Resource) AddReadyRequirements(requirements ResourceConditionReadyRequirements)

Adds a resource ready requirement

func (*Resource) IsOwnedBy

func (r *Resource) IsOwnedBy(ownerUID string) bool

Returns true of the resource is owned by the given guid

func (*Resource) IsReady

func (r *Resource) IsReady() bool

Get the ready status

type ResourceConditionReadyRequirements

type ResourceConditionReadyRequirements struct {
	Type   string
	Status string
}

In order to status check resources we check their status conditions for a condition with a specific type and status. This type lets us define and pass those values around

type ResourceCounter

type ResourceCounter struct {
	CountManaged      int
	CountReady        int
	BrokenLog         []string
	Query             ResourceCounterQuery
	ReadyRequirements []ResourceConditionReadyRequirements
}

Provides a simple API for getting common figures on Resources and ResourceLists The Count method returns a ResourceCounterResults instance

func (*ResourceCounter) Count

Counts the resources

func (*ResourceCounter) GetResourceList

func (r *ResourceCounter) GetResourceList(pClient client.Client, ctx context.Context, namespace string) ResourceList

type ResourceCounterQuery

type ResourceCounterQuery struct {
	OfType     client.Object
	Namespaces []string
	OwnerGUID  string
}

Represents a resource query for a count We count resources of a given GVK (which derive from OfType ), in a given set of namespaces, owned by a given guid

type ResourceCounterResults

type ResourceCounterResults struct {
	Managed       int
	Ready         int
	BrokenMessage string
}

Results that a resource counter provides back when its count method is called

type ResourceFigures

type ResourceFigures struct {
	Total int32
	Ready int32
}

An operator is interested in how many of a resource it manages and how many are ready

type ResourceList

type ResourceList struct {
	Resources []Resource
	// contains filtered or unexported fields
}

The pattern other k8s SDKs follow is that resources are queried by some criteria resulting in a list object that then can be iterated over or acted on. ResourceList can query k8s for a list of resources by GVK and namespace which it then parses into Resource instances.

func (*ResourceList) AddReadyRequirementsFromSlice

func (r *ResourceList) AddReadyRequirementsFromSlice(reqsList []ResourceConditionReadyRequirements)

Add resource ready requirements for all of the resources in the list

func (*ResourceList) Count

func (r *ResourceList) Count() int

Get a count of the resources

func (*ResourceList) CountReady

func (r *ResourceList) CountReady() int

Get a count of the ready resources

func (*ResourceList) FilterByOwnerUID

func (r *ResourceList) FilterByOwnerUID(ownerUID string) ResourceList

Get a new list filtered by a specific owner UID

func (*ResourceList) GetByGVKAndNamespace

func (r *ResourceList) GetByGVKAndNamespace(pClient client.Client, ctx context.Context, namespace string, gvk schema.GroupVersionKind) error

Gets a ResourceList by a provided GVK and Namespace

func (*ResourceList) GetResourceStatusBuckets

func (r *ResourceList) GetResourceStatusBuckets() ResourceStatusBuckets

Get a lists of resources bucketed by status

func (*ResourceList) SetListAndParse

func (r *ResourceList) SetListAndParse(uList unstructured.UnstructuredList)

Set the source unstructured list and then parse it

type ResourceMetadata

type ResourceMetadata struct {
	Generation      int64
	Namespace       string
	Name            string
	UID             string
	ResourceVersion string
	OwnerUIDs       []string
}

Represents the metadata we pull off the unstructured resource

type ResourceStatus

type ResourceStatus struct {
	ObservedGeneration int64
}

Represents the status we pull off the unstructured resource I only parse what I need to reduce the oppurtunity for bugs

type ResourceStatusBuckets

type ResourceStatusBuckets struct {
	Ready  []Resource
	Broken []Resource
}

Jump to

Keyboard shortcuts

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