provider

package
v1.0.2 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: 21 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func CollectBaseOCITargets added in v1.0.0

func CollectBaseOCITargets(
	ctx context.Context,
	readWriter fileio.ReadWriter,
	spec *v1beta1.DeviceSpec,
	pullSecret *client.PullSecret,
) ([]dependency.OCIPullTarget, error)

CollectBaseOCITargets collects only the base OCI targets (images and volumes) from the device spec without creating providers or extracting nested targets. This is used in phase 1 of prefetching before the base images are available locally.

func NewAppDataCache added in v1.0.0

func NewAppDataCache() map[string]*AppData

NewAppDataCache creates a new app data cache

func ResolveImageAppName added in v1.0.0

func ResolveImageAppName(appSpec *v1beta1.ApplicationProviderSpec) (string, error)

ResolveImageAppName resolves the canonical application name from an ApplicationProviderSpec. If the spec has an explicit name, it uses that; otherwise, it falls back to the image reference.

func ToLifecycleVolumes added in v0.8.1

func ToLifecycleVolumes(volumes []*Volume) []lifecycle.Volume

ToLifecycleVolumes converts provider volumes to lifecycle volumes

Types

type AppData added in v1.0.0

type AppData struct {
	Targets   []dependency.OCIPullTarget
	TmpPath   string
	CleanupFn func() error
}

AppData holds the extracted application data and cleanup function

func ExtractNestedTargetsFromImage added in v1.0.0

func ExtractNestedTargetsFromImage(
	ctx context.Context,
	log *log.PrefixLogger,
	podman *client.Podman,
	readWriter fileio.ReadWriter,
	appSpec *v1beta1.ApplicationProviderSpec,
	imageSpec *v1beta1.ImageApplicationProviderSpec,
	pullSecret *client.PullSecret,
) (*AppData, error)

ExtractNestedTargetsFromImage extracts nested OCI targets from a single image-based application. This is used by the manager for per-application caching. Returns the extracted app data with targets. Caller is responsible for cleanup.

func (*AppData) Cleanup added in v1.0.0

func (e *AppData) Cleanup() error

type ApplicationSpec

type ApplicationSpec struct {
	// Name of the application
	Name string
	// ID of the application
	ID string
	// Type of the application
	AppType v1beta1.AppType
	// Path to the application
	Path string
	// EnvVars are the environment variables to be passed to the application
	EnvVars map[string]string
	// Embedded is true if the application is embedded in the device
	Embedded bool

	// Volume manager.
	Volume VolumeManager
	// ImageProvider is the spec for the image provider
	ImageProvider *v1beta1.ImageApplicationProviderSpec
	// InlineProvider is the spec for the inline provider
	InlineProvider *v1beta1.InlineApplicationProviderSpec
	// contains filtered or unexported fields
}

type CacheEntry added in v1.0.0

type CacheEntry struct {
	Name string
	// Parent is the parent image from which child OCI targets were extracted.
	Parent dependency.OCIPullTarget
	// Children are OCI targets extracted from parent image.
	Children []dependency.OCIPullTarget
}

CacheEntry represents cached nested targets extracted from image-based applications.

type Diff

type Diff struct {
	// Ensure contains both newly added and unchanged app provders
	Ensure []Provider
	// Removed contains app providers that are no longer part of the desired state
	Removed []Provider
	// Changed contains app providers that have changed between the current and desired state
	Changed []Provider
}

func GetDiff

func GetDiff(
	current []Provider,
	desired []Provider,
) (Diff, error)

type OCITargetCache added in v1.0.0

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

OCITargetCache caches child OCI targets extracted from parents.

func NewOCITargetCache added in v1.0.0

func NewOCITargetCache() *OCITargetCache

NewOCITargetCache creates a new cache instance

func (*OCITargetCache) Clear added in v1.0.0

func (c *OCITargetCache) Clear()

Clear removes all entries from the cache

func (*OCITargetCache) GC added in v1.0.0

func (c *OCITargetCache) GC(activeNames []string)

GC removes cache entries for entities not in the activeNames list. This prevents unbounded cache growth as entities are added/removed.

func (*OCITargetCache) Get added in v1.0.0

func (c *OCITargetCache) Get(name string) (CacheEntry, bool)

Get retrieves cached nested targets for the given entity name. Returns the entry and true if found, empty entry and false otherwise.

func (*OCITargetCache) Len added in v1.0.0

func (c *OCITargetCache) Len() int

Len returns the number of entries in the cache

func (*OCITargetCache) Set added in v1.0.0

func (c *OCITargetCache) Set(entry CacheEntry)

Set stores a cache entry.

type ParseOpt

type ParseOpt func(*parseConfig)

func WithAppDataCache added in v1.0.0

func WithAppDataCache(cache map[string]*AppData) ParseOpt

func WithEmbedded

func WithEmbedded(bootTime string) ParseOpt

func WithInstalledEmbedded added in v1.0.0

func WithInstalledEmbedded() ParseOpt

func WithProviderTypes

func WithProviderTypes(providerTypes ...v1beta1.ApplicationProviderType) ParseOpt

func WithVerify added in v0.9.0

func WithVerify() ParseOpt

type Provider

type Provider interface {
	// Verify the application content is valid and dependencies are met.
	Verify(ctx context.Context) error
	// Install the application content to the device.
	Install(ctx context.Context) error
	// Remove the application content from the device.
	Remove(ctx context.Context) error
	// Name returns the name of the application.
	Name() string
	// Spec returns the application spec.
	Spec() *ApplicationSpec
}

Provider defines the interface for supplying and managing an application's spec and lifecycle operations for installation to disk.

func FromDeviceSpec

func FromDeviceSpec(
	ctx context.Context,
	log *log.PrefixLogger,
	podman *client.Podman,
	readWriter fileio.ReadWriter,
	spec *v1beta1.DeviceSpec,
	opts ...ParseOpt,
) ([]Provider, error)

FromDeviceSpec parses the application spec and returns a list of providers.

type Volume added in v0.8.1

type Volume struct {
	// Name is the user defined name for the volume
	Name string
	// ID is a unique internal idenfier used to create the actual volume
	ID string
	// Reference is the reference used to populate the volume
	Reference string
	// Available is true if the volume has been created
	Available bool
	// ReclaimPolicy controls how the volume is handled when the application is removed
	ReclaimPolicy v1beta1.ApplicationVolumeReclaimPolicy
}

type VolumeManager added in v0.8.1

type VolumeManager interface {
	// Get returns the Volume by name, if it exists.
	Get(name string) (*Volume, bool)
	// Add adds a new Volume to the manager.
	Add(volume *Volume)
	// Update updates an existing Volume. Returns true if the volume existed and was updated.
	Update(volume *Volume) bool
	// Remove deletes the Volume by name. Returns true if the volume existed and was removed.
	Remove(name string) bool
	// List returns all managed Volumes.
	List() []*Volume
	// Status populates the given DeviceApplicationStatus with volume status information.
	Status(status *v1beta1.DeviceApplicationStatus)
	// UpdateStatus processes a Podman event and updates internal volume status as needed.
	UpdateStatus(event *client.PodmanEvent)
	// AddVolumes adds all specified volumes to the manager. An ID will be added if one does not exist
	AddVolumes([]*Volume)
}

func NewVolumeManager added in v0.8.1

func NewVolumeManager(log *log.PrefixLogger, appName string, appType v1beta1.AppType, volumes *[]v1beta1.ApplicationVolume) (VolumeManager, error)

NewVolumeManager returns a new VolumeManager.

Jump to

Keyboard shortcuts

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