]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/terraform/svchost/auth/static.go
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / svchost / auth / static.go
1 package auth
2
3 import (
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.
12 func StaticCredentialsSource(creds map[svchost.Hostname]map[string]interface{}) CredentialsSource {
13 return staticCredentialsSource(creds)
14 }
15
16 type staticCredentialsSource map[svchost.Hostname]map[string]interface{}
17
18 func (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 }