device

package
v1.3.0 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: 32 Imported by: 0

Documentation

Overview

Package device is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDeviceFromUntrusted

func CreateDeviceFromUntrusted(ctx context.Context, svc Service, orgId uuid.UUID, device domain.Device) (*domain.Device, domain.Status)

CreateDeviceFromUntrusted sanitizes an untrusted device document, then creates it.

func EmitDeviceDecommissionEvent

func EmitDeviceDecommissionEvent(ctx context.Context, eventsService events.Service, _ domain.ResourceKind, orgId uuid.UUID, name string, created bool, err error)

EmitDeviceDecommissionEvent handles device decommission event emission logic.

func EmitDeviceUpdatedEvent

func EmitDeviceUpdatedEvent(ctx context.Context, eventsService events.Service, log logrus.FieldLogger, resourceKind domain.ResourceKind, orgId uuid.UUID, name string, oldResource, newResource interface{}, created bool, err error)

EmitDeviceUpdatedEvent handles all device-related event emission logic for a device create/update. Exported so packages that create devices as a side effect of their own operation (e.g. internal/service/enrollmentrequest, approving an enrollment request) can emit the same device-updated event a direct device update would, without depending on a generic events hub for device-specific decisions.

func ReplaceDeviceFromUntrusted

func ReplaceDeviceFromUntrusted(ctx context.Context, svc Service, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string, enforceOwnership bool, enforceCapabilities bool) (*domain.Device, domain.Status)

ReplaceDeviceFromUntrusted sanitizes an untrusted device document, then replaces it.

func SanitizeDevice

func SanitizeDevice(device *domain.Device)

SanitizeDevice clears status and managed metadata from an untrusted device document (HTTP body). Trusted callers that must preserve Owner/annotations must not use this.

Types

type DeviceServiceHandler

type DeviceServiceHandler struct {
	// contains filtered or unexported fields
}

DeviceServiceHandler implements Service.

func (*DeviceServiceHandler) CountDevices

func (h *DeviceServiceHandler) CountDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (int64, domain.Status)

func (*DeviceServiceHandler) CountDevicesByLabels

func (h *DeviceServiceHandler) CountDevicesByLabels(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, groupBy []string) ([]map[string]any, domain.Status)

func (*DeviceServiceHandler) CreateDevice

func (h *DeviceServiceHandler) CreateDevice(ctx context.Context, orgId uuid.UUID, device domain.Device) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) DecommissionDevice

func (h *DeviceServiceHandler) DecommissionDevice(ctx context.Context, orgId uuid.UUID, name string, decom domain.DeviceDecommission) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) DeleteDevice

func (h *DeviceServiceHandler) DeleteDevice(ctx context.Context, orgId uuid.UUID, name string) domain.Status

func (*DeviceServiceHandler) ForceUpdateServerSideDeviceStatus

func (h *DeviceServiceHandler) ForceUpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) error

func (*DeviceServiceHandler) GetDevice

func (h *DeviceServiceHandler) GetDevice(ctx context.Context, orgId uuid.UUID, name string) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) GetDeviceCompletionCounts

func (h *DeviceServiceHandler) GetDeviceCompletionCounts(ctx context.Context, orgId uuid.UUID, owner string, templateVersion string, updateTimeout *time.Duration) ([]domain.DeviceCompletionCount, domain.Status)

func (*DeviceServiceHandler) GetDeviceLastSeen

func (h *DeviceServiceHandler) GetDeviceLastSeen(ctx context.Context, orgId uuid.UUID, name string) (*domain.DeviceLastSeen, domain.Status)

func (*DeviceServiceHandler) GetDeviceRepositoryRefs

func (h *DeviceServiceHandler) GetDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string) (*domain.RepositoryList, domain.Status)

func (*DeviceServiceHandler) GetDeviceStatus

func (h *DeviceServiceHandler) GetDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) (*domain.Device, domain.Status)

(GET /api/v1/devices/{name}/status)

func (*DeviceServiceHandler) GetDevicesSummary

func (h *DeviceServiceHandler) GetDevicesSummary(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (*domain.DevicesSummary, domain.Status)

func (*DeviceServiceHandler) GetRenderedDevice

func (h *DeviceServiceHandler) GetRenderedDevice(ctx context.Context, orgId uuid.UUID, name string, params domain.GetRenderedDeviceParams) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) ListConnectivityChangedDevices

func (h *DeviceServiceHandler) ListConnectivityChangedDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, cutoffTime time.Time) (*domain.DeviceList, domain.Status)

func (*DeviceServiceHandler) ListDevices

func (h *DeviceServiceHandler) ListDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (*domain.DeviceList, domain.Status)

func (*DeviceServiceHandler) ListDevicesByServiceCondition

func (h *DeviceServiceHandler) ListDevicesByServiceCondition(ctx context.Context, orgId uuid.UUID, conditionType string, conditionStatus string, listParams store.ListParams) (*domain.DeviceList, domain.Status)

func (*DeviceServiceHandler) ListLabels

ListLabels only ever supports domain.DeviceKind (its monolith implementation never handled any other kind), so it moves here verbatim rather than to a new cross-resource home.

func (*DeviceServiceHandler) MarkDevicesRolloutSelection

func (h *DeviceServiceHandler) MarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, limit *int) domain.Status

func (*DeviceServiceHandler) OverwriteDeviceRepositoryRefs

func (h *DeviceServiceHandler) OverwriteDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string, repositoryNames ...string) domain.Status

func (*DeviceServiceHandler) PatchDevice

func (h *DeviceServiceHandler) PatchDevice(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest, enforceOwnership bool, enforceCapabilities bool) (*domain.Device, domain.Status)

Only metadata.labels and spec can be patched. If we try to patch other fields, HTTP 400 Bad Request is returned.

func (*DeviceServiceHandler) PatchDeviceStatus

func (h *DeviceServiceHandler) PatchDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) ReplaceDevice

func (h *DeviceServiceHandler) ReplaceDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string, enforceOwnership bool, enforceCapabilities bool) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) ReplaceDeviceSpec

func (h *DeviceServiceHandler) ReplaceDeviceSpec(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, spec domain.DeviceSpec, setAnnotations map[string]string, deleteAnnotations []string) (*domain.Device, domain.Status)

ReplaceDeviceSpec is the internal-reconciler counterpart to ReplaceDevice: it overwrites Spec and merges setAnnotations/deleteAnnotations into the existing annotation map, without requiring the caller's resourceVersion to match. Ownership is re-verified against the freshly-loaded device on every retry attempt (not a stale caller-held snapshot), so a concurrent owner change is still caught. Labels are never touched.

func (*DeviceServiceHandler) ReplaceDeviceStatus

func (h *DeviceServiceHandler) ReplaceDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, incomingDevice domain.Device, refreshLastSeen bool) (*domain.Device, domain.Status)

func (*DeviceServiceHandler) RestartDeviceApplication

func (h *DeviceServiceHandler) RestartDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (*domain.Device, domain.Status)

RestartDeviceApplication increments the device-level restartGeneration override for the named application, atomically against concurrent restarts. restartGeneration is device-only and left untouched by stop/start, so it's safe to simply increment whatever is currently stored.

func (*DeviceServiceHandler) ResumeDevices

func (*DeviceServiceHandler) SetDeviceOwner

func (h *DeviceServiceHandler) SetDeviceOwner(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, newOwner *string) (*domain.Device, domain.Status)

SetDeviceOwner sets (newOwner non-nil) or clears (newOwner nil) only Owner, re-verified against the freshly-loaded device's owner on every retry attempt. Spec/Labels/Annotations are never part of the write payload, so this cannot race with heartbeats or clobber a concurrently-rendered spec the way a full ReplaceDevice call would.

func (*DeviceServiceHandler) SetDeviceServiceConditions

func (h *DeviceServiceHandler) SetDeviceServiceConditions(ctx context.Context, orgId uuid.UUID, name string, conditions []domain.Condition) domain.Status

func (*DeviceServiceHandler) SetOutOfDate

func (h *DeviceServiceHandler) SetOutOfDate(ctx context.Context, orgId uuid.UUID, owner string) error

func (*DeviceServiceHandler) StartDeviceApplication

func (h *DeviceServiceHandler) StartDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (*domain.Device, domain.Status)

StartDeviceApplication sets a device-level override so that the named application's desiredState is "running", independent of the application's declarative spec. Same recency-based arbitration against the fleet-level default as StopDeviceApplication.

func (*DeviceServiceHandler) StopDeviceApplication

func (h *DeviceServiceHandler) StopDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (*domain.Device, domain.Status)

StopDeviceApplication sets a device-level override so that the named application's desiredState is "stopped", independent of the application's declarative spec. The override is stamped with a fresh version so it wins over an earlier fleet-level default for the same application, as long as no more recent fleet-level action has been taken since.

func (*DeviceServiceHandler) UnmarkDevicesRolloutSelection

func (h *DeviceServiceHandler) UnmarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, fleetName string) domain.Status

func (*DeviceServiceHandler) UpdateDevice

func (h *DeviceServiceHandler) UpdateDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string) (*domain.Device, error)

func (*DeviceServiceHandler) UpdateDeviceAnnotations

func (h *DeviceServiceHandler) UpdateDeviceAnnotations(ctx context.Context, orgId uuid.UUID, name string, annotations map[string]string, deleteKeys []string) domain.Status

func (*DeviceServiceHandler) UpdateRenderedDevice

func (h *DeviceServiceHandler) UpdateRenderedDevice(ctx context.Context, orgId uuid.UUID, name, renderedConfig, renderedApplications, specHash, osImage string, configFingerprints []domain.DependencySyncConfigRefStatus, forceUpdate bool) domain.Status

func (*DeviceServiceHandler) UpdateServerSideDeviceStatus

func (h *DeviceServiceHandler) UpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) error

func (*DeviceServiceHandler) UpdateServiceSideDeviceStatus

func (h *DeviceServiceHandler) UpdateServiceSideDeviceStatus(ctx context.Context, orgId uuid.UUID, device domain.Device) bool

type MockService

type MockService struct {
	// contains filtered or unexported fields
}

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) CountDevices

func (m *MockService) CountDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (int64, domain.Status)

CountDevices mocks base method.

func (*MockService) CountDevicesByLabels

func (m *MockService) CountDevicesByLabels(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, groupBy []string) ([]map[string]any, domain.Status)

CountDevicesByLabels mocks base method.

func (*MockService) CreateDevice

func (m *MockService) CreateDevice(ctx context.Context, orgId uuid.UUID, device domain.Device) (*domain.Device, domain.Status)

CreateDevice mocks base method.

func (*MockService) DecommissionDevice

func (m *MockService) DecommissionDevice(ctx context.Context, orgId uuid.UUID, name string, decom domain.DeviceDecommission) (*domain.Device, domain.Status)

DecommissionDevice mocks base method.

func (*MockService) DeleteDevice

func (m *MockService) DeleteDevice(ctx context.Context, orgId uuid.UUID, name string) domain.Status

DeleteDevice mocks base method.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) ForceUpdateServerSideDeviceStatus

func (m *MockService) ForceUpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) error

ForceUpdateServerSideDeviceStatus mocks base method.

func (*MockService) GetDevice

func (m *MockService) GetDevice(ctx context.Context, orgId uuid.UUID, name string) (*domain.Device, domain.Status)

GetDevice mocks base method.

func (*MockService) GetDeviceCompletionCounts

func (m *MockService) GetDeviceCompletionCounts(ctx context.Context, orgId uuid.UUID, owner, templateVersion string, updateTimeout *time.Duration) ([]domain.DeviceCompletionCount, domain.Status)

GetDeviceCompletionCounts mocks base method.

func (*MockService) GetDeviceLastSeen

func (m *MockService) GetDeviceLastSeen(ctx context.Context, orgId uuid.UUID, name string) (*domain.DeviceLastSeen, domain.Status)

GetDeviceLastSeen mocks base method.

func (*MockService) GetDeviceRepositoryRefs

func (m *MockService) GetDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string) (*domain.RepositoryList, domain.Status)

GetDeviceRepositoryRefs mocks base method.

func (*MockService) GetDeviceStatus

func (m *MockService) GetDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) (*domain.Device, domain.Status)

GetDeviceStatus mocks base method.

func (*MockService) GetDevicesSummary

func (m *MockService) GetDevicesSummary(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (*domain.DevicesSummary, domain.Status)

GetDevicesSummary mocks base method.

func (*MockService) GetRenderedDevice

func (m *MockService) GetRenderedDevice(ctx context.Context, orgId uuid.UUID, name string, params domain.GetRenderedDeviceParams) (*domain.Device, domain.Status)

GetRenderedDevice mocks base method.

func (*MockService) ListConnectivityChangedDevices

func (m *MockService) ListConnectivityChangedDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, cutoffTime time.Time) (*domain.DeviceList, domain.Status)

ListConnectivityChangedDevices mocks base method.

func (*MockService) ListDevices

func (m *MockService) ListDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (*domain.DeviceList, domain.Status)

ListDevices mocks base method.

func (*MockService) ListDevicesByServiceCondition

func (m *MockService) ListDevicesByServiceCondition(ctx context.Context, orgId uuid.UUID, conditionType, conditionStatus string, listParams store.ListParams) (*domain.DeviceList, domain.Status)

ListDevicesByServiceCondition mocks base method.

func (*MockService) ListLabels

func (m *MockService) ListLabels(ctx context.Context, orgId uuid.UUID, params domain.ListLabelsParams) (*domain.LabelList, domain.Status)

ListLabels mocks base method.

func (*MockService) MarkDevicesRolloutSelection

func (m *MockService) MarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, limit *int) domain.Status

MarkDevicesRolloutSelection mocks base method.

func (*MockService) OverwriteDeviceRepositoryRefs

func (m *MockService) OverwriteDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string, repositoryNames ...string) domain.Status

OverwriteDeviceRepositoryRefs mocks base method.

func (*MockService) PatchDevice

func (m *MockService) PatchDevice(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest, enforceOwnership, enforceCapabilities bool) (*domain.Device, domain.Status)

PatchDevice mocks base method.

func (*MockService) PatchDeviceStatus

func (m *MockService) PatchDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest) (*domain.Device, domain.Status)

PatchDeviceStatus mocks base method.

func (*MockService) ReplaceDevice

func (m *MockService) ReplaceDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string, enforceOwnership, enforceCapabilities bool) (*domain.Device, domain.Status)

ReplaceDevice mocks base method.

func (*MockService) ReplaceDeviceSpec

func (m *MockService) ReplaceDeviceSpec(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, spec domain.DeviceSpec, setAnnotations map[string]string, deleteAnnotations []string) (*domain.Device, domain.Status)

ReplaceDeviceSpec mocks base method.

func (*MockService) ReplaceDeviceStatus

func (m *MockService) ReplaceDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, refreshLastSeen bool) (*domain.Device, domain.Status)

ReplaceDeviceStatus mocks base method.

func (*MockService) RestartDeviceApplication

func (m *MockService) RestartDeviceApplication(ctx context.Context, orgId uuid.UUID, name, appName string) (*domain.Device, domain.Status)

RestartDeviceApplication mocks base method.

func (*MockService) ResumeDevices

ResumeDevices mocks base method.

func (*MockService) SetDeviceOwner

func (m *MockService) SetDeviceOwner(ctx context.Context, orgId uuid.UUID, name string, expectedOwner, newOwner *string) (*domain.Device, domain.Status)

SetDeviceOwner mocks base method.

func (*MockService) SetDeviceServiceConditions

func (m *MockService) SetDeviceServiceConditions(ctx context.Context, orgId uuid.UUID, name string, conditions []domain.Condition) domain.Status

SetDeviceServiceConditions mocks base method.

func (*MockService) SetOutOfDate

func (m *MockService) SetOutOfDate(ctx context.Context, orgId uuid.UUID, owner string) error

SetOutOfDate mocks base method.

func (*MockService) StartDeviceApplication

func (m *MockService) StartDeviceApplication(ctx context.Context, orgId uuid.UUID, name, appName string) (*domain.Device, domain.Status)

StartDeviceApplication mocks base method.

func (*MockService) StopDeviceApplication

func (m *MockService) StopDeviceApplication(ctx context.Context, orgId uuid.UUID, name, appName string) (*domain.Device, domain.Status)

StopDeviceApplication mocks base method.

func (*MockService) UnmarkDevicesRolloutSelection

func (m *MockService) UnmarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, fleetName string) domain.Status

UnmarkDevicesRolloutSelection mocks base method.

func (*MockService) UpdateDevice

func (m *MockService) UpdateDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string) (*domain.Device, error)

UpdateDevice mocks base method.

func (*MockService) UpdateDeviceAnnotations

func (m *MockService) UpdateDeviceAnnotations(ctx context.Context, orgId uuid.UUID, name string, annotations map[string]string, deleteKeys []string) domain.Status

UpdateDeviceAnnotations mocks base method.

func (*MockService) UpdateRenderedDevice

func (m *MockService) UpdateRenderedDevice(ctx context.Context, orgId uuid.UUID, name, renderedConfig, renderedApplications, specHash, osImage string, configFingerprints []domain.DependencySyncConfigRefStatus, forceUpdate bool) domain.Status

UpdateRenderedDevice mocks base method.

func (*MockService) UpdateServerSideDeviceStatus

func (m *MockService) UpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) error

UpdateServerSideDeviceStatus mocks base method.

func (*MockService) UpdateServiceSideDeviceStatus

func (m *MockService) UpdateServiceSideDeviceStatus(ctx context.Context, orgId uuid.UUID, device domain.Device) bool

UpdateServiceSideDeviceStatus mocks base method.

type MockServiceMockRecorder

type MockServiceMockRecorder struct {
	// contains filtered or unexported fields
}

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) CountDevices

func (mr *MockServiceMockRecorder) CountDevices(ctx, orgId, params, annotationSelector any) *gomock.Call

CountDevices indicates an expected call of CountDevices.

func (*MockServiceMockRecorder) CountDevicesByLabels

func (mr *MockServiceMockRecorder) CountDevicesByLabels(ctx, orgId, params, annotationSelector, groupBy any) *gomock.Call

CountDevicesByLabels indicates an expected call of CountDevicesByLabels.

func (*MockServiceMockRecorder) CreateDevice

func (mr *MockServiceMockRecorder) CreateDevice(ctx, orgId, device any) *gomock.Call

CreateDevice indicates an expected call of CreateDevice.

func (*MockServiceMockRecorder) DecommissionDevice

func (mr *MockServiceMockRecorder) DecommissionDevice(ctx, orgId, name, decom any) *gomock.Call

DecommissionDevice indicates an expected call of DecommissionDevice.

func (*MockServiceMockRecorder) DeleteDevice

func (mr *MockServiceMockRecorder) DeleteDevice(ctx, orgId, name any) *gomock.Call

DeleteDevice indicates an expected call of DeleteDevice.

func (*MockServiceMockRecorder) ForceUpdateServerSideDeviceStatus

func (mr *MockServiceMockRecorder) ForceUpdateServerSideDeviceStatus(ctx, orgId, name any) *gomock.Call

ForceUpdateServerSideDeviceStatus indicates an expected call of ForceUpdateServerSideDeviceStatus.

func (*MockServiceMockRecorder) GetDevice

func (mr *MockServiceMockRecorder) GetDevice(ctx, orgId, name any) *gomock.Call

GetDevice indicates an expected call of GetDevice.

func (*MockServiceMockRecorder) GetDeviceCompletionCounts

func (mr *MockServiceMockRecorder) GetDeviceCompletionCounts(ctx, orgId, owner, templateVersion, updateTimeout any) *gomock.Call

GetDeviceCompletionCounts indicates an expected call of GetDeviceCompletionCounts.

func (*MockServiceMockRecorder) GetDeviceLastSeen

func (mr *MockServiceMockRecorder) GetDeviceLastSeen(ctx, orgId, name any) *gomock.Call

GetDeviceLastSeen indicates an expected call of GetDeviceLastSeen.

func (*MockServiceMockRecorder) GetDeviceRepositoryRefs

func (mr *MockServiceMockRecorder) GetDeviceRepositoryRefs(ctx, orgId, name any) *gomock.Call

GetDeviceRepositoryRefs indicates an expected call of GetDeviceRepositoryRefs.

func (*MockServiceMockRecorder) GetDeviceStatus

func (mr *MockServiceMockRecorder) GetDeviceStatus(ctx, orgId, name any) *gomock.Call

GetDeviceStatus indicates an expected call of GetDeviceStatus.

func (*MockServiceMockRecorder) GetDevicesSummary

func (mr *MockServiceMockRecorder) GetDevicesSummary(ctx, orgId, params, annotationSelector any) *gomock.Call

GetDevicesSummary indicates an expected call of GetDevicesSummary.

func (*MockServiceMockRecorder) GetRenderedDevice

func (mr *MockServiceMockRecorder) GetRenderedDevice(ctx, orgId, name, params any) *gomock.Call

GetRenderedDevice indicates an expected call of GetRenderedDevice.

func (*MockServiceMockRecorder) ListConnectivityChangedDevices

func (mr *MockServiceMockRecorder) ListConnectivityChangedDevices(ctx, orgId, params, cutoffTime any) *gomock.Call

ListConnectivityChangedDevices indicates an expected call of ListConnectivityChangedDevices.

func (*MockServiceMockRecorder) ListDevices

func (mr *MockServiceMockRecorder) ListDevices(ctx, orgId, params, annotationSelector any) *gomock.Call

ListDevices indicates an expected call of ListDevices.

func (*MockServiceMockRecorder) ListDevicesByServiceCondition

func (mr *MockServiceMockRecorder) ListDevicesByServiceCondition(ctx, orgId, conditionType, conditionStatus, listParams any) *gomock.Call

ListDevicesByServiceCondition indicates an expected call of ListDevicesByServiceCondition.

func (*MockServiceMockRecorder) ListLabels

func (mr *MockServiceMockRecorder) ListLabels(ctx, orgId, params any) *gomock.Call

ListLabels indicates an expected call of ListLabels.

func (*MockServiceMockRecorder) MarkDevicesRolloutSelection

func (mr *MockServiceMockRecorder) MarkDevicesRolloutSelection(ctx, orgId, params, annotationSelector, limit any) *gomock.Call

MarkDevicesRolloutSelection indicates an expected call of MarkDevicesRolloutSelection.

func (*MockServiceMockRecorder) OverwriteDeviceRepositoryRefs

func (mr *MockServiceMockRecorder) OverwriteDeviceRepositoryRefs(ctx, orgId, name any, repositoryNames ...any) *gomock.Call

OverwriteDeviceRepositoryRefs indicates an expected call of OverwriteDeviceRepositoryRefs.

func (*MockServiceMockRecorder) PatchDevice

func (mr *MockServiceMockRecorder) PatchDevice(ctx, orgId, name, patch, enforceOwnership, enforceCapabilities any) *gomock.Call

PatchDevice indicates an expected call of PatchDevice.

func (*MockServiceMockRecorder) PatchDeviceStatus

func (mr *MockServiceMockRecorder) PatchDeviceStatus(ctx, orgId, name, patch any) *gomock.Call

PatchDeviceStatus indicates an expected call of PatchDeviceStatus.

func (*MockServiceMockRecorder) ReplaceDevice

func (mr *MockServiceMockRecorder) ReplaceDevice(ctx, orgId, name, device, fieldsToUnset, enforceOwnership, enforceCapabilities any) *gomock.Call

ReplaceDevice indicates an expected call of ReplaceDevice.

func (*MockServiceMockRecorder) ReplaceDeviceSpec

func (mr *MockServiceMockRecorder) ReplaceDeviceSpec(ctx, orgId, name, expectedOwner, spec, setAnnotations, deleteAnnotations any) *gomock.Call

ReplaceDeviceSpec indicates an expected call of ReplaceDeviceSpec.

func (*MockServiceMockRecorder) ReplaceDeviceStatus

func (mr *MockServiceMockRecorder) ReplaceDeviceStatus(ctx, orgId, name, device, refreshLastSeen any) *gomock.Call

ReplaceDeviceStatus indicates an expected call of ReplaceDeviceStatus.

func (*MockServiceMockRecorder) RestartDeviceApplication

func (mr *MockServiceMockRecorder) RestartDeviceApplication(ctx, orgId, name, appName any) *gomock.Call

RestartDeviceApplication indicates an expected call of RestartDeviceApplication.

func (*MockServiceMockRecorder) ResumeDevices

func (mr *MockServiceMockRecorder) ResumeDevices(ctx, orgId, request any) *gomock.Call

ResumeDevices indicates an expected call of ResumeDevices.

func (*MockServiceMockRecorder) SetDeviceOwner

func (mr *MockServiceMockRecorder) SetDeviceOwner(ctx, orgId, name, expectedOwner, newOwner any) *gomock.Call

SetDeviceOwner indicates an expected call of SetDeviceOwner.

func (*MockServiceMockRecorder) SetDeviceServiceConditions

func (mr *MockServiceMockRecorder) SetDeviceServiceConditions(ctx, orgId, name, conditions any) *gomock.Call

SetDeviceServiceConditions indicates an expected call of SetDeviceServiceConditions.

func (*MockServiceMockRecorder) SetOutOfDate

func (mr *MockServiceMockRecorder) SetOutOfDate(ctx, orgId, owner any) *gomock.Call

SetOutOfDate indicates an expected call of SetOutOfDate.

func (*MockServiceMockRecorder) StartDeviceApplication

func (mr *MockServiceMockRecorder) StartDeviceApplication(ctx, orgId, name, appName any) *gomock.Call

StartDeviceApplication indicates an expected call of StartDeviceApplication.

func (*MockServiceMockRecorder) StopDeviceApplication

func (mr *MockServiceMockRecorder) StopDeviceApplication(ctx, orgId, name, appName any) *gomock.Call

StopDeviceApplication indicates an expected call of StopDeviceApplication.

func (*MockServiceMockRecorder) UnmarkDevicesRolloutSelection

func (mr *MockServiceMockRecorder) UnmarkDevicesRolloutSelection(ctx, orgId, fleetName any) *gomock.Call

UnmarkDevicesRolloutSelection indicates an expected call of UnmarkDevicesRolloutSelection.

func (*MockServiceMockRecorder) UpdateDevice

func (mr *MockServiceMockRecorder) UpdateDevice(ctx, orgId, name, device, fieldsToUnset any) *gomock.Call

UpdateDevice indicates an expected call of UpdateDevice.

func (*MockServiceMockRecorder) UpdateDeviceAnnotations

func (mr *MockServiceMockRecorder) UpdateDeviceAnnotations(ctx, orgId, name, annotations, deleteKeys any) *gomock.Call

UpdateDeviceAnnotations indicates an expected call of UpdateDeviceAnnotations.

func (*MockServiceMockRecorder) UpdateRenderedDevice

func (mr *MockServiceMockRecorder) UpdateRenderedDevice(ctx, orgId, name, renderedConfig, renderedApplications, specHash, osImage, configFingerprints, forceUpdate any) *gomock.Call

UpdateRenderedDevice indicates an expected call of UpdateRenderedDevice.

func (*MockServiceMockRecorder) UpdateServerSideDeviceStatus

func (mr *MockServiceMockRecorder) UpdateServerSideDeviceStatus(ctx, orgId, name any) *gomock.Call

UpdateServerSideDeviceStatus indicates an expected call of UpdateServerSideDeviceStatus.

func (*MockServiceMockRecorder) UpdateServiceSideDeviceStatus

func (mr *MockServiceMockRecorder) UpdateServiceSideDeviceStatus(ctx, orgId, device any) *gomock.Call

UpdateServiceSideDeviceStatus indicates an expected call of UpdateServiceSideDeviceStatus.

type Service

type Service interface {
	CreateDevice(ctx context.Context, orgId uuid.UUID, device domain.Device) (*domain.Device, domain.Status)
	ListDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (*domain.DeviceList, domain.Status)
	ListDevicesByServiceCondition(ctx context.Context, orgId uuid.UUID, conditionType string, conditionStatus string, listParams store.ListParams) (*domain.DeviceList, domain.Status)
	UpdateDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string) (*domain.Device, error)
	GetDevice(ctx context.Context, orgId uuid.UUID, name string) (*domain.Device, domain.Status)
	ReplaceDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string, enforceOwnership bool, enforceCapabilities bool) (*domain.Device, domain.Status)
	// ReplaceDeviceSpec overwrites Spec and merges the given annotation changes for an
	// internal reconciler that already owns this device (fleet rollout). It does not
	// require the caller's resourceVersion to match, and never touches Labels or Owner,
	// so it cannot race with agent status heartbeats or clobber concurrent label/owner
	// writes. expectedOwner is checked against the freshly loaded owner on every retry
	// attempt; a mismatch returns a conflict so callers can detect it exactly as they
	// would a resourceVersion conflict today.
	ReplaceDeviceSpec(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, spec domain.DeviceSpec, setAnnotations map[string]string, deleteAnnotations []string) (*domain.Device, domain.Status)
	// SetDeviceOwner sets (or clears, when newOwner is nil) only the Owner field.
	// Like ReplaceDeviceSpec, it skips resourceVersion matching and never touches
	// Spec/Labels/Annotations, so fleet-selector reassignment can't race with heartbeats
	// or silently overwrite a concurrently-rendered spec.
	SetDeviceOwner(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, newOwner *string) (*domain.Device, domain.Status)
	DeleteDevice(ctx context.Context, orgId uuid.UUID, name string) domain.Status
	GetDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) (*domain.Device, domain.Status)
	GetDeviceLastSeen(ctx context.Context, orgId uuid.UUID, name string) (*domain.DeviceLastSeen, domain.Status)
	ReplaceDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, refreshLastSeen bool) (*domain.Device, domain.Status)
	PatchDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest) (*domain.Device, domain.Status)
	GetRenderedDevice(ctx context.Context, orgId uuid.UUID, name string, params domain.GetRenderedDeviceParams) (*domain.Device, domain.Status)
	PatchDevice(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest, enforceOwnership bool, enforceCapabilities bool) (*domain.Device, domain.Status)
	DecommissionDevice(ctx context.Context, orgId uuid.UUID, name string, decom domain.DeviceDecommission) (*domain.Device, domain.Status)
	ResumeDevices(ctx context.Context, orgId uuid.UUID, request domain.DeviceResumeRequest) (domain.DeviceResumeResponse, domain.Status)
	UpdateDeviceAnnotations(ctx context.Context, orgId uuid.UUID, name string, annotations map[string]string, deleteKeys []string) domain.Status
	StopDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (*domain.Device, domain.Status)
	StartDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (*domain.Device, domain.Status)
	RestartDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (*domain.Device, domain.Status)
	UpdateRenderedDevice(ctx context.Context, orgId uuid.UUID, name, renderedConfig, renderedApplications, specHash, osImage string, configFingerprints []domain.DependencySyncConfigRefStatus, forceUpdate bool) domain.Status
	SetDeviceServiceConditions(ctx context.Context, orgId uuid.UUID, name string, conditions []domain.Condition) domain.Status
	OverwriteDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string, repositoryNames ...string) domain.Status
	GetDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string) (*domain.RepositoryList, domain.Status)
	CountDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (int64, domain.Status)
	UnmarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, fleetName string) domain.Status
	MarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, limit *int) domain.Status
	GetDeviceCompletionCounts(ctx context.Context, orgId uuid.UUID, owner string, templateVersion string, updateTimeout *time.Duration) ([]domain.DeviceCompletionCount, domain.Status)
	CountDevicesByLabels(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, groupBy []string) ([]map[string]any, domain.Status)
	GetDevicesSummary(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (*domain.DevicesSummary, domain.Status)
	UpdateServiceSideDeviceStatus(ctx context.Context, orgId uuid.UUID, device domain.Device) bool
	SetOutOfDate(ctx context.Context, orgId uuid.UUID, owner string) error
	UpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) error
	ForceUpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) error
	ListConnectivityChangedDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, cutoffTime time.Time) (*domain.DeviceList, domain.Status)
	ListLabels(ctx context.Context, orgId uuid.UUID, params domain.ListLabelsParams) (*domain.LabelList, domain.Status)
}

func NewDeviceServiceHandler

func NewDeviceServiceHandler(
	deviceStore devicestore.Store,
	catalogStore catalogstore.Store,
	fleetStore fleetstore.Store,
	events events.Service,
	kvStore kvstore.KVStore,
	agentEndpoint string,
	log logrus.FieldLogger,
) Service

NewDeviceServiceHandler creates a new DeviceServiceHandler instance. catalogStore is optional — when nil, catalog item ref validation is skipped.

func WrapWithTracing

func WrapWithTracing(inner Service) Service

WrapWithTracing returns a Service that wraps inner with tracing spans, or nil if inner is nil.

type TracedDeviceService

type TracedDeviceService struct {
	// contains filtered or unexported fields
}

TracedDeviceService wraps a Service implementation with OpenTelemetry tracing.

func (*TracedDeviceService) CountDevices

func (_d *TracedDeviceService) CountDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (i1 int64, s1 domain.Status)

func (*TracedDeviceService) CountDevicesByLabels

func (_d *TracedDeviceService) CountDevicesByLabels(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, groupBy []string) (ma1 []map[string]any, s1 domain.Status)

func (*TracedDeviceService) CreateDevice

func (_d *TracedDeviceService) CreateDevice(ctx context.Context, orgId uuid.UUID, device domain.Device) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) DecommissionDevice

func (_d *TracedDeviceService) DecommissionDevice(ctx context.Context, orgId uuid.UUID, name string, decom domain.DeviceDecommission) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) DeleteDevice

func (_d *TracedDeviceService) DeleteDevice(ctx context.Context, orgId uuid.UUID, name string) (s1 domain.Status)

func (*TracedDeviceService) ForceUpdateServerSideDeviceStatus

func (_d *TracedDeviceService) ForceUpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) (err error)

func (*TracedDeviceService) GetDevice

func (_d *TracedDeviceService) GetDevice(ctx context.Context, orgId uuid.UUID, name string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) GetDeviceCompletionCounts

func (_d *TracedDeviceService) GetDeviceCompletionCounts(ctx context.Context, orgId uuid.UUID, owner string, templateVersion string, updateTimeout *time.Duration) (da1 []domain.DeviceCompletionCount, s1 domain.Status)

func (*TracedDeviceService) GetDeviceLastSeen

func (_d *TracedDeviceService) GetDeviceLastSeen(ctx context.Context, orgId uuid.UUID, name string) (dp1 *domain.DeviceLastSeen, s1 domain.Status)

func (*TracedDeviceService) GetDeviceRepositoryRefs

func (_d *TracedDeviceService) GetDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string) (rp1 *domain.RepositoryList, s1 domain.Status)

func (*TracedDeviceService) GetDeviceStatus

func (_d *TracedDeviceService) GetDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) GetDevicesSummary

func (_d *TracedDeviceService) GetDevicesSummary(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (dp1 *domain.DevicesSummary, s1 domain.Status)

func (*TracedDeviceService) GetRenderedDevice

func (_d *TracedDeviceService) GetRenderedDevice(ctx context.Context, orgId uuid.UUID, name string, params domain.GetRenderedDeviceParams) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) ListConnectivityChangedDevices

func (_d *TracedDeviceService) ListConnectivityChangedDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, cutoffTime time.Time) (dp1 *domain.DeviceList, s1 domain.Status)

func (*TracedDeviceService) ListDevices

func (_d *TracedDeviceService) ListDevices(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector) (dp1 *domain.DeviceList, s1 domain.Status)

func (*TracedDeviceService) ListDevicesByServiceCondition

func (_d *TracedDeviceService) ListDevicesByServiceCondition(ctx context.Context, orgId uuid.UUID, conditionType string, conditionStatus string, listParams store.ListParams) (dp1 *domain.DeviceList, s1 domain.Status)

func (*TracedDeviceService) ListLabels

func (_d *TracedDeviceService) ListLabels(ctx context.Context, orgId uuid.UUID, params domain.ListLabelsParams) (lp1 *domain.LabelList, s1 domain.Status)

func (*TracedDeviceService) MarkDevicesRolloutSelection

func (_d *TracedDeviceService) MarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, params domain.ListDevicesParams, annotationSelector *selector.AnnotationSelector, limit *int) (s1 domain.Status)

func (*TracedDeviceService) OverwriteDeviceRepositoryRefs

func (_d *TracedDeviceService) OverwriteDeviceRepositoryRefs(ctx context.Context, orgId uuid.UUID, name string, repositoryNames ...string) (s1 domain.Status)

func (*TracedDeviceService) PatchDevice

func (_d *TracedDeviceService) PatchDevice(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest, enforceOwnership bool, enforceCapabilities bool) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) PatchDeviceStatus

func (_d *TracedDeviceService) PatchDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, patch domain.PatchRequest) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) ReplaceDevice

func (_d *TracedDeviceService) ReplaceDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string, enforceOwnership bool, enforceCapabilities bool) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) ReplaceDeviceSpec

func (_d *TracedDeviceService) ReplaceDeviceSpec(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, spec domain.DeviceSpec, setAnnotations map[string]string, deleteAnnotations []string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) ReplaceDeviceStatus

func (_d *TracedDeviceService) ReplaceDeviceStatus(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, refreshLastSeen bool) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) RestartDeviceApplication

func (_d *TracedDeviceService) RestartDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) ResumeDevices

func (*TracedDeviceService) SetDeviceOwner

func (_d *TracedDeviceService) SetDeviceOwner(ctx context.Context, orgId uuid.UUID, name string, expectedOwner *string, newOwner *string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) SetDeviceServiceConditions

func (_d *TracedDeviceService) SetDeviceServiceConditions(ctx context.Context, orgId uuid.UUID, name string, conditions []domain.Condition) (s1 domain.Status)

func (*TracedDeviceService) SetOutOfDate

func (_d *TracedDeviceService) SetOutOfDate(ctx context.Context, orgId uuid.UUID, owner string) (err error)

func (*TracedDeviceService) StartDeviceApplication

func (_d *TracedDeviceService) StartDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) StopDeviceApplication

func (_d *TracedDeviceService) StopDeviceApplication(ctx context.Context, orgId uuid.UUID, name string, appName string) (dp1 *domain.Device, s1 domain.Status)

func (*TracedDeviceService) UnmarkDevicesRolloutSelection

func (_d *TracedDeviceService) UnmarkDevicesRolloutSelection(ctx context.Context, orgId uuid.UUID, fleetName string) (s1 domain.Status)

func (*TracedDeviceService) UpdateDevice

func (_d *TracedDeviceService) UpdateDevice(ctx context.Context, orgId uuid.UUID, name string, device domain.Device, fieldsToUnset []string) (dp1 *domain.Device, err error)

func (*TracedDeviceService) UpdateDeviceAnnotations

func (_d *TracedDeviceService) UpdateDeviceAnnotations(ctx context.Context, orgId uuid.UUID, name string, annotations map[string]string, deleteKeys []string) (s1 domain.Status)

func (*TracedDeviceService) UpdateRenderedDevice

func (_d *TracedDeviceService) UpdateRenderedDevice(ctx context.Context, orgId uuid.UUID, name string, renderedConfig string, renderedApplications string, specHash string, osImage string, configFingerprints []domain.DependencySyncConfigRefStatus, forceUpdate bool) (s1 domain.Status)

func (*TracedDeviceService) UpdateServerSideDeviceStatus

func (_d *TracedDeviceService) UpdateServerSideDeviceStatus(ctx context.Context, orgId uuid.UUID, name string) (err error)

func (*TracedDeviceService) UpdateServiceSideDeviceStatus

func (_d *TracedDeviceService) UpdateServiceSideDeviceStatus(ctx context.Context, orgId uuid.UUID, device domain.Device) (b1 bool)

Jump to

Keyboard shortcuts

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