1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

- fix panic in log and improve CLI error reporting

This commit is contained in:
Jim Bugwadia 2020-06-12 18:23:59 -07:00
parent e889918d62
commit 912bc3ccc4
3 changed files with 9 additions and 2 deletions

View file

@ -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))
}

View file

@ -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 {

View file

@ -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