kubernetes

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPermission added in v0.1.0

func CheckPermission(ctx context.Context, client client.Client, group, resource, namespace, name, verb string) (bool, error)

CheckPermission can be used to check if the current user/service-account is allowed to execute a given operation in the cluster. E.g. checkPermission(client, olmv1alpha1.GroupName, "clusterserviceversions", namespace, "yaks", "get")

nolint:unparam

func GetConfigMap added in v0.1.0

func GetConfigMap(context context.Context, client k8sclient.Reader, name string, namespace string) (*corev1.ConfigMap, error)

GetConfigMap --

func GetSecret added in v0.1.0

func GetSecret(context context.Context, client k8sclient.Reader, name string, namespace string) (*corev1.Secret, error)

GetSecret --

func IsAPIResourceInstalled added in v0.4.0

func IsAPIResourceInstalled(c client.Client, groupVersion string, kind string) (bool, error)

func IsUnknownAPIError added in v0.1.0

func IsUnknownAPIError(err error) bool

IsUnknownAPIError checks if the given error is due to some missing APIs in the cluster. Apparently there's no such method in Kubernetes Go API.

func JSONToYAML added in v0.1.0

func JSONToYAML(src []byte) ([]byte, error)

JSONToYAML --

func LoadRawResourceFromYaml

func LoadRawResourceFromYaml(data string) (ctrl.Object, error)

LoadRawResourceFromYaml loads a k8s resource from a yaml definition without making assumptions on the underlying type

func LoadResourceFromYaml

func LoadResourceFromYaml(scheme *runtime.Scheme, data string) (ctrl.Object, error)

LoadResourceFromYaml loads a k8s resource from a yaml definition

func ReplaceResource

func ReplaceResource(ctx context.Context, c client.Client, res ctrl.Object) error

ReplaceResource allows to completely replace a resource on Kubernetes, taking care of immutable fields and resource versions

func ReplaceResources

func ReplaceResources(ctx context.Context, c client.Client, objects []ctrl.Object) error

ReplaceResources allows to completely replace a list of resources on Kubernetes, taking care of immutable fields and resource versions

func SanitizeFileName

func SanitizeFileName(name string) string

func SanitizeLabel

func SanitizeLabel(name string) string

SanitizeLabel sanitizes the given name to be compatible with k8s

func SanitizeName

func SanitizeName(name string) string

SanitizeName sanitizes the given name to be compatible with k8s

func ToJSON added in v0.1.0

func ToJSON(value runtime.Object) ([]byte, error)

ToJSON --

func ToYAML added in v0.1.0

func ToYAML(value runtime.Object) ([]byte, error)

ToYAML --

func WaitCondition

func WaitCondition(ctx context.Context, c client.Client, obj ctrl.Object, condition ResourceCheckFunction, maxDuration time.Duration) error

WaitCondition --

Types

type Collection

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

A Collection is a container of Kubernetes resources

func NewCollection

func NewCollection(objects ...ctrl.Object) *Collection

NewCollection creates a new empty collection

func (*Collection) Add

func (c *Collection) Add(resource ctrl.Object)

Add adds a resource to the collection

func (*Collection) AddAll

func (c *Collection) AddAll(resource []ctrl.Object)

AddAll adds all resources to the collection

func (*Collection) AsKubernetesList

func (c *Collection) AsKubernetesList() *corev1.List

AsKubernetesList returns all resources wrapped in a Kubernetes list

func (*Collection) GetConfigMap

func (c *Collection) GetConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap

GetConfigMap returns a ConfigMap that matches the given function

func (*Collection) GetDeployment

func (c *Collection) GetDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment

GetDeployment returns a Deployment that matches the given function

func (*Collection) GetService

func (c *Collection) GetService(filter func(*corev1.Service) bool) *corev1.Service

GetService returns a Service that matches the given function

func (*Collection) HasDeployment

func (c *Collection) HasDeployment(filter func(*appsv1.Deployment) bool) bool

HasDeployment returns true if a deployment matching the given condition is present

func (*Collection) Items

func (c *Collection) Items() []ctrl.Object

Items returns all resources belonging to the collection

func (*Collection) Remove

func (c *Collection) Remove(selector func(ctrl.Object) bool) ctrl.Object

Remove removes the given element from the collection and returns it

func (*Collection) RemoveConfigMap

func (c *Collection) RemoveConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap

RemoveConfigMap removes and returns a ConfigMap that matches the given function

func (*Collection) RemoveDeployment

func (c *Collection) RemoveDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment

RemoveDeployment removes and returns a Deployment that matches the given function

func (*Collection) Size

func (c *Collection) Size() int

Size returns the number of resources belonging to the collection

func (*Collection) Visit

func (c *Collection) Visit(visitor func(ctrl.Object))

Visit executes the visitor function on all resources

func (*Collection) VisitConfigMap

func (c *Collection) VisitConfigMap(visitor func(*corev1.ConfigMap))

VisitConfigMap executes the visitor function on all ConfigMap resources

func (*Collection) VisitContainer

func (c *Collection) VisitContainer(visitor func(container *corev1.Container))

VisitContainer executes the visitor function on all Containers inside deployments or other resources

func (*Collection) VisitDeployment

func (c *Collection) VisitDeployment(visitor func(*appsv1.Deployment))

VisitDeployment executes the visitor function on all Deployment resources

func (*Collection) VisitMetaObject

func (c *Collection) VisitMetaObject(visitor func(metav1.Object))

VisitMetaObject executes the visitor function on all meta.Object resources

func (*Collection) VisitService

func (c *Collection) VisitService(visitor func(*corev1.Service))

VisitService executes the visitor function on all Service resources

type ResourceCheckFunction

type ResourceCheckFunction func(interface{}) (bool, error)

ResourceCheckFunction --

type ResourceRetrieveFunction

type ResourceRetrieveFunction func() (interface{}, error)

ResourceRetrieveFunction --

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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