From ba8386b8a2b0af7d66e86ff92fb5b993c2ba92d2 Mon Sep 17 00:00:00 2001 From: UKEME BASSEY Date: Sun, 7 Apr 2024 12:18:26 -0400 Subject: [PATCH] json does not support interactive prompt so dont allow setting of both -migrate-state and -json options --- internal/command/init.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/command/init.go b/internal/command/init.go index a869503ce8..f382c1c3e2 100644 --- a/internal/command/init.go +++ b/internal/command/init.go @@ -77,6 +77,16 @@ func (c *InitCommand) Run(args []string) int { c.migrateState = initArgs.MigrateState c.Meta.ignoreRemoteVersion = initArgs.IgnoreRemoteVersion + if initArgs.MigrateState && initArgs.Json { + diags = diags.Append(tfdiags.Sourceless( + tfdiags.Error, + "The -migrate-state and -json options are mutually-exclusive", + "Terraform cannot ask for interactive approval when -json is set. To use the -migrate-state option, disable the -json option.", + )) + view.Diagnostics(diags) + return 1 + } + if c.migrateState && c.reconfigure { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error,