Admission warning (#9975)
* Add warning feature in admission code * Apply suggestions from code review Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com> * Add deprecation and validation path notice --------- Co-authored-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
This commit is contained in:
parent
897783557a
commit
1282345be2
4 changed files with 177 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ import (
|
|||
// contains invalid instructions
|
||||
type Checker interface {
|
||||
CheckIngress(ing *networking.Ingress) error
|
||||
CheckWarning(ing *networking.Ingress) ([]string, error)
|
||||
}
|
||||
|
||||
// IngressAdmission implements the AdmissionController interface
|
||||
|
|
@ -85,6 +86,15 @@ func (ia *IngressAdmission) HandleAdmission(obj runtime.Object) (runtime.Object,
|
|||
return review, nil
|
||||
}
|
||||
|
||||
// Adds the warnings regardless of operation being allowed or not
|
||||
warning, err := ia.Checker.CheckWarning(&ingress)
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "failed to get ingress warnings")
|
||||
}
|
||||
if len(warning) > 0 {
|
||||
status.Warnings = warning
|
||||
}
|
||||
|
||||
if err := ia.Checker.CheckIngress(&ingress); err != nil {
|
||||
klog.ErrorS(err, "invalid ingress configuration", "ingress", fmt.Sprintf("%v/%v", review.Request.Namespace, review.Request.Name))
|
||||
status.Allowed = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue