diff options
author | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
---|---|---|
committer | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
commit | bae9f6d2fd5eb5bc80929bd393932b23f14d7c93 (patch) | |
tree | ca9ab12a7d78b1fc27a8f734729081357ce6d252 /vendor/github.com/hashicorp/terraform/plugin/ui_input.go | |
parent | 254c495b6bebab3fb72a243c4bce858d79e6ee99 (diff) | |
download | terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.gz terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.zst terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.zip |
Initial transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/plugin/ui_input.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/plugin/ui_input.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/plugin/ui_input.go b/vendor/github.com/hashicorp/terraform/plugin/ui_input.go new file mode 100644 index 0000000..493efc0 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/plugin/ui_input.go | |||
@@ -0,0 +1,51 @@ | |||
1 | package plugin | ||
2 | |||
3 | import ( | ||
4 | "net/rpc" | ||
5 | |||
6 | "github.com/hashicorp/go-plugin" | ||
7 | "github.com/hashicorp/terraform/terraform" | ||
8 | ) | ||
9 | |||
10 | // UIInput is an implementatin of terraform.UIInput that communicates | ||
11 | // over RPC. | ||
12 | type UIInput struct { | ||
13 | Client *rpc.Client | ||
14 | } | ||
15 | |||
16 | func (i *UIInput) Input(opts *terraform.InputOpts) (string, error) { | ||
17 | var resp UIInputInputResponse | ||
18 | err := i.Client.Call("Plugin.Input", opts, &resp) | ||
19 | if err != nil { | ||
20 | return "", err | ||
21 | } | ||
22 | if resp.Error != nil { | ||
23 | err = resp.Error | ||
24 | return "", err | ||
25 | } | ||
26 | |||
27 | return resp.Value, nil | ||
28 | } | ||
29 | |||
30 | type UIInputInputResponse struct { | ||
31 | Value string | ||
32 | Error *plugin.BasicError | ||
33 | } | ||
34 | |||
35 | // UIInputServer is a net/rpc compatible structure for serving | ||
36 | // a UIInputServer. This should not be used directly. | ||
37 | type UIInputServer struct { | ||
38 | UIInput terraform.UIInput | ||
39 | } | ||
40 | |||
41 | func (s *UIInputServer) Input( | ||
42 | opts *terraform.InputOpts, | ||
43 | reply *UIInputInputResponse) error { | ||
44 | value, err := s.UIInput.Input(opts) | ||
45 | *reply = UIInputInputResponse{ | ||
46 | Value: value, | ||
47 | Error: plugin.NewBasicError(err), | ||
48 | } | ||
49 | |||
50 | return nil | ||
51 | } | ||