-
Notifications
You must be signed in to change notification settings - Fork 0
/
props.go
91 lines (81 loc) · 3.03 KB
/
props.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package kindsys
import "github.com/grafana/thema"
// CommonProperties contains the metadata common to all categories of kinds.
type CommonProperties struct {
Name string `json:"name"`
PluralName string `json:"pluralName"`
MachineName string `json:"machineName"`
PluralMachineName string `json:"pluralMachineName"`
LineageIsGroup bool `json:"lineageIsGroup"`
Maturity Maturity `json:"maturity"`
Description string `json:"description,omitempty"`
}
// CoreProperties represents the static properties in the definition of a
// Core kind that are representable with basic Go types. This
// excludes Thema schemas.
//
// When .cue file(s) containing a Core definition is loaded through the standard
// [LoadCoreKindDef], func, it is fully validated and populated according to all
// rules specified in CUE for Core kinds.
type CoreProperties struct {
CommonProperties
CurrentVersion thema.SyntacticVersion `json:"currentVersion"`
CRD struct {
Group string `json:"group"`
Scope string `json:"scope"`
DummySchema bool `json:"dummySchema"`
} `json:"crd"`
}
func (m CoreProperties) _private() {}
func (m CoreProperties) Common() CommonProperties {
return m.CommonProperties
}
// CustomProperties represents the static properties in the definition of a
// Custom kind that are representable with basic Go types. This
// excludes Thema schemas.
type CustomProperties struct {
CommonProperties
CurrentVersion thema.SyntacticVersion `json:"currentVersion"`
IsCRD bool `json:"isCRD"`
Group string `json:"group"`
CRD struct {
Group string `json:"group"`
Scope string `json:"scope"`
GroupOverride *string `json:"groupOverride"`
} `json:"crd"`
Codegen struct {
Frontend bool `json:"frontend"`
Backend bool `json:"backend"`
} `json:"codegen"`
}
func (m CustomProperties) _private() {}
func (m CustomProperties) Common() CommonProperties {
return m.CommonProperties
}
// ComposableProperties represents the static properties in the definition of a
// Composable kind that are representable with basic Go types. This
// excludes Thema schemas.
type ComposableProperties struct {
CommonProperties
CurrentVersion thema.SyntacticVersion `json:"currentVersion"`
SchemaInterface string `json:"schemaInterface"`
}
func (m ComposableProperties) _private() {}
func (m ComposableProperties) Common() CommonProperties {
return m.CommonProperties
}
// SomeKindProperties is an interface type to abstract over the different kind
// property struct types: [CoreProperties], [CustomProperties],
// [ComposableProperties].
//
// It is the traditional interface counterpart to the generic type constraint
// KindProperties.
type SomeKindProperties interface {
_private()
Common() CommonProperties
}
// KindProperties is a type parameter that comprises the base possible set of
// kind metadata configurations.
type KindProperties interface {
CoreProperties | CustomProperties | ComposableProperties
}