aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/svchost/auth/static.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/svchost/auth/static.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/svchost/auth/static.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/svchost/auth/static.go b/vendor/github.com/hashicorp/terraform/svchost/auth/static.go
new file mode 100644
index 0000000..5373fdd
--- /dev/null
+++ b/vendor/github.com/hashicorp/terraform/svchost/auth/static.go
@@ -0,0 +1,28 @@
1package auth
2
3import (
4 "github.com/hashicorp/terraform/svchost"
5)
6
7// StaticCredentialsSource is a credentials source that retrieves credentials
8// from the provided map. It returns nil if a requested hostname is not
9// present in the map.
10//
11// The caller should not modify the given map after passing it to this function.
12func StaticCredentialsSource(creds map[svchost.Hostname]map[string]interface{}) CredentialsSource {
13 return staticCredentialsSource(creds)
14}
15
16type staticCredentialsSource map[svchost.Hostname]map[string]interface{}
17
18func (s staticCredentialsSource) ForHost(host svchost.Hostname) (HostCredentials, error) {
19 if s == nil {
20 return nil, nil
21 }
22
23 if m, exists := s[host]; exists {
24 return HostCredentialsFromMap(m), nil
25 }
26
27 return nil, nil
28}