github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/providers/common/get_device_name.go (about) 1 package common 2 3 import ( 4 "github.com/emc-advanced-dev/pkg/errors" 5 "github.com/solo-io/unik/pkg/types" 6 ) 7 8 func GetDeviceNameForMnt(image *types.Image, mntPoint string) (string, error) { 9 for _, mapping := range image.RunSpec.DeviceMappings { 10 if mntPoint == mapping.MountPoint { 11 return mapping.DeviceName, nil 12 } 13 } 14 return "", errors.New("no mapping found on image "+image.Id+" for mount point "+mntPoint, nil) 15 } 16 17 func GetControllerPortForMnt(image *types.Image, mntPoint string) (int, error) { 18 for controllerPort, mapping := range image.RunSpec.DeviceMappings { 19 if mntPoint == mapping.MountPoint { 20 return controllerPort, nil 21 } 22 } 23 return -1, errors.New("no mapping found on image "+image.Id+" for mount point "+mntPoint, nil) 24 }