Bug Description
The run subcommand registers a --disk-size flag (cmd/virtwork/main.go:82), but LoadConfig binds Viper to data-disk-size (internal/config/config.go:120). Because bindFlagIfSet looks up the flag by exact name (cmd.Flags().Changed("data-disk-size")), it never finds the --disk-size flag and cfg.DataDiskSize always falls through to the default value.
Users passing --disk-size 20Gi silently get the default disk size instead.
Steps to Reproduce
- Run:
virtwork run --workloads disk --disk-size 50Gi --dry-run
- Observe the dry-run output — the data disk size is the default (
10Gi), not 50Gi
Expected Behavior
--disk-size 50Gi should set cfg.DataDiskSize to 50Gi, which is then used in VM spec construction and workload options.
Actual Behavior
The --disk-size flag is accepted by Cobra without error but never read by LoadConfig. The Viper key data-disk-size is never populated from the CLI flag because bindFlagIfSet looks for a flag named data-disk-size which does not exist on the command. cfg.DataDiskSize always receives the default value.
Root cause trace:
cmd/virtwork/main.go:82 — registers flag as disk-size
internal/config/config.go:81 — BindFlags registers a separate data-disk-size flag (used only by config tests)
internal/config/config.go:120 — bindFlagIfSet(v, cmd, "data-disk-size") calls cmd.Flags().Changed("data-disk-size") which is always false on the real run command
internal/config/config.go:150 — cfg.DataDiskSize = v.GetString("data-disk-size") returns the default
Additional Context
The test at cmd/virtwork/main_test.go:153 only verifies Cobra parsed the --disk-size flag value — it does not assert that cfg.DataDiskSize reflects it. A functional test through LoadConfig is needed.
The fix should align the flag name: either rename the flag in main.go to --data-disk-size (breaking change) or update bindFlagIfSet in config.go to look up disk-size and map it to the data-disk-size Viper key.
Bug Description
The
runsubcommand registers a--disk-sizeflag (cmd/virtwork/main.go:82), butLoadConfigbinds Viper todata-disk-size(internal/config/config.go:120). BecausebindFlagIfSetlooks up the flag by exact name (cmd.Flags().Changed("data-disk-size")), it never finds the--disk-sizeflag andcfg.DataDiskSizealways falls through to the default value.Users passing
--disk-size 20Gisilently get the default disk size instead.Steps to Reproduce
virtwork run --workloads disk --disk-size 50Gi --dry-run10Gi), not50GiExpected Behavior
--disk-size 50Gishould setcfg.DataDiskSizeto50Gi, which is then used in VM spec construction and workload options.Actual Behavior
The
--disk-sizeflag is accepted by Cobra without error but never read byLoadConfig. The Viper keydata-disk-sizeis never populated from the CLI flag becausebindFlagIfSetlooks for a flag nameddata-disk-sizewhich does not exist on the command.cfg.DataDiskSizealways receives the default value.Root cause trace:
cmd/virtwork/main.go:82— registers flag asdisk-sizeinternal/config/config.go:81—BindFlagsregisters a separatedata-disk-sizeflag (used only by config tests)internal/config/config.go:120—bindFlagIfSet(v, cmd, "data-disk-size")callscmd.Flags().Changed("data-disk-size")which is always false on the real run commandinternal/config/config.go:150—cfg.DataDiskSize = v.GetString("data-disk-size")returns the defaultAdditional Context
The test at
cmd/virtwork/main_test.go:153only verifies Cobra parsed the--disk-sizeflag value — it does not assert thatcfg.DataDiskSizereflects it. A functional test throughLoadConfigis needed.The fix should align the flag name: either rename the flag in
main.goto--data-disk-size(breaking change) or updatebindFlagIfSetinconfig.goto look updisk-sizeand map it to thedata-disk-sizeViper key.