forked from sensu/sensu-go
/
rbac.go
44 lines (35 loc) · 1.03 KB
/
rbac.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package graphql
import (
"github.com/sensu/sensu-go/backend/apid/graphql/globalid"
"github.com/sensu/sensu-go/backend/apid/graphql/schema"
"github.com/sensu/sensu-go/graphql"
"github.com/sensu/sensu-go/types"
)
var _ schema.RuleFieldResolvers = (*ruleImpl)(nil)
var _ schema.RoleFieldResolvers = (*roleImpl)(nil)
//
// Implement RuleFieldResolvers
//
type ruleImpl struct {
schema.RuleAliases
}
// IsTypeOf is used to determine if a given value is associated with the type
func (*ruleImpl) IsTypeOf(s interface{}, p graphql.IsTypeOfParams) bool {
_, ok := s.(types.Rule)
return ok
}
//
// Implement RoleFieldResolvers
//
type roleImpl struct {
schema.RoleAliases
}
// ID implements response to request for 'id' field.
func (*roleImpl) ID(p graphql.ResolveParams) (string, error) {
return globalid.RoleTranslator.EncodeToString(p.Source), nil
}
// IsTypeOf is used to determine if a given value is associated with the type
func (*roleImpl) IsTypeOf(s interface{}, p graphql.IsTypeOfParams) bool {
_, ok := s.(*types.Role)
return ok
}