MCPcopy Create free account
hub / github.com/conforma/cli / processSnapshotComponentWithWorkerContext

Function processSnapshotComponentWithWorkerContext

cmd/validate/vsa.go:1732–1774  ·  view source on GitHub ↗

processSnapshotComponentWithWorkerContext processes a single component using worker-specific fallback context

(ctx context.Context, component app.SnapshotComponent, data *validateVSAData, workerFallbackContext *vsa.WorkerFallbackContext)

Source from the content-addressed store, hash-verified

1730
1731// processSnapshotComponentWithWorkerContext processes a single component using worker-specific fallback context
1732func processSnapshotComponentWithWorkerContext(ctx context.Context, component app.SnapshotComponent, data *validateVSAData, workerFallbackContext *vsa.WorkerFallbackContext) vsa.ComponentResult {
1733 // Extract digest from ContainerImage
1734 digest, err := vsa.ExtractDigestFromImageRef(component.ContainerImage)
1735 if err != nil {
1736 // Extract digest errors don't trigger fallback (invalid input)
1737 return createErrorResult(component, fmt.Errorf("failed to extract digest: %w", err))
1738 }
1739
1740 // Perform VSA validation
1741 result, err := performVSAValidation(ctx, digest, data)
1742
1743 // Create ValidationResult from error if needed (for proper display)
1744 if err != nil {
1745 // Create a ValidationResult from the error for proper display
1746 errorResult := createValidationResultFromError(err)
1747
1748 // Check if fallback should be triggered BEFORE returning error
1749 if data.fallbackToImageValidation && shouldTriggerFallbackForComponent(err, errorResult) {
1750 return handleComponentFallback(ctx, component, data, errorResult, workerFallbackContext)
1751 }
1752
1753 // Return error result with ValidationResult for proper display
1754 return vsa.ComponentResult{
1755 ComponentName: component.Name,
1756 ImageRef: component.ContainerImage,
1757 Result: errorResult,
1758 Error: fmt.Errorf("VSA validation failed: %w", err),
1759 }
1760 }
1761
1762 // Handle fallback if enabled and needed
1763 if data.fallbackToImageValidation && shouldTriggerFallbackForComponent(nil, result) {
1764 return handleComponentFallback(ctx, component, data, result, workerFallbackContext)
1765 }
1766
1767 // Return VSA-only result
1768 return vsa.ComponentResult{
1769 ComponentName: component.Name,
1770 ImageRef: component.ContainerImage,
1771 Result: result,
1772 Error: nil,
1773 }
1774}
1775
1776// performVSAValidation performs VSA validation for a component
1777func performVSAValidation(ctx context.Context, digest string, data *validateVSAData) (*vsa.ValidationResult, error) {

Callers 2

workerFunction · 0.85

Calls 7

createErrorResultFunction · 0.85
performVSAValidationFunction · 0.85
handleComponentFallbackFunction · 0.85
ErrorfMethod · 0.65

Tested by 1