resource

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

resource package contains utility functions for working on Unstructured data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindCRDs

FindCRDs return a new slice containing unstructured data for CRDs contained inside a Resource slice

func Info

Info return a kubernetes resource Info backed by a copy of the unstructured

func IsCRD

func IsCRD(obj *unstructured.Unstructured) bool

IsCRD return true if the Unstructured contains a CRD kubernetes resource, the check is done via equality on GroupKind, it will not validate that the resource is actually a CRD or its version

func IsNamespace

func IsNamespace(obj *unstructured.Unstructured) bool

IsNamespace return true if the Unstructured contains a Namespace kubernetes resource, the check is done via equality on GroupKind, it will not validate that the resource is actually a Namespace or its version

func IsRegistrationWebhook

func IsRegistrationWebhook(obj *unstructured.Unstructured) bool

IsRegistrationWebhook return true if the Unstructured contains a ValidatingWebhookConfiguration or MutatingWebhookConfiguration kubernetes resource, the check is done via equality on GroupKind, it will not validate that the resource is a valid webhook configuration or its version

func MetadataIsCRD

func MetadataIsCRD(obj ObjectMetadata) bool

MetadataIsCRD return true if the ObjectMetadata contains a CRD kubernetes resource, the check is done via equality on GroupKind, it will not validate that the resource is actually a CRD or its version

func Scope

func Scope(obj *unstructured.Unstructured, mapper meta.RESTMapper, addtionalCRDs []*unstructured.Unstructured) (meta.RESTScope, error)

Scope will lookup the resource against the provided mapper for getting its scope. If the mapper return a resource type not found error, we will search inside the additionalCRDs Unstructured objects. If no addtionalCRDs are passed or the type is not found even in those objects we return an UnknownResourceTypesError.

Types

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

func NewDependencyGraph

func NewDependencyGraph(objs []*unstructured.Unstructured) *DependencyGraph

func (*DependencyGraph) SortedResourceGroups

func (g *DependencyGraph) SortedResourceGroups() [][]*unstructured.Unstructured

type ObjectMetadata

type ObjectMetadata struct {
	Name      string
	Namespace string
	Group     string
	Kind      string
}

ObjectMetadata reppresent the minimum subset of data to uniquely identify a resource deployed on a remote cluster

func ObjectMetadataFromString

func ObjectMetadataFromString(str string) (bool, ObjectMetadata)

ObjectMetadataFromString will parse the given string and will try to extract all the metadata encoded in it. Will return true if the string is compatible with an ObjectMetadata string rappresentation, false if the string is something else

func ObjectMetadataFromUnstructured

func ObjectMetadataFromUnstructured(obj *unstructured.Unstructured) ObjectMetadata

ObjectMetadataFromUnstructured transform an unstructured data to a subset of metadata useful identification

func (ObjectMetadata) ToString

func (m ObjectMetadata) ToString() string

ToString return a string rappresentation of the metadata

type SortableMetadatas

type SortableMetadatas []ObjectMetadata

func (SortableMetadatas) Len

func (objs SortableMetadatas) Len() int

Len implement sort.Interface

func (SortableMetadatas) Less

func (objs SortableMetadatas) Less(i, j int) bool

Less implement sort.Interface

func (SortableMetadatas) Swap

func (objs SortableMetadatas) Swap(i, j int)

Swap implement sort.Interface

type SortableObjects

type SortableObjects []*unstructured.Unstructured

SortableObjects internal type for applying the sort interface to an array of Unstructured

func (SortableObjects) Len

func (objs SortableObjects) Len() int

Len implement sort.Interface

func (SortableObjects) Less

func (objs SortableObjects) Less(i, j int) bool

Less implement sort.Interface

func (SortableObjects) Swap

func (objs SortableObjects) Swap(i, j int)

Swap implement sort.Interface

type UnknownResourceTypeError

type UnknownResourceTypeError struct {
	ResourceGVK schema.GroupVersionKind
}

UnknownResourceTypeError is used to signal that an unknown resource has been found

func (UnknownResourceTypeError) Error

func (e UnknownResourceTypeError) Error() string

Error implement error interface

Jump to

Keyboard shortcuts

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