/
resourcekind.go
43 lines (37 loc) · 908 Bytes
/
resourcekind.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
package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ResourceKind holds the schema definition for the ResourceKind entity.
type ResourceKind struct {
ent.Schema
}
// Fields of the ResourceKind.
func (ResourceKind) Fields() []ent.Field {
return []ent.Field{
field.String("name").NotEmpty().Unique(),
field.String("apiVersion").NotEmpty().Unique(),
field.Bool("namespaced").Default(true),
field.String("kind").NotEmpty().Unique(),
}
}
// Edges of the ResourceKind.
func (ResourceKind) Edges() []ent.Edge {
return nil
}
func (ResourceKind) Indexes() []ent.Index {
return []ent.Index{
index.Fields("apiVersion", "name"),
index.Fields("name"),
}
}
func (ResourceKind) Annotations() []schema.Annotation {
return []schema.Annotation{
entgql.RelayConnection(),
entgql.QueryField(),
}
}