github.com/Cloud-Foundations/Dominator@v0.3.4/cmd/imagetool/findLatestImage.go (about) 1 package main 2 3 import ( 4 "errors" 5 "fmt" 6 7 "github.com/Cloud-Foundations/Dominator/imageserver/client" 8 "github.com/Cloud-Foundations/Dominator/lib/log" 9 proto "github.com/Cloud-Foundations/Dominator/proto/imageserver" 10 ) 11 12 func findLatestImageSubcommand(args []string, logger log.DebugLogger) error { 13 if err := findLatestImage(args[0]); err != nil { 14 return fmt.Errorf("error finding latest image: %s", err) 15 } 16 return nil 17 } 18 19 func findLatestImage(dirname string) error { 20 imageSClient, _ := getClients() 21 imageName, err := client.FindLatestImageReq(imageSClient, 22 proto.FindLatestImageRequest{ 23 BuildCommitId: *buildCommitId, 24 DirectoryName: dirname, 25 IgnoreExpiringImages: *ignoreExpiring, 26 TagsToMatch: tagsToMatch, 27 }) 28 if err != nil { 29 return err 30 } 31 if imageName == "" { 32 return errors.New("no image found") 33 } 34 fmt.Println(imageName) 35 return nil 36 }