servicebindingrequest

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const ClusterServiceVersionKind = "ClusterServiceVersion"

ClusterServiceVersionKind the name of ClusterServiceVersion kind.

View Source
const DeploymentConfigKind = "DeploymentConfig"

DeploymentConfigKind defines the name of DeploymentConfig kind.

View Source
const ServiceBindingRequestKind = "ServiceBindingRequest"

ServiceBindingRequestKind defines the name of the CRD kind.

View Source
const ServiceBindingRequestResource = "servicebindingrequests"

ServiceBindingRequestResource the name of ServiceBindingRequest resource.

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager) error

Add creates a new ServiceBindingRequest Controller and adds it to the Manager. The Manager will set fields on the Controller and Start it when the Manager is Started.

func Done

func Done() (reconcile.Result, error)

Done when no error is informed and request is not set for requeue.

func GetSBRNamespacedNameFromObject added in v0.0.19

func GetSBRNamespacedNameFromObject(obj runtime.Object) (types.NamespacedName, error)

GetSBRNamespacedNameFromObject returns a types.NamespacedName if the required service binding request annotations are present in the given runtime.Object, empty otherwise. When annotations are not present, it checks if the object is an actual SBR, returning the details when positive. An error can be returned in the case the object can't be decoded.

func IsNamespacedNameEmpty added in v0.0.19

func IsNamespacedNameEmpty(namespacedName types.NamespacedName) bool

IsNamespacedNameEmpty returns true if any of the fields from the given namespacedName is empty.

func NewCreateWatchEventHandler added in v0.0.19

func NewCreateWatchEventHandler(controller *SBRController) handler.EventHandler

NewCreateWatchEventHandler creates a new instance of handler.EventHandler interface with CSVToWatcherMapper as map-func.

func Requeue

func Requeue(err error, requeueAfter int64) (reconcile.Result, error)

Requeue based on empty result and no error informed upstream, request will be requeued.

func RequeueError

func RequeueError(err error) (reconcile.Result, error)

RequeueError simply requeue exposing the error.

func RequeueOnNotFound

func RequeueOnNotFound(err error, requeueAfter int64) (reconcile.Result, error)

RequeueOnNotFound inspect error, if not-found then returns Requeue, otherwise expose the error.

func SetSBRAnnotations added in v0.0.19

func SetSBRAnnotations(
	client dynamic.Interface,
	namespacedName types.NamespacedName,
	objs []*unstructured.Unstructured,
) error

SetSBRAnnotations update existing annotations to include operator's. The annotations added are referring to a existing SBR namespaced name.

Types

type Binder

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

Binder executes the "binding" act of updating different application kinds to use intermediary secret. Those secrets should be offered as environment variables.

func NewBinder

func NewBinder(
	ctx context.Context,
	client client.Client,
	dynClient dynamic.Interface,
	sbr *v1alpha1.ServiceBindingRequest,
	volumeKeys []string,
) *Binder

NewBinder returns a new Binder instance.

func (*Binder) Bind

func (b *Binder) Bind() ([]*unstructured.Unstructured, error)

Bind resources to intermediary secret, by searching informed ResourceKind containing the labels in ApplicationSelector, and then updating spec.

type CSVToWatcherMapper added in v0.0.19

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

CSVToWatcherMapper creates a EventHandler interface to map ClusterServiceVersion objects back to controller and add given GVK to watch list.

func (*CSVToWatcherMapper) Map added in v0.0.19

Map requests directed to CSV objects and exctract related GVK to trigger another watch on controller instance.

type CustomEnvParser added in v0.0.19

type CustomEnvParser struct {
	EnvMap []v1alpha1.CustomEnvMap
	Cache  map[string]interface{}
}

CustomEnvParser is responsible to interpolate a given CustomEnvMap containing templates.

func NewCustomEnvParser added in v0.0.19

func NewCustomEnvParser(envMap []v1alpha1.CustomEnvMap, cache map[string]interface{}) *CustomEnvParser

NewCustomEnvParser returns a new CustomEnvParser.

func (*CustomEnvParser) Parse added in v0.0.19

func (c *CustomEnvParser) Parse() (map[string]interface{}, error)

Parse interpolates and caches the templates in EnvMap.

type DetectBindableResources added in v0.0.21

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

DetectBindableResources struct contains information about operator backed CR and list of expected GVRs to extract information from.

func NewDetectBindableResources added in v0.0.21

NewDetectBindableResources returns new instance

func (DetectBindableResources) GetBindableVariables added in v0.0.21

func (b DetectBindableResources) GetBindableVariables() (map[string]interface{}, error)

GetBindableVariables extracts required key value information from provided GVRs subresources

func (DetectBindableResources) GetOwnedResources added in v0.0.21

func (b DetectBindableResources) GetOwnedResources() ([]unstructured.Unstructured, error)

GetBindableVariables returns list of subresources owned by operator backed CR

type OLM added in v0.0.19

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

OLM represents the actions this operator needs to take upon Operator-Lifecycle-Manager resources, like ClusterServiceVersions (CSV) and CRDDescriptions.

func NewOLM added in v0.0.19

func NewOLM(client dynamic.Interface, ns string) *OLM

NewOLM instantiate a new OLM.

func (*OLM) ListCSVOwnedCRDs added in v0.0.19

func (o *OLM) ListCSVOwnedCRDs() ([]unstructured.Unstructured, error)

ListCSVOwnedCRDs return a unstructured list of CRD objects from "owned" section in CSVs.

func (*OLM) ListCSVOwnedCRDsAsGVKs added in v0.0.19

func (o *OLM) ListCSVOwnedCRDsAsGVKs() ([]schema.GroupVersionKind, error)

ListCSVOwnedCRDsAsGVKs return the list of owned CRDs from all CSV objects as a list of GVKs.

func (*OLM) ListGVKsFromCSVNamespacedName added in v0.0.19

func (o *OLM) ListGVKsFromCSVNamespacedName(
	namespacedName types.NamespacedName,
) ([]schema.GroupVersionKind, error)

ListGVKsFromCSVNamespacedName return the list of owned GVKs for a given CSV namespaced named.

func (*OLM) SelectCRDByGVK added in v0.0.19

func (o *OLM) SelectCRDByGVK(gvk schema.GroupVersionKind) (*olmv1alpha1.CRDDescription, error)

SelectCRDByGVK return a single CRD based on a given GVK.

type Plan

type Plan struct {
	Ns             string                         // namespace name
	Name           string                         // plan name, same than ServiceBindingRequest
	CRDDescription *olmv1alpha1.CRDDescription    // custom resource definition description
	CR             *unstructured.Unstructured     // custom resource object
	SBR            v1alpha1.ServiceBindingRequest // service binding request
}

Plan outcome, after executing planner.

type Planner

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

Planner plans resources needed to bind a given backend service, using OperatorLifecycleManager standards and CustomResourceDefinitionDescription data to understand which attributes are needed.

func NewPlanner

func NewPlanner(
	ctx context.Context,
	client dynamic.Interface,
	sbr *v1alpha1.ServiceBindingRequest,
) *Planner

NewPlanner instantiate Planner type.

func (*Planner) Plan

func (p *Planner) Plan() (*Plan, error)

Plan by retrieving the necessary resources related to binding a service backend.

type Reconciler

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

Reconciler reconciles a ServiceBindingRequest object

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error)

Reconcile a ServiceBindingRequest by the following steps:

  1. Inspecting SBR in order to identify backend service. The service is composed by a CRD name and kind, and by inspecting "connects-to" label identify the name of service instance;
  2. Using OperatorLifecycleManager standards, identifying which items are intersting for binding by parsing CustomResourceDefinitionDescripton object;
  3. Search and read contents identified in previous step, creating an intermediary secret to hold data formatted as environment variables key/value;
  4. Search applications that are interested to bind with given service, by inspecting labels. The Deployment (and other kinds) will be updated in "spec" level.

type Retriever

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

Retriever reads all data referred in plan instance, and store in a secret.

func NewRetriever

func NewRetriever(client dynamic.Interface, plan *Plan, bindingPrefix string) *Retriever

NewRetriever instantiate a new retriever instance.

func (*Retriever) Retrieve

func (r *Retriever) Retrieve() ([]*unstructured.Unstructured, error)

Retrieve loop and read data pointed by the references in plan instance. It returns a slice of Unstructured refering the objects in use by the Retriever, and error when issues reading fields.

type SBRController added in v0.0.19

type SBRController struct {
	Controller controller.Controller // controller-runtime instance
	Client     dynamic.Interface     // kubernetes dynamic api client
	// contains filtered or unexported fields
}

SBRController hold the controller instance and methods for a ServiceBindingRequest.

func NewSBRController added in v0.0.19

func NewSBRController(
	mgr manager.Manager,
	options controller.Options,
	client dynamic.Interface,
) (*SBRController, error)

NewSBRController creates a new SBRController instance. It can return error on bootstrapping a new dynamic client.

func (*SBRController) AddWatchForGVK added in v0.0.19

func (s *SBRController) AddWatchForGVK(gvk schema.GroupVersionKind) error

AddWatchForGVK creates a watch on a given GVK, as long as it's not duplicated.

func (*SBRController) Watch added in v0.0.19

func (s *SBRController) Watch() error

Watch setup "watch" for all GVKs relevant for SBRController.

type SBRRequestMapper added in v0.0.19

type SBRRequestMapper struct{}

SBRRequestMapper is the handler.Mapper interface implementation. It should influence the enqueue process considering the resources informed.

func (*SBRRequestMapper) Map added in v0.0.19

Map execute the mapping of a resource with the requests it would produce. Here we inspect the given object trying to identify if this object is part of a SBR, or a actual SBR resource.

Jump to

Keyboard shortcuts

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