applications

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 24 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 applications is a generated GoMock package.

Index

Constants

View Source
const (
	AppTypeLabel            = "appType"
	DefaultImageManifestDir = "/"
)

Variables

This section is empty.

Functions

func ImageProvidersFromSpec

func ImageProvidersFromSpec(spec *v1alpha1.RenderedDeviceSpec) ([]v1alpha1.ImageApplicationProvider, error)

ImageProvidersFromSpec returns a list of image application providers from a rendered device spec.

func NewApplication

func NewApplication[T any](id, name string, provider T, appType AppType) *application[T]

Types

type AppType

type AppType string
const (
	AppCompose AppType = "compose"
)

func ParseAppType

func ParseAppType(s string) (AppType, error)

func (AppType) ActionHandler

func (a AppType) ActionHandler() (lifecycle.ActionHandlerType, error)

type Application

type Application interface {
	// ID is an internal identifier for tracking the application this may or may
	// not be the name provided by the user. How this ID is generated is
	// determined on the application type level.
	ID() string
	// Name is the name of the application as defined by the user. If the name
	// is not populated by the user a name will be generated based on the
	// application type.
	Name() string
	// Type returns the application type.
	Type() AppType
	// EnvVars returns the environment variables for the application.
	EnvVars() map[string]string
	// SetEnvVars sets the environment variables for the application.
	SetEnvVars(envVars map[string]string) bool
	// Path returns the path to the application on the device.
	Path() (string, error)
	// Container returns a container by name.
	Container(name string) (*Container, bool)
	// AddContainer adds a container to the application.
	AddContainer(container Container)
	// RemoveContainer removes a container from the application.
	RemoveContainer(name string) bool
	// IsEmbedded returns true if the application is embedded.
	IsEmbedded() bool
	// Status reports the status of an application using the name as defined by
	// the user. In the case there is no name provided it will be populated
	// according to the rules of the application type.
	Status() (*v1alpha1.DeviceApplicationStatus, v1alpha1.DeviceApplicationsSummaryStatus, error)
}

type Container

type Container struct {
	ID       string
	Image    string
	Name     string
	Status   ContainerStatusType
	Restarts int
}

type ContainerStatusType

type ContainerStatusType string
const (
	ContainerStatusCreated ContainerStatusType = "created"
	ContainerStatusInit    ContainerStatusType = "init"
	ContainerStatusRunning ContainerStatusType = "start"
	ContainerStatusStop    ContainerStatusType = "stop"
	ContainerStatusDie     ContainerStatusType = "die" // docker only
	ContainerStatusDied    ContainerStatusType = "died"
	ContainerStatusRemove  ContainerStatusType = "remove"
	ContainerStatusExited  ContainerStatusType = "exited"
)

func (ContainerStatusType) String

func (c ContainerStatusType) String() string

type Controller

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

func NewController

func NewController(
	podman *client.Podman,
	manager Manager,
	readWriter fileio.ReadWriter,
	log *log.PrefixLogger,
) *Controller

func (*Controller) Sync

func (c *Controller) Sync(ctx context.Context, current, desired *v1alpha1.RenderedDeviceSpec) error

type EmbeddedProvider

type EmbeddedProvider struct{}

EmbeddedProvider is a provider for embedded applications.

type Manager

type Manager interface {
	Ensure(app Application) error
	Remove(app Application) error
	Update(app Application) error
	BeforeUpdate(ctx context.Context, desired *v1alpha1.RenderedDeviceSpec) error
	AfterUpdate(ctx context.Context) error
	Stop(ctx context.Context) error
	status.Exporter
}

func NewManager

func NewManager(
	log *log.PrefixLogger,
	readWriter fileio.ReadWriter,
	exec executer.Executer,
	podmanClient *client.Podman,
	systemClient client.System,
) Manager

type MockApplication

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

MockApplication is a mock of Application interface.

func NewMockApplication

func NewMockApplication(ctrl *gomock.Controller) *MockApplication

NewMockApplication creates a new mock instance.

func (*MockApplication) AddContainer

func (m *MockApplication) AddContainer(container Container)

AddContainer mocks base method.

func (*MockApplication) Container

func (m *MockApplication) Container(name string) (*Container, bool)

Container mocks base method.

func (*MockApplication) EXPECT

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

func (*MockApplication) EnvVars

func (m *MockApplication) EnvVars() map[string]string

EnvVars mocks base method.

func (*MockApplication) ID added in v0.4.0

func (m *MockApplication) ID() string

ID mocks base method.

func (*MockApplication) IsEmbedded

func (m *MockApplication) IsEmbedded() bool

IsEmbedded mocks base method.

func (*MockApplication) Name

func (m *MockApplication) Name() string

Name mocks base method.

func (*MockApplication) Path

func (m *MockApplication) Path() (string, error)

Path mocks base method.

func (*MockApplication) RemoveContainer

func (m *MockApplication) RemoveContainer(name string) bool

RemoveContainer mocks base method.

func (*MockApplication) SetEnvVars

func (m *MockApplication) SetEnvVars(envVars map[string]string) bool

SetEnvVars mocks base method.

func (*MockApplication) Status

Status mocks base method.

func (*MockApplication) Type

func (m *MockApplication) Type() AppType

Type mocks base method.

type MockApplicationMockRecorder

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

MockApplicationMockRecorder is the mock recorder for MockApplication.

func (*MockApplicationMockRecorder) AddContainer

func (mr *MockApplicationMockRecorder) AddContainer(container any) *gomock.Call

AddContainer indicates an expected call of AddContainer.

func (*MockApplicationMockRecorder) Container

func (mr *MockApplicationMockRecorder) Container(name any) *gomock.Call

Container indicates an expected call of Container.

func (*MockApplicationMockRecorder) EnvVars

func (mr *MockApplicationMockRecorder) EnvVars() *gomock.Call

EnvVars indicates an expected call of EnvVars.

func (*MockApplicationMockRecorder) ID added in v0.4.0

ID indicates an expected call of ID.

func (*MockApplicationMockRecorder) IsEmbedded

func (mr *MockApplicationMockRecorder) IsEmbedded() *gomock.Call

IsEmbedded indicates an expected call of IsEmbedded.

func (*MockApplicationMockRecorder) Name

Name indicates an expected call of Name.

func (*MockApplicationMockRecorder) Path

Path indicates an expected call of Path.

func (*MockApplicationMockRecorder) RemoveContainer

func (mr *MockApplicationMockRecorder) RemoveContainer(name any) *gomock.Call

RemoveContainer indicates an expected call of RemoveContainer.

func (*MockApplicationMockRecorder) SetEnvVars

func (mr *MockApplicationMockRecorder) SetEnvVars(envVars any) *gomock.Call

SetEnvVars indicates an expected call of SetEnvVars.

func (*MockApplicationMockRecorder) Status

func (mr *MockApplicationMockRecorder) Status() *gomock.Call

Status indicates an expected call of Status.

func (*MockApplicationMockRecorder) Type

Type indicates an expected call of Type.

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) AfterUpdate added in v0.4.0

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

AfterUpdate mocks base method.

func (*MockManager) BeforeUpdate added in v0.4.0

func (m *MockManager) BeforeUpdate(ctx context.Context, desired *v1alpha1.RenderedDeviceSpec) error

BeforeUpdate 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(app Application) error

Ensure mocks base method.

func (*MockManager) Remove

func (m *MockManager) Remove(app Application) error

Remove mocks base method.

func (*MockManager) Status

func (m *MockManager) Status(arg0 context.Context, arg1 *v1alpha1.DeviceStatus) error

Status mocks base method.

func (*MockManager) Stop

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

Stop mocks base method.

func (*MockManager) Update

func (m *MockManager) Update(app Application) error

Update mocks base method.

type MockManagerMockRecorder

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

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) AfterUpdate added in v0.4.0

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

AfterUpdate indicates an expected call of AfterUpdate.

func (*MockManagerMockRecorder) BeforeUpdate added in v0.4.0

func (mr *MockManagerMockRecorder) BeforeUpdate(ctx, desired any) *gomock.Call

BeforeUpdate indicates an expected call of BeforeUpdate.

func (*MockManagerMockRecorder) Ensure

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

Ensure indicates an expected call of Ensure.

func (*MockManagerMockRecorder) Remove

func (mr *MockManagerMockRecorder) Remove(app any) *gomock.Call

Remove indicates an expected call of Remove.

func (*MockManagerMockRecorder) Status

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

Status indicates an expected call of Status.

func (*MockManagerMockRecorder) Stop

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

Stop indicates an expected call of Stop.

func (*MockManagerMockRecorder) Update

func (mr *MockManagerMockRecorder) Update(app any) *gomock.Call

Update indicates an expected call of Update.

type MockMonitor

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

MockMonitor is a mock of Monitor interface.

func NewMockMonitor

func NewMockMonitor(ctrl *gomock.Controller) *MockMonitor

NewMockMonitor creates a new mock instance.

func (*MockMonitor) EXPECT

func (m *MockMonitor) EXPECT() *MockMonitorMockRecorder

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

func (*MockMonitor) Run

func (m *MockMonitor) Run(ctx context.Context)

Run mocks base method.

func (*MockMonitor) Status

Status mocks base method.

type MockMonitorMockRecorder

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

MockMonitorMockRecorder is the mock recorder for MockMonitor.

func (*MockMonitorMockRecorder) Run

func (mr *MockMonitorMockRecorder) Run(ctx any) *gomock.Call

Run indicates an expected call of Run.

func (*MockMonitorMockRecorder) Status

func (mr *MockMonitorMockRecorder) Status() *gomock.Call

Status indicates an expected call of Status.

type Monitor

type Monitor interface {
	Run(ctx context.Context)
	Status() []v1alpha1.DeviceApplicationStatus
}

type PodmanContainerConfig

type PodmanContainerConfig struct {
	Labels map[string]string `json:"Labels"`
}

type PodmanContainerState

type PodmanContainerState struct {
	OciVersion  string `json:"OciVersion"`
	Status      string `json:"Status"`
	Running     bool   `json:"Running"`
	Paused      bool   `json:"Paused"`
	Restarting  bool   `json:"Restarting"`
	OOMKilled   bool   `json:"OOMKilled"`
	Dead        bool   `json:"Dead"`
	Pid         int    `json:"Pid"`
	ExitCode    int    `json:"ExitCode"`
	Error       string `json:"Error"`
	StartedAt   string `json:"StartedAt"`
	FinishedAt  string `json:"FinishedAt"`
	Healthcheck string `json:"Healthcheck"`
}

ContainerState represents the container state part of the podman inspect output

type PodmanEvent

type PodmanEvent struct {
	ContainerExitCode int               `json:"ContainerExitCode,omitempty"`
	ID                string            `json:"ID"`
	Image             string            `json:"Image"`
	Name              string            `json:"Name"`
	Status            string            `json:"Status"`
	Type              string            `json:"Type"`
	Attributes        map[string]string `json:"Attributes"`
}

type PodmanInspect

type PodmanInspect struct {
	Restarts int                   `json:"RestartCount"`
	State    PodmanContainerState  `json:"State"`
	Config   PodmanContainerConfig `json:"Config"`
}

PodmanInspect represents the overall structure of podman inspect output

type PodmanMonitor

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

func NewPodmanMonitor

func NewPodmanMonitor(log *log.PrefixLogger, exec executer.Executer, podman *client.Podman, bootTime string) *PodmanMonitor

func (*PodmanMonitor) ExecuteActions

func (m *PodmanMonitor) ExecuteActions(ctx context.Context) error

func (*PodmanMonitor) Initialize

func (m *PodmanMonitor) Initialize()

func (*PodmanMonitor) IsInitialized

func (m *PodmanMonitor) IsInitialized() bool

func (*PodmanMonitor) Run

func (m *PodmanMonitor) Run(ctx context.Context) error

func (*PodmanMonitor) Stop

func (m *PodmanMonitor) Stop(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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