...
1
9
10 package openapi
11
12 type Container struct {
13 Name string `json:"name"`
14
15 Image string `json:"image"`
16
17 Command []string `json:"command"`
18
19 Args []string `json:"args"`
20
21 MemoryRequest string `json:"memoryRequest"`
22
23 MemoryLimit string `json:"memoryLimit"`
24
25 CpuRequest string `json:"cpuRequest"`
26
27 CpuLimit string `json:"cpuLimit"`
28
29 VolumeMounts []VolumeMount `json:"volumeMounts"`
30
31 Annotation Annotation `json:"annotation"`
32
33 Endpoints []Endpoint `json:"endpoints"`
34
35 Env []Env `json:"env"`
36
37 ConfigureSources bool `json:"configureSources"`
38
39 MountSources bool `json:"mountSources"`
40
41 SourceMapping string `json:"sourceMapping"`
42 }
43
44
45 func AssertContainerRequired(obj Container) error {
46 elements := map[string]interface{}{
47 "name": obj.Name,
48 "image": obj.Image,
49 "command": obj.Command,
50 "args": obj.Args,
51 "memoryRequest": obj.MemoryRequest,
52 "memoryLimit": obj.MemoryLimit,
53 "cpuRequest": obj.CpuRequest,
54 "cpuLimit": obj.CpuLimit,
55 "volumeMounts": obj.VolumeMounts,
56 "annotation": obj.Annotation,
57 "endpoints": obj.Endpoints,
58 "env": obj.Env,
59 "configureSources": obj.ConfigureSources,
60 "mountSources": obj.MountSources,
61 "sourceMapping": obj.SourceMapping,
62 }
63 for name, el := range elements {
64 if isZero := IsZeroValue(el); isZero {
65 return &RequiredError{Field: name}
66 }
67 }
68
69 for _, el := range obj.VolumeMounts {
70 if err := AssertVolumeMountRequired(el); err != nil {
71 return err
72 }
73 }
74 if err := AssertAnnotationRequired(obj.Annotation); err != nil {
75 return err
76 }
77 for _, el := range obj.Endpoints {
78 if err := AssertEndpointRequired(el); err != nil {
79 return err
80 }
81 }
82 for _, el := range obj.Env {
83 if err := AssertEnvRequired(el); err != nil {
84 return err
85 }
86 }
87 return nil
88 }
89
90
91
92 func AssertRecurseContainerRequired(objSlice interface{}) error {
93 return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
94 aContainer, ok := obj.(Container)
95 if !ok {
96 return ErrTypeAssertionError
97 }
98 return AssertContainerRequired(aContainer)
99 })
100 }
101
View as plain text