resource

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

resource package contains utility functions for working on Unstructured data

Index

Constants

View Source
const (
	DependsOnAnnotation = "config.kubernetes.io/depends-on"
)

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.

func SetObjectExplicitDependencies added in v0.4.0

func SetObjectExplicitDependencies(obj *unstructured.Unstructured, dependencies []ObjectMetadata) error

SetObjectExplicitDependencies set an annotation on obj to contains the formatted dependencies as string. Return an error if one of the dependencies is malformed.

Types

type CyclicDependencyError added in v0.4.0

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

func (CyclicDependencyError) Error added in v0.4.0

func (e CyclicDependencyError) Error() string

Error implement error interface

type Dependency added in v0.4.0

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

type DependencyGraph

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

func NewDependencyGraph

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

func (*DependencyGraph) SortedResourceGroups

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

type ExternalDependencyError added in v0.4.0

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

ExternalDependencyError is used to signal that an external explicit dependency has been found

func (ExternalDependencyError) Error added in v0.4.0

func (e ExternalDependencyError) Error() string

Error implement error interface

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 ObjectExplicitDependencies added in v0.4.0

func ObjectExplicitDependencies(obj *unstructured.Unstructured) ([]ObjectMetadata, error)

ObjectExplicitDependencies return a set of explicitly set dependencies of the object if any are found or an error if one of the dependencies found in the annotation cannot be parsed correctly

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