spec

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package spec is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRollback added in v0.8.1

func IsRollback(current *v1beta1.Device, desired *v1beta1.Device) bool

IsRollback returns true if the version of the current spec is greater than the desired.

func IsUpgrading added in v0.3.0

func IsUpgrading(current *v1beta1.Device, desired *v1beta1.Device) bool

func NewManager

func NewManager(
	deviceName string,
	dataDir string,
	policyManager policy.Manager,
	deviceReadWriter fileio.ReadWriter,
	osClient os.Client,
	fetchInterval util.Duration,
	backoff wait.Backoff,
	deviceNotFoundHandler func() error,
	auditLogger audit.Logger,
	log *log.PrefixLogger,
) *manager

NewManager creates a new device spec manager.

Note: This manager is designed for sequential operations only and is not thread-safe.

Types

type Item added in v0.3.0

type Item struct {
	Version int64
	Spec    *v1beta1.Device
}

type ItemHeap added in v0.3.0

type ItemHeap []*Item

ItemHeap is a priority queue that orders items by version.

func (ItemHeap) Len added in v0.3.0

func (h ItemHeap) Len() int

func (ItemHeap) Less added in v0.3.0

func (h ItemHeap) Less(i, j int) bool

func (*ItemHeap) Pop added in v0.3.0

func (h *ItemHeap) Pop() interface{}

func (*ItemHeap) Push added in v0.3.0

func (h *ItemHeap) Push(x interface{})

func (ItemHeap) Swap added in v0.3.0

func (h ItemHeap) Swap(i, j int)

type Manager

type Manager interface {
	// Initialize initializes the current, desired and rollback device files on
	// disk. If the files already exist, they are overwritten.
	Initialize(ctx context.Context) error
	// Ensure ensures that spec files exist on disk and re initializes them if they do not.
	Ensure() error
	// RenderedVersion returns the rendered version of the specified spec type.
	RenderedVersion(specType Type) string
	// OSVersion returns the OS version of the specified spec type.
	OSVersion(specType Type) string
	// Read returns the rendered device of the specified type from disk.
	Read(specType Type) (*v1beta1.Device, error)
	// Upgrade updates the current rendered spec to the desired rendered spec
	// and resets the rollback spec.
	Upgrade(ctx context.Context) error
	// SetUpgradeFailed marks the desired rendered spec as failed.
	SetUpgradeFailed(version string) error
	// IsUpdating returns true if the device is in the process of reconciling the desired spec.
	IsUpgrading() bool
	// IsOSUpdate returns true if an OS update is in progress by checking the current rendered spec.
	IsOSUpdate() bool
	// CheckOsReconciliation checks if the booted OS image matches the desired OS image.
	CheckOsReconciliation(ctx context.Context) (string, bool, error)
	// IsRollingBack returns true if the device is in a rollback state.
	IsRollingBack(ctx context.Context) (bool, error)
	// CreateRollback creates a rollback version of the current rendered spec.
	CreateRollback(ctx context.Context) error
	// ClearRollback clears the rollback rendered spec.
	ClearRollback() error
	// Rollback reverts the device to the state of the rollback rendered spec.
	Rollback(ctx context.Context, opts ...RollbackOption) error
	// GetDesired returns the desired rendered device from the management API.
	GetDesired(ctx context.Context) (*v1beta1.Device, bool, error)
	// CheckPolicy validates the update policy is ready to process.
	CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
	// SetClient sets the management client for fetching specs.
	SetClient(client client.Management)
	status.Exporter
}

Manager provides the public API for managing device specifications. This interface is used by the device agent for normal operations.

type MockManager

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

MockManager is a mock of Manager interface.

func NewMockManager

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) CheckOsReconciliation

func (m *MockManager) CheckOsReconciliation(ctx context.Context) (string, bool, error)

CheckOsReconciliation mocks base method.

func (*MockManager) CheckPolicy added in v0.4.0

func (m *MockManager) CheckPolicy(ctx context.Context, policyType policy.Type, version string) error

CheckPolicy mocks base method.

func (*MockManager) ClearRollback added in v0.4.0

func (m *MockManager) ClearRollback() error

ClearRollback mocks base method.

func (*MockManager) CreateRollback added in v0.4.0

func (m *MockManager) CreateRollback(ctx context.Context) error

CreateRollback mocks base method.

func (*MockManager) EXPECT

func (m *MockManager) EXPECT() *MockManagerMockRecorder

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

func (*MockManager) Ensure

func (m *MockManager) Ensure() error

Ensure mocks base method.

func (*MockManager) GetDesired

func (m *MockManager) GetDesired(ctx context.Context) (*v1beta1.Device, bool, error)

GetDesired mocks base method.

func (*MockManager) Initialize

func (m *MockManager) Initialize(ctx context.Context) error

Initialize mocks base method.

func (*MockManager) IsOSUpdate

func (m *MockManager) IsOSUpdate() bool

IsOSUpdate mocks base method.

func (*MockManager) IsRollingBack

func (m *MockManager) IsRollingBack(ctx context.Context) (bool, error)

IsRollingBack mocks base method.

func (*MockManager) IsUpgrading added in v0.3.0

func (m *MockManager) IsUpgrading() bool

IsUpgrading mocks base method.

func (*MockManager) OSVersion added in v0.4.0

func (m *MockManager) OSVersion(specType Type) string

OSVersion mocks base method.

func (*MockManager) Read

func (m *MockManager) Read(specType Type) (*v1beta1.Device, error)

Read mocks base method.

func (*MockManager) RenderedVersion added in v0.4.0

func (m *MockManager) RenderedVersion(specType Type) string

RenderedVersion mocks base method.

func (*MockManager) Rollback

func (m *MockManager) Rollback(ctx context.Context, opts ...RollbackOption) error

Rollback mocks base method.

func (*MockManager) SetClient

func (m *MockManager) SetClient(client client.Management)

SetClient mocks base method.

func (*MockManager) SetUpgradeFailed added in v0.3.0

func (m *MockManager) SetUpgradeFailed(version string) error

SetUpgradeFailed mocks base method.

func (*MockManager) Status added in v0.4.0

func (m *MockManager) Status(arg0 context.Context, arg1 *v1beta1.DeviceStatus, arg2 ...status.CollectorOpt) error

Status mocks base method.

func (*MockManager) Upgrade

func (m *MockManager) Upgrade(ctx context.Context) error

Upgrade mocks base method.

type MockManagerMockRecorder

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

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) CheckOsReconciliation

func (mr *MockManagerMockRecorder) CheckOsReconciliation(ctx any) *gomock.Call

CheckOsReconciliation indicates an expected call of CheckOsReconciliation.

func (*MockManagerMockRecorder) CheckPolicy added in v0.4.0

func (mr *MockManagerMockRecorder) CheckPolicy(ctx, policyType, version any) *gomock.Call

CheckPolicy indicates an expected call of CheckPolicy.

func (*MockManagerMockRecorder) ClearRollback added in v0.4.0

func (mr *MockManagerMockRecorder) ClearRollback() *gomock.Call

ClearRollback indicates an expected call of ClearRollback.

func (*MockManagerMockRecorder) CreateRollback added in v0.4.0

func (mr *MockManagerMockRecorder) CreateRollback(ctx any) *gomock.Call

CreateRollback indicates an expected call of CreateRollback.

func (*MockManagerMockRecorder) Ensure

func (mr *MockManagerMockRecorder) Ensure() *gomock.Call

Ensure indicates an expected call of Ensure.

func (*MockManagerMockRecorder) GetDesired

func (mr *MockManagerMockRecorder) GetDesired(ctx any) *gomock.Call

GetDesired indicates an expected call of GetDesired.

func (*MockManagerMockRecorder) Initialize

func (mr *MockManagerMockRecorder) Initialize(ctx any) *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockManagerMockRecorder) IsOSUpdate

func (mr *MockManagerMockRecorder) IsOSUpdate() *gomock.Call

IsOSUpdate indicates an expected call of IsOSUpdate.

func (*MockManagerMockRecorder) IsRollingBack

func (mr *MockManagerMockRecorder) IsRollingBack(ctx any) *gomock.Call

IsRollingBack indicates an expected call of IsRollingBack.

func (*MockManagerMockRecorder) IsUpgrading added in v0.3.0

func (mr *MockManagerMockRecorder) IsUpgrading() *gomock.Call

IsUpgrading indicates an expected call of IsUpgrading.

func (*MockManagerMockRecorder) OSVersion added in v0.4.0

func (mr *MockManagerMockRecorder) OSVersion(specType any) *gomock.Call

OSVersion indicates an expected call of OSVersion.

func (*MockManagerMockRecorder) Read

func (mr *MockManagerMockRecorder) Read(specType any) *gomock.Call

Read indicates an expected call of Read.

func (*MockManagerMockRecorder) RenderedVersion added in v0.4.0

func (mr *MockManagerMockRecorder) RenderedVersion(specType any) *gomock.Call

RenderedVersion indicates an expected call of RenderedVersion.

func (*MockManagerMockRecorder) Rollback

func (mr *MockManagerMockRecorder) Rollback(ctx any, opts ...any) *gomock.Call

Rollback indicates an expected call of Rollback.

func (*MockManagerMockRecorder) SetClient

func (mr *MockManagerMockRecorder) SetClient(client any) *gomock.Call

SetClient indicates an expected call of SetClient.

func (*MockManagerMockRecorder) SetUpgradeFailed added in v0.3.0

func (mr *MockManagerMockRecorder) SetUpgradeFailed(version any) *gomock.Call

SetUpgradeFailed indicates an expected call of SetUpgradeFailed.

func (*MockManagerMockRecorder) Status added in v0.4.0

func (mr *MockManagerMockRecorder) Status(arg0, arg1 any, arg2 ...any) *gomock.Call

Status indicates an expected call of Status.

func (*MockManagerMockRecorder) Upgrade

func (mr *MockManagerMockRecorder) Upgrade(ctx any) *gomock.Call

Upgrade indicates an expected call of Upgrade.

type MockPriorityQueue added in v0.3.0

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

MockPriorityQueue is a mock of PriorityQueue interface.

func NewMockPriorityQueue added in v0.3.0

func NewMockPriorityQueue(ctrl *gomock.Controller) *MockPriorityQueue

NewMockPriorityQueue creates a new mock instance.

func (*MockPriorityQueue) Add added in v0.3.0

func (m *MockPriorityQueue) Add(ctx context.Context, spec *v1beta1.Device)

Add mocks base method.

func (*MockPriorityQueue) CheckPolicy added in v0.4.0

func (m *MockPriorityQueue) CheckPolicy(ctx context.Context, policyType policy.Type, version string) error

CheckPolicy mocks base method.

func (*MockPriorityQueue) EXPECT added in v0.3.0

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

func (*MockPriorityQueue) IsFailed added in v0.4.0

func (m *MockPriorityQueue) IsFailed(version int64) bool

IsFailed mocks base method.

func (*MockPriorityQueue) Next added in v0.3.0

Next mocks base method.

func (*MockPriorityQueue) Remove added in v0.3.0

func (m *MockPriorityQueue) Remove(version int64)

Remove mocks base method.

func (*MockPriorityQueue) SetFailed added in v0.4.0

func (m *MockPriorityQueue) SetFailed(version int64)

SetFailed mocks base method.

type MockPriorityQueueMockRecorder added in v0.3.0

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

MockPriorityQueueMockRecorder is the mock recorder for MockPriorityQueue.

func (*MockPriorityQueueMockRecorder) Add added in v0.3.0

func (mr *MockPriorityQueueMockRecorder) Add(ctx, spec any) *gomock.Call

Add indicates an expected call of Add.

func (*MockPriorityQueueMockRecorder) CheckPolicy added in v0.4.0

func (mr *MockPriorityQueueMockRecorder) CheckPolicy(ctx, policyType, version any) *gomock.Call

CheckPolicy indicates an expected call of CheckPolicy.

func (*MockPriorityQueueMockRecorder) IsFailed added in v0.4.0

func (mr *MockPriorityQueueMockRecorder) IsFailed(version any) *gomock.Call

IsFailed indicates an expected call of IsFailed.

func (*MockPriorityQueueMockRecorder) Next added in v0.3.0

Next indicates an expected call of Next.

func (*MockPriorityQueueMockRecorder) Remove added in v0.3.0

func (mr *MockPriorityQueueMockRecorder) Remove(version any) *gomock.Call

Remove indicates an expected call of Remove.

func (*MockPriorityQueueMockRecorder) SetFailed added in v0.4.0

func (mr *MockPriorityQueueMockRecorder) SetFailed(version any) *gomock.Call

SetFailed indicates an expected call of SetFailed.

type MockWatcher added in v0.10.0

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

MockWatcher is a mock of Watcher interface.

func NewMockWatcher added in v0.10.0

func NewMockWatcher(ctrl *gomock.Controller) *MockWatcher

NewMockWatcher creates a new mock instance.

func (*MockWatcher) EXPECT added in v0.10.0

func (m *MockWatcher) EXPECT() *MockWatcherMockRecorder

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

func (*MockWatcher) Pop added in v0.10.0

func (m *MockWatcher) Pop() (*v1beta1.Device, error)

Pop mocks base method.

func (*MockWatcher) TryPop added in v0.10.0

func (m *MockWatcher) TryPop() (*v1beta1.Device, bool, error)

TryPop mocks base method.

type MockWatcherMockRecorder added in v0.10.0

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

MockWatcherMockRecorder is the mock recorder for MockWatcher.

func (*MockWatcherMockRecorder) Pop added in v0.10.0

func (mr *MockWatcherMockRecorder) Pop() *gomock.Call

Pop indicates an expected call of Pop.

func (*MockWatcherMockRecorder) TryPop added in v0.10.0

func (mr *MockWatcherMockRecorder) TryPop() *gomock.Call

TryPop indicates an expected call of TryPop.

type PriorityQueue added in v0.3.0

type PriorityQueue interface {
	// Add adds a new spec to the scheduler
	Add(ctx context.Context, spec *v1beta1.Device)
	// Next returns the next spec to process
	Next(ctx context.Context) (*v1beta1.Device, bool)
	// Remove removes a spec from the scheduler
	Remove(version int64)
	// SetFailed marks a rendered spec version as failed
	SetFailed(version int64)
	// IsFailed returns true if a version is marked as failed
	IsFailed(version int64) bool
	// CheckPolicy validates the update policy is ready to process.
	CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
}

type Publisher added in v0.10.0

type Publisher interface {
	Run(ctx context.Context)
	Watch() Watcher
	SetClient(client.Management)
}

type RollbackOption added in v0.5.0

type RollbackOption func(*rollbackConfig)

func WithSetFailed added in v0.5.0

func WithSetFailed() RollbackOption

WithSetFailed enables setting the desired spec as failed.

type Type

type Type string
const (
	Current  Type = "current"
	Desired  Type = "desired"
	Rollback Type = "rollback"
)

type Watcher added in v0.10.0

type Watcher interface {
	// Pop blocks until a device is available or returns error if closed
	Pop() (*v1beta1.Device, error)
	// TryPop attempts to get a device without blocking
	TryPop() (*v1beta1.Device, bool, error)
}

Watcher provides a way to watch for device spec updates.

Directories

Path Synopsis
Package audit provides structured audit logging for device spec transitions.
Package audit provides structured audit logging for device spec transitions.

Jump to

Keyboard shortcuts

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