@@ -112,6 +112,9 @@ type ServerGroupSpecVolume struct {
112112
113113 // ConfigMap which should be mounted into pod
114114 ConfigMap * ServerGroupSpecVolumeConfigMap `json:"configMap,omitempty"`
115+
116+ // EmptyDir
117+ EmptyDir * ServerGroupSpecVolumeEmptyDir `json:"emptyDir,omitempty"`
115118}
116119
117120// Validate if ServerGroupSpec volume is valid
@@ -124,6 +127,7 @@ func (s *ServerGroupSpecVolume) Validate() error {
124127 shared .PrefixResourceErrors ("name" , sharedv1 .AsKubernetesResourceName (& s .Name ).Validate ()),
125128 shared .PrefixResourceErrors ("secret" , s .Secret .Validate ()),
126129 shared .PrefixResourceErrors ("configMap" , s .ConfigMap .Validate ()),
130+ shared .PrefixResourceErrors ("emptyDir" , s .EmptyDir .Validate ()),
127131 s .validate (),
128132 )
129133}
@@ -135,22 +139,43 @@ func (s ServerGroupSpecVolume) Volume() core.Volume {
135139 VolumeSource : core.VolumeSource {
136140 ConfigMap : (* core .ConfigMapVolumeSource )(s .ConfigMap ),
137141 Secret : (* core .SecretVolumeSource )(s .Secret ),
142+ EmptyDir : (* core .EmptyDirVolumeSource )(s .EmptyDir ),
138143 },
139144 }
140145}
141146
142147func (s * ServerGroupSpecVolume ) validate () error {
143- if s .ConfigMap == nil && s .Secret == nil {
144- return errors .Errorf ("at least one option need to be defined: secret or configMap" )
148+ count := s .notNilFields ()
149+
150+ if count == 0 {
151+ return errors .Errorf ("at least one option need to be defined: secret, configMap or emptyDir" )
145152 }
146153
147- if s . ConfigMap != nil && s . Secret != nil {
148- return errors .Errorf ("only one option can be defined: secret or configMap " )
154+ if count > 1 {
155+ return errors .Errorf ("only one option can be defined: secret, configMap or emptyDir " )
149156 }
150157
151158 return nil
152159}
153160
161+ func (s * ServerGroupSpecVolume ) notNilFields () int {
162+ i := 0
163+
164+ if s .ConfigMap != nil {
165+ i ++
166+ }
167+
168+ if s .Secret != nil {
169+ i ++
170+ }
171+
172+ if s .EmptyDir != nil {
173+ i ++
174+ }
175+
176+ return i
177+ }
178+
154179type ServerGroupSpecVolumeSecret core.SecretVolumeSource
155180
156181func (s * ServerGroupSpecVolumeSecret ) Validate () error {
@@ -174,3 +199,9 @@ func (s *ServerGroupSpecVolumeConfigMap) Validate() error {
174199 shared .PrefixResourceError ("name" , sharedv1 .AsKubernetesResourceName (& s .Name ).Validate ()),
175200 )
176201}
202+
203+ type ServerGroupSpecVolumeEmptyDir core.EmptyDirVolumeSource
204+
205+ func (s * ServerGroupSpecVolumeEmptyDir ) Validate () error {
206+ return nil
207+ }
0 commit comments