...
1
9
10 package openapi
11
12 type Command struct {
13 Name string `json:"name"`
14
15 Group string `json:"group"`
16
17 Default bool `json:"default,omitempty"`
18
19 Type string `json:"type"`
20
21 Exec ExecCommand `json:"exec,omitempty"`
22
23 Apply ApplyCommand `json:"apply,omitempty"`
24
25 Image ImageCommand `json:"image,omitempty"`
26
27 Composite CompositeCommand `json:"composite,omitempty"`
28 }
29
30
31 func AssertCommandRequired(obj Command) error {
32 elements := map[string]interface{}{
33 "name": obj.Name,
34 "group": obj.Group,
35 "type": obj.Type,
36 }
37 for name, el := range elements {
38 if isZero := IsZeroValue(el); isZero {
39 return &RequiredError{Field: name}
40 }
41 }
42
43 if err := AssertExecCommandRequired(obj.Exec); err != nil {
44 return err
45 }
46 if err := AssertApplyCommandRequired(obj.Apply); err != nil {
47 return err
48 }
49 if err := AssertImageCommandRequired(obj.Image); err != nil {
50 return err
51 }
52 if err := AssertCompositeCommandRequired(obj.Composite); err != nil {
53 return err
54 }
55 return nil
56 }
57
58
59
60 func AssertRecurseCommandRequired(objSlice interface{}) error {
61 return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
62 aCommand, ok := obj.(Command)
63 if !ok {
64 return ErrTypeAssertionError
65 }
66 return AssertCommandRequired(aCommand)
67 })
68 }
69
View as plain text