mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: Add post-exec reporting support (#134)
* feat: Add post install reporting support * fix: UI report handling * fix: Duplicate reporting * fix: Show warning on insecure bypass * fix: Proxy event log insecure skip installation * fix: Proxy event log insecure skip installation * fix: Common definition for infer outcome
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package flows
|
||||
|
||||
import "github.com/safedep/pmg/internal/ui"
|
||||
|
||||
// inferOutcome determines the execution outcome based on configuration and execution data.
|
||||
// This function is shared across different flow implementations (guard-based, proxy-based)
|
||||
// to maintain consistent outcome logic without coupling flows to each other.
|
||||
//
|
||||
// Outcome precedence:
|
||||
// 1. Error (if no packages were blocked)
|
||||
// 2. Insecure installation bypass
|
||||
// 3. Dry run mode
|
||||
// 4. User cancellation
|
||||
// 5. Packages blocked
|
||||
// 6. Success (default)
|
||||
func inferOutcome(insecureMode, dryRun bool, blockedCount, userCancelledCount int, err error) ui.ExecutionOutcome {
|
||||
// Error takes precedence unless we have blocked packages
|
||||
if err != nil && blockedCount == 0 {
|
||||
return ui.OutcomeError
|
||||
}
|
||||
|
||||
// Config-based outcomes
|
||||
if insecureMode {
|
||||
return ui.OutcomeInsecureBypass
|
||||
}
|
||||
|
||||
if dryRun {
|
||||
return ui.OutcomeDryRun
|
||||
}
|
||||
|
||||
// User cancellation
|
||||
if userCancelledCount > 0 {
|
||||
return ui.OutcomeUserCancelled
|
||||
}
|
||||
|
||||
// Blocked packages take precedence over errors
|
||||
if blockedCount > 0 {
|
||||
return ui.OutcomeBlocked
|
||||
}
|
||||
|
||||
return ui.OutcomeSuccess
|
||||
}
|
||||
Reference in New Issue
Block a user