Skip to content

Commit

Permalink
config: ability to specifying memory in decimal GiB (#1206)
Browse files Browse the repository at this point in the history
Co-authored-by: summer <qq0538925@gmail.com>
  • Loading branch information
qiao-summer and summer-temp authored Dec 4, 2024
1 parent ad5102e commit 7435a59
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func init() {
startCmd.Flags().BoolVar(&startCmdArgs.Flags.ActivateRuntime, "activate", true, "set as active Docker/Kubernetes context on startup")
startCmd.Flags().IntVarP(&startCmdArgs.CPU, "cpu", "c", defaultCPU, "number of CPUs")
startCmd.Flags().StringVar(&startCmdArgs.CPUType, "cpu-type", "", "the CPU type, options can be checked with 'qemu-system-"+defaultArch+" -cpu help'")
startCmd.Flags().IntVarP(&startCmdArgs.Memory, "memory", "m", defaultMemory, "memory in GiB")
startCmd.Flags().Float32VarP(&startCmdArgs.Memory, "memory", "m", defaultMemory, "memory in GiB")
startCmd.Flags().IntVarP(&startCmdArgs.Disk, "disk", "d", defaultDisk, "disk size in GiB")
startCmd.Flags().StringVarP(&startCmdArgs.Arch, "arch", "a", defaultArch, "architecture (aarch64, x86_64)")
startCmd.Flags().BoolVarP(&startCmdArgs.Flags.Foreground, "foreground", "f", false, "Keep colima in the foreground")
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
type Config struct {
CPU int `yaml:"cpu,omitempty"`
Disk int `yaml:"disk,omitempty"`
Memory int `yaml:"memory,omitempty"`
Memory float32 `yaml:"memory,omitempty"`
Arch string `yaml:"arch,omitempty"`
CPUType string `yaml:"cpuType,omitempty"`
Network Network `yaml:"network,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func newConf(ctx context.Context, conf config.Config) (l limaconfig.Config, err
l.CPUs = &conf.CPU
}
if conf.Memory > 0 {
l.Memory = fmt.Sprintf("%dGiB", conf.Memory)
l.Memory = fmt.Sprintf("%dMiB", uint32(conf.Memory*1024))
}
if conf.Disk > 0 {
l.Disk = fmt.Sprintf("%dGiB", conf.Disk)
Expand Down

0 comments on commit 7435a59

Please sign in to comment.