Skip to content

[Bug]: --disk-size flag silently ignored — name mismatch with config binding #95

Description

@mrhillsman

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

  1. Run: virtwork run --workloads disk --disk-size 50Gi --dry-run
  2. 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:81BindFlags registers a separate data-disk-size flag (used only by config tests)
  • internal/config/config.go:120bindFlagIfSet(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:150cfg.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.tech-debtTechnical debt, code quality, or maintenance concerntriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions