Ensure that the state locking is configured correctly

This is necessary because calling the Meta.extendedFlagSet was having this
side-effect to set the stateLock=true.
Now that we move away from it but we still don't have a unified way to
handle the default cases for the stateLocking attributes, we will do
this for the moment and unify it later.

Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
This commit is contained in:
Andrei Ciobanu 2026-02-16 16:12:20 +02:00
parent e0fb51030b
commit ac0c8f1777
No known key found for this signature in database
GPG key ID: 58C6DAFBD444BE45
2 changed files with 12 additions and 0 deletions

View file

@ -65,6 +65,13 @@ func (c *ConsoleCommand) Run(rawArgs []string) int {
// operation, but there is no clear path to pass this value down, so we
// continue to mutate the Meta object state for now.
c.Meta.input = args.ViewOptions.InputEnabled
// TODO meta-refactor: when the stateLock and stateLockTimeout are extracted to be configured separately, remove
// these and use a common way to configure this
// The stateLock=true is here this way because this command used before meta.extendedFlagSet which did the same
// and left for the command to configure flags for this if needed.
c.Meta.stateLock = true
c.GatherVariables(args.Vars)
configPath := c.WorkingDir.NormalizePath(c.WorkingDir.RootModuleDir())

View file

@ -115,6 +115,11 @@ func TestConsole_multiline_interactive(t *testing.T) {
if diff := cmp.Diff(got, tc.expected); diff != "" {
t.Fatalf("unexpected output. For input: %s\n%s", tc.input, diff)
}
// TODO meta-refactor: remove this assertion once the stateLock from Meta is removed
if !c.Meta.stateLock {
t.Errorf("stateLock should always be nil for this command")
}
})
}
}