/
helpers.go
30 lines (25 loc) · 732 Bytes
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package internalversion
import (
"time"
units "github.com/docker/go-units"
authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization"
)
func formatRelativeTime(t time.Time) string {
return units.HumanDuration(timeNowFn().Sub(t))
}
var timeNowFn = func() time.Time {
return time.Now()
}
// roleBindingRestrictionType returns a string that indicates the type of the
// given RoleBindingRestriction.
func roleBindingRestrictionType(rbr *authorizationapi.RoleBindingRestriction) string {
switch {
case rbr.Spec.UserRestriction != nil:
return "User"
case rbr.Spec.GroupRestriction != nil:
return "Group"
case rbr.Spec.ServiceAccountRestriction != nil:
return "ServiceAccount"
}
return ""
}