diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/bgentry/speakeasy/speakeasy_windows.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/bgentry/speakeasy/speakeasy_windows.go')
-rw-r--r-- | vendor/github.com/bgentry/speakeasy/speakeasy_windows.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/github.com/bgentry/speakeasy/speakeasy_windows.go b/vendor/github.com/bgentry/speakeasy/speakeasy_windows.go new file mode 100644 index 0000000..c2093a8 --- /dev/null +++ b/vendor/github.com/bgentry/speakeasy/speakeasy_windows.go | |||
@@ -0,0 +1,41 @@ | |||
1 | // +build windows | ||
2 | |||
3 | package speakeasy | ||
4 | |||
5 | import ( | ||
6 | "syscall" | ||
7 | ) | ||
8 | |||
9 | // SetConsoleMode function can be used to change value of ENABLE_ECHO_INPUT: | ||
10 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx | ||
11 | const ENABLE_ECHO_INPUT = 0x0004 | ||
12 | |||
13 | func getPassword() (password string, err error) { | ||
14 | var oldMode uint32 | ||
15 | |||
16 | err = syscall.GetConsoleMode(syscall.Stdin, &oldMode) | ||
17 | if err != nil { | ||
18 | return | ||
19 | } | ||
20 | |||
21 | var newMode uint32 = (oldMode &^ ENABLE_ECHO_INPUT) | ||
22 | |||
23 | err = setConsoleMode(syscall.Stdin, newMode) | ||
24 | defer setConsoleMode(syscall.Stdin, oldMode) | ||
25 | if err != nil { | ||
26 | return | ||
27 | } | ||
28 | |||
29 | return readline() | ||
30 | } | ||
31 | |||
32 | func setConsoleMode(console syscall.Handle, mode uint32) (err error) { | ||
33 | dll := syscall.MustLoadDLL("kernel32") | ||
34 | proc := dll.MustFindProc("SetConsoleMode") | ||
35 | r, _, err := proc.Call(uintptr(console), uintptr(mode)) | ||
36 | |||
37 | if r == 0 { | ||
38 | return err | ||
39 | } | ||
40 | return nil | ||
41 | } | ||