service

package
v1.1.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 34 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

Index

Constants

View Source
const (
	MaxRecordsPerListRequest = 1000
)

Variables

View Source
var (
	// Validation errors (4xx)
	ErrImageExportNotReady               = errors.New("imageExport is not ready")
	ErrImageExportStatusNotReady         = errors.New("imageExport status is not ready")
	ErrImageExportReadyConditionNotFound = errors.New("imageExport ready condition not found")
	ErrImageExportManifestDigestNotSet   = errors.New("imageExport manifestDigest is not set")
	ErrInvalidManifestDigest             = errors.New("invalid manifest digest")
	ErrInvalidManifestLayerCount         = errors.New("invalid manifest layer count")
	ErrRepositoryNotFound                = errors.New("repository not found")

	// External service errors (5xx - Service Unavailable)
	ErrExternalServiceUnavailable = errors.New("external service unavailable")
)

Error types for distinguishing between validation and internal errors

View Source
var (
	// ErrNotCancelable indicates the resource is not in a cancelable state
	ErrNotCancelable = errors.New("resource is not in a cancelable state")
)

Sentinel errors for cancellation operations

Functions

func IsStatusOK

func IsStatusOK(status domain.Status) bool

IsStatusOK returns true if the status code is in the 2xx range

func NilOutManagedObjectMetaProperties

func NilOutManagedObjectMetaProperties(om *domain.ObjectMeta)

NilOutManagedObjectMetaProperties clears fields that are managed by the service

func StatusBadRequest

func StatusBadRequest(message string) domain.Status

StatusBadRequest returns a 400 Bad Request status with the given message

func StatusConflict

func StatusConflict(message string) domain.Status

StatusConflict returns a 409 Conflict status with the given message

func StatusCreated

func StatusCreated() domain.Status

StatusCreated returns a 201 Created status

func StatusInternalServerError

func StatusInternalServerError(message string) domain.Status

StatusInternalServerError returns a 500 Internal Server Error status with the given message

func StatusNotFound

func StatusNotFound(message string) domain.Status

StatusNotFound returns a 404 Not Found status with the given message

func StatusOK

func StatusOK() domain.Status

StatusOK returns a 200 OK status

func StatusResourceNotFound

func StatusResourceNotFound(kind string, name string) domain.Status

StatusResourceNotFound returns a 404 status for a specific resource

func StatusServiceUnavailable

func StatusServiceUnavailable(message string) domain.Status

StatusServiceUnavailable returns a 503 Service Unavailable status with the given message

func StoreErrorToApiStatus

func StoreErrorToApiStatus(err error, created bool, kind string, name *string) domain.Status

StoreErrorToApiStatus converts a store error to an API status

func ValidateImageName

func ValidateImageName(imageName *string, path string) []error

ValidateImageName validates an OCI image repository name according to RFC specifications. Repository names must: - Consist of lowercase alphanumeric characters - May contain dots, underscores, and hyphens as separators - Cannot start or end with a separator - Components are separated by forward slashes

func ValidateImageTag

func ValidateImageTag(imageTag *string, path string) []error

ValidateImageTag validates an OCI image tag according to RFC specifications. Tags must: - Start with a word character (letter, digit, or underscore) - May contain word characters, dots, and hyphens - Cannot start with a period or dash - Maximum length is 128 characters

func ValidatePublicKey

func ValidatePublicKey(publicKey *string, path string) []error

ValidatePublicKey validates an SSH public key to prevent Containerfile injection attacks. Public key must: - Be a valid SSH public key format (starts with key type like "ssh-rsa", "ssh-ed25519", etc.) - Not contain dangerous characters that could break out of context - Have reasonable length (max 8192 characters) - Follow SSH public key format: "key-type base64-data [comment]"

func ValidateUsername

func ValidateUsername(username *string, path string) []error

ValidateUsername validates a username to prevent Containerfile injection attacks. Username must follow RHEL/Fedora useradd rules: - First char: letter, digit, underscore, or dot - Subsequent chars: letters, digits, underscore, dot, or hyphen - Optional trailing '$' (for Samba machine accounts) - '@' is NOT allowed (rejected by useradd) - Be reasonable length (max 256 characters) - Not have leading or trailing whitespace

Types

type ImageBuildService

type ImageBuildService interface {
	Create(ctx context.Context, orgId uuid.UUID, imageBuild domain.ImageBuild) (*domain.ImageBuild, domain.Status)
	Get(ctx context.Context, orgId uuid.UUID, name string, withExports bool) (*domain.ImageBuild, domain.Status)
	List(ctx context.Context, orgId uuid.UUID, params domain.ListImageBuildsParams) (*domain.ImageBuildList, domain.Status)
	Delete(ctx context.Context, orgId uuid.UUID, name string) (*domain.ImageBuild, domain.Status)
	// Cancel cancels an ImageBuild. Returns ErrNotCancelable if not in cancelable state.
	Cancel(ctx context.Context, orgId uuid.UUID, name string) (*domain.ImageBuild, error)
	// CancelWithReason cancels an ImageBuild with a custom reason message (e.g., for timeout).
	// Returns ErrNotCancelable if not in cancelable state.
	CancelWithReason(ctx context.Context, orgId uuid.UUID, name string, reason string) (*domain.ImageBuild, error)
	GetLogs(ctx context.Context, orgId uuid.UUID, name string, follow bool) (LogStreamReader, string, domain.Status)
	// Internal methods (not exposed via API)
	UpdateStatus(ctx context.Context, orgId uuid.UUID, imageBuild *domain.ImageBuild) (*domain.ImageBuild, error)
	UpdateLastSeen(ctx context.Context, orgId uuid.UUID, name string, timestamp time.Time) error
	UpdateLogs(ctx context.Context, orgId uuid.UUID, name string, logs string) error
}

ImageBuildService handles business logic for ImageBuild resources

func NewImageBuildService

func NewImageBuildService(s store.ImageBuildStore, repositoryStore mainstore.Repository, imageExportService ImageExportService, eventHandler *internalservice.EventHandler, queueProducer queues.QueueProducer, kvStore kvstore.KVStore, cfg *config.ImageBuilderServiceConfig, log logrus.FieldLogger) ImageBuildService

NewImageBuildService creates a new ImageBuildService

type ImageExportDownload

type ImageExportDownload struct {
	RedirectURL string
	BlobReader  io.ReadCloser
	Headers     http.Header
	StatusCode  int
}

ImageExportDownload contains information for downloading an ImageExport artifact

type ImageExportService

type ImageExportService interface {
	Create(ctx context.Context, orgId uuid.UUID, imageExport domain.ImageExport) (*domain.ImageExport, domain.Status)
	Get(ctx context.Context, orgId uuid.UUID, name string) (*domain.ImageExport, domain.Status)
	List(ctx context.Context, orgId uuid.UUID, params domain.ListImageExportsParams) (*domain.ImageExportList, domain.Status)
	Delete(ctx context.Context, orgId uuid.UUID, name string) (*domain.ImageExport, domain.Status)
	// Cancel cancels an ImageExport. Returns ErrNotCancelable if not in cancelable state.
	Cancel(ctx context.Context, orgId uuid.UUID, name string) (*domain.ImageExport, error)
	// CancelWithReason cancels an ImageExport with a custom reason message (e.g., for timeout).
	// Returns ErrNotCancelable if not in cancelable state.
	CancelWithReason(ctx context.Context, orgId uuid.UUID, name string, reason string) (*domain.ImageExport, error)
	Download(ctx context.Context, orgId uuid.UUID, name string) (*ImageExportDownload, error)
	GetLogs(ctx context.Context, orgId uuid.UUID, name string, follow bool) (LogStreamReader, string, domain.Status)
	// Internal methods (not exposed via API)
	UpdateStatus(ctx context.Context, orgId uuid.UUID, imageExport *domain.ImageExport) (*domain.ImageExport, error)
	UpdateLastSeen(ctx context.Context, orgId uuid.UUID, name string, timestamp time.Time) error
	UpdateLogs(ctx context.Context, orgId uuid.UUID, name string, logs string) error
}

ImageExportService handles business logic for ImageExport resources

func NewImageExportService

func NewImageExportService(imageExportStore store.ImageExportStore, imageBuildStore store.ImageBuildStore, repositoryStore mainstore.Repository, eventHandler *internalservice.EventHandler, queueProducer queues.QueueProducer, kvStore kvstore.KVStore, cfg *config.ImageBuilderServiceConfig, log logrus.FieldLogger) ImageExportService

NewImageExportService creates a new ImageExportService

type LogStreamReader

type LogStreamReader interface {
	// ReadAll reads all available logs from Redis and returns them as a string
	ReadAll(ctx context.Context) (string, error)
	// Stream reads logs from Redis and writes them to the provided writer
	// It blocks until the context is cancelled or an error occurs
	Stream(ctx context.Context, w io.Writer) error
}

LogStreamReader provides an interface for reading logs from Redis

type Service

type Service interface {
	ImageBuild() ImageBuildService
	ImageExport() ImageExportService
}

Service is the aggregate service interface for the ImageBuilder API. It provides access to all sub-services (ImageBuild, ImageExport, and future services).

func NewService

func NewService(ctx context.Context, cfg *config.Config, s imagebuilderstore.Store, mainStore mainstore.Store, queueProducer queues.QueueProducer, kvStore kvstore.KVStore, log logrus.FieldLogger) Service

NewService creates a new aggregate Service with all sub-services

Jump to

Keyboard shortcuts

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