-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1483 from svanharmelen/f-winrm-support
core: add WinRM support
- Loading branch information
Showing
23 changed files
with
1,116 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/bin/sh | ||
cd /tmp | ||
wget http://foobar | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package communicator | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform/communicator/remote" | ||
"github.com/hashicorp/terraform/communicator/ssh" | ||
"github.com/hashicorp/terraform/communicator/winrm" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
// Communicator is an interface that must be implemented by all communicators | ||
// used for any of the provisioners | ||
type Communicator interface { | ||
// Connect is used to setup the connection | ||
Connect(terraform.UIOutput) error | ||
|
||
// Disconnect is used to terminate the connection | ||
Disconnect() error | ||
|
||
// Timeout returns the configured connection timeout | ||
Timeout() time.Duration | ||
|
||
// ScriptPath returns the configured script path | ||
ScriptPath() string | ||
|
||
// Start executes a remote command in a new session | ||
Start(*remote.Cmd) error | ||
|
||
// Upload is used to upload a single file | ||
Upload(string, io.Reader) error | ||
|
||
// UploadScript is used to upload a file as a executable script | ||
UploadScript(string, io.Reader) error | ||
|
||
// UploadDir is used to upload a directory | ||
UploadDir(string, string) error | ||
} | ||
|
||
// New returns a configured Communicator or an error if the connection type is not supported | ||
func New(s *terraform.InstanceState) (Communicator, error) { | ||
connType := s.Ephemeral.ConnInfo["type"] | ||
switch connType { | ||
case "ssh", "": // The default connection type is ssh, so if connType is empty use ssh | ||
return ssh.New(s) | ||
case "winrm": | ||
return winrm.New(s) | ||
default: | ||
return nil, fmt.Errorf("connection type '%s' not supported", connType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package communicator | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
func TestCommunicator_new(t *testing.T) { | ||
r := &terraform.InstanceState{ | ||
Ephemeral: terraform.EphemeralState{ | ||
ConnInfo: map[string]string{ | ||
"type": "telnet", | ||
}, | ||
}, | ||
} | ||
if _, err := New(r); err == nil { | ||
t.Fatalf("expected error with telnet") | ||
} | ||
|
||
r.Ephemeral.ConnInfo["type"] = "ssh" | ||
if _, err := New(r); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
r.Ephemeral.ConnInfo["type"] = "winrm" | ||
if _, err := New(r); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
} |
Oops, something went wrong.