- fixed up the api changing mountPath to path

- added additional validation of the spec for the volumes
This commit is contained in:
Rohith 2018-11-10 01:19:27 +00:00
parent 1774ce5861
commit 42aee24caa
4 changed files with 31 additions and 4 deletions

View File

@ -164,7 +164,7 @@ type InstanceGroupVolumeFilesystemSpec struct {
// Ext4 is the specification for a ext4 filesystem
Ext4 *Ext4FileSystemSpec `json:"ext4,omitempty"`
// Path is the location to mount the volume
Path string `json:"mountPath,omitempty"`
Path string `json:"path,omitempty"`
}
// Ext4FileSystemSpec defines a specification for a ext4 filesystem on a instancegroup volume

View File

@ -159,7 +159,7 @@ type InstanceGroupVolumeFilesystemSpec struct {
// Ext4 is the specification for a ext4 filesystem
Ext4 *Ext4FileSystemSpec `json:"ext4,omitempty"`
// Path is the location to mount the volume
Path string `json:"mountPath,omitempty"`
Path string `json:"path,omitempty"`
}
// Ext4FileSystemSpec defines a specification for a ext4 filesystem on a instancegroup volume

View File

@ -153,7 +153,7 @@ type InstanceGroupVolumeFilesystemSpec struct {
// Ext4 is the specification for a ext4 filesystem
Ext4 *Ext4FileSystemSpec `json:"ext4,omitempty"`
// Path is the location to mount the volume
Path string `json:"mountPath,omitempty"`
Path string `json:"path,omitempty"`
}
// Ext4FileSystemSpec defines a specification for a ext4 filesystem on a instancegroup volume

View File

@ -89,9 +89,24 @@ func ValidateInstanceGroup(g *kops.InstanceGroup) error {
}
for i, x := range g.Spec.Volumes {
used := make(map[string]bool, 0)
path := field.NewPath("volumes").Index(i)
if x.DeviceName == nil {
return field.Invalid(field.NewPath("volumes").Index(i).Child("deviceName"), "", "volume must have a device name")
return field.Invalid(path.Child("deviceName"), "", "volume must have a device name")
}
// @check the device name has not been used already
if _, found := used[*x.DeviceName]; found {
return field.Invalid(path.Child("deviceName"), *x.DeviceName, "duplicate device name found")
}
// @check the filesystem specification if we have one
if x.Filesystem != nil {
if err := validateInstanceGroupFilesystem(path.Child("filesystem"), x.Filesystem); err != nil {
return err
}
}
used[*x.DeviceName] = true
}
if err := validateInstanceProfile(g.Spec.IAM, field.NewPath("iam")); err != nil {
@ -101,6 +116,18 @@ func ValidateInstanceGroup(g *kops.InstanceGroup) error {
return nil
}
// validateInstanceGroupFilesystem is responsible for validation the volume filesystem spec
func validateInstanceGroupFilesystem(path *field.Path, item *kops.InstanceGroupVolumeFilesystemSpec) error {
if item.Path == "" {
return field.Invalid(path.Child("path"), item.Path, "no path for filesystem defined")
}
if item.Ext4 == nil {
item.Ext4 = &kops.Ext4FileSystemSpec{}
}
return nil
}
// CrossValidateInstanceGroup performs validation of the instance group, including that it is consistent with the Cluster
// It calls ValidateInstanceGroup, so all that validation is included.
func CrossValidateInstanceGroup(g *kops.InstanceGroup, cluster *kops.Cluster, strict bool) error {