utils

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 39 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ExposeBindingOverrideSecretSuffix = "-expose-binding-override"
	ExposeBindingSecretSuffix         = "-expose-binding"
)

String constants

View Source
const (
	ReconcileInterval = 15
)

Variables

This section is empty.

Functions

func AppendIfNotSubstring

func AppendIfNotSubstring(a, s string) string

AppendIfNotSubstring appends `a` to comma-separated list of strings in `s`

func BuildServiceBindingSecretName

func BuildServiceBindingSecretName(name, namespace string) string

BuildServiceBindingSecretName returns secret name of a consumable service

func ContainsString

func ContainsString(slice []string, s string) bool

ContainsString returns true if `s` is in the slice. Otherwise, returns false

func CustomizeAffinity

func CustomizeAffinity(affinity *corev1.Affinity, ba common.BaseComponent)

CustomizeAffinity ...

func CustomizeDeployment

func CustomizeDeployment(deploy *appsv1.Deployment, ba common.BaseComponent)

CustomizeDeployment ...

func CustomizeHPA

CustomizeHPA ...

func CustomizeIngress

func CustomizeIngress(ing *networkingv1.Ingress, ba common.BaseComponent)

CustomizeIngress customizes ingress resource

func CustomizeKnativeService

func CustomizeKnativeService(ksvc *servingv1.Service, ba common.BaseComponent)

CustomizeKnativeService ...

func CustomizePersistence

func CustomizePersistence(statefulSet *appsv1.StatefulSet, ba common.BaseComponent)

CustomizePersistence ...

func CustomizePodSpec

func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent)

CustomizePodSpec ...

func CustomizeRoute

func CustomizeRoute(route *routev1.Route, ba common.BaseComponent, key string, crt string, ca string, destCACert string)

CustomizeRoute ...

func CustomizeService

func CustomizeService(svc *corev1.Service, ba common.BaseComponent)

CustomizeService ...

func CustomizeServiceAccount

func CustomizeServiceAccount(sa *corev1.ServiceAccount, ba common.BaseComponent)

CustomizeServiceAccount ...

func CustomizeServiceMonitor

func CustomizeServiceMonitor(sm *prometheusv1.ServiceMonitor, ba common.BaseComponent)

CustomizeServiceMonitor ...

func CustomizeStatefulSet

func CustomizeStatefulSet(statefulSet *appsv1.StatefulSet, ba common.BaseComponent)

CustomizeStatefulSet ...

func EnsureOwnerRef

func EnsureOwnerRef(metadata metav1.Object, newOwnerRef metav1.OwnerReference) bool

EnsureOwnerRef adds the ownerref if needed. Removes ownerrefs with conflicting UIDs. Returns true if the input is mutated. Copied from "https://github.com/openshift/library-go/blob/release-4.5/pkg/controller/ownerref.go"

func ErrorIsNoMatchesForKind

func ErrorIsNoMatchesForKind(err error, kind string, version string) bool

ErrorIsNoMatchesForKind ...

func ExecuteCommandInContainer

func ExecuteCommandInContainer(config *rest.Config, podName, podNamespace, containerName string, command []string) (string, error)

ExecuteCommandInContainer Execute command inside a container in a pod through API

func GetAppContainer

func GetAppContainer(containerList []corev1.Container) *corev1.Container

GetAppContainer returns the container that is running the app

func GetOpenShiftAnnotations

func GetOpenShiftAnnotations(ba common.BaseComponent) map[string]string

GetOpenShiftAnnotations returns OpenShift specific annotations

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the Namespace the operator installed in

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the Namespace the operator should be watching for changes

func GetWatchNamespaces

func GetWatchNamespaces() ([]string, error)

GetWatchNamespaces returns a slice of namespaces the operator should watch based on WATCH_NAMESPSCE value WATCH_NAMESPSCE value could be empty for watching the whole cluster or a comma-separated list of namespaces

func IsClusterWide

func IsClusterWide(watchNamespaces []string) bool

IsClusterWide returns true if watchNamespaces is set to [""]

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps returns a map containing the union of al the key-value pairs from the input maps. The order of the maps passed into the func, defines the importance. e.g. if (keyA, value1) is in map1, and (keyA, value2) is in map2, mergeMaps(map1, map2) would contain (keyA, value2). If the input map is nil, it is treated as empty map.

func ServiceAccountPullSecretExists added in v0.8.2

func ServiceAccountPullSecretExists(ba common.BaseComponent, client client.Client) error

Looks for a pull secret in the service account retrieved from the component Returns nil if there is at least one image pull secret, otherwise an error

func SetCondition

SetCondition ...

func Validate

func Validate(ba common.BaseComponent) (bool, error)

Validate if the BaseComponent is valid

Types

type ReconcilerBase

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

ReconcilerBase base reconciler with some common behaviour

func NewReconcilerBase

func NewReconcilerBase(apiReader client.Reader, client client.Client, scheme *runtime.Scheme, restConfig *rest.Config, recorder record.EventRecorder) ReconcilerBase

NewReconcilerBase creates a new ReconcilerBase

func (*ReconcilerBase) CreateOrUpdate

func (r *ReconcilerBase) CreateOrUpdate(obj client.Object, owner metav1.Object, reconcile func() error) error

CreateOrUpdate ...

func (*ReconcilerBase) DeleteResource

func (r *ReconcilerBase) DeleteResource(obj client.Object) error

DeleteResource deletes kubernetes resource

func (*ReconcilerBase) DeleteResources

func (r *ReconcilerBase) DeleteResources(resources []client.Object) error

DeleteResources ...

func (*ReconcilerBase) GetAPIReader

func (r *ReconcilerBase) GetAPIReader() client.Reader

GetAPIReader returns a client.Reader. Use client.Reader only if a particular resource does not implement the 'watch' verb such as ImageStreamTag. This is because the operator-sdk Client automatically performs a Watch on all the objects that are obtained with Get, but some resources such as the ImageStreamTag kind does not implement the Watch verb, which caused errors. Here is an example of how the error would look like:

`Failed to watch *v1.ImageStreamTag: the server does not allow this method on the requested resource (get imagestreamtags.image.openshift.io)`

func (*ReconcilerBase) GetClient

func (r *ReconcilerBase) GetClient() client.Client

GetClient returns client

func (*ReconcilerBase) GetController

func (r *ReconcilerBase) GetController() controller.Controller

GetController returns controller

func (*ReconcilerBase) GetDiscoveryClient

func (r *ReconcilerBase) GetDiscoveryClient() (discovery.DiscoveryInterface, error)

GetDiscoveryClient ...

func (*ReconcilerBase) GetOpConfigMap

func (r *ReconcilerBase) GetOpConfigMap(name string, ns string) (*corev1.ConfigMap, error)

GetOpConfigMap ...

func (*ReconcilerBase) GetRecorder

func (r *ReconcilerBase) GetRecorder() record.EventRecorder

GetRecorder returns the underlying recorder

func (*ReconcilerBase) GetRouteTLSValues

func (r *ReconcilerBase) GetRouteTLSValues(ba common.BaseComponent) (key string, cert string, ca string, destCa string, err error)

GetRouteTLSValues returns certificate an key values to be used in the route

func (*ReconcilerBase) IsGroupVersionSupported

func (r *ReconcilerBase) IsGroupVersionSupported(groupVersion string, kind string) (bool, error)

IsGroupVersionSupported ...

func (*ReconcilerBase) IsOpenShift

func (r *ReconcilerBase) IsOpenShift() bool

IsOpenShift returns true if the operator is running on an OpenShift platform

func (*ReconcilerBase) ManageError

func (r *ReconcilerBase) ManageError(issue error, conditionType common.StatusConditionType, ba common.BaseComponent) (reconcile.Result, error)

ManageError ...

func (*ReconcilerBase) ManageSuccess

func (r *ReconcilerBase) ManageSuccess(conditionType common.StatusConditionType, ba common.BaseComponent) (reconcile.Result, error)

ManageSuccess ...

func (*ReconcilerBase) ReconcileBindings

func (r *ReconcilerBase) ReconcileBindings(ba common.BaseComponent) error

ReconcileBindings goes through the reconcile logic for service binding

func (*ReconcilerBase) SetController

func (r *ReconcilerBase) SetController(c controller.Controller)

SetController sets controller

func (*ReconcilerBase) SetDiscoveryClient

func (r *ReconcilerBase) SetDiscoveryClient(discovery discovery.DiscoveryInterface)

SetDiscoveryClient ...

func (*ReconcilerBase) UpdateStatus

func (r *ReconcilerBase) UpdateStatus(obj client.Object) error

UpdateStatus updates the fields corresponding to the status subresource for the object

Jump to

Keyboard shortcuts

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