Documentation ¶
Overview ¶
Copyright 2022 Matrix Origin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2022 Matrix Origin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2022 Matrix Origin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func CreateOwnedOrUpdate(kubeCli KubeClient, obj client.Object, mutateFn func() error) error
- func GetCondition(c Conditional, conditionType ConditionType) (*metav1.Condition, bool)
- func IsNil(object interface{}) bool
- func IsReady(c Conditional) bool
- func IsSynced(c Conditional) bool
- func IsSyncedWithLatestGeneration(c Conditional, latest int64) bool
- func Setup[T client.Object](tpl T, name string, mgr ctrl.Manager, actor Actor[T], applyOpts ...ApplyOption) error
- type Action
- type Actor
- type ApplyOption
- func SkipFinalizer() ApplyOption
- func SkipPatchFinalizer() ApplyOption
- func SkipStatusSync() ApplyOption
- func WithBuildFn(buildFn func(*builder.Builder)) ApplyOption
- func WithControllerOptions(opts controller.Options) ApplyOption
- func WithEventRecorder(recorder record.EventRecorder) ApplyOption
- func WithLogger(logger logr.Logger) ApplyOption
- func WithPredicate(pred predicate.Predicate) ApplyOption
- type ConditionType
- type Conditional
- type ConditionalStatus
- type Context
- func (c *Context[T]) Create(obj client.Object, opts ...client.CreateOption) error
- func (c *Context[T]) CreateOwned(obj client.Object, opts ...client.CreateOption) error
- func (c *Context[T]) Delete(obj client.Object, opts ...client.DeleteOption) error
- func (c *Context[T]) Exist(objKey client.ObjectKey, kind client.Object) (bool, error)
- func (c *Context[T]) Get(objKey client.ObjectKey, obj client.Object) error
- func (c *Context[T]) List(objList client.ObjectList, opts ...client.ListOption) error
- func (c *Context[T]) Patch(obj client.Object, mutateFn func() error, opts ...client.PatchOption) error
- func (c *Context[T]) PatchStatus(obj client.Object, mutateFn func() error, ...) error
- func (c *Context[T]) Update(obj client.Object, opts ...client.UpdateOption) error
- func (c *Context[T]) UpdateStatus(obj client.Object, opts ...client.SubResourceUpdateOption) error
- type Dependant
- type Dependency
- type EmitEventWrapper
- func (e *EmitEventWrapper) EmitEventGeneric(eventReason, msg string, err error)
- func (e *EmitEventWrapper) EmitEventOnCreate(createObj client.Object, err error)
- func (e *EmitEventWrapper) EmitEventOnDelete(deleteObj client.Object, err error)
- func (e *EmitEventWrapper) EmitEventOnGetError(getObj client.Object, err error)
- func (e *EmitEventWrapper) EmitEventOnList(listObj client.ObjectList, err error)
- func (e *EmitEventWrapper) EmitEventOnPatch(patchObj client.Object, err error)
- func (e *EmitEventWrapper) EmitEventOnUpdate(updateObj client.Object, err error)
- func (e *EmitEventWrapper) EmitEventRollingDeployWait(k8sObj client.Object)
- type EventEmitter
- type EventReason
- type GenericEventEmitter
- type K8sEventEmitter
- type KubeClient
- type ObjectDependency
- type ReSync
- type Reconciler
Constants ¶
const ( // ConditionTypeReady Whether the object is ready to act ConditionTypeReady = "Ready" // ConditionTypeSynced Whether the object is update to date ConditionTypeSynced = "Synced" )
const ( Error = 0 Warn = 1 Info = 2 ExtendedInfo = 3 Debug = 4 Trace = 5 )
Variables ¶
This section is empty.
Functions ¶
func CreateOwnedOrUpdate ¶
func CreateOwnedOrUpdate(kubeCli KubeClient, obj client.Object, mutateFn func() error) error
func GetCondition ¶
func GetCondition(c Conditional, conditionType ConditionType) (*metav1.Condition, bool)
func IsReady ¶
func IsReady(c Conditional) bool
func IsSynced ¶
func IsSynced(c Conditional) bool
deprecated: use IsSyncedWithLatestGeneration instead
func IsSyncedWithLatestGeneration ¶
func IsSyncedWithLatestGeneration(c Conditional, latest int64) bool
func Setup ¶
func Setup[T client.Object](tpl T, name string, mgr ctrl.Manager, actor Actor[T], applyOpts ...ApplyOption) error
Setup register a kubernetes reconciler to the resource kind defined by T. Name is the name of the reconciler, which should be unique across a cluster. Manager represents the kubernetes cluster. Actor implements the logic of the reconciliation.
Types ¶
type ApplyOption ¶
type ApplyOption func(*options)
func SkipFinalizer ¶
func SkipFinalizer() ApplyOption
func SkipPatchFinalizer ¶
func SkipPatchFinalizer() ApplyOption
func SkipStatusSync ¶
func SkipStatusSync() ApplyOption
func WithBuildFn ¶
func WithBuildFn(buildFn func(*builder.Builder)) ApplyOption
WithBuildFn allows customizing reconciler.Builder defined the controller-runtime
func WithControllerOptions ¶
func WithControllerOptions(opts controller.Options) ApplyOption
WithControllerOptions set the controller options of the reconciler
func WithEventRecorder ¶
func WithEventRecorder(recorder record.EventRecorder) ApplyOption
WithEventRecorder set the event recorder of the reconciler
func WithLogger ¶
func WithLogger(logger logr.Logger) ApplyOption
WithLogger set the logger of the reconciler
func WithPredicate ¶
func WithPredicate(pred predicate.Predicate) ApplyOption
type ConditionType ¶
type ConditionType string
type Conditional ¶
type ConditionalStatus ¶
func (*ConditionalStatus) DeepCopy ¶
func (in *ConditionalStatus) DeepCopy() *ConditionalStatus
func (*ConditionalStatus) DeepCopyInto ¶
func (in *ConditionalStatus) DeepCopyInto(out *ConditionalStatus)
func (*ConditionalStatus) GetConditions ¶
func (c *ConditionalStatus) GetConditions() []metav1.Condition
func (*ConditionalStatus) SetCondition ¶
func (c *ConditionalStatus) SetCondition(condition metav1.Condition)
type Context ¶
type Context[T client.Object] struct { context.Context Obj T // Dep hold the dependencies of the object T, will only be set when // the object implement the `Dependant` interface Dep T Client client.Client // TODO(aylei): add tracing Event EventEmitter Log logr.Logger }
func (*Context[T]) CreateOwned ¶
CreateOwned create the given object with an OwnerReference to the currently reconciling controller object (ctx.Obj)
func (*Context[T]) List ¶
func (c *Context[T]) List(objList client.ObjectList, opts ...client.ListOption) error
func (*Context[T]) Patch ¶
func (c *Context[T]) Patch(obj client.Object, mutateFn func() error, opts ...client.PatchOption) error
Patch patches the mutation by mutateFn to the spec of given obj an error would be raised if mutateFn changed anything immutable (e.g. namespace / name). Changes will be merged with current object, optimisticLock is enforced.
func (*Context[T]) PatchStatus ¶
func (c *Context[T]) PatchStatus(obj client.Object, mutateFn func() error, opts ...client.SubResourcePatchOption) error
PatchStatus patches the mutation by mutateFn to the status of given obj an error would be raised if mutateFn changed anything immutable (e.g. namespace / name)
func (*Context[T]) UpdateStatus ¶
UpdateStatus update the status of the given obj
type Dependant ¶
type Dependant interface {
GetDependencies() []Dependency
}
type Dependency ¶
type Dependency interface { // IsReady checks whether the given object is ready IsReady(kubeCli KubeClient) (bool, error) }
type EmitEventWrapper ¶
type EmitEventWrapper struct { record.EventRecorder // contains filtered or unexported fields }
EmitEventWrapper captures the object being reconciled and associated all emitted events with that object
func (*EmitEventWrapper) EmitEventGeneric ¶
func (e *EmitEventWrapper) EmitEventGeneric(eventReason, msg string, err error)
EmitEventGeneric shall emit a generic event
func (*EmitEventWrapper) EmitEventOnCreate ¶
func (e *EmitEventWrapper) EmitEventOnCreate(createObj client.Object, err error)
EmitEventOnCreate shall emit event on CREATE operation
func (*EmitEventWrapper) EmitEventOnDelete ¶
func (e *EmitEventWrapper) EmitEventOnDelete(deleteObj client.Object, err error)
EmitEventOnDelete shall emit event on DELETE operation
func (*EmitEventWrapper) EmitEventOnGetError ¶
func (e *EmitEventWrapper) EmitEventOnGetError(getObj client.Object, err error)
EmitEventOnGetError shall emit event on GET err operation
func (*EmitEventWrapper) EmitEventOnList ¶
func (e *EmitEventWrapper) EmitEventOnList(listObj client.ObjectList, err error)
EmitEventOnList shall emit event on LIST err operation
func (*EmitEventWrapper) EmitEventOnPatch ¶
func (e *EmitEventWrapper) EmitEventOnPatch(patchObj client.Object, err error)
EmitEventOnPatch shall emit event on PATCH operation
func (*EmitEventWrapper) EmitEventOnUpdate ¶
func (e *EmitEventWrapper) EmitEventOnUpdate(updateObj client.Object, err error)
EmitEventOnUpdate shall emit event on UPDATE operation
func (*EmitEventWrapper) EmitEventRollingDeployWait ¶
func (e *EmitEventWrapper) EmitEventRollingDeployWait(k8sObj client.Object)
type EventEmitter ¶
type EventEmitter interface { K8sEventEmitter GenericEventEmitter }
EventEmitter Interface is a wrapper interface for all the emitter interface operator shall support.
type EventReason ¶
type EventReason string
TODO(aylei): event.go is modified from pkg/controller/event.go, remove the original one once we migrate to mo-runtime
type GenericEventEmitter ¶
GenericEventEmitter can be used for any case where the state change isn't handled by reader,writer or any custom event.
type K8sEventEmitter ¶
type K8sEventEmitter interface { EmitEventRollingDeployWait(k8sObj client.Object) EmitEventOnGetError(getObj client.Object, err error) EmitEventOnUpdate(updateObj client.Object, err error) EmitEventOnDelete(deleteObj client.Object, err error) EmitEventOnCreate(createObj client.Object, err error) EmitEventOnPatch(patchObj client.Object, err error) EmitEventOnList(listObj client.ObjectList, err error) }
type KubeClient ¶
type KubeClient interface { Create(obj client.Object, opts ...client.CreateOption) error CreateOwned(obj client.Object, opts ...client.CreateOption) error Get(objKey client.ObjectKey, obj client.Object) error Update(obj client.Object, opts ...client.UpdateOption) error UpdateStatus(obj client.Object, opts ...client.SubResourceUpdateOption) error Delete(obj client.Object, opts ...client.DeleteOption) error List(objList client.ObjectList, opts ...client.ListOption) error Patch(obj client.Object, mutateFn func() error, opts ...client.PatchOption) error Exist(objKey client.ObjectKey, kind client.Object) (bool, error) }
type ObjectDependency ¶
func (*ObjectDependency[T]) IsReady ¶
func (od *ObjectDependency[T]) IsReady(kubeCli KubeClient) (bool, error)