images

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package images provides periodic image resolution and caching across infrastructure providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSResolver

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

AWSResolver implements the Resolver interface for AWS EC2

func NewAWSResolver

func NewAWSResolver(providerCfg infra.ProviderConfig) (*AWSResolver, error)

NewAWSResolver creates a new AWS image resolver

func NewAWSResolverWithClient

func NewAWSResolverWithClient(client EC2API, region string) *AWSResolver

NewAWSResolverWithClient creates a new AWS image resolver with a custom EC2 client (for testing)

func (*AWSResolver) Resolve

func (r *AWSResolver) Resolve(ctx context.Context, configs map[string]config.ImageConfig) (map[string]string, error)

Resolve looks up all configured images and returns a map of name -> image ID

func (*AWSResolver) ResolveOne

func (r *AWSResolver) ResolveOne(ctx context.Context, name string, cfg config.ImageConfig) (string, error)

ResolveOne looks up a single image configuration

type EC2API

type EC2API interface {
	DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)
}

EC2API defines the interface for EC2 operations needed by AWSResolver

type Resolver

type Resolver interface {
	// Resolve looks up all configured images and returns a map of name -> image ID
	Resolve(ctx context.Context, configs map[string]config.ImageConfig) (map[string]string, error)

	// ResolveOne looks up a single image configuration
	ResolveOne(ctx context.Context, name string, cfg config.ImageConfig) (string, error)
}

Resolver interface supports multiple cloud providers Initial implementation: AWS only In future, other providers requiring this mechanism, such as Oracle Cloud, could be added

func NewResolver

func NewResolver(provider string, providerCfg infra.ProviderConfig) (Resolver, error)

NewResolver creates a provider-specific resolver

type Service

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

Service manages periodic image resolution and caching

func NewService

func NewService(opts ServiceOptions) (*Service, error)

NewService creates a new image resolution service

func (*Service) Get

func (s *Service) Get(name string) string

Get returns the resolved image ID for a given image name Returns empty string if not resolved

func (*Service) GetAll

func (s *Service) GetAll() map[string]string

GetAll returns all resolved images

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start begins the periodic image resolution process Should be called when the server becomes shard leader Uses SWR (stale-while-revalidate) strategy: returns early if all images are cached, otherwise blocks on fresh lookup

func (*Service) Stop

func (s *Service) Stop()

Stop stops the periodic refresh Should be called when losing shard leadership

type ServiceOptions

type ServiceOptions struct {
	ProviderConfig infra.ProviderConfig
	DB             *localdb.DB
	Configs        map[string]config.ImageConfig
	Interval       time.Duration
	Logger         *slog.Logger
}

ServiceOptions contains options for creating an image service

Jump to

Keyboard shortcuts

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