diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/svchost/auth/from_map.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/svchost/auth/from_map.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/svchost/auth/from_map.go b/vendor/github.com/hashicorp/terraform/svchost/auth/from_map.go new file mode 100644 index 0000000..f91006a --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/svchost/auth/from_map.go | |||
@@ -0,0 +1,18 @@ | |||
1 | package auth | ||
2 | |||
3 | // HostCredentialsFromMap converts a map of key-value pairs from a credentials | ||
4 | // definition provided by the user (e.g. in a config file, or via a credentials | ||
5 | // helper) into a HostCredentials object if possible, or returns nil if | ||
6 | // no credentials could be extracted from the map. | ||
7 | // | ||
8 | // This function ignores map keys it is unfamiliar with, to allow for future | ||
9 | // expansion of the credentials map format for new credential types. | ||
10 | func HostCredentialsFromMap(m map[string]interface{}) HostCredentials { | ||
11 | if m == nil { | ||
12 | return nil | ||
13 | } | ||
14 | if token, ok := m["token"].(string); ok { | ||
15 | return HostCredentialsToken(token) | ||
16 | } | ||
17 | return nil | ||
18 | } | ||