-
Notifications
You must be signed in to change notification settings - Fork 20
/
utils.go
38 lines (30 loc) · 1.16 KB
/
utils.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
package api
import (
"github.com/open-component-model/ocm/pkg/runtime"
)
type _Object = runtime.ObjectVersionedTypedObject
type actionType struct {
_Object
spectype ActionSpecType
restype ActionResultType
}
var _ ActionType = (*actionType)(nil)
func NewActionType[IS ActionSpec, IR ActionResult](kind, version string) ActionType {
return NewActionTypeByConverter[IS, IS, IR, IR](kind, version, runtime.IdentityConverter[IS]{}, runtime.IdentityConverter[IR]{})
}
func NewActionTypeByConverter[IS ActionSpec, VS runtime.TypedObject, IR ActionResult, VR runtime.TypedObject](kind, version string, specconv runtime.Converter[IS, VS], resconv runtime.Converter[IR, VR]) ActionType {
name := runtime.TypeName(kind, version)
st := runtime.NewVersionedTypedObjectTypeByConverter[ActionSpec, IS, VS](name, specconv)
rt := runtime.NewVersionedTypedObjectTypeByConverter[ActionResult, IR, VR](name, resconv)
return &actionType{
_Object: runtime.NewVersionedTypedObject(kind, version),
spectype: st,
restype: rt,
}
}
func (a *actionType) SpecificationType() ActionSpecType {
return a.spectype
}
func (a *actionType) ResultType() ActionResultType {
return a.restype
}