Documentation ¶
Index ¶
- func LogEnqueueError(logger *zap.SugaredLogger, f func(interface{}) error) func(interface{})
- func NewControllerLogger(ctx context.Context, resource string) *zap.SugaredLogger
- type Base
- func (b *Base) CleanupCompletedTaskRunSidecars(ctx context.Context, tr *tektonv1beta1.TaskRun) error
- func (base *Base) IsNamespaceTerminating(namespace string) bool
- func (b *Base) ReconcileDeployment(ctx context.Context, desired, actual *appsv1.Deployment) (*appsv1.Deployment, error)
- func (b *Base) ReconcileRole(ctx context.Context, desired *rbacv1.Role, actual *rbacv1.Role) (*rbacv1.Role, error)
- func (b *Base) ReconcileRoleBinding(ctx context.Context, desired *rbacv1.RoleBinding, actual *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
- func (b *Base) ReconcileSecret(ctx context.Context, desired *corev1.Secret, actual *corev1.Secret) (*corev1.Secret, error)
- func (b *Base) ReconcileService(ctx context.Context, desired, actual *corev1.Service) (*corev1.Service, error)
- func (b *Base) ReconcileServiceAccount(ctx context.Context, desired *corev1.ServiceAccount, ...) (*corev1.ServiceAccount, error)
- type SemanticEqualityBuilder
- type ServiceCatalogBase
- func (scb *ServiceCatalogBase) GetBrokerForInstance(instance *v1alpha1.ServiceInstance) (broker v1alpha1.CommonServiceBroker, err error)
- func (scb *ServiceCatalogBase) GetClientForServiceInstance(serviceInstance *v1alpha1.ServiceInstance) (osbclient.Client, error)
- func (scb *ServiceCatalogBase) GetCredentialsSecretForBroker(broker v1alpha1.CommonServiceBroker) (*corev1.Secret, error)
- func (scb *ServiceCatalogBase) GetInstanceForBinding(binding *v1alpha1.ServiceInstanceBinding) (*v1alpha1.ServiceInstance, error)
- type UnstructuredSemanticEqualityBuilder
- func (s *UnstructuredSemanticEqualityBuilder) Append(fieldStr string, desired *unstructured.Unstructured, ...) *UnstructuredSemanticEqualityBuilder
- func (s *UnstructuredSemanticEqualityBuilder) IsSemanticallyEqual() bool
- func (s *UnstructuredSemanticEqualityBuilder) Transform(existing *unstructured.Unstructured)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogEnqueueError ¶
func LogEnqueueError(logger *zap.SugaredLogger, f func(interface{}) error) func(interface{})
LogEnqueueError allows functions that assist with enqueing to return an error. Normal workflows work better when errors can be returned (instead of just logged). Therefore logError allows these functions to return an error and it will take care of swallowing and logging it.
func NewControllerLogger ¶
func NewControllerLogger(ctx context.Context, resource string) *zap.SugaredLogger
Types ¶
type Base ¶
type Base struct { // KubeClientSet allows us to talk to the k8s for core APIs KubeClientSet kubernetes.Interface // KfClientSet allows us to configure Kf objects KfClientSet kfclientset.Interface // ConfigMapWatcher allows us to watch for ConfigMap changes. ConfigMapWatcher configmap.Watcher // NamespaceLister allows us to list Namespaces. We use this to check for // terminating namespaces. NamespaceLister v1listers.NamespaceLister // SecretLister allows us to list Secrets. SecretLister v1listers.SecretLister // SecretInformer allows us to AddEventHandlers for Secrets. SecretInformer informerscorev1.SecretInformer }
Base implements the core controller logic, given a Reconciler.
func NewBase ¶
NewBase instantiates a new instance of Base implementing the common & boilerplate code between our reconcilers.
func (*Base) CleanupCompletedTaskRunSidecars ¶
func (b *Base) CleanupCompletedTaskRunSidecars(ctx context.Context, tr *tektonv1beta1.TaskRun) error
CleanupCompletedTaskRunSidecars removes sidecars if the TaskRun is completed.
func (*Base) IsNamespaceTerminating ¶
IsNamespaceTerminating returns true if the namespace is marked as terminating and false if the state is unknown or not terminating.
func (*Base) ReconcileDeployment ¶
func (b *Base) ReconcileDeployment(ctx context.Context, desired, actual *appsv1.Deployment) (*appsv1.Deployment, error)
ReconcileDeployment syncs the existing K8s Deployment to the desired Deployment.
func (*Base) ReconcileRole ¶
func (b *Base) ReconcileRole( ctx context.Context, desired *rbacv1.Role, actual *rbacv1.Role, ) (*rbacv1.Role, error)
ReconcileRole syncs the existing K8s Role to the desired Role.
func (*Base) ReconcileRoleBinding ¶
func (b *Base) ReconcileRoleBinding( ctx context.Context, desired *rbacv1.RoleBinding, actual *rbacv1.RoleBinding, ) (*rbacv1.RoleBinding, error)
ReconcileRoleBinding syncs the existing K8s RoleBinding to the desired RoleBinding.
func (*Base) ReconcileSecret ¶
func (b *Base) ReconcileSecret( ctx context.Context, desired *corev1.Secret, actual *corev1.Secret, ) (*corev1.Secret, error)
ReconcileSecret syncs the existing K8s Secret to the desired Secret.
func (*Base) ReconcileService ¶
func (b *Base) ReconcileService(ctx context.Context, desired, actual *corev1.Service) (*corev1.Service, error)
ReconcileService syncs the existing K8s Service to the desired Service.
func (*Base) ReconcileServiceAccount ¶
func (b *Base) ReconcileServiceAccount( ctx context.Context, desired *corev1.ServiceAccount, actual *corev1.ServiceAccount, checkForWI bool, ) (*corev1.ServiceAccount, error)
ReconcileServiceAccount syncs the actual service account to the desired SA. The reconciliation merges the secrets on the service accounts rather than replacing them. This is because the k8s cluster creates a default token secret per SA after the SA is first created.
type SemanticEqualityBuilder ¶
type SemanticEqualityBuilder struct {
// contains filtered or unexported fields
}
SemanticEqualityBuilder assists in building deep equality checks for reconcilers.
func NewSemanticEqualityBuilder ¶
func NewSemanticEqualityBuilder(logger *zap.SugaredLogger, typeName string) *SemanticEqualityBuilder
NewSemanticEqualityBuilder creates a SemanticEqualityBuilder.
Example ¶
logger := zap.NewNop() builder := NewSemanticEqualityBuilder(logger.Sugar(), "ExampleType") fmt.Println("Initially equal:", builder.IsSemanticallyEqual()) builder.Append("some.field", "a", "a") fmt.Println("After some.field:", builder.IsSemanticallyEqual()) builder.Append("bad.field", "a", 1) fmt.Println("After bad.field:", builder.IsSemanticallyEqual())
Output: Initially equal: true After some.field: true After bad.field: false
Example (Logging) ¶
logger := zap.NewExample() defer logger.Sync() NewSemanticEqualityBuilder(logger.Sugar(), "ExampleType"). Append("some.field", "a", "a"). Append("bad.field", "a", 1). IsSemanticallyEqual()
Output: {"level":"debug","msg":"detected diff","type":"ExampleType","desired":"a","actual":1,"field":"bad.field"}
func (*SemanticEqualityBuilder) Append ¶
func (s *SemanticEqualityBuilder) Append(field string, desired, actual interface{}) *SemanticEqualityBuilder
Append adds a semantic deep equality check of the given field to the builder.
func (*SemanticEqualityBuilder) IsSemanticallyEqual ¶
func (s *SemanticEqualityBuilder) IsSemanticallyEqual() bool
IsSemanticallyEqual returns true if the fields that have been checked are all semantically equal.
type ServiceCatalogBase ¶
type ServiceCatalogBase struct { *Base KfClusterServiceBrokerLister kflisters.ClusterServiceBrokerLister KfServiceBrokerLister kflisters.ServiceBrokerLister KfServiceInstanceLister kflisters.ServiceInstanceLister KfServiceInstanceBindingLister kflisters.ServiceInstanceBindingLister }
ServiceCatalogBase contains utilities used by service brokers.
func NewServiceCatalogBase ¶
func NewServiceCatalogBase(ctx context.Context, cmw configmap.Watcher) *ServiceCatalogBase
NewServiceCatalogBase instantiates a new instance of ServiceCatalogBase.
func (*ServiceCatalogBase) GetBrokerForInstance ¶
func (scb *ServiceCatalogBase) GetBrokerForInstance( instance *v1alpha1.ServiceInstance, ) (broker v1alpha1.CommonServiceBroker, err error)
GetBrokerForInstance returns a ServiceBroker that the ServiceInstance belongs to.
func (*ServiceCatalogBase) GetClientForServiceInstance ¶
func (scb *ServiceCatalogBase) GetClientForServiceInstance(serviceInstance *v1alpha1.ServiceInstance) (osbclient.Client, error)
GetClientForServiceInstance gets the OSB client for a specific ServiceInstance.
func (*ServiceCatalogBase) GetCredentialsSecretForBroker ¶
func (scb *ServiceCatalogBase) GetCredentialsSecretForBroker( broker v1alpha1.CommonServiceBroker, ) (*corev1.Secret, error)
GetCredentialsSecretForBroker returns the credentials secret for the given broker.
func (*ServiceCatalogBase) GetInstanceForBinding ¶
func (scb *ServiceCatalogBase) GetInstanceForBinding( binding *v1alpha1.ServiceInstanceBinding, ) (*v1alpha1.ServiceInstance, error)
GetInstanceForBinding returns a ServiceInstance that the binding belongs to.
type UnstructuredSemanticEqualityBuilder ¶
type UnstructuredSemanticEqualityBuilder struct {
// contains filtered or unexported fields
}
UnstructuredSemanticEqualityBuilder assists in building deep equality checks for reconcilers.
func NewUnstructuredSemanticEqualityBuilder ¶
func NewUnstructuredSemanticEqualityBuilder(logger *zap.SugaredLogger, typeName string) *UnstructuredSemanticEqualityBuilder
NewUnstructuredSemanticEqualityBuilder creates a UnstructuredSemanticEqualityBuilder.
Example ¶
logger := zap.NewNop() a := &unstructured.Unstructured{ Object: map[string]interface{}{ "spec": map[string]interface{}{ "a": 0, "b": 1, "slice": []int{ 0, 1, }, }, }, } b := &unstructured.Unstructured{ Object: map[string]interface{}{ "spec": map[string]interface{}{ "a": 0, "b": 2, }, }, } builder := NewUnstructuredSemanticEqualityBuilder(logger.Sugar(), "ExampleType") fmt.Println("Initially equal:", builder.IsSemanticallyEqual()) builder.Append("spec.a", a, b) fmt.Println("After spec.a:", builder.IsSemanticallyEqual()) builder.Append("spec.slice.bad", a, b) fmt.Println("After spec.slice.bad:", builder.IsSemanticallyEqual())
Output: Initially equal: true After spec.a: true After spec.slice.bad: false
Example (Logging) ¶
logger := zap.NewExample() defer logger.Sync() a := &unstructured.Unstructured{ Object: map[string]interface{}{ "spec": map[string]interface{}{ "a": 0, "b": 1, }, }, } b := &unstructured.Unstructured{ Object: map[string]interface{}{ "spec": map[string]interface{}{ "a": 0, "b": 2, }, }, } NewUnstructuredSemanticEqualityBuilder(logger.Sugar(), "ExampleType"). Append("spec.a", a, b). Append("spec.b", a, b). IsSemanticallyEqual()
Output: {"level":"debug","msg":"detected diff","type":"ExampleType","desired":1,"actual":2,"field":"spec.b"}
Example (Transform) ¶
logger := zap.NewNop() desired := &unstructured.Unstructured{ Object: map[string]interface{}{ "spec": map[string]interface{}{ "a": 0, "b": 1, }, }, } actual := &unstructured.Unstructured{ Object: map[string]interface{}{ "spec": map[string]interface{}{ "a": 0, "b": 2, }, }, } builder := NewUnstructuredSemanticEqualityBuilder(logger.Sugar(), "ExampleType") fmt.Println("Initially equal:", builder.IsSemanticallyEqual()) builder.Append("spec.a", desired, actual) fmt.Println("After spec.a:", builder.IsSemanticallyEqual()) builder.Append("spec.b", desired, actual) fmt.Println("After spec.b:", builder.IsSemanticallyEqual()) builder.Transform(actual) builder2 := NewUnstructuredSemanticEqualityBuilder(logger.Sugar(), "ExampleType") builder2.Append("spec.b", desired, actual) fmt.Println("After transform spec.b:", builder2.IsSemanticallyEqual())
Output: Initially equal: true After spec.a: true After spec.b: false After transform spec.b: true
func (*UnstructuredSemanticEqualityBuilder) Append ¶
func (s *UnstructuredSemanticEqualityBuilder) Append( fieldStr string, desired *unstructured.Unstructured, actual *unstructured.Unstructured, ) *UnstructuredSemanticEqualityBuilder
Append adds a semantic deep equality check of the given field to the builder.
func (*UnstructuredSemanticEqualityBuilder) IsSemanticallyEqual ¶
func (s *UnstructuredSemanticEqualityBuilder) IsSemanticallyEqual() bool
IsSemanticallyEqual returns true if the fields that have been checked are all semantically equal.
func (*UnstructuredSemanticEqualityBuilder) Transform ¶
func (s *UnstructuredSemanticEqualityBuilder) Transform(existing *unstructured.Unstructured)
Transform will perform all the transformations on the Unstructured object to make the actual object match the desired one.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
resources
Package resources holds simple functions for synthesizing child resources from an App.
|
Package resources holds simple functions for synthesizing child resources from an App. |
resources
Package resources holds simple functions for synthesizing child resources from a Build.
|
Package resources holds simple functions for synthesizing child resources from a Build. |
Package integration contains integration tests for the reconciler and its dependencies.
|
Package integration contains integration tests for the reconciler and its dependencies. |
Package reconcilerutil holds utility functions for Kf reconcilers similar to go's ioutil and httputil packages.
|
Package reconcilerutil holds utility functions for Kf reconcilers similar to go's ioutil and httputil packages. |
Package route contains the reconciler for three types:
|
Package route contains the reconciler for three types: |
resources
Package resources holds simple functions for synthesizing child resources from a Route.
|
Package resources holds simple functions for synthesizing child resources from a Route. |
resources
Package resources holds simple functions for synthesizing child resources from a Space.
|
Package resources holds simple functions for synthesizing child resources from a Space. |