Documentation
¶
Index ¶
- Constants
- Variables
- func IsStatusOK(status v1beta1.Status) bool
- func NilOutManagedObjectMetaProperties(om *v1beta1.ObjectMeta)
- func StatusBadRequest(message string) v1beta1.Status
- func StatusConflict(message string) v1beta1.Status
- func StatusCreated() v1beta1.Status
- func StatusInternalServerError(message string) v1beta1.Status
- func StatusNotFound(message string) v1beta1.Status
- func StatusOK() v1beta1.Status
- func StatusResourceNotFound(kind string, name string) v1beta1.Status
- func StatusServiceUnavailable(message string) v1beta1.Status
- func StoreErrorToApiStatus(err error, created bool, kind string, name *string) v1beta1.Status
- func ValidateImageName(imageName *string, path string) []error
- func ValidateImageTag(imageTag *string, path string) []error
- func ValidatePublicKey(publicKey *string, path string) []error
- func ValidateUsername(username *string, path string) []error
- type ImageBuildService
- type ImageExportDownload
- type ImageExportService
- type LogStreamReader
- type Service
Constants ¶
const (
MaxRecordsPerListRequest = 1000
)
Variables ¶
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") ErrExternalServiceUnavailable = errors.New("external service unavailable") )
Error types for distinguishing between validation and internal errors
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 ¶
IsStatusOK returns true if the status code is in the 2xx range
func NilOutManagedObjectMetaProperties ¶
func NilOutManagedObjectMetaProperties(om *v1beta1.ObjectMeta)
NilOutManagedObjectMetaProperties clears fields that are managed by the service
func StatusBadRequest ¶
StatusBadRequest returns a 400 Bad Request status with the given message
func StatusConflict ¶
StatusConflict returns a 409 Conflict status with the given message
func StatusInternalServerError ¶
StatusInternalServerError returns a 500 Internal Server Error status with the given message
func StatusNotFound ¶
StatusNotFound returns a 404 Not Found status with the given message
func StatusResourceNotFound ¶
StatusResourceNotFound returns a 404 status for a specific resource
func StatusServiceUnavailable ¶
StatusServiceUnavailable returns a 503 Service Unavailable status with the given message
func StoreErrorToApiStatus ¶
StoreErrorToApiStatus converts a store error to an API status
func ValidateImageName ¶
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 ¶
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 ¶
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 ¶
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 api.ImageBuild) (*api.ImageBuild, v1beta1.Status)
Get(ctx context.Context, orgId uuid.UUID, name string, withExports bool) (*api.ImageBuild, v1beta1.Status)
List(ctx context.Context, orgId uuid.UUID, params api.ListImageBuildsParams) (*api.ImageBuildList, v1beta1.Status)
Delete(ctx context.Context, orgId uuid.UUID, name string) (*api.ImageBuild, v1beta1.Status)
// Cancel cancels an ImageBuild. Returns ErrNotCancelable if not in cancelable state.
Cancel(ctx context.Context, orgId uuid.UUID, name string) (*api.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) (*api.ImageBuild, error)
GetLogs(ctx context.Context, orgId uuid.UUID, name string, follow bool) (LogStreamReader, string, v1beta1.Status)
// Internal methods (not exposed via API)
UpdateStatus(ctx context.Context, orgId uuid.UUID, imageBuild *api.ImageBuild) (*api.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 api.ImageExport) (*api.ImageExport, v1beta1.Status)
Get(ctx context.Context, orgId uuid.UUID, name string) (*api.ImageExport, v1beta1.Status)
List(ctx context.Context, orgId uuid.UUID, params api.ListImageExportsParams) (*api.ImageExportList, v1beta1.Status)
Delete(ctx context.Context, orgId uuid.UUID, name string) (*api.ImageExport, v1beta1.Status)
// Cancel cancels an ImageExport. Returns ErrNotCancelable if not in cancelable state.
Cancel(ctx context.Context, orgId uuid.UUID, name string) (*api.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) (*api.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, v1beta1.Status)
// Internal methods (not exposed via API)
UpdateStatus(ctx context.Context, orgId uuid.UUID, imageExport *api.ImageExport) (*api.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