Documentation ¶
Index ¶
- func IsRecognizedObject(specObj crclient.Object) bool
- func SyncObjectWithCluster(specObj crclient.Object, api ClusterAPI) (crclient.Object, error)
- func SyncUnrecognizedObjectWithCluster(specObj crclient.Object, api ClusterAPI) (crclient.Object, error)
- type ClusterAPI
- type NotInSyncError
- type NotInSyncReason
- type UnrecoverableSyncError
- type WarningError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRecognizedObject ¶ added in v0.18.0
IsRecognizedObject returns whether the provided object kind is recognized by the sync package to support updating existing objects on the cluster. If the object is not recognized, passing it to SyncObjectWithCluster will fail. Instead, SyncUnrecognizedObjectWithCluster should be used.
func SyncObjectWithCluster ¶
SyncObjectWithCluster synchronises the state of specObj to the cluster, creating or updating the cluster object as required. If specObj is in sync with the cluster, returns the object as it exists on the cluster. Returns a NotInSyncError if an update is required, UnrecoverableSyncError if object provided is invalid, or generic error if an unexpected error is encountered
func SyncUnrecognizedObjectWithCluster ¶ added in v0.18.0
func SyncUnrecognizedObjectWithCluster(specObj crclient.Object, api ClusterAPI) (crclient.Object, error)
SyncUnrecognizedObjectWithCluster allows syncing objects not supported by SyncObjectWithCluster. As there is no generic way of deciding if an object needs to be updated, a WarningError is returned if the object exists on the cluster. The only object updating performed by this function is to ensure labels/annotations and ownerReferences in specObj are synced to the cluster. The reason arbitrary updates are not supported is 1) certain objects have defaulted fields that can always trigger naive diff checks (causing reconciles to get stuck), and 2) it's unknown which fields are unmodifiable, (e.g. services must keep ClusterIP once set; pod fields cannot be changed after creation)
Types ¶
type ClusterAPI ¶
type NotInSyncError ¶
type NotInSyncError struct { Reason NotInSyncReason Object crclient.Object }
NotInSyncError is returned when a spec object is out-of-sync with its cluster counterpart
func NewNotInSync ¶
func NewNotInSync(obj crclient.Object, reason NotInSyncReason) *NotInSyncError
NewNotInSync wraps creation of NotInSyncErrors for simplicity
func (*NotInSyncError) Error ¶
func (e *NotInSyncError) Error() string
type NotInSyncReason ¶
type NotInSyncReason string
const ( UpdatedObjectReason NotInSyncReason = "Updated object" CreatedObjectReason NotInSyncReason = "Created object" DeletedObjectReason NotInSyncReason = "Deleted object" NeedRetryReason NotInSyncReason = "Need to retry" )
type UnrecoverableSyncError ¶
type UnrecoverableSyncError struct {
Cause error
}
UnrecoverableSyncError is returned when provided objects cannot be synced with the cluster due to an unexpected error (e.g. they are invalid according to the object's spec).
func (*UnrecoverableSyncError) Error ¶
func (e *UnrecoverableSyncError) Error() string
func (*UnrecoverableSyncError) Unwrap ¶ added in v0.18.0
func (e *UnrecoverableSyncError) Unwrap() error
type WarningError ¶ added in v0.18.0
WarningError is returned when syncing is successful and can continue but there is a warning regarding the objects synced to the cluster (e.g. they will not be updated)
func (*WarningError) Error ¶ added in v0.18.0
func (e *WarningError) Error() string
func (*WarningError) Unwrap ¶ added in v0.18.0
func (e *WarningError) Unwrap() error