mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
updated sanitized error
This commit is contained in:
parent
9806339f1d
commit
c482459e0e
2 changed files with 7 additions and 7 deletions
|
@ -58,7 +58,7 @@ func Command() *cobra.Command {
|
|||
}()
|
||||
|
||||
if len(resourcePaths) == 0 && !cluster {
|
||||
return sanitizedError.New(fmt.Sprintf("Specify path to resource file or cluster name"))
|
||||
return sanitizedError.NewWithError(fmt.Sprintf("Specify path to resource file or cluster name"), err)
|
||||
}
|
||||
|
||||
policies, openAPIController, err := common.GetPoliciesValidation(policyPaths)
|
||||
|
@ -73,7 +73,7 @@ func Command() *cobra.Command {
|
|||
os.Exit(3)
|
||||
}
|
||||
if policyHasVariables(*policy) {
|
||||
return sanitizedError.New(fmt.Sprintf("Policy %v is not valid - 'apply' does not support policies with variables", policy.Name))
|
||||
return sanitizedError.NewWithError(fmt.Sprintf("Policy %v is not valid - 'apply' does not support policies with variables", policy.Name), err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ func Command() *cobra.Command {
|
|||
|
||||
err = applyPolicyOnResource(policy, resource)
|
||||
if err != nil {
|
||||
return sanitizedError.New(fmt.Errorf("Issues applying policy %v on resource %v", policy.Name, resource.GetName()).Error())
|
||||
return sanitizedError.NewWithError(fmt.Errorf("Issues applying policy %v on resource %v", policy.Name, resource.GetName()).Error(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ func applyPolicyOnResource(policy *v1.ClusterPolicy, resource *unstructured.Unst
|
|||
}
|
||||
}
|
||||
|
||||
if responseError == true{
|
||||
if responseError == true {
|
||||
os.Exit(1)
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -32,7 +32,7 @@ func GetPolicies(paths []string) (policies []*v1.ClusterPolicy, error error) {
|
|||
if fileDesc.IsDir() {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, sanitizedError.New(fmt.Sprintf("failed to parse %v", path))
|
||||
return nil, sanitizedError.NewWithError(fmt.Sprintf("failed to parse %v", path), err)
|
||||
}
|
||||
|
||||
listOfFiles := make([]string, 0)
|
||||
|
@ -43,7 +43,7 @@ func GetPolicies(paths []string) (policies []*v1.ClusterPolicy, error error) {
|
|||
policiesFromDir, err := GetPolicies(listOfFiles)
|
||||
if err != nil {
|
||||
log.Error(err, fmt.Sprintf("failed to extract policies from %v", listOfFiles))
|
||||
return nil, sanitizedError.New(("failed to extract policies"))
|
||||
return nil, sanitizedError.NewWithError(("failed to extract policies"), err)
|
||||
}
|
||||
|
||||
policies = append(policies, policiesFromDir...)
|
||||
|
@ -134,7 +134,7 @@ func GetPoliciesValidation(policyPaths []string) ([]*v1.ClusterPolicy, *openapi.
|
|||
policies, err := GetPolicies(policyPaths)
|
||||
if err != nil {
|
||||
if !sanitizedError.IsErrorSanitized(err) {
|
||||
return nil, nil, sanitizedError.New((fmt.Sprintf("failed to parse %v path/s.", policyPaths)))
|
||||
return nil, nil, sanitizedError.NewWithError((fmt.Sprintf("failed to parse %v path/s.", policyPaths)), err)
|
||||
}
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue