handleComponentFallback handles fallback validation for a component
(ctx context.Context, component app.SnapshotComponent, data *validateVSAData, result *vsa.ValidationResult, workerFallbackContext *vsa.WorkerFallbackContext)
| 1803 | |
| 1804 | // handleComponentFallback handles fallback validation for a component |
| 1805 | func handleComponentFallback(ctx context.Context, component app.SnapshotComponent, data *validateVSAData, result *vsa.ValidationResult, workerFallbackContext *vsa.WorkerFallbackContext) vsa.ComponentResult { |
| 1806 | predicateStatus := "" |
| 1807 | if result != nil { |
| 1808 | predicateStatus = result.PredicateOutcome |
| 1809 | } |
| 1810 | |
| 1811 | // Use the common fallback validation logic |
| 1812 | fallbackResult := vsa.PerformFallbackValidation(result, predicateStatus) |
| 1813 | if fallbackResult.Error != nil { |
| 1814 | return createErrorResult(component, fallbackResult.Error) |
| 1815 | } |
| 1816 | |
| 1817 | // Perform image validation |
| 1818 | fallbackOutput, fallbackErr := validateImageFallbackWithWorkerContext(ctx, data, component, workerFallbackContext) |
| 1819 | if fallbackErr != nil { |
| 1820 | return createErrorResult(component, fmt.Errorf("fallback image validation failed: %w", fallbackErr)) |
| 1821 | } |
| 1822 | |
| 1823 | // Set the fallback output |
| 1824 | fallbackResult.FallbackOutput = fallbackOutput |
| 1825 | |
| 1826 | // Create validate_utils.Result for fallback (same as validate image command) |
| 1827 | // Use defaults for showSuccesses and outputFormats to match validate image behavior |
| 1828 | // Note: VSA command doesn't have these flags, so we use defaults (showSuccesses=false, empty outputFormats) |
| 1829 | fallbackValidationResult := validate_utils.PopulateResultFromOutput( |
| 1830 | fallbackOutput, |
| 1831 | nil, // err is nil here since we already checked it above |
| 1832 | component, |
| 1833 | false, // showSuccesses - default to false if not specified |
| 1834 | data.output, // outputFormats - use the same as VSA command output |
| 1835 | ) |
| 1836 | |
| 1837 | return vsa.ComponentResult{ |
| 1838 | ComponentName: component.Name, |
| 1839 | ImageRef: component.ContainerImage, |
| 1840 | Result: result, // Keep original VSA result for VSA display |
| 1841 | Error: nil, |
| 1842 | FallbackResult: &fallbackValidationResult, // Store fallback result for WriteReport compatibility |
| 1843 | } |
| 1844 | } |
| 1845 | |
| 1846 | // createErrorResult creates a ComponentResult with an error |
| 1847 | func createErrorResult(component app.SnapshotComponent, err error) vsa.ComponentResult { |
no test coverage detected