golang 1.14 doesn't like calling NewFile on existing files. Port solution over from Terraform

This commit is contained in:
Megan Marsh
2020-04-09 14:38:17 -07:00
parent 73c349d09c
commit 217dcbb97f
8 changed files with 143 additions and 113 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/chzyer/readline"
"github.com/hashicorp/packer/helper/wrappedreadline"
"github.com/hashicorp/packer/helper/wrappedstreams"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template"
"github.com/hashicorp/packer/template/interpolate"
@@ -115,7 +116,7 @@ func (*ConsoleCommand) AutocompleteFlags() complete.Flags {
func (c *ConsoleCommand) modePiped(session *REPLSession) int {
var lastResult string
scanner := bufio.NewScanner(wrappedreadline.Stdin())
scanner := bufio.NewScanner(wrappedstreams.Stdin())
for scanner.Scan() {
result, err := session.Handle(strings.TrimSpace(scanner.Text()))
if err != nil {
+2 -2
View File
@@ -9,7 +9,7 @@ import (
kvflag "github.com/hashicorp/packer/helper/flag-kv"
sliceflag "github.com/hashicorp/packer/helper/flag-slice"
"github.com/hashicorp/packer/helper/wrappedreadline"
"github.com/hashicorp/packer/helper/wrappedstreams"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template"
)
@@ -166,7 +166,7 @@ func (m *Meta) ValidateFlags() error {
// StdinPiped returns true if the input is piped.
func (m *Meta) StdinPiped() bool {
fi, err := wrappedreadline.Stdin().Stat()
fi, err := wrappedstreams.Stdin().Stat()
if err != nil {
// If there is an error, let's just say its not piped
return false