github.com/sathish1597/hashicorp-terraform@v0.11.12-beta1/svchost/auth/static.go (about) 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 }