2023-11-07 17:20:54 +00:00
|
|
|
package chain
|
2023-10-17 14:10:48 +00:00
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
2023-11-01 08:02:16 +00:00
|
|
|
// Status is the status for policy application.
|
2023-10-17 14:10:48 +00:00
|
|
|
type Status byte
|
|
|
|
|
|
|
|
const (
|
|
|
|
Allow Status = iota
|
|
|
|
NoRuleFound
|
|
|
|
AccessDenied
|
|
|
|
QuotaLimitReached
|
|
|
|
last
|
|
|
|
)
|
|
|
|
|
|
|
|
// Valid returns true if the status is valid.
|
|
|
|
func (s Status) Valid() bool {
|
|
|
|
return s < last
|
|
|
|
}
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer interface.
|
|
|
|
func (s Status) String() string {
|
|
|
|
switch s {
|
|
|
|
case Allow:
|
|
|
|
return "Allowed"
|
|
|
|
case NoRuleFound:
|
|
|
|
return "NoRuleFound"
|
|
|
|
case AccessDenied:
|
|
|
|
return "Access denied"
|
|
|
|
case QuotaLimitReached:
|
|
|
|
return "Quota limit reached"
|
|
|
|
default:
|
|
|
|
return fmt.Sprintf("Denied with status: %d", s)
|
|
|
|
}
|
|
|
|
}
|