From 1c95b21c6cfffc50cb6b3c3c23b2257d28b61a9c Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Fri, 12 Apr 2019 07:37:27 -0400 Subject: [PATCH] command/output: get the state path from the workspace or CLI argument (#20994) Previously this command was setting the state path to the default state file, instead of honoring the backend configuration. --- command/output.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/command/output.go b/command/output.go index 090f320c6..789be53a4 100644 --- a/command/output.go +++ b/command/output.go @@ -28,11 +28,11 @@ func (c *OutputCommand) Run(args []string) int { return 1 } - var module string + var module, statePath string var jsonOutput bool cmdFlags := c.Meta.defaultFlagSet("output") cmdFlags.BoolVar(&jsonOutput, "json", false, "json") - cmdFlags.StringVar(&c.Meta.statePath, "state", DefaultStateFilename, "path") + cmdFlags.StringVar(&statePath, "state", "", "path") cmdFlags.StringVar(&module, "module", "", "module") cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } if err := cmdFlags.Parse(args); err != nil { @@ -53,6 +53,10 @@ func (c *OutputCommand) Run(args []string) int { name = args[0] } + if statePath != "" { + c.Meta.statePath = statePath + } + var diags tfdiags.Diagnostics // Load the backend