Documentation
¶
Index ¶
- Constants
- func EnrichSBOMMetadata(sbomData []byte, imageRef, imageDigest string) ([]byte, error)
- func GetCanceledStreamKey(orgID uuid.UUID, imageExportName string) string
- func GetEffectivePurlTransformConfig(userCfg *config.PurlTransformConfig) *config.PurlTransformConfig
- func GetImageBuildCanceledStreamKey(orgID uuid.UUID, imageBuildName string) string
- func LaunchConsumers(ctx context.Context, queuesProvider queues.Provider, ...) error
- func StartStatusUpdater(ctx context.Context, cancelBuild func(), ...) (*statusUpdater, func())
- func TransformPurl(purl string, cfg *config.PurlTransformConfig) string
- func TransformSBOMPurls(sbomData []byte, cfg *config.PurlTransformConfig) ([]byte, error)
- type Consumer
- func (c *Consumer) CheckAndMarkTimeoutsForOrg(ctx context.Context, orgID uuid.UUID, timeoutDuration time.Duration, ...) (int, error)
- func (c *Consumer) Consume(ctx context.Context, payload []byte, entryID string, ...) error
- func (c *Consumer) HandleImageBuildUpdate(ctx context.Context, eventWithOrgId worker_client.EventWithOrgId, ...) error
- func (c *Consumer) RunRequeueOnStartup(ctx context.Context)
- type ContainerfileResult
- type EnrollmentCredentialGenerator
- type SBOMResult
Constants ¶
const ( // AckTimeout is the timeout for acknowledging messages AckTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func EnrichSBOMMetadata ¶ added in v1.2.0
EnrichSBOMMetadata adds image metadata (digest, purl) to the SBOM's metadata.component section. This ensures the SBOM is self-contained and can be correlated with the image it describes.
func GetCanceledStreamKey ¶
GetCanceledStreamKey returns the Redis stream key used for signaling cancellation completion
func GetEffectivePurlTransformConfig ¶ added in v1.2.0
func GetEffectivePurlTransformConfig(userCfg *config.PurlTransformConfig) *config.PurlTransformConfig
GetEffectivePurlTransformConfig merges user-level purlTransform with defaults per package type. Map keys under byType are normalized to lowercase type IDs (e.g. rpm, npm).
func GetImageBuildCanceledStreamKey ¶
GetImageBuildCanceledStreamKey returns the Redis stream key used for signaling cancellation completion This is exported so the API service can use the same key format
func LaunchConsumers ¶
func LaunchConsumers( ctx context.Context, queuesProvider queues.Provider, store imagebuilderstore.Store, mainStore store.Store, kvStore kvstore.KVStore, serviceHandler *service.ServiceHandler, imageBuilderService imagebuilderapi.Service, cfg *config.Config, log logrus.FieldLogger, ) error
LaunchConsumers starts the specified number of queue consumers for imagebuild jobs
func StartStatusUpdater ¶
func StartStatusUpdater( ctx context.Context, cancelBuild func(), imageBuildService imagebuilderapi.ImageBuildService, orgID uuid.UUID, imageBuildName string, kvStore kvstore.KVStore, cfg *config.Config, log logrus.FieldLogger, ) (*statusUpdater, func())
StartStatusUpdater starts a goroutine that is the single writer for ImageBuild status updates. It receives condition updates via a channel and periodically updates LastSeen. It also listens for cancellation signals via Redis Stream and calls cancelBuild when received. Returns the updater and a cleanup function. Exported for testing purposes.
func TransformPurl ¶ added in v1.2.0
func TransformPurl(purl string, cfg *config.PurlTransformConfig) string
TransformPurl normalizes a PURL for Trustify advisory matching. Rules come from cfg.byType keyed by package type ID (segment after pkg:). When no rule block exists for that type, the PURL is returned unchanged. For a configured type: 1. Namespace: NamespaceMapping replaces when a key matches the namespace (case-insensitive). 2. AllowedQualifiers: when non-empty, only those qualifier keys are kept (distro uses DistroMapping); when empty or unset, qualifiers are preserved as in the original PURL.
func TransformSBOMPurls ¶ added in v1.2.0
func TransformSBOMPurls(sbomData []byte, cfg *config.PurlTransformConfig) ([]byte, error)
TransformSBOMPurls transforms all PURLs in a CycloneDX SBOM. It parses the SBOM JSON, transforms each component's PURL, and returns the modified SBOM.
Types ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer handles incoming jobs from the queue and routes them to appropriate handlers
func NewConsumer ¶
func NewConsumer( store imagebuilderstore.Store, mainStore store.Store, kvStore kvstore.KVStore, serviceHandler *service.ServiceHandler, imageBuilderService imagebuilderapi.Service, queueProducer queues.QueueProducer, cfg *config.Config, log logrus.FieldLogger, ) *Consumer
NewConsumer creates a new Consumer instance with the provided dependencies
func (*Consumer) CheckAndMarkTimeoutsForOrg ¶
func (c *Consumer) CheckAndMarkTimeoutsForOrg(ctx context.Context, orgID uuid.UUID, timeoutDuration time.Duration, log logrus.FieldLogger) (int, error)
CheckAndMarkTimeoutsForOrg checks for timed-out image builds and exports in a specific organization This method is public to allow testing with mocked services Returns the number of resources moved to fail
func (*Consumer) Consume ¶
func (c *Consumer) Consume(ctx context.Context, payload []byte, entryID string, consumer queues.QueueConsumer, log logrus.FieldLogger) error
Consume handles incoming events from the queue and routes them to appropriate handlers
func (*Consumer) HandleImageBuildUpdate ¶
func (c *Consumer) HandleImageBuildUpdate(ctx context.Context, eventWithOrgId worker_client.EventWithOrgId, log logrus.FieldLogger) error
HandleImageBuildUpdate handles ImageBuild ResourceUpdated events.
- Completed: requeues related pending ImageExports, then evaluates waiting promotions.
- Failed/Canceled: fails waiting promotions.
This method is public to allow testing with mocked services.
func (*Consumer) RunRequeueOnStartup ¶
RunRequeueOnStartup runs the requeue task once on startup This method is public to allow testing with mocked services
type ContainerfileResult ¶
type ContainerfileResult struct {
// Containerfile is the generated Containerfile content (static template)
Containerfile string
// BuildArgs contains the arguments to pass to podman build via --build-arg
BuildArgs containerfileBuildArgs
// AgentConfig contains the full agent config.yaml content (for early binding)
// This includes: client-certificate-data, client-key-data, certificate-authority-data, server URL
AgentConfig []byte
// Publickey contains the SSH public key content (for user configuration)
Publickey []byte
}
ContainerfileResult contains the generated Containerfile and any associated files
func GenerateContainerfile ¶
func GenerateContainerfile( ctx context.Context, mainStore store.Store, credentialGenerator EnrollmentCredentialGenerator, orgID uuid.UUID, imageBuild *domain.ImageBuild, log logrus.FieldLogger, ) (*ContainerfileResult, error)
GenerateContainerfile generates a Containerfile from an ImageBuild spec This function is exported for testing purposes
type EnrollmentCredentialGenerator ¶
type EnrollmentCredentialGenerator interface {
GenerateEnrollmentCredential(ctx context.Context, orgId uuid.UUID, baseName string, ownerKind string, ownerName string) (*crypto.EnrollmentCredential, coredomain.Status)
}
EnrollmentCredentialGenerator is an interface for generating enrollment credentials This allows for easier testing by mocking the service handler
type SBOMResult ¶ added in v1.2.0
type SBOMResult struct {
SBOMPath string // Path to the transformed SBOM file
ImageDigest string // Digest of the image the SBOM was generated for
}
SBOMResult contains the result of SBOM generation