Skip to content

Commit c827cb9

Browse files
committed
feat(machine): support vm-max-memory for run and update
1 parent c77732c commit c827cb9

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ require (
7373
github.com/spf13/pflag v1.0.10
7474
github.com/spf13/viper v1.20.1
7575
github.com/stretchr/testify v1.11.1
76-
github.com/superfly/fly-go v0.4.1
76+
github.com/superfly/fly-go v0.4.2
7777
github.com/superfly/graphql v0.2.6
7878
github.com/superfly/lfsc-go v0.1.1
7979
github.com/superfly/macaroon v0.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
653653
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
654654
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
655655
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
656-
github.com/superfly/fly-go v0.4.1 h1:l29ohaVaeQ55VdMJJsxCiIPUHrROXvwDswE8LAttXgk=
657-
github.com/superfly/fly-go v0.4.1/go.mod h1:9ZPc5Yagx2y4gQJ0yP1+xxHyWR9U9lA2QSKjb5h4944=
656+
github.com/superfly/fly-go v0.4.2 h1:QDAKDUSjR0tzYHoSqWTaHJXkECTwNl/F6RUFAaWikgQ=
657+
github.com/superfly/fly-go v0.4.2/go.mod h1:9ZPc5Yagx2y4gQJ0yP1+xxHyWR9U9lA2QSKjb5h4944=
658658
github.com/superfly/graphql v0.2.6 h1:zppbodNerWecoXEdjkhrqaNaSjGqobhXNlViHFuZzb4=
659659
github.com/superfly/graphql v0.2.6/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
660660
github.com/superfly/lfsc-go v0.1.1 h1:dGjLgt81D09cG+aR9lJZIdmonjZSR5zYCi7s54+ZU2Q=

internal/flag/machines.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ func GetMachineGuest(ctx context.Context, guest *fly.MachineGuest) (*fly.Machine
5858
}
5959
}
6060

61+
if IsSpecified(ctx, "vm-max-memory") {
62+
rawValue := GetString(ctx, "vm-max-memory")
63+
maxMemoryMB, err := helpers.ParseSize(rawValue, units.RAMInBytes, units.MiB)
64+
switch {
65+
case err != nil:
66+
return nil, err
67+
case maxMemoryMB == 0:
68+
return nil, fmt.Errorf("--vm-max-memory cannot be zero")
69+
default:
70+
guest.MaxMemoryMB = maxMemoryMB
71+
}
72+
}
73+
6174
if IsSpecified(ctx, "vm-cpu-kind") {
6275
guest.CPUKind = GetString(ctx, "vm-cpu-kind")
6376
if k := guest.CPUKind; k != "shared" && k != "performance" {
@@ -121,6 +134,11 @@ var VMSizeFlags = Set{
121134
Description: "Memory (in megabytes) to attribute to the VM",
122135
Aliases: []string{"memory"},
123136
},
137+
String{
138+
Name: "vm-max-memory",
139+
Description: "Maximum memory (in megabytes) to allow for the VM",
140+
Aliases: []string{"max-memory"},
141+
},
124142
Int{
125143
Name: "vm-gpus",
126144
Description: "Number of GPUs. Must also choose the GPU model with --vm-gpu-kind flag",

0 commit comments

Comments
 (0)