github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/cmd/imagetool/estimate.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/Cloud-Foundations/Dominator/lib/format" 7 "github.com/Cloud-Foundations/Dominator/lib/log" 8 "github.com/Cloud-Foundations/Dominator/lib/srpc" 9 ) 10 11 func estimateImageUsageSubcommand(args []string, logger log.DebugLogger) error { 12 imageSClient, _ := getClients() 13 if err := estimateImageUsage(imageSClient, args[0]); err != nil { 14 return fmt.Errorf("Error estimating image size: %s", err) 15 } 16 return nil 17 } 18 19 func estimateImageUsage(client *srpc.Client, image string) error { 20 fs, err := getFsOfImage(client, image) 21 if err != nil { 22 return err 23 } 24 _, err = fmt.Println(format.FormatBytes(fs.EstimateUsage(0))) 25 return err 26 }