mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-23 04:06:21 +00:00
36 lines
937 B
Go
36 lines
937 B
Go
package vmware
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
func classifyInventoryEnrichmentIssue(stage, entityType, entityID string, err error) (*InventoryEnrichmentIssue, bool) {
|
|
if err == nil {
|
|
return nil, false
|
|
}
|
|
var connectionErr *ConnectionError
|
|
if !errors.As(err, &connectionErr) || connectionErr == nil {
|
|
return nil, false
|
|
}
|
|
if !isNonFatalInventoryEnrichmentCategory(connectionErr.Category) {
|
|
return nil, false
|
|
}
|
|
return &InventoryEnrichmentIssue{
|
|
Stage: strings.TrimSpace(stage),
|
|
EntityType: strings.TrimSpace(entityType),
|
|
EntityID: strings.TrimSpace(entityID),
|
|
Category: strings.TrimSpace(connectionErr.Category),
|
|
Message: strings.TrimSpace(connectionErr.Message),
|
|
}, true
|
|
}
|
|
|
|
func isNonFatalInventoryEnrichmentCategory(category string) bool {
|
|
switch strings.ToLower(strings.TrimSpace(category)) {
|
|
case "permission", "not_found", "unavailable", "endpoint":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|