common

package
v1.3.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationStatusInfoHealthy      = "Device's application workloads are healthy."
	ApplicationStatusInfoUndefined    = "Device has not reported any application workloads yet."
	DeviceStatusInfoHealthy           = "Device's system resources are healthy."
	DeviceStatusInfoRebooting         = "Device is rebooting."
	DeviceStatusInfoAwaitingReconnect = "Device has not reconnected since restore to confirm its current state."
	DeviceStatusInfoConflictPaused    = "" /* 132-byte string literal not displayed */
	CPUIsCritical                     = "CPU utilization has reached a critical level."
	CPUIsWarning                      = "CPU utilization has reached a warning level."
	CPUIsNormal                       = "CPU utilization has returned to normal."
	MemoryIsCritical                  = "Memory utilization has reached a critical level."
	MemoryIsWarning                   = "Memory utilization has reached a warning level."
	MemoryIsNormal                    = "Memory utilization has returned to normal."
	DiskIsCritical                    = "Disk utilization has reached a critical level."
	DiskIsWarning                     = "Disk utilization has reached a warning level."
	DiskIsNormal                      = "Disk utilization has returned to normal."
)
View Source
const MaxConcurrentAgents = 15

MaxConcurrentAgents bounds the number of concurrent agent-originated requests a resource's ServiceHandler will process at once via its own semaphore.Weighted gate.

View Source
const MaxRecordsPerListRequest = 1000

MaxRecordsPerListRequest bounds the number of records a single list request may return.

Variables

This section is empty.

Functions

func ApiStatusToErr added in v1.3.0

func ApiStatusToErr(status domain.Status) error

ApiStatusToErr converts a non-2xx domain.Status into an error, or nil for 2xx statuses.

func AppTypeToItemType added in v1.3.0

func AppTypeToItemType(appType domain.AppType) domain.CatalogItemType

func ApplyJSONPatch added in v1.3.0

func ApplyJSONPatch[T any](ctx context.Context, obj T, newObj T, patchRequest domain.PatchRequest, objPath string, getSwagger ...SwaggerGetter) error

ApplyJSONPatch applies patchRequest to obj, validates the result against the OpenAPI schema at objPath, and decodes it into newObj.

func CastResources added in v1.3.0

func CastResources[T any](oldResource, newResource interface{}) (oldTyped, newTyped *T, ok bool)

CastResources safely casts both old and new interface{} resources to the specified type T. Returns ok=true only if both resources are either nil or successfully cast to *T.

func CheckResourceVersionConflict added in v1.3.0

func CheckResourceVersionConflict(current, incoming *domain.ObjectMeta) error

CheckResourceVersionConflict rejects a client-supplied resourceVersion that does not match the current stored value. A nil incoming resourceVersion skips the check (server-side CAS still applies on persist). When the client supplies a value (including "0") and the current resourceVersion is unset, the request conflicts — do not treat nil current as matching "0".

func CollectCatalogItemRefs added in v1.3.0

func CollectCatalogItemRefs(spec *domain.DeviceSpec) []domain.CatalogItemRefSpec

CollectCatalogItemRefs extracts all CatalogItemRefSpec values from a device spec's OS, application, and volume fields.

func ComputeResourceUpdatedDetails added in v1.3.0

func ComputeResourceUpdatedDetails(oldMetadata, newMetadata domain.ObjectMeta) *domain.ResourceUpdatedDetails

ComputeResourceUpdatedDetails determines which fields were updated by comparing old and new ObjectMeta. Generic across all resource kinds; resource-specific event handlers use this to build domain.ResourceUpdatedDetails before emitting a ResourceUpdated event.

func EmitMultipleOwnersEvents added in v0.9.0

func EmitMultipleOwnersEvents(ctx context.Context, device *domain.Device, oldCondition, newCondition *domain.Condition,
	createEvent func(context.Context, *domain.Event),
	getDeviceMultipleOwnersDetectedEvent func(context.Context, string, []string, logrus.FieldLogger) *domain.Event,
	getDeviceMultipleOwnersResolvedEvent func(context.Context, string, domain.DeviceMultipleOwnersResolvedDetailsResolutionType, *string, []string, logrus.FieldLogger) *domain.Event,
	log logrus.FieldLogger)

EmitMultipleOwnersEvents emits events for MultipleOwners condition changes

func EmitSpecValidEvents added in v0.9.0

func EmitSpecValidEvents(ctx context.Context, device *domain.Device, oldCondition, newCondition *domain.Condition,
	createEvent func(context.Context, *domain.Event),
	getDeviceSpecValidEvent func(ctx context.Context, deviceName string) *domain.Event,
	getDeviceSpecInvalidEvent func(ctx context.Context, deviceName string, message string) *domain.Event,
	log logrus.FieldLogger,
)

EmitSpecValidEvents emits events for SpecValid condition changes

func ExtractAppCatalogItemRef added in v1.3.0

func ExtractAppCatalogItemRef(app *domain.ApplicationProviderSpec) (*domain.CatalogItemRefSpec, *string)

ExtractAppCatalogItemRef returns the catalog item ref and application name from an application provider spec, if it uses a catalog item ref provider type.

func ExtractVolumeCatalogItemRefs added in v1.3.0

func ExtractVolumeCatalogItemRefs(app *domain.ApplicationProviderSpec) ([]domain.CatalogItemRefSpec, *string)

ExtractVolumeCatalogItemRefs returns all catalog item refs from an application's volumes, along with the application name.

func GetApplicationLifecycleChangedEvent added in v1.3.0

func GetApplicationLifecycleChangedEvent(ctx context.Context, deviceName string, appName string, action domain.ApplicationLifecycleChangedDetailsAction) *domain.Event

GetApplicationLifecycleChangedEvent creates an event for a device-level application lifecycle change (stop/start/restart).

func GetDependencyChangeDetectedEvent added in v1.2.0

func GetDependencyChangeDetectedEvent(ctx context.Context, kind domain.ResourceKind, name, resourceKey, fingerprint string) *domain.Event

GetDependencyChangeDetectedEvent creates an event when the sync controller detects an upstream change.

func GetDependencySyncProbeFailedEvent added in v1.2.0

func GetDependencySyncProbeFailedEvent(ctx context.Context, kind domain.ResourceKind, name, resourceKey, sanitizedError string) *domain.Event

GetDependencySyncProbeFailedEvent creates an audit event when a dependency probe fails.

func GetDeviceConflictPausedEvent added in v0.10.0

func GetDeviceConflictPausedEvent(ctx context.Context, deviceName string) *domain.Event

GetDeviceConflictPausedEvent creates an event for device being paused due to version conflict

func GetDeviceConflictResolvedEvent added in v0.10.0

func GetDeviceConflictResolvedEvent(ctx context.Context, deviceName string) *domain.Event

GetDeviceConflictResolvedEvent creates an event for device conflict being resolved

func GetDeviceDecommissionedFailureEvent added in v0.9.0

func GetDeviceDecommissionedFailureEvent(ctx context.Context, _ bool, _ domain.ResourceKind, resourceName string, status domain.Status) *domain.Event

GetDeviceDecommissionedFailureEvent creates an event for failed device decommission

func GetDeviceDecommissionedSuccessEvent added in v0.9.0

func GetDeviceDecommissionedSuccessEvent(ctx context.Context, _ bool, _ domain.ResourceKind, resourceName string, update *domain.ResourceUpdatedDetails, log logrus.FieldLogger) *domain.Event

GetDeviceDecommissionedSuccessEvent creates an event for successful device decommission

func GetDeviceEventFromUpdateDetails added in v0.9.0

func GetDeviceEventFromUpdateDetails(ctx context.Context, resourceName string, update ResourceUpdate) *domain.Event

GetDeviceEventFromUpdateDetails creates a device event from update details

func GetDeviceMultipleOwnersDetectedEvent added in v0.9.0

func GetDeviceMultipleOwnersDetectedEvent(ctx context.Context, deviceName string, matchingFleets []string, log logrus.FieldLogger) *domain.Event

GetDeviceMultipleOwnersDetectedEvent creates an event for multiple fleet owners detected

func GetDeviceMultipleOwnersResolvedEvent added in v0.9.0

func GetDeviceMultipleOwnersResolvedEvent(ctx context.Context, deviceName string, resolutionType domain.DeviceMultipleOwnersResolvedDetailsResolutionType, assignedOwner *string, previousMatchingFleets []string, log logrus.FieldLogger) *domain.Event

GetDeviceMultipleOwnersResolvedEvent creates an event for multiple fleet owners resolved

func GetDeviceSpecInvalidEvent added in v0.9.0

func GetDeviceSpecInvalidEvent(ctx context.Context, deviceName string, message string) *domain.Event

GetDeviceSpecInvalidEvent creates an event for device spec becoming invalid

func GetDeviceSpecValidEvent added in v0.9.0

func GetDeviceSpecValidEvent(ctx context.Context, deviceName string) *domain.Event

GetDeviceSpecValidEvent creates an event for device spec becoming valid

func GetEncryptionMigrationCompletedEvent added in v1.3.0

func GetEncryptionMigrationCompletedEvent(ctx context.Context, keyID string, retiredKeyIDs []string) *domain.Event

GetEncryptionMigrationCompletedEvent creates a system-wide event when encryption migration finishes for a key. retiredKeyIDs lists previous keys prepared for retirement after the migration completed.

func GetEncryptionMigrationStartedEvent added in v1.3.0

func GetEncryptionMigrationStartedEvent(ctx context.Context, keyID string) *domain.Event

GetEncryptionMigrationStartedEvent creates a system-wide event when encryption migration begins for a key.

func GetEnrollmentRequestApprovalFailedEvent added in v0.9.0

func GetEnrollmentRequestApprovalFailedEvent(ctx context.Context, resourceName string, status domain.Status, log logrus.FieldLogger) *domain.Event

GetEnrollmentRequestApprovalFailedEvent creates an event for failed enrollment request approval

func GetEnrollmentRequestApprovedEvent added in v0.9.0

func GetEnrollmentRequestApprovedEvent(ctx context.Context, resourceName string, log logrus.FieldLogger) *domain.Event

GetEnrollmentRequestApprovedEvent creates an event for enrollment request approval

func GetFleetApplicationLifecycleChangedEvent added in v1.3.0

func GetFleetApplicationLifecycleChangedEvent(ctx context.Context, fleetName string, appName string, action domain.ApplicationLifecycleChangedDetailsAction) *domain.Event

GetFleetApplicationLifecycleChangedEvent creates an event for a fleet-level application lifecycle change (fleet-scoped stop/start APIs).

func GetFleetRolloutBatchCompletedEvent added in v0.9.0

func GetFleetRolloutBatchCompletedEvent(ctx context.Context, name string, deployingTemplateVersion string, report *domain.RolloutBatchCompletionReport) *domain.Event

GetFleetRolloutBatchCompletedEvent creates an event for fleet rollout completion

func GetFleetRolloutBatchDispatchedEvent added in v0.9.0

func GetFleetRolloutBatchDispatchedEvent(ctx context.Context, fleetName string, templateVersion string, batch string) *domain.Event

GetFleetRolloutBatchDispatchedEvent creates an event for fleet rollout batch dispatch

func GetFleetRolloutCompletedEvent added in v0.9.0

func GetFleetRolloutCompletedEvent(ctx context.Context, name string, templateVersion string) *domain.Event

GetFleetRolloutCompletedEvent creates an event for fleet rollout completion

func GetFleetRolloutDeviceSelectedEvent added in v0.9.0

func GetFleetRolloutDeviceSelectedEvent(ctx context.Context, deviceName string, fleetName string, templateVersion string) *domain.Event

GetFleetRolloutDeviceSelectedEvent creates an event for fleet rollout device selection

func GetFleetRolloutFailedEvent added in v0.9.0

func GetFleetRolloutFailedEvent(ctx context.Context, name string, deployingTemplateVersion string, message string) *domain.Event

GetFleetRolloutFailedEvent creates an event for fleet rollout failure

func GetFleetRolloutNewEvent added in v0.9.0

func GetFleetRolloutNewEvent(ctx context.Context, name string) *domain.Event

GetFleetRolloutNewEvent creates an event for fleet rollout creation

func GetFleetRolloutStartedEvent added in v0.9.0

func GetFleetRolloutStartedEvent(ctx context.Context, templateVersionName string, fleetName string, immediateRollout bool, policyRemoved bool) *domain.Event

GetFleetRolloutStartedEvent creates an event for fleet rollout start

func GetFleetSpecInvalidEvent added in v0.9.0

func GetFleetSpecInvalidEvent(ctx context.Context, fleetName string, message string) *domain.Event

GetFleetSpecInvalidEvent creates an event for fleet spec becoming invalid

func GetFleetSpecValidEvent added in v0.9.0

func GetFleetSpecValidEvent(ctx context.Context, fleetName string) *domain.Event

GetFleetSpecValidEvent creates an event for fleet spec becoming valid

func GetReferencedRepositoryUpdatedEvent added in v0.9.0

func GetReferencedRepositoryUpdatedEvent(ctx context.Context, kind domain.ResourceKind, name, repositoryName string) *domain.Event

GetReferencedRepositoryUpdatedEvent creates an event for a referenced repository being updated

func GetRepositoryAccessibleEvent added in v0.9.0

func GetRepositoryAccessibleEvent(ctx context.Context, name string) *domain.Event

GetRepositoryAccessibleEvent creates an event for repository accessibility

func GetRepositoryInaccessibleEvent added in v0.9.0

func GetRepositoryInaccessibleEvent(ctx context.Context, name string, errorMessage string) *domain.Event

GetRepositoryInaccessibleEvent creates an event for repository inaccessibility

func GetResourceCreatedOrUpdatedFailureEvent added in v0.9.0

func GetResourceCreatedOrUpdatedFailureEvent(ctx context.Context, created bool, resourceKind domain.ResourceKind, resourceName string, status domain.Status, updatedDetails *domain.ResourceUpdatedDetails) *domain.Event

GetResourceCreatedOrUpdatedFailureEvent creates an event for failed resource creation or update

func GetResourceCreatedOrUpdatedSuccessEvent added in v0.9.0

func GetResourceCreatedOrUpdatedSuccessEvent(ctx context.Context, created bool, resourceKind domain.ResourceKind, resourceName string, updates *domain.ResourceUpdatedDetails, log logrus.FieldLogger, annotations map[string]string) *domain.Event

GetResourceCreatedOrUpdatedSuccessEvent creates an event for successful resource creation or update

func GetResourceDeletedFailureEvent added in v0.9.0

func GetResourceDeletedFailureEvent(ctx context.Context, resourceKind domain.ResourceKind, resourceName string, status domain.Status) *domain.Event

GetResourceDeletedFailureEvent creates an event for failed resource deletion

func GetResourceDeletedSuccessEvent added in v0.9.0

func GetResourceDeletedSuccessEvent(ctx context.Context, resourceKind domain.ResourceKind, resourceName string) *domain.Event

GetResourceDeletedSuccessEvent creates an event for successful resource deletion

func GetResourceSyncAccessibleEvent added in v0.9.0

func GetResourceSyncAccessibleEvent(ctx context.Context, resourceName string) *domain.Event

func GetResourceSyncCommitDetectedEvent added in v0.9.0

func GetResourceSyncCommitDetectedEvent(ctx context.Context, resourceName string, commitHash string) *domain.Event

ResourceSync event functions

func GetResourceSyncInaccessibleEvent added in v0.9.0

func GetResourceSyncInaccessibleEvent(ctx context.Context, resourceName string, errorMessage string) *domain.Event

func GetResourceSyncParsedEvent added in v0.9.0

func GetResourceSyncParsedEvent(ctx context.Context, resourceName string) *domain.Event

func GetResourceSyncParsingFailedEvent added in v0.9.0

func GetResourceSyncParsingFailedEvent(ctx context.Context, resourceName string, errorMessage string) *domain.Event

func GetResourceSyncSyncFailedEvent added in v0.9.0

func GetResourceSyncSyncFailedEvent(ctx context.Context, resourceName string, errorMessage string) *domain.Event

func GetResourceSyncSyncedEvent added in v0.9.0

func GetResourceSyncSyncedEvent(ctx context.Context, resourceName string) *domain.Event

func GetSystemRestoredEvent added in v0.10.0

func GetSystemRestoredEvent(ctx context.Context, devicesUpdated int64) *domain.Event

GetSystemRestoredEvent creates an event for system restoration completion Associates the event with a system-level resource using the System kind

func HasConditionChanged added in v1.3.0

func HasConditionChanged(oldCondition, newCondition *domain.Condition) bool

HasConditionChanged checks if a condition actually changed between old and new.

func KeepDBDeviceStatus added in v0.9.0

func KeepDBDeviceStatus(device, dbDevice *domain.Device)

do not overwrite valid service-side statuses with placeholder device-side status

func NilOutManagedObjectMetaProperties

func NilOutManagedObjectMetaProperties(om *domain.ObjectMeta)

NilOutManagedObjectMetaProperties clears the ObjectMeta fields that are managed by the service and must not be set by API callers.

func PrepareListParams added in v1.3.0

func PrepareListParams(cont *string, lSelector *string, fSelector *string, limit *int32) (*store.ListParams, domain.Status)

PrepareListParams parses list-request query parameters into store.ListParams, applying the default/max limit and parsing the continue token and selectors.

Relocated from the unexported internal/service.prepareListParams (renamed/exported as part of this move so it is callable from outside internal/service).

func StoreErrorToApiStatus added in v1.3.0

func StoreErrorToApiStatus(err error, created bool, kind string, name *string) domain.Status

StoreErrorToApiStatus maps a store error into the appropriate domain.Status.

func UpdateServiceSideStatus added in v0.4.0

func UpdateServiceSideStatus(ctx context.Context, orgId uuid.UUID, device *domain.Device, fleetStore fleetstore.Store, log logrus.FieldLogger) bool

func ValidateCatalogItemRefs added in v1.3.0

func ValidateCatalogItemRefs(ctx context.Context, orgId uuid.UUID, store catalogstore.Store, spec *domain.DeviceSpec) domain.Status

ValidateCatalogItemRefs checks that all catalog item references in a device spec point to existing catalog items with valid versions. When store is nil, validation is skipped.

Types

type DeviceFailureEvent added in v0.9.0

type DeviceFailureEvent func(ctx context.Context, created bool, resourceKind domain.ResourceKind, resourceName string, status domain.Status) *domain.Event

type DeviceSuccessEvent added in v0.9.0

type DeviceSuccessEvent func(ctx context.Context, created bool, resourceKind domain.ResourceKind, resourceName string, updateDetails *domain.ResourceUpdatedDetailsUpdatedFields, log logrus.FieldLogger) *domain.Event

type GetResourceEventFromUpdateDetailsFunc added in v0.9.0

type GetResourceEventFromUpdateDetailsFunc func(ctx context.Context, update ResourceUpdate) *domain.Event

type ResourceUpdate added in v0.9.0

type ResourceUpdate struct {
	Reason  domain.EventReason
	Details string
}

type ResourceUpdates added in v0.9.0

type ResourceUpdates []ResourceUpdate

func ComputeDeviceStatusChanges added in v0.9.0

func ComputeDeviceStatusChanges(ctx context.Context, oldDevice, newDevice *domain.Device, orgId uuid.UUID) ResourceUpdates

type SwaggerGetter added in v1.3.0

type SwaggerGetter func() (*openapi3.T, error)

SwaggerGetter is a function that returns a parsed OpenAPI spec.

Jump to

Keyboard shortcuts

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