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.
This commit is contained in:
Kristin Laemmert 2019-04-12 07:37:27 -04:00 committed by GitHub
parent 88982fdbc3
commit 1c95b21c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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