forked from fybrik/crdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
74 lines (63 loc) · 1.42 KB
/
model.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2021 IBM Corp.
// SPDX-License-Identifier: Apache-2.0
package builder
import "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
type Model struct {
Metadata PageMetadata `yaml:"metadata"`
Groups []*GroupModel `yaml:"groups"`
}
type GroupModel struct {
// Metadata PageMetadata `yaml:"metadata"`
Group string `yaml:"group"`
Version string `yaml:"version"`
Kinds []*KindModel `yaml:"kinds"`
}
type KindModel struct {
// Metadata PageMetadata `yaml:"metadata"`
Name string `yaml:"name"`
Key string
Types []*TypeModel
}
type PageMetadata struct {
Title string `yaml:"title"`
Weight int `yaml:"weight"`
Description string `yaml:"description"`
}
type TypeModel struct {
Order int
Name string
Key string
Parents []Parent
Description string
IsTopLevel bool
Headings string
Fields []*FieldModel
}
type Parent struct {
Name string
Key string
}
type FieldModel struct {
Name string
Type string
TypeKey *string
Description string
Required bool
Schema apiextensions.JSONSchemaProps
}
func (m *Model) findGroupModel(group, version string) *GroupModel {
for _, v := range m.Groups {
if group == v.Group && version == v.Version {
return v
}
}
return nil
}
func (m *GroupModel) findKindModel(kind string) *KindModel {
for _, v := range m.Kinds {
if kind == v.Name {
return v
}
}
return nil
}