Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for memory in decimal GiB #1205

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,17 @@ func (c colimaApp) SSH(args ...string) error {
}

type statusInfo struct {
DisplayName string `json:"display_name"`
Driver string `json:"driver"`
Arch string `json:"arch"`
Runtime string `json:"runtime"`
MountType string `json:"mount_type"`
IPAddress string `json:"ip_address"`
DockerSocket string `json:"docker_socket"`
Kubernetes bool `json:"kubernetes"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"`
Disk int64 `json:"disk"`
DisplayName string `json:"display_name"`
Driver string `json:"driver"`
Arch string `json:"arch"`
Runtime string `json:"runtime"`
MountType string `json:"mount_type"`
IPAddress string `json:"ip_address"`
DockerSocket string `json:"docker_socket"`
Kubernetes bool `json:"kubernetes"`
CPU int `json:"cpu"`
Memory float32 `json:"memory"`
Disk int64 `json:"disk"`
}

func (c colimaApp) getStatus() (status statusInfo, err error) {
Expand Down
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
14 changes: 7 additions & 7 deletions environment/vm/lima/limautil/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func Instance() (InstanceInfo, error) {

// InstanceInfo is the information about a Lima instance
type InstanceInfo struct {
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Arch string `json:"arch,omitempty"`
CPU int `json:"cpus,omitempty"`
Memory int64 `json:"memory,omitempty"`
Disk int64 `json:"disk,omitempty"`
Dir string `json:"dir,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Arch string `json:"arch,omitempty"`
CPU int `json:"cpus,omitempty"`
Memory float32 `json:"memory,omitempty"`
Disk int64 `json:"disk,omitempty"`
Dir string `json:"dir,omitempty"`
Network []struct {
VNL string `json:"vnl,omitempty"`
Interface string `json:"interface,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)) //memorySize is a multiple of 1 megabyte
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is not needed.

Suggested change
l.Memory = fmt.Sprintf("%dMiB", uint32(conf.Memory*1024)) //memorySize is a multiple of 1 megabyte
l.Memory = fmt.Sprintf("%dMiB", uint32(conf.Memory*1024))

}
if conf.Disk > 0 {
l.Disk = fmt.Sprintf("%dGiB", conf.Disk)
Expand Down
Loading