kubernetes

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 40 Imported by: 36

Documentation

Index

Constants

View Source
const (
	CamelCreatorLabelPrefix = "camel.apache.org/created.by"

	CamelCreatorLabelKind = CamelCreatorLabelPrefix + ".kind"
	CamelCreatorLabelName = CamelCreatorLabelPrefix + ".name"
)

CamelCreatorLabelPrefix --

Variables

This section is empty.

Functions

func CheckPermission

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, "camel-k", "get")

nolint:unparam

func FilterCamelCreatorLabels

func FilterCamelCreatorLabels(source map[string]string) map[string]string

FilterCamelCreatorLabels is used to inherit the creator information among resources

func GetBuild

func GetBuild(context context.Context, client client.Client, name string, namespace string) (*v1.Build, error)

GetBuild --

func GetCamelCreator

func GetCamelCreator(obj runtime.Object) *v1.ObjectReference

GetCamelCreator returns the Camel creator object referenced by this runtime object, if present

func GetConfigMap

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

GetConfigMap --

func GetConfigMapRefValue

func GetConfigMapRefValue(ctx context.Context, client k8sclient.Reader, namespace string, selector *corev1.ConfigMapKeySelector) (string, error)

GetConfigMapRefValue returns the value of a configmap in the supplied namespace

func GetIntegration

func GetIntegration(context context.Context, client k8sclient.Reader, name string, namespace string) (*v1.Integration, error)

GetIntegration --

func GetIntegrationKit

func GetIntegrationKit(context context.Context, client k8sclient.Reader, name string, namespace string) (*v1.IntegrationKit, error)

GetIntegrationKit --

func GetIntegrationPlatform

func GetIntegrationPlatform(context context.Context, client k8sclient.Reader, name string, namespace string) (*v1.IntegrationPlatform, error)

GetIntegrationPlatform --

func GetSecret

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

GetSecret --

func GetSecretRefValue

func GetSecretRefValue(ctx context.Context, client k8sclient.Reader, namespace string, selector *corev1.SecretKeySelector) (string, error)

GetSecretRefValue returns the value of a secret in the supplied namespace --

func GetService

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

GetService --

func IsUnknownAPIError

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 LoadRawResourceFromYaml

func LoadRawResourceFromYaml(data string) (runtime.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) (runtime.Object, error)

LoadResourceFromYaml loads a k8s resource from a yaml definition

func MergeCamelCreatorLabels

func MergeCamelCreatorLabels(source map[string]string, target map[string]string) map[string]string

MergeCamelCreatorLabels is used to inject the creator information from another set of labels

func MirrorReadyCondition

func MirrorReadyCondition(ctx context.Context, c client.Client, it *v1.Integration)

nolint: gocritic

func PortForward added in v1.3.0

func PortForward(ctx context.Context, c client.Client, ns, labelSelector string, localPort, remotePort uint, stdOut, stdErr io.Writer) error

func ReplaceResource

func ReplaceResource(ctx context.Context, c client.Client, res runtime.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 []runtime.Object) error

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

func Resolve

func Resolve(data *v1.DataSpec, mapLookup func(string) (*corev1.ConfigMap, error)) error

Resolve --

func ResolveIntegrationResources

func ResolveIntegrationResources(
	context context.Context,
	client controller.Reader,
	integration *v1.Integration,
	resources *Collection) ([]v1.ResourceSpec, error)

ResolveIntegrationResources -- nolint: lll

func ResolveIntegrationSources

func ResolveIntegrationSources(
	context context.Context,
	client controller.Reader,
	integration *v1.Integration,
	resources *Collection) ([]v1.SourceSpec, error)

ResolveIntegrationSources --

func ResolveResource

func ResolveResource(elements []v1.ResourceSpec, mapLookup func(string) (*corev1.ConfigMap, error)) ([]v1.ResourceSpec, error)

ResolveResource --

func ResolveSources

func ResolveSources(elements []v1.SourceSpec, mapLookup func(string) (*corev1.ConfigMap, error)) ([]v1.SourceSpec, error)

ResolveSources --

func ResolveValueSource

func ResolveValueSource(ctx context.Context, client k8sclient.Reader, namespace string, valueSource *v1.ValueSource) (string, error)

ResolveValueSource --

func RuntimeObjectFromUnstructured

func RuntimeObjectFromUnstructured(scheme *runtime.Scheme, u *unstructured.Unstructured) (runtime.Object, error)

RuntimeObjectFromUnstructured converts an unstructured to a runtime object

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

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

ToJSON --

func ToYAML

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

ToYAML --

func WaitCondition

func WaitCondition(ctx context.Context, c client.Client, obj runtime.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 ...runtime.Object) *Collection

NewCollection creates a new empty collection

func (*Collection) Add

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

Add adds a resource to the collection

func (*Collection) AddAll

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

AddAll adds all resources to the collection

func (*Collection) AddFirst added in v1.2.0

func (c *Collection) AddFirst(resource runtime.Object)

AddFirst adds a resource to the head of 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) GetContainer

func (c *Collection) GetContainer(filter func(container *corev1.Container) bool) *corev1.Container

GetContainer --

func (*Collection) GetContainerByName

func (c *Collection) GetContainerByName(name string) *corev1.Container

GetContainerByName --

func (*Collection) GetController added in v1.2.0

func (c *Collection) GetController(filter func(object runtime.Object) bool) runtime.Object

GetController returns the controller associated with the integration (e.g. Deployment, Knative Service or CronJob)

func (*Collection) GetCronJob added in v1.2.0

func (c *Collection) GetCronJob(filter func(job *v1beta1.CronJob) bool) *v1beta1.CronJob

GetCronJob returns a CronJob 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) GetDeploymentForIntegration

func (c *Collection) GetDeploymentForIntegration(integration *v1.Integration) *appsv1.Deployment

GetDeploymentForIntegration returns a Deployment for the given integration

func (*Collection) GetKnativeService

func (c *Collection) GetKnativeService(filter func(*serving.Service) bool) *serving.Service

GetKnativeService returns a knative Service that matches the given function

func (*Collection) GetRoute

func (c *Collection) GetRoute(filter func(*routev1.Route) bool) *routev1.Route

GetRoute returns a Route 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) GetServiceForIntegration

func (c *Collection) GetServiceForIntegration(integration *v1.Integration) *corev1.Service

GetServiceForIntegration returns a user Service for the given integration

func (*Collection) GetServiceMonitor

func (c *Collection) GetServiceMonitor(filter func(*monitoringv1.ServiceMonitor) bool) *monitoringv1.ServiceMonitor

GetServiceMonitor ---

func (*Collection) GetUserServiceForIntegration

func (c *Collection) GetUserServiceForIntegration(integration *v1.Integration) *corev1.Service

GetUserServiceForIntegration returns a user Service for the given integration

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) HasKnativeTrigger

func (c *Collection) HasKnativeTrigger(filter func(trigger *eventing.Trigger) bool) bool

HasKnativeTrigger returns true if a Knative trigger respecting filter is found

func (*Collection) Items

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

Items returns all resources belonging to the collection

func (*Collection) Remove

func (c *Collection) Remove(selector func(runtime.Object) bool) runtime.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(runtime.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) VisitCronJob

func (c *Collection) VisitCronJob(visitor func(*v1beta1.CronJob))

VisitCronJob executes the visitor function on all CronJob resources

func (*Collection) VisitCronJobE

func (c *Collection) VisitCronJobE(visitor func(*v1beta1.CronJob) error) error

VisitCronJobE executes the visitor function on all CronJob resources

func (*Collection) VisitDeployment

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

VisitDeployment executes the visitor function on all Deployment resources

func (*Collection) VisitDeploymentE

func (c *Collection) VisitDeploymentE(visitor func(*appsv1.Deployment) error) error

VisitDeploymentE executes the visitor function on all Deployment resources

func (*Collection) VisitE

func (c *Collection) VisitE(visitor func(runtime.Object) error) error

VisitE executes the visitor function on all resources breaking if the visitor function returns an error

func (*Collection) VisitKnativeConfigurationSpec

func (c *Collection) VisitKnativeConfigurationSpec(visitor func(container *serving.ConfigurationSpec))

VisitKnativeConfigurationSpec executes the visitor function on all knative ConfigurationSpec inside serving Services

func (*Collection) VisitKnativeService

func (c *Collection) VisitKnativeService(visitor func(*serving.Service))

VisitKnativeService executes the visitor function on all Knative serving Service resources

func (*Collection) VisitKnativeServiceE

func (c *Collection) VisitKnativeServiceE(visitor func(*serving.Service) error) error

VisitKnativeServiceE executes the visitor function on all Knative serving Service resources

func (*Collection) VisitKnativeTrigger

func (c *Collection) VisitKnativeTrigger(visitor func(trigger *eventing.Trigger))

VisitKnativeTrigger executes the visitor function on all Knative eventing Trigger resources

func (*Collection) VisitMetaObject

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

VisitMetaObject executes the visitor function on all meta.Object resources

func (*Collection) VisitPodSpec

func (c *Collection) VisitPodSpec(visitor func(container *corev1.PodSpec))

VisitPodSpec executes the visitor function on all PodSpec inside deployments or other resources

func (*Collection) VisitPodTemplateMeta added in v1.3.0

func (c *Collection) VisitPodTemplateMeta(visitor func(meta *metav1.ObjectMeta))

VisitPodTemplateMeta executes the visitor function on all PodTemplate metadata inside deployments or other resources

func (*Collection) VisitRoute

func (c *Collection) VisitRoute(visitor func(*routev1.Route))

VisitRoute executes the visitor function on all Route resources

func (*Collection) VisitService

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

VisitService executes the visitor function on all Service resources

func (*Collection) VisitServiceMonitor

func (c *Collection) VisitServiceMonitor(visitor func(*monitoringv1.ServiceMonitor))

VisitServiceMonitor ---

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