{"modulePath":"github.com/devfile/devworkspace-operator","version":"v1.1.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sync\n\n## Functions\n\n```go\nfunc IsRecognizedObject(specObj crclient.Object) bool\n```\nIsRecognizedObject 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.\n\n```go\nfunc SyncObjectWithCluster(specObj crclient.Object, api ClusterAPI) (crclient.Object, error)\n```\nSyncObjectWithCluster 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\n\n```go\nfunc SyncUnrecognizedObjectWithCluster(specObj crclient.Object, api ClusterAPI) (crclient.Object, error)\n```\nSyncUnrecognizedObjectWithCluster 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)\n\n## Types\n\n```go\ntype ClusterAPI struct {\n\tClient           crclient.Client\n\tNonCachingClient crclient.Client\n\tScheme           *runtime.Scheme\n\tLogger           logr.Logger\n\tCtx              context.Context\n}\n```\n\n```go\ntype NotInSyncError struct {\n\tReason NotInSyncReason\n\tObject crclient.Object\n}\n```\nNotInSyncError is returned when a spec object is out-of-sync with its cluster counterpart\n\n```go\nfunc NewNotInSync(obj crclient.Object, reason NotInSyncReason) *NotInSyncError\n```\nNewNotInSync wraps creation of NotInSyncErrors for simplicity\n\n```go\nfunc (e *NotInSyncError) Error() string\n```\n\n```go\ntype NotInSyncReason string\n```\n\n```go\nconst (\n\tUpdatedObjectReason NotInSyncReason = \"Updated object\"\n\tCreatedObjectReason NotInSyncReason = \"Created object\"\n\tDeletedObjectReason NotInSyncReason = \"Deleted object\"\n\tNeedRetryReason     NotInSyncReason = \"Need to retry\"\n)\n```\n\n```go\ntype UnrecoverableSyncError struct {\n\tCause error\n}\n```\nUnrecoverableSyncError 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).\n\n```go\nfunc (e *UnrecoverableSyncError) Error() string\n```\n\n```go\nfunc (e *UnrecoverableSyncError) Unwrap() error\n```\n\n```go\ntype WarningError struct {\n\tMessage string\n\tErr     error\n}\n```\nWarningError 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)\n\n```go\nfunc (e *WarningError) Error() string\n```\n\n```go\nfunc (e *WarningError) Unwrap() error\n```\n\n","path":"github.com/devfile/devworkspace-operator/pkg/provision/sync","name":"sync","synopsis":"","isRedistributable":true}
