don't explicitly specify defaults in argument parsing

This commit is contained in:
Daniel Schmidt 2026-02-16 17:34:52 +01:00
parent 89bea5de5b
commit 32fb18572d
No known key found for this signature in database
GPG key ID: 377C3A4D62FBBBE2
2 changed files with 7 additions and 17 deletions

View file

@ -41,9 +41,7 @@ type StateRm struct {
// representing the best effort interpretation of the arguments.
func ParseStateRm(args []string) (*StateRm, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
rm := &StateRm{
StateLock: true,
}
rm := &StateRm{}
cmdFlags := defaultFlagSet("state rm")
cmdFlags.BoolVar(&rm.DryRun, "dry-run", false, "dry run")

View file

@ -18,25 +18,17 @@ func TestParseStateRm_valid(t *testing.T) {
"single address": {
[]string{"test_instance.foo"},
&StateRm{
DryRun: false,
BackupPath: "-",
StateLock: true,
StateLockTimeout: 0,
StatePath: "",
IgnoreRemoteVersion: false,
Addrs: []string{"test_instance.foo"},
BackupPath: "-",
StateLock: true,
Addrs: []string{"test_instance.foo"},
},
},
"multiple addresses": {
[]string{"test_instance.foo", "test_instance.bar"},
&StateRm{
DryRun: false,
BackupPath: "-",
StateLock: true,
StateLockTimeout: 0,
StatePath: "",
IgnoreRemoteVersion: false,
Addrs: []string{"test_instance.foo", "test_instance.bar"},
BackupPath: "-",
StateLock: true,
Addrs: []string{"test_instance.foo", "test_instance.bar"},
},
},
"all options": {