github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/providers/common/verify_mount_points.go (about) 1 package common 2 3 import ( 4 "github.com/sirupsen/logrus" 5 "github.com/emc-advanced-dev/pkg/errors" 6 "github.com/solo-io/unik/pkg/providers" 7 "github.com/solo-io/unik/pkg/types" 8 ) 9 10 func VerifyMntsInput(p providers.Provider, image *types.Image, mntPointsToVolumeIds map[string]string) error { 11 for _, deviceMapping := range image.RunSpec.DeviceMappings { 12 if deviceMapping.MountPoint == "/" { 13 //ignore boot mount point 14 continue 15 } 16 _, ok := mntPointsToVolumeIds[deviceMapping.MountPoint] 17 if !ok { 18 logrus.WithFields(logrus.Fields{"required-device-mappings": image.RunSpec.DeviceMappings}).Errorf("requied mount point missing: %s", deviceMapping.MountPoint) 19 return errors.New("required mount point missing from input", nil) 20 } 21 } 22 for mntPoint, volumeId := range mntPointsToVolumeIds { 23 mntPointExists := false 24 for _, deviceMapping := range image.RunSpec.DeviceMappings { 25 if deviceMapping.MountPoint == mntPoint { 26 mntPointExists = true 27 break 28 } 29 } 30 if !mntPointExists { 31 return errors.New("mount point "+mntPoint+" does not exist for image "+image.Id, nil) 32 } 33 _, err := p.GetVolume(volumeId) 34 if err != nil { 35 return errors.New("could not find volume "+volumeId, err) 36 } 37 } 38 return nil 39 }