mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Add EmptyDir to Volumes (#648)
This commit is contained in:
parent
14a0c9b815
commit
6db28e8afb
4 changed files with 63 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
# Change Log
|
||||
|
||||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||
- Allow to mount EmptyDir
|
||||
|
||||
## [1.1.0](https://github.com/arangodb/kube-arangodb/tree/master) (2020-10-14)
|
||||
- Change NumberOfCores and MemoryOverride flags to be set to true by default
|
||||
|
|
|
@ -112,6 +112,9 @@ type ServerGroupSpecVolume struct {
|
|||
|
||||
// ConfigMap which should be mounted into pod
|
||||
ConfigMap *ServerGroupSpecVolumeConfigMap `json:"configMap,omitempty"`
|
||||
|
||||
// EmptyDir
|
||||
EmptyDir *ServerGroupSpecVolumeEmptyDir `json:"emptyDir,omitempty"`
|
||||
}
|
||||
|
||||
// Validate if ServerGroupSpec volume is valid
|
||||
|
@ -124,6 +127,7 @@ func (s *ServerGroupSpecVolume) Validate() error {
|
|||
shared.PrefixResourceErrors("name", sharedv1.AsKubernetesResourceName(&s.Name).Validate()),
|
||||
shared.PrefixResourceErrors("secret", s.Secret.Validate()),
|
||||
shared.PrefixResourceErrors("configMap", s.ConfigMap.Validate()),
|
||||
shared.PrefixResourceErrors("emptyDir", s.EmptyDir.Validate()),
|
||||
s.validate(),
|
||||
)
|
||||
}
|
||||
|
@ -135,22 +139,43 @@ func (s ServerGroupSpecVolume) Volume() core.Volume {
|
|||
VolumeSource: core.VolumeSource{
|
||||
ConfigMap: (*core.ConfigMapVolumeSource)(s.ConfigMap),
|
||||
Secret: (*core.SecretVolumeSource)(s.Secret),
|
||||
EmptyDir: (*core.EmptyDirVolumeSource)(s.EmptyDir),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerGroupSpecVolume) validate() error {
|
||||
if s.ConfigMap == nil && s.Secret == nil {
|
||||
return errors.Errorf("at least one option need to be defined: secret or configMap")
|
||||
count := s.notNilFields()
|
||||
|
||||
if count == 0 {
|
||||
return errors.Errorf("at least one option need to be defined: secret, configMap or emptyDir")
|
||||
}
|
||||
|
||||
if s.ConfigMap != nil && s.Secret != nil {
|
||||
return errors.Errorf("only one option can be defined: secret or configMap")
|
||||
if count > 1 {
|
||||
return errors.Errorf("only one option can be defined: secret, configMap or emptyDir")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServerGroupSpecVolume) notNilFields() int {
|
||||
i := 0
|
||||
|
||||
if s.ConfigMap != nil {
|
||||
i++
|
||||
}
|
||||
|
||||
if s.Secret != nil {
|
||||
i++
|
||||
}
|
||||
|
||||
if s.EmptyDir != nil {
|
||||
i++
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
type ServerGroupSpecVolumeSecret core.SecretVolumeSource
|
||||
|
||||
func (s *ServerGroupSpecVolumeSecret) Validate() error {
|
||||
|
@ -174,3 +199,9 @@ func (s *ServerGroupSpecVolumeConfigMap) Validate() error {
|
|||
shared.PrefixResourceError("name", sharedv1.AsKubernetesResourceName(&s.Name).Validate()),
|
||||
)
|
||||
}
|
||||
|
||||
type ServerGroupSpecVolumeEmptyDir core.EmptyDirVolumeSource
|
||||
|
||||
func (s *ServerGroupSpecVolumeEmptyDir) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func Test_Volume_Validation(t *testing.T) {
|
|||
|
||||
fail: true,
|
||||
failedFields: map[string]string{
|
||||
"0": "only one option can be defined: secret or configMap",
|
||||
"0": "only one option can be defined: secret, configMap or emptyDir",
|
||||
},
|
||||
|
||||
volumes: []ServerGroupSpecVolume{
|
||||
|
|
26
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
26
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
|
@ -1412,6 +1412,11 @@ func (in *ServerGroupSpecVolume) DeepCopyInto(out *ServerGroupSpecVolume) {
|
|||
*out = new(ServerGroupSpecVolumeConfigMap)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.EmptyDir != nil {
|
||||
in, out := &in.EmptyDir, &out.EmptyDir
|
||||
*out = new(ServerGroupSpecVolumeEmptyDir)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1459,6 +1464,27 @@ func (in *ServerGroupSpecVolumeConfigMap) DeepCopy() *ServerGroupSpecVolumeConfi
|
|||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServerGroupSpecVolumeEmptyDir) DeepCopyInto(out *ServerGroupSpecVolumeEmptyDir) {
|
||||
*out = *in
|
||||
if in.SizeLimit != nil {
|
||||
in, out := &in.SizeLimit, &out.SizeLimit
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerGroupSpecVolumeEmptyDir.
|
||||
func (in *ServerGroupSpecVolumeEmptyDir) DeepCopy() *ServerGroupSpecVolumeEmptyDir {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ServerGroupSpecVolumeEmptyDir)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServerGroupSpecVolumeMount) DeepCopyInto(out *ServerGroupSpecVolumeMount) {
|
||||
*out = *in
|
||||
|
|
Loading…
Reference in a new issue