resources

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonGVKs = GVKs{
	Deployment: schema.GroupVersionKind{
		Group:   "apps",
		Version: "v1",
		Kind:    "Deployment",
	},
	Kafka: schema.GroupVersionKind{
		Group:   "kafka.strimzi.io",
		Version: "v1beta2",
		Kind:    "Kafka",
	},
	KafkaConnect: schema.GroupVersionKind{
		Group:   "kafka.strimzi.io",
		Version: "v1beta2",
		Kind:    "KafkaConnect",
	},
	KafkaTopic: schema.GroupVersionKind{
		Group:   "kafka.strimzi.io",
		Version: "v1beta2",
		Kind:    "KafkaTopic",
	},
}

Functions

This section is empty.

Types

type GVKs added in v0.5.1

type GVKs struct {
	Deployment   schema.GroupVersionKind
	Kafka        schema.GroupVersionKind
	KafkaTopic   schema.GroupVersionKind
	KafkaConnect schema.GroupVersionKind
}

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 MakeResourceCounterForType added in v0.5.1

func MakeResourceCounterForType(typeSpecimen client.Object, scheme runtime.Scheme, namespaces []string, uid types.UID, readyRequirements []ResourceConditionReadyRequirements) (ResourceCounter, error)

Encapsulates the logic for making a query and returning a resource counter in one method call

func (*ResourceCounter) Count

Counts the resources

func (*ResourceCounter) GetResourceList

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

type ResourceCounterQuery

type ResourceCounterQuery struct {
	GVK        schema.GroupVersionKind
	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

func MakeQuery added in v0.5.1

func MakeQuery(typeSpecimen client.Object, scheme runtime.Scheme, namespaces []string, uid types.UID) (ResourceCounterQuery, error)

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(ctx context.Context, pClient client.Client, 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