labelsyncmapping

package
v1.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package labelsyncmapping is a generated GoMock package.

Package labelsyncmapping is a generated GoMock package.

Index

Constants

View Source
const MaxProvenanceLabelKeys = 50

MaxProvenanceLabelKeys is the maximum number of exact label keys accepted by one organization query.

Variables

View Source
var ErrConditionPersistence = errors.New("label reconciliation condition was not persisted")

ErrConditionPersistence distinguishes an unrecorded result from a device failure. A scan must retain its page when the result cannot be persisted.

Functions

func CreateLabelSyncMappingFromInitialManifest

func CreateLabelSyncMappingFromInitialManifest(ctx context.Context, svc Service, orgID uuid.UUID, mapping domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

CreateLabelSyncMappingFromInitialManifest strips server-managed fields while retaining operator-provided annotations from the trusted deployment configuration.

func CreateLabelSyncMappingFromUntrusted

func CreateLabelSyncMappingFromUntrusted(ctx context.Context, svc Service, orgID uuid.UUID, mapping domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

CreateLabelSyncMappingFromUntrusted sanitizes an untrusted document before creation.

func ReadInitialLabelSyncMappingEntries

func ReadInitialLabelSyncMappingEntries(filePath string) ([]json.RawMessage, error)

ReadInitialLabelSyncMappingEntries reads and validates the manifest's top-level YAML sequence. Individual entries are decoded during provisioning so a malformed entry does not block later ones.

func ReplaceLabelSyncMappingFromUntrusted

func ReplaceLabelSyncMappingFromUntrusted(ctx context.Context, svc Service, orgID uuid.UUID, name string, mapping domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

ReplaceLabelSyncMappingFromUntrusted sanitizes an untrusted document before replacement.

func SanitizeLabelSyncMapping

func SanitizeLabelSyncMapping(mapping *domain.LabelSyncMapping)

SanitizeLabelSyncMapping clears status and managed metadata from an untrusted document.

Types

type Activation

type Activation interface{}

Activation is a value passed to CEL when evaluating an expression.

func ActivateDevice

func ActivateDevice(device domain.Device) (Activation, error)

ActivateDevice builds a CEL activation from the supported device roots.

type Evaluator

type Evaluator interface {
	ValidateExpressionIs(expression string, expectedKind ResultKind) error
	// Evaluate evaluates an expression using a prebuilt activation.
	Evaluate(expression string, activation Activation) (Result, error)
}

func NewEvaluator

func NewEvaluator() (Evaluator, error)

type InitialLabelSyncMappingProvisioner

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

InitialLabelSyncMappingProvisioner applies a deployment-provided mapping sequence.

func NewInitialLabelSyncMappingProvisioner

func NewInitialLabelSyncMappingProvisioner(filePath string, service Service, log logrus.FieldLogger) (*InitialLabelSyncMappingProvisioner, error)

NewInitialLabelSyncMappingProvisioner creates a best-effort seeder for deployment-provided mappings.

func (*InitialLabelSyncMappingProvisioner) Provision

func (p *InitialLabelSyncMappingProvisioner) Provision(ctx context.Context, orgID uuid.UUID)

Provision applies the configured mappings to one organization.

func (*InitialLabelSyncMappingProvisioner) ProvisionEntriesForOrganizations

func (p *InitialLabelSyncMappingProvisioner) ProvisionEntriesForOrganizations(ctx context.Context, orgIDs []uuid.UUID, entries []json.RawMessage)

ProvisionEntriesForOrganizations attempts each decoded manifest entry for each organization.

func (*InitialLabelSyncMappingProvisioner) ProvisionForOrganizations

func (p *InitialLabelSyncMappingProvisioner) ProvisionForOrganizations(ctx context.Context, orgIDs []uuid.UUID)

ProvisionForOrganizations reads the source once and attempts every mapping for each organization.

type MapResult

type MapResult map[string]string

MapResult contains sanitized values returned by a map expression.

type MappingOutcome

type MappingOutcome struct {
	MappingID       uuid.UUID
	Generation      int64
	ResourceVersion string
	Err             error
}

type MappingScanToken

type MappingScanToken struct {
	MappingID        uuid.UUID
	Generation       int64
	DeletionRevision *int64
	FailureRevision  int64
}

type MockReconciliationDeviceStore

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

MockReconciliationDeviceStore is a mock of ReconciliationDeviceStore interface.

func NewMockReconciliationDeviceStore

func NewMockReconciliationDeviceStore(ctrl *gomock.Controller) *MockReconciliationDeviceStore

NewMockReconciliationDeviceStore creates a new mock instance.

func (*MockReconciliationDeviceStore) ApplyLabels

ApplyLabels mocks base method.

func (*MockReconciliationDeviceStore) EXPECT

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

func (*MockReconciliationDeviceStore) GetLabelSnapshot

func (m *MockReconciliationDeviceStore) GetLabelSnapshot(arg0 context.Context, arg1 uuid.UUID, arg2 string) (domain.DeviceLabelSnapshot, error)

GetLabelSnapshot mocks base method.

func (*MockReconciliationDeviceStore) GetLabelSyncMappingIDsByKeys

func (m *MockReconciliationDeviceStore) GetLabelSyncMappingIDsByKeys(arg0 context.Context, arg1 uuid.UUID, arg2 []string) (map[string][]uuid.UUID, error)

GetLabelSyncMappingIDsByKeys mocks base method.

type MockReconciliationDeviceStoreMockRecorder

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

MockReconciliationDeviceStoreMockRecorder is the mock recorder for MockReconciliationDeviceStore.

func (*MockReconciliationDeviceStoreMockRecorder) ApplyLabels

func (mr *MockReconciliationDeviceStoreMockRecorder) ApplyLabels(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call

ApplyLabels indicates an expected call of ApplyLabels.

func (*MockReconciliationDeviceStoreMockRecorder) GetLabelSnapshot

func (mr *MockReconciliationDeviceStoreMockRecorder) GetLabelSnapshot(arg0, arg1, arg2 any) *gomock.Call

GetLabelSnapshot indicates an expected call of GetLabelSnapshot.

func (*MockReconciliationDeviceStoreMockRecorder) GetLabelSyncMappingIDsByKeys

func (mr *MockReconciliationDeviceStoreMockRecorder) GetLabelSyncMappingIDsByKeys(arg0, arg1, arg2 any) *gomock.Call

GetLabelSyncMappingIDsByKeys indicates an expected call of GetLabelSyncMappingIDsByKeys.

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) CompleteMappingScan

func (m *MockService) CompleteMappingScan(arg0 context.Context, arg1 uuid.UUID, arg2 []MappingScanToken) (map[uuid.UUID]bool, error)

CompleteMappingScan mocks base method.

func (*MockService) CreateLabelSyncMapping

func (m *MockService) CreateLabelSyncMapping(arg0 context.Context, arg1 uuid.UUID, arg2 domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

CreateLabelSyncMapping mocks base method.

func (*MockService) DeleteLabelSyncMapping

func (m *MockService) DeleteLabelSyncMapping(arg0 context.Context, arg1 uuid.UUID, arg2 string) domain.Status

DeleteLabelSyncMapping 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) GetDeviceLabelSyncProvenance

func (m *MockService) GetDeviceLabelSyncProvenance(arg0 context.Context, arg1 uuid.UUID, arg2 string) (*domain.LabelSyncProvenanceList, domain.Status)

GetDeviceLabelSyncProvenance mocks base method.

func (*MockService) GetLabelSyncMapping

func (m *MockService) GetLabelSyncMapping(arg0 context.Context, arg1 uuid.UUID, arg2 string) (*domain.LabelSyncMapping, domain.Status)

GetLabelSyncMapping mocks base method.

func (*MockService) GetLabelSyncProvenance

func (m *MockService) GetLabelSyncProvenance(arg0 context.Context, arg1 uuid.UUID, arg2 []string) (*domain.LabelSyncProvenanceList, domain.Status)

GetLabelSyncProvenance mocks base method.

func (*MockService) ListLabelSyncMappings

ListLabelSyncMappings mocks base method.

func (*MockService) ListMappingScanTargets

func (m *MockService) ListMappingScanTargets(arg0 context.Context, arg1 uuid.UUID) ([]MappingScanToken, error)

ListMappingScanTargets mocks base method.

func (*MockService) PatchLabelSyncMapping

func (m *MockService) PatchLabelSyncMapping(arg0 context.Context, arg1 uuid.UUID, arg2 string, arg3 domain.PatchRequest) (*domain.LabelSyncMapping, domain.Status)

PatchLabelSyncMapping mocks base method.

func (*MockService) ReconcileDeviceLabels

func (m *MockService) ReconcileDeviceLabels(arg0 context.Context, arg1 uuid.UUID, arg2 string) (ReconciliationResult, error)

ReconcileDeviceLabels mocks base method.

func (*MockService) RecordMappingScanFailure

func (m *MockService) RecordMappingScanFailure(arg0 context.Context, arg1 uuid.UUID, arg2 MappingScanToken, arg3 string) (MappingScanToken, bool, error)

RecordMappingScanFailure mocks base method.

func (*MockService) ReplaceLabelSyncMapping

func (m *MockService) ReplaceLabelSyncMapping(arg0 context.Context, arg1 uuid.UUID, arg2 string, arg3 domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

ReplaceLabelSyncMapping mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) CompleteMappingScan

func (mr *MockServiceMockRecorder) CompleteMappingScan(arg0, arg1, arg2 any) *gomock.Call

CompleteMappingScan indicates an expected call of CompleteMappingScan.

func (*MockServiceMockRecorder) CreateLabelSyncMapping

func (mr *MockServiceMockRecorder) CreateLabelSyncMapping(arg0, arg1, arg2 any) *gomock.Call

CreateLabelSyncMapping indicates an expected call of CreateLabelSyncMapping.

func (*MockServiceMockRecorder) DeleteLabelSyncMapping

func (mr *MockServiceMockRecorder) DeleteLabelSyncMapping(arg0, arg1, arg2 any) *gomock.Call

DeleteLabelSyncMapping indicates an expected call of DeleteLabelSyncMapping.

func (*MockServiceMockRecorder) GetDeviceLabelSyncProvenance

func (mr *MockServiceMockRecorder) GetDeviceLabelSyncProvenance(arg0, arg1, arg2 any) *gomock.Call

GetDeviceLabelSyncProvenance indicates an expected call of GetDeviceLabelSyncProvenance.

func (*MockServiceMockRecorder) GetLabelSyncMapping

func (mr *MockServiceMockRecorder) GetLabelSyncMapping(arg0, arg1, arg2 any) *gomock.Call

GetLabelSyncMapping indicates an expected call of GetLabelSyncMapping.

func (*MockServiceMockRecorder) GetLabelSyncProvenance

func (mr *MockServiceMockRecorder) GetLabelSyncProvenance(arg0, arg1, arg2 any) *gomock.Call

GetLabelSyncProvenance indicates an expected call of GetLabelSyncProvenance.

func (*MockServiceMockRecorder) ListLabelSyncMappings

func (mr *MockServiceMockRecorder) ListLabelSyncMappings(arg0, arg1, arg2 any) *gomock.Call

ListLabelSyncMappings indicates an expected call of ListLabelSyncMappings.

func (*MockServiceMockRecorder) ListMappingScanTargets

func (mr *MockServiceMockRecorder) ListMappingScanTargets(arg0, arg1 any) *gomock.Call

ListMappingScanTargets indicates an expected call of ListMappingScanTargets.

func (*MockServiceMockRecorder) PatchLabelSyncMapping

func (mr *MockServiceMockRecorder) PatchLabelSyncMapping(arg0, arg1, arg2, arg3 any) *gomock.Call

PatchLabelSyncMapping indicates an expected call of PatchLabelSyncMapping.

func (*MockServiceMockRecorder) ReconcileDeviceLabels

func (mr *MockServiceMockRecorder) ReconcileDeviceLabels(arg0, arg1, arg2 any) *gomock.Call

ReconcileDeviceLabels indicates an expected call of ReconcileDeviceLabels.

func (*MockServiceMockRecorder) RecordMappingScanFailure

func (mr *MockServiceMockRecorder) RecordMappingScanFailure(arg0, arg1, arg2, arg3 any) *gomock.Call

RecordMappingScanFailure indicates an expected call of RecordMappingScanFailure.

func (*MockServiceMockRecorder) ReplaceLabelSyncMapping

func (mr *MockServiceMockRecorder) ReplaceLabelSyncMapping(arg0, arg1, arg2, arg3 any) *gomock.Call

ReplaceLabelSyncMapping indicates an expected call of ReplaceLabelSyncMapping.

type NoResult

type NoResult struct{}

NoResult represents a successful expression with no value to map.

type ReconciliationDeviceStore

type ReconciliationDeviceStore interface {
	GetLabelSnapshot(context.Context, uuid.UUID, string) (domain.DeviceLabelSnapshot, error)
	GetLabelSyncMappingIDsByKeys(context.Context, uuid.UUID, []string) (map[string][]uuid.UUID, error)
	ApplyLabels(context.Context, uuid.UUID, string, domain.DeviceLabelSnapshot, map[string]domain.DesiredDeviceLabel, *domain.Condition) (domain.DeviceLabelApplyResult, error)
}

ReconciliationDeviceStore exposes the device-label operations used by the reconciliation and provenance flows.

type ReconciliationResult

type ReconciliationResult struct {
	DeviceDeleted         bool
	MappingApplyCommitted bool
	LabelsChanged         bool
	ManagedLabelsChanged  bool
	OwnershipChanged      bool
	MappingOutcomes       []MappingOutcome
}

type Result

type Result interface {
	// contains filtered or unexported methods
}

Result is a scalar value, map, or successful evaluation with no value.

type ResultKind

type ResultKind string

ResultKind identifies the expected shape of a mapping expression result.

const (
	// ResultKindScalar expects a scalar expression result.
	ResultKindScalar ResultKind = "scalar"
	// ResultKindMap expects a map expression result.
	ResultKindMap ResultKind = "map"
)

type ScalarResult

type ScalarResult string

ScalarResult is a sanitized scalar value produced by an expression.

type Service

func NewService

NewService builds the label-sync mapping service with CEL evaluation and tracing. deviceStore and events must either both be provided or both be nil. When nil, device-label reconciliation is unavailable on the returned service.

func WrapWithTracing

func WrapWithTracing(inner Service) Service

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

type ServiceHandler

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

func NewServiceHandler

func NewServiceHandler(store labelsyncmappingstore.Store, deviceStore ReconciliationDeviceStore, evaluator Evaluator, events eventservice.Service, log logrus.FieldLogger) (*ServiceHandler, error)

NewServiceHandler constructs the label-sync mapping service, including CEL validation for CRUD operations and device-label reconciliation. It returns an error if any required dependency is nil.

func (*ServiceHandler) CompleteMappingScan

func (h *ServiceHandler) CompleteMappingScan(ctx context.Context, orgID uuid.UUID, tokens []MappingScanToken) (map[uuid.UUID]bool, error)

func (*ServiceHandler) CreateLabelSyncMapping

func (h *ServiceHandler) CreateLabelSyncMapping(ctx context.Context, orgID uuid.UUID, mapping domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

func (*ServiceHandler) DeleteLabelSyncMapping

func (h *ServiceHandler) DeleteLabelSyncMapping(ctx context.Context, orgID uuid.UUID, name string) domain.Status

func (*ServiceHandler) GetDeviceLabelSyncProvenance

func (h *ServiceHandler) GetDeviceLabelSyncProvenance(ctx context.Context, orgID uuid.UUID, deviceName string) (*domain.LabelSyncProvenanceList, domain.Status)

func (*ServiceHandler) GetLabelSyncMapping

func (h *ServiceHandler) GetLabelSyncMapping(ctx context.Context, orgID uuid.UUID, name string) (*domain.LabelSyncMapping, domain.Status)

func (*ServiceHandler) GetLabelSyncProvenance

func (h *ServiceHandler) GetLabelSyncProvenance(ctx context.Context, orgID uuid.UUID, labelKeys []string) (*domain.LabelSyncProvenanceList, domain.Status)

func (*ServiceHandler) ListLabelSyncMappings

func (*ServiceHandler) ListMappingScanTargets

func (h *ServiceHandler) ListMappingScanTargets(ctx context.Context, orgID uuid.UUID) ([]MappingScanToken, error)

func (*ServiceHandler) PatchLabelSyncMapping

func (h *ServiceHandler) PatchLabelSyncMapping(ctx context.Context, orgID uuid.UUID, name string, patch domain.PatchRequest) (*domain.LabelSyncMapping, domain.Status)

func (*ServiceHandler) ReconcileDeviceLabels

func (h *ServiceHandler) ReconcileDeviceLabels(ctx context.Context, orgID uuid.UUID, deviceName string) (ReconciliationResult, error)

func (*ServiceHandler) RecordMappingScanFailure

func (h *ServiceHandler) RecordMappingScanFailure(ctx context.Context, orgID uuid.UUID, token MappingScanToken, message string) (MappingScanToken, bool, error)

func (*ServiceHandler) ReplaceLabelSyncMapping

func (h *ServiceHandler) ReplaceLabelSyncMapping(ctx context.Context, orgID uuid.UUID, name string, mapping domain.LabelSyncMapping) (*domain.LabelSyncMapping, domain.Status)

type TracedService

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

TracedService wraps a Service implementation with OpenTelemetry tracing.

func (*TracedService) CompleteMappingScan

func (_d *TracedService) CompleteMappingScan(ctx context.Context, u1 uuid.UUID, ma1 []MappingScanToken) (m1 map[uuid.UUID]bool, err error)

func (*TracedService) CreateLabelSyncMapping

func (_d *TracedService) CreateLabelSyncMapping(ctx context.Context, u1 uuid.UUID, l1 domain.LabelSyncMapping) (lp1 *domain.LabelSyncMapping, s1 domain.Status)

func (*TracedService) DeleteLabelSyncMapping

func (_d *TracedService) DeleteLabelSyncMapping(ctx context.Context, u1 uuid.UUID, s1 string) (s2 domain.Status)

func (*TracedService) GetDeviceLabelSyncProvenance

func (_d *TracedService) GetDeviceLabelSyncProvenance(ctx context.Context, u1 uuid.UUID, s1 string) (lp1 *domain.LabelSyncProvenanceList, s2 domain.Status)

func (*TracedService) GetLabelSyncMapping

func (_d *TracedService) GetLabelSyncMapping(ctx context.Context, u1 uuid.UUID, s1 string) (lp1 *domain.LabelSyncMapping, s2 domain.Status)

func (*TracedService) GetLabelSyncProvenance

func (_d *TracedService) GetLabelSyncProvenance(ctx context.Context, u1 uuid.UUID, sa1 []string) (lp1 *domain.LabelSyncProvenanceList, s1 domain.Status)

func (*TracedService) ListLabelSyncMappings

func (*TracedService) ListMappingScanTargets

func (_d *TracedService) ListMappingScanTargets(ctx context.Context, u1 uuid.UUID) (ma1 []MappingScanToken, err error)

func (*TracedService) PatchLabelSyncMapping

func (_d *TracedService) PatchLabelSyncMapping(ctx context.Context, u1 uuid.UUID, s1 string, p1 domain.PatchRequest) (lp1 *domain.LabelSyncMapping, s2 domain.Status)

func (*TracedService) ReconcileDeviceLabels

func (_d *TracedService) ReconcileDeviceLabels(ctx context.Context, u1 uuid.UUID, s1 string) (r1 ReconciliationResult, err error)

func (*TracedService) RecordMappingScanFailure

func (_d *TracedService) RecordMappingScanFailure(ctx context.Context, u1 uuid.UUID, m1 MappingScanToken, s1 string) (m2 MappingScanToken, b1 bool, err error)

func (*TracedService) ReplaceLabelSyncMapping

func (_d *TracedService) ReplaceLabelSyncMapping(ctx context.Context, u1 uuid.UUID, s1 string, l1 domain.LabelSyncMapping) (lp1 *domain.LabelSyncMapping, s2 domain.Status)

Jump to

Keyboard shortcuts

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