diff --git a/pkg/engine/mutate/overlayCondition.go b/pkg/engine/mutate/overlayCondition.go index 56b19de4e9..97d0210e80 100755 --- a/pkg/engine/mutate/overlayCondition.go +++ b/pkg/engine/mutate/overlayCondition.go @@ -112,7 +112,7 @@ func validateConditionAnchorMap(resourceMap, anchors map[string]interface{}, pat // resource - A: B2 func compareOverlay(resource, overlay interface{}, path string) (string, overlayError) { if reflect.TypeOf(resource) != reflect.TypeOf(overlay) { - log.Log.V(4).Info("Found anchor on different types of element: overlay %T, resource %T", overlay, resource) + log.Log.V(4).Info("Found anchor on different types of element", "overlay", overlay, "resource", resource) return path, newOverlayError(conditionFailure, fmt.Sprintf("Found anchor on different types of element: overlay %T, resource %T", overlay, resource)) } diff --git a/pkg/kyverno/apply/command.go b/pkg/kyverno/apply/command.go index 5aa92e33f2..8cf38db99c 100644 --- a/pkg/kyverno/apply/command.go +++ b/pkg/kyverno/apply/command.go @@ -91,7 +91,7 @@ func Command() *cobra.Command { resources, err := getResources(policies, resourcePaths, dClient) if err != nil { - return sanitizedError.New(fmt.Errorf("Issues fetching resources").Error()) + return sanitizedError.NewWithError("Failed to load resources", err) } for i, policy := range policies { diff --git a/pkg/kyverno/sanitizedError/error.go b/pkg/kyverno/sanitizedError/error.go index 3c8ef003f7..9d0dbab0af 100644 --- a/pkg/kyverno/sanitizedError/error.go +++ b/pkg/kyverno/sanitizedError/error.go @@ -1,5 +1,7 @@ package sanitizedError +import "fmt" + type customError struct { message string } @@ -12,6 +14,11 @@ func New(message string) error { return customError{message: message} } +func NewWithError(message string, err error) error { + msg := fmt.Sprintf("%s \nCause: %s", message, err.Error()) + return customError{message: msg} +} + func IsErrorSanitized(err error) bool { if _, ok := err.(customError); !ok { return false