mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
Added different exit code(3) on invalid policy
This commit is contained in:
parent
c605f316cb
commit
2d74937bd6
1 changed files with 6 additions and 0 deletions
|
@ -2,6 +2,7 @@ package validate
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/nirmata/kyverno/pkg/utils"
|
||||
|
||||
|
@ -34,15 +35,20 @@ func Command() *cobra.Command {
|
|||
return err
|
||||
}
|
||||
|
||||
invalidPolicyFound := false
|
||||
for _, policy := range policies {
|
||||
err = policyvalidate.Validate(utils.MarshalPolicy(*policy), nil, true, openAPIController)
|
||||
if err != nil {
|
||||
fmt.Println("Policy " + policy.Name + " is invalid")
|
||||
invalidPolicyFound = true
|
||||
} else {
|
||||
fmt.Println("Policy " + policy.Name + " is valid")
|
||||
}
|
||||
}
|
||||
|
||||
if invalidPolicyFound == true {
|
||||
os.Exit(3)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue