forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.go
28 lines (22 loc) · 767 Bytes
/
static.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package auth
import (
"github.com/hashicorp/terraform/svchost"
)
// StaticCredentialsSource is a credentials source that retrieves credentials
// from the provided map. It returns nil if a requested hostname is not
// present in the map.
//
// The caller should not modify the given map after passing it to this function.
func StaticCredentialsSource(creds map[svchost.Hostname]map[string]interface{}) CredentialsSource {
return staticCredentialsSource(creds)
}
type staticCredentialsSource map[svchost.Hostname]map[string]interface{}
func (s staticCredentialsSource) ForHost(host svchost.Hostname) (HostCredentials, error) {
if s == nil {
return nil, nil
}
if m, exists := s[host]; exists {
return HostCredentialsFromMap(m), nil
}
return nil, nil
}