/
bind_composable.go
53 lines (41 loc) · 1.13 KB
/
bind_composable.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
package kindsys
import "github.com/grafana/thema"
// genericComposable is a general representation of a parsed and validated
// Composable kind.
type genericComposable struct {
def Def[ComposableProperties]
lin thema.Lineage
}
func (k genericComposable) Maturity() Maturity {
return k.def.Properties.Maturity
}
func (k genericComposable) CurrentVersion() thema.SyntacticVersion {
return k.def.Properties.CurrentVersion
}
var _ Composable = genericComposable{}
func (k genericComposable) Props() SomeKindProperties {
return k.def.Properties
}
func (k genericComposable) Name() string {
return k.def.Properties.Name
}
func (k genericComposable) MachineName() string {
return k.def.Properties.MachineName
}
func (k genericComposable) Def() Def[ComposableProperties] {
return k.def
}
func (k genericComposable) Lineage() thema.Lineage {
return k.lin
}
// TODO docs
func BindComposable(rt *thema.Runtime, def Def[ComposableProperties], opts ...thema.BindOption) (Composable, error) {
lin, err := def.Some().BindKindLineage(rt, opts...)
if err != nil {
return nil, err
}
return genericComposable{
def: def,
lin: lin,
}, nil
}