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