Skip to content

Commit

Permalink
Round in MB and set default volume size to 10GB
Browse files Browse the repository at this point in the history
  • Loading branch information
torrefatto committed Jun 18, 2024
1 parent 74c9046 commit 6de932b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/koyeb/volumes.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package koyeb

import (
"math"
"regexp"
"strconv"

Expand Down Expand Up @@ -67,7 +68,7 @@ func NewVolumeCmd() *cobra.Command {
}),
}
createVolumeCmd.Flags().String("region", "was", "Region of the volume")
createVolumeCmd.Flags().String("size", "100M", "Size of the volume")
createVolumeCmd.Flags().String("size", "10G", "Size of the volume (will be rounded to the nearest upper size in MB)")
createVolumeCmd.Flags().Bool("read-only", false, "Force the volume to be read-only")
volumeCmd.AddCommand(createVolumeCmd)

Expand Down Expand Up @@ -179,5 +180,11 @@ func parseSize(size string) (int64, error) {
}
}

return result, nil
return roundToMB(result), nil
}

func roundToMB(size int64) int64 {
const MB int64 = 1024*1024 - 1
rounded := (size + MB) &^ MB
return int64(float64(rounded) / 1024 / 1024)
}

0 comments on commit 6de932b

Please sign in to comment.