command/output: Remote enable
This commit is contained in:
parent
53704db4ee
commit
0c9436f37b
|
@ -3,10 +3,7 @@ package command
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/terraform"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// OutputCommand is a Command implementation that reads an output
|
// OutputCommand is a Command implementation that reads an output
|
||||||
|
@ -16,12 +13,10 @@ type OutputCommand struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OutputCommand) Run(args []string) int {
|
func (c *OutputCommand) Run(args []string) int {
|
||||||
var statePath string
|
|
||||||
|
|
||||||
args = c.Meta.process(args, false)
|
args = c.Meta.process(args, false)
|
||||||
|
|
||||||
cmdFlags := flag.NewFlagSet("output", flag.ContinueOnError)
|
cmdFlags := flag.NewFlagSet("output", flag.ContinueOnError)
|
||||||
cmdFlags.StringVar(&statePath, "state", DefaultStateFilename, "path")
|
cmdFlags.StringVar(&c.Meta.statePath, "state", DefaultStateFilename, "path")
|
||||||
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||||
if err := cmdFlags.Parse(args); err != nil {
|
if err := cmdFlags.Parse(args); err != nil {
|
||||||
return 1
|
return 1
|
||||||
|
@ -37,14 +32,7 @@ func (c *OutputCommand) Run(args []string) int {
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
f, err := os.Open(statePath)
|
state, err := c.Meta.loadState()
|
||||||
if err != nil {
|
|
||||||
c.Ui.Error(fmt.Sprintf("Error loading file: %s", err))
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
state, err := terraform.ReadState(f)
|
|
||||||
f.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error reading state: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error reading state: %s", err))
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in New Issue