Add default value managed disks #355
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #52464
Problem
Rancher Machine drivers define CLI flags using
mcnflag. For boolean flags, the current flow effectively assumes the default is alwaysfalse. This makes it hard to express flags that should default totrue, like Azure managed disks, and causes inconsistencies across Rancher components (Rancher UI, terraform provider, and machine).Azure unmanaged disks are being retired, so we need
azure-managed-disksto default totrueand still allow users to explicitly disable it.Solution
Bool flags default support
Extend
mcnflag.BoolFlagwith aValue boolfield and return it inBoolFlag.Default().Update CLI flag conversion (
convertMcnFlagsToCliFlags) to preserve defaulttrue:mcnflag.BoolFlag.Valueistrue, convert it tocli.BoolTFlag(default true).cli.BoolFlag(default false).Pass default bool values through RPC opts
libmachine/drivers/rpc/util.gosoGetDriverOptspasses a default value tosetFlagonly when the bool default istrue. This keeps existing behavior for defaultfalse, and allows default true flags to be represented correctly.Azure managed disks default to true
Value: trueforazure-managed-disks.Tests
Add a table-driven test for
convertMcnFlagsToCliFlagscovering:cli.BoolTFlagcli.BoolFlagExtend RPC util tests to cover:
Testing
Manual Testing
CLI (rancher-machine binary)
--azure-managed-disks.RPC (driver opts via CRD)
AzureConfigCRD without specifying the managed disks option.managedDisksto true.rancher/rancher(tracked in a follow-up PR).Automated Testing
Unit tests added/updated:
commands/create_test.go(flag conversion coverage)libmachine/drivers/rpc/util_test.go(driver opts default-true coverage)