Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/spf13/pflag v1.0.9
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.11.1
github.com/superfly/fly-go v0.2.3
github.com/superfly/fly-go v0.3.0
github.com/superfly/graphql v0.2.6
github.com/superfly/lfsc-go v0.1.1
github.com/superfly/macaroon v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/superfly/fly-go v0.2.3 h1:sK9lLjKNB/HWYtDcXp4G8WH4BIPkZe/8/MPa7VN1FzY=
github.com/superfly/fly-go v0.2.3/go.mod h1:2gCFoNR3iUELADGTJtbBoviMa2jlh2vlPK3cKUajOp8=
github.com/superfly/fly-go v0.3.0 h1:opzCfB5GeDe2AaqZgtPzWps+fW1zAMhISWAyQrhnV+Y=
github.com/superfly/fly-go v0.3.0/go.mod h1:2gCFoNR3iUELADGTJtbBoviMa2jlh2vlPK3cKUajOp8=
github.com/superfly/graphql v0.2.6 h1:zppbodNerWecoXEdjkhrqaNaSjGqobhXNlViHFuZzb4=
github.com/superfly/graphql v0.2.6/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
github.com/superfly/lfsc-go v0.1.1 h1:dGjLgt81D09cG+aR9lJZIdmonjZSR5zYCi7s54+ZU2Q=
Expand Down
40 changes: 33 additions & 7 deletions internal/command/machine/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ var sharedFlags = flag.Set{
Name: "rootfs-persist",
Description: "Whether to persist the root filesystem across restarts. Options include 'never', 'always', and 'restart'.",
},
flag.Int{
flag.String{
Name: "rootfs-size",
Description: "Root filesystem size in GB. Uses an overlayfs to allow the root filesystem to exceed its default size.",
Description: "Root filesystem size in GB. Accepts a plain number (in GB) or a human-readable size (e.g. 2gb, 5gb). Uses an overlayfs to allow the root filesystem to exceed its default size. Set to 0 to unset.",
},
flag.String{
Name: "rootfs-fs-size",
Description: "Root filesystem size in GB. Accepts a plain number (in GB) or a human-readable size (e.g. 2gb, 5gb). Sets the size of the filesystem itself, independent of the rootfs volume size. Set to 0 to unset.",
},
flag.String{
Name: "swap-size",
Expand Down Expand Up @@ -712,7 +716,7 @@ func determineMachineConfig(
}

// Root filesystem persistence and size
if flag.IsSpecified(ctx, "rootfs-persist") || flag.IsSpecified(ctx, "rootfs-size") {
if flag.IsSpecified(ctx, "rootfs-persist") || flag.IsSpecified(ctx, "rootfs-size") || flag.IsSpecified(ctx, "rootfs-fs-size") {
if machineConf.Rootfs == nil {
machineConf.Rootfs = &fly.MachineRootfs{}
}
Expand All @@ -731,11 +735,33 @@ func determineMachineConfig(
}

if flag.IsSpecified(ctx, "rootfs-size") {
size := flag.GetInt(ctx, "rootfs-size")
if size <= 0 {
return machineConf, fmt.Errorf("--rootfs-size must be greater than zero")
sizeGB, err := helpers.ParseSize(flag.GetString(ctx, "rootfs-size"), units.RAMInBytes, units.GiB)
if err != nil {
return machineConf, fmt.Errorf("invalid rootfs size: %w", err)
}
if sizeGB < 0 {
return machineConf, fmt.Errorf("--rootfs-size must not be negative")
}
machineConf.Rootfs.SizeGB = uint64(sizeGB)
}

if flag.IsSpecified(ctx, "rootfs-fs-size") {
sizeGB, err := helpers.ParseSize(flag.GetString(ctx, "rootfs-fs-size"), units.RAMInBytes, units.GiB)
if err != nil {
return machineConf, fmt.Errorf("invalid rootfs fs size: %w", err)
}
if sizeGB < 0 {
return machineConf, fmt.Errorf("--rootfs-fs-size must not be negative")
}
machineConf.Rootfs.FsSizeGB = uint64(sizeGB)
}

if machineConf.Rootfs.FsSizeGB > 0 {
if machineConf.Rootfs.SizeGB == 0 {
machineConf.Rootfs.SizeGB = machineConf.Rootfs.FsSizeGB
} else if machineConf.Rootfs.FsSizeGB > machineConf.Rootfs.SizeGB {
return machineConf, fmt.Errorf("--rootfs-fs-size must be smaller than or equal to --rootfs-size")
}
machineConf.Rootfs.SizeGB = uint64(size)
}
}

Expand Down
Loading