tasks

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package tasks is a generated GoMock package.

Index

Constants

View Source
const (
	// Task to roll out a fleet's template to its devices upon update
	FleetRolloutTask = "fleet-rollout"

	// Task to set devices' owners
	FleetSelectorMatchTask = "fleet-selector-match"

	// Task to populate a template version
	TemplateVersionPopulateTask = "template-version-populate"

	// Task to validate a fleet template
	FleetValidateTask = "fleet-template-validate"

	// Task to render device
	DeviceRenderTask = "device-render"

	// Task to re-evaluate fleets and devices if a repository resource changes
	RepositoryUpdatesTask = "repository-updates"
)
View Source
const (
	FleetRolloutOpUpdate              = "update"
	FleetSelectorMatchOpUpdate        = "update"
	FleetSelectorMatchOpUpdateOverlap = "update-overlap"
	FleetSelectorMatchOpDeleteAll     = "delete-all"
	TemplateVersionPopulateOpCreated  = "create"
	FleetValidateOpUpdate             = "update"
	DeviceRenderOpUpdate              = "update"
	RepositoryUpdateOpUpdate          = "update"
	RepositoryUpdateOpDeleteAll       = "delete-all"
)
View Source
const (
	// TODO: make configurable
	// DeviceDisconnectedTimeout is the duration after which a device is considered to be not reporting and set to unknown status.
	DeviceDisconnectedTimeout = 5 * time.Minute
	// DeviceDisconnectedPollingInterval is the interval at which the device liveness task runs.
	DeviceDisconnectedPollingInterval = 2 * time.Minute
)
View Source
const ItemsPerPage = 1000
View Source
const TaskQueue = "task-queue"

Variables

View Source
var ErrUnknownConfigName = errors.New("failed to find configuration item name")

Functions

func CloneGitRepo

func CloneGitRepo(repo *model.Repository, revision *string, depth *int) (billy.Filesystem, string, error)

func ContainsParameter

func ContainsParameter(b []byte) bool

func ConvertFileSystemToIgnition

func ConvertFileSystemToIgnition(mfs billy.Filesystem, path string, mountPath string) (*config_latest_types.Config, error)

ConvertFileSystemToIgnition converts a filesystem to an ignition config The filesystem is expected to be a git repo, and the path is the root of the repo The function will recursively walk the filesystem and add all files to the ignition config In case user provides file path we will add file as "/file-name" In case user provides folder we will drop folder path add all files and subfolder with subfolder paths, like Example: ConvertFileSystemToIgnition(mfs, "/test-path) will go through all subfolder and files and build ignition paths like /etc/motd, /etc/config/file.yaml The function will return an error if the path does not exist or if there is an error reading the filesystem

func GetAuth

func GetAuth(repository *model.Repository) (transport.AuthMethod, error)

Read repository's ssh/http config and create transport.AuthMethod. If no ssh/http config is defined a nil is returned.

func LaunchConsumers

func LaunchConsumers(ctx context.Context,
	provider queues.Provider,
	store store.Store,
	callbackManager CallbackManager,
	k8sClient k8sclient.K8SClient,
	numConsumers, threadsPerConsumer int) error

func ReplaceParameters

func ReplaceParameters(b []byte, objectMeta api.ObjectMeta) ([]byte, []string)

func TaskQueuePublisher

func TaskQueuePublisher(provider queues.Provider) (queues.Publisher, error)

func ValidateParameterFormat

func ValidateParameterFormat(b []byte) error

Types

type API

type API interface {
	Test()
}

type CallbackManager

type CallbackManager interface {
	FleetUpdatedCallback(before *model.Fleet, after *model.Fleet)
	RepositoryUpdatedCallback(repository *model.Repository)
	AllRepositoriesDeletedCallback(orgId uuid.UUID)
	AllFleetsDeletedCallback(orgId uuid.UUID)
	AllDevicesDeletedCallback(orgId uuid.UUID)
	DeviceUpdatedCallback(before *model.Device, after *model.Device)
	TemplateVersionCreatedCallback(templateVersion *model.TemplateVersion)
	TemplateVersionValidatedCallback(templateVersion *model.TemplateVersion)
	FleetSourceUpdated(orgId uuid.UUID, name string)
	DeviceSourceUpdated(orgId uuid.UUID, name string)
}

func NewCallbackManager

func NewCallbackManager(publisher queues.Publisher, log logrus.FieldLogger) CallbackManager

type DeviceDisconnected

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

func NewDeviceDisconnected

func NewDeviceDisconnected(log logrus.FieldLogger, store store.Store) *DeviceDisconnected

func (*DeviceDisconnected) Poll

func (t *DeviceDisconnected) Poll()

Poll checks the status of devices and updates the status to unknown if the device has not reported in the last DeviceDisconnectedTimeout.

type DeviceRenderLogic

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

func NewDeviceRenderLogic

func NewDeviceRenderLogic(callbackManager CallbackManager, log logrus.FieldLogger, store store.Store, k8sClient k8sclient.K8SClient, resourceRef ResourceReference) DeviceRenderLogic

func (*DeviceRenderLogic) RenderDevice

func (t *DeviceRenderLogic) RenderDevice(ctx context.Context) error

type FleetRolloutsLogic

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

func NewFleetRolloutsLogic

func NewFleetRolloutsLogic(callbackManager CallbackManager, log logrus.FieldLogger, storeInst store.Store, resourceRef ResourceReference) FleetRolloutsLogic

func (FleetRolloutsLogic) RolloutDevice

func (f FleetRolloutsLogic) RolloutDevice(ctx context.Context) error

The device's owner was changed, roll out if necessary

func (FleetRolloutsLogic) RolloutFleet

func (f FleetRolloutsLogic) RolloutFleet(ctx context.Context) error

func (*FleetRolloutsLogic) SetItemsPerPage

func (f *FleetRolloutsLogic) SetItemsPerPage(items int)

type FleetSelectorMatchingLogic

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

func NewFleetSelectorMatchingLogic

func NewFleetSelectorMatchingLogic(callbackManager CallbackManager, log logrus.FieldLogger, storeInst store.Store, resourceRef ResourceReference) FleetSelectorMatchingLogic

func (FleetSelectorMatchingLogic) CompareFleetsAndSetDeviceOwner

func (f FleetSelectorMatchingLogic) CompareFleetsAndSetDeviceOwner(ctx context.Context) error

Iterate fleets and set the device's owner/conditions as necessary

func (FleetSelectorMatchingLogic) FleetSelectorUpdatedNoOverlapping

func (f FleetSelectorMatchingLogic) FleetSelectorUpdatedNoOverlapping(ctx context.Context) error

Iterate devices that match the fleet's selector and set owners/conditions as necessary

func (FleetSelectorMatchingLogic) HandleDeleteAllDevices

func (f FleetSelectorMatchingLogic) HandleDeleteAllDevices(ctx context.Context) error

func (FleetSelectorMatchingLogic) HandleDeleteAllFleets

func (f FleetSelectorMatchingLogic) HandleDeleteAllFleets(ctx context.Context) error

func (FleetSelectorMatchingLogic) HandleOrgwideUpdate

func (f FleetSelectorMatchingLogic) HandleOrgwideUpdate(ctx context.Context) error

We had overlapping selectors and now need to iterate over all devices in the org to see if those overlaps were resolved

func (*FleetSelectorMatchingLogic) SetItemsPerPage

func (f *FleetSelectorMatchingLogic) SetItemsPerPage(items int)

type FleetValidateLogic

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

func NewFleetValidateLogic

func NewFleetValidateLogic(callbackManager CallbackManager, log logrus.FieldLogger, store store.Store, k8sClient k8sclient.K8SClient, resourceRef ResourceReference) FleetValidateLogic

func (*FleetValidateLogic) CreateNewTemplateVersionIfFleetValid

func (t *FleetValidateLogic) CreateNewTemplateVersionIfFleetValid(ctx context.Context) error

type GitRepoTester

type GitRepoTester struct {
}

func (*GitRepoTester) TestAccess

func (r *GitRepoTester) TestAccess(repository *model.Repository) error

type MockCallbackManager

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

MockCallbackManager is a mock of CallbackManager interface.

func NewMockCallbackManager

func NewMockCallbackManager(ctrl *gomock.Controller) *MockCallbackManager

NewMockCallbackManager creates a new mock instance.

func (*MockCallbackManager) AllDevicesDeletedCallback

func (m *MockCallbackManager) AllDevicesDeletedCallback(orgId uuid.UUID)

AllDevicesDeletedCallback mocks base method.

func (*MockCallbackManager) AllFleetsDeletedCallback

func (m *MockCallbackManager) AllFleetsDeletedCallback(orgId uuid.UUID)

AllFleetsDeletedCallback mocks base method.

func (*MockCallbackManager) AllRepositoriesDeletedCallback

func (m *MockCallbackManager) AllRepositoriesDeletedCallback(orgId uuid.UUID)

AllRepositoriesDeletedCallback mocks base method.

func (*MockCallbackManager) DeviceSourceUpdated

func (m *MockCallbackManager) DeviceSourceUpdated(orgId uuid.UUID, name string)

DeviceSourceUpdated mocks base method.

func (*MockCallbackManager) DeviceUpdatedCallback

func (m *MockCallbackManager) DeviceUpdatedCallback(before, after *model.Device)

DeviceUpdatedCallback mocks base method.

func (*MockCallbackManager) EXPECT

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

func (*MockCallbackManager) FleetSourceUpdated

func (m *MockCallbackManager) FleetSourceUpdated(orgId uuid.UUID, name string)

FleetSourceUpdated mocks base method.

func (*MockCallbackManager) FleetUpdatedCallback

func (m *MockCallbackManager) FleetUpdatedCallback(before, after *model.Fleet)

FleetUpdatedCallback mocks base method.

func (*MockCallbackManager) RepositoryUpdatedCallback

func (m *MockCallbackManager) RepositoryUpdatedCallback(repository *model.Repository)

RepositoryUpdatedCallback mocks base method.

func (*MockCallbackManager) TemplateVersionCreatedCallback

func (m *MockCallbackManager) TemplateVersionCreatedCallback(templateVersion *model.TemplateVersion)

TemplateVersionCreatedCallback mocks base method.

func (*MockCallbackManager) TemplateVersionValidatedCallback

func (m *MockCallbackManager) TemplateVersionValidatedCallback(templateVersion *model.TemplateVersion)

TemplateVersionValidatedCallback mocks base method.

type MockCallbackManagerMockRecorder

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

MockCallbackManagerMockRecorder is the mock recorder for MockCallbackManager.

func (*MockCallbackManagerMockRecorder) AllDevicesDeletedCallback

func (mr *MockCallbackManagerMockRecorder) AllDevicesDeletedCallback(orgId any) *gomock.Call

AllDevicesDeletedCallback indicates an expected call of AllDevicesDeletedCallback.

func (*MockCallbackManagerMockRecorder) AllFleetsDeletedCallback

func (mr *MockCallbackManagerMockRecorder) AllFleetsDeletedCallback(orgId any) *gomock.Call

AllFleetsDeletedCallback indicates an expected call of AllFleetsDeletedCallback.

func (*MockCallbackManagerMockRecorder) AllRepositoriesDeletedCallback

func (mr *MockCallbackManagerMockRecorder) AllRepositoriesDeletedCallback(orgId any) *gomock.Call

AllRepositoriesDeletedCallback indicates an expected call of AllRepositoriesDeletedCallback.

func (*MockCallbackManagerMockRecorder) DeviceSourceUpdated

func (mr *MockCallbackManagerMockRecorder) DeviceSourceUpdated(orgId, name any) *gomock.Call

DeviceSourceUpdated indicates an expected call of DeviceSourceUpdated.

func (*MockCallbackManagerMockRecorder) DeviceUpdatedCallback

func (mr *MockCallbackManagerMockRecorder) DeviceUpdatedCallback(before, after any) *gomock.Call

DeviceUpdatedCallback indicates an expected call of DeviceUpdatedCallback.

func (*MockCallbackManagerMockRecorder) FleetSourceUpdated

func (mr *MockCallbackManagerMockRecorder) FleetSourceUpdated(orgId, name any) *gomock.Call

FleetSourceUpdated indicates an expected call of FleetSourceUpdated.

func (*MockCallbackManagerMockRecorder) FleetUpdatedCallback

func (mr *MockCallbackManagerMockRecorder) FleetUpdatedCallback(before, after any) *gomock.Call

FleetUpdatedCallback indicates an expected call of FleetUpdatedCallback.

func (*MockCallbackManagerMockRecorder) RepositoryUpdatedCallback

func (mr *MockCallbackManagerMockRecorder) RepositoryUpdatedCallback(repository any) *gomock.Call

RepositoryUpdatedCallback indicates an expected call of RepositoryUpdatedCallback.

func (*MockCallbackManagerMockRecorder) TemplateVersionCreatedCallback

func (mr *MockCallbackManagerMockRecorder) TemplateVersionCreatedCallback(templateVersion any) *gomock.Call

TemplateVersionCreatedCallback indicates an expected call of TemplateVersionCreatedCallback.

func (*MockCallbackManagerMockRecorder) TemplateVersionValidatedCallback

func (mr *MockCallbackManagerMockRecorder) TemplateVersionValidatedCallback(templateVersion any) *gomock.Call

TemplateVersionValidatedCallback indicates an expected call of TemplateVersionValidatedCallback.

type RepoTester

type RepoTester struct {
	TypeSpecificRepoTester TypeSpecificRepoTester
	// contains filtered or unexported fields
}

func NewRepoTester

func NewRepoTester(log logrus.FieldLogger, store store.Store) *RepoTester

func (*RepoTester) SetAccessCondition

func (r *RepoTester) SetAccessCondition(repository model.Repository, err error) error

func (*RepoTester) TestRepositories

func (r *RepoTester) TestRepositories()

type RepositoryUpdateLogic

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

func NewRepositoryUpdateLogic

func NewRepositoryUpdateLogic(callbackManager CallbackManager, log logrus.FieldLogger, store store.Store, resourceRef ResourceReference) RepositoryUpdateLogic

func (*RepositoryUpdateLogic) HandleAllRepositoriesDeleted

func (t *RepositoryUpdateLogic) HandleAllRepositoriesDeleted(ctx context.Context, log logrus.FieldLogger) error

func (*RepositoryUpdateLogic) HandleRepositoryUpdate

func (t *RepositoryUpdateLogic) HandleRepositoryUpdate(ctx context.Context) error

type ResourceReference

type ResourceReference struct {
	TaskName string
	Op       string
	OrgID    uuid.UUID
	Kind     string
	Name     string
	Owner    string
}

type ResourceSync

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

func NewResourceSync

func NewResourceSync(callbackManager CallbackManager, store store.Store, log logrus.FieldLogger) *ResourceSync

func (*ResourceSync) Poll

func (r *ResourceSync) Poll()

type TemplateVersionPopulateLogic

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

func NewTemplateVersionPopulateLogic

func NewTemplateVersionPopulateLogic(callbackManager CallbackManager, log logrus.FieldLogger, store store.Store, k8sClient k8sclient.K8SClient, resourceRef ResourceReference) TemplateVersionPopulateLogic

func (*TemplateVersionPopulateLogic) SyncFleetTemplateToTemplateVersion

func (t *TemplateVersionPopulateLogic) SyncFleetTemplateToTemplateVersion(ctx context.Context) error

type TypeSpecificRepoTester

type TypeSpecificRepoTester interface {
	TestAccess(repository *model.Repository) error
}

Jump to

Keyboard shortcuts

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