From a2e044829b8e6094075e80908dfb314734e47ac8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 22 Dec 2016 16:43:52 -0800 Subject: [PATCH] provisioners/file: use the old communicator.New just to minimize risk --- .../provisioners/file/resource_provisioner.go | 4 ++-- communicator/communicator.go | 16 ---------------- helper/schema/provisioner.go | 5 +++++ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/builtin/provisioners/file/resource_provisioner.go b/builtin/provisioners/file/resource_provisioner.go index 012fc768d..71fde0610 100644 --- a/builtin/provisioners/file/resource_provisioner.go +++ b/builtin/provisioners/file/resource_provisioner.go @@ -40,11 +40,11 @@ func Provisioner() terraform.ResourceProvisioner { } func applyFn(ctx context.Context) error { - connData := ctx.Value(schema.ProvConnDataKey).(*schema.ResourceData) + connState := ctx.Value(schema.ProvRawStateKey).(*terraform.InstanceState) data := ctx.Value(schema.ProvConfigDataKey).(*schema.ResourceData) // Get a new communicator - comm, err := communicator.NewData(connData) + comm, err := communicator.New(connState) if err != nil { return err } diff --git a/communicator/communicator.go b/communicator/communicator.go index 21f7b6fea..5fa2631a4 100644 --- a/communicator/communicator.go +++ b/communicator/communicator.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform/communicator/remote" "github.com/hashicorp/terraform/communicator/ssh" "github.com/hashicorp/terraform/communicator/winrm" - "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) @@ -52,18 +51,3 @@ func New(s *terraform.InstanceState) (Communicator, error) { return nil, fmt.Errorf("connection type '%s' not supported", connType) } } - -// NewData creates a new Communicator from a ResourceData structure that -// represents the connection information. -func NewData(d *schema.ResourceData) (Communicator, error) { - // Turn the ResourceData into a legacy-style ConnInfo struct that - // is used to instantiate the communicator. - raw := d.State() - state := &terraform.InstanceState{ - Ephemeral: terraform.EphemeralState{ - ConnInfo: raw.Attributes, - }, - } - - return New(state) -} diff --git a/helper/schema/provisioner.go b/helper/schema/provisioner.go index d73aaa95e..6ac3fc1bf 100644 --- a/helper/schema/provisioner.go +++ b/helper/schema/provisioner.go @@ -61,6 +61,10 @@ const ( // This returns a terraform.UIOutput. Guaranteed to never be nil. ProvOutputKey + + // This returns the raw InstanceState passed to Apply. Guaranteed to + // be set, but may be nil. + ProvRawStateKey ) // InternalValidate should be called to validate the structure @@ -171,5 +175,6 @@ func (p *Provisioner) Apply( ctx = context.WithValue(ctx, ProvConnDataKey, connData) ctx = context.WithValue(ctx, ProvConfigDataKey, configData) ctx = context.WithValue(ctx, ProvOutputKey, o) + ctx = context.WithValue(ctx, ProvRawStateKey, s) return p.ApplyFunc(ctx) }