Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(234)

Side by Side Diff: identity/identity.go

Issue 6844087: goose: all current code
Patch Set: Created 12 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 package identity
2
3 import (
4 "os"
5 )
6
7 const (
8 AUTH_LEGACY = iota
rog 2012/11/26 12:51:38 authLegacy ?
jameinel 2012/11/26 16:30:58 This one is actually part of the public api. Thoug
rog 2012/11/26 18:27:36 yeah, i saw that. although, given that the auth me
9 AUTH_USERPASS
10 )
11
12 type AuthDetails struct {
rog 2012/11/26 12:51:38 doc comment
13 TokenId string
14 TenantId string
15 UserId string
16 ServiceURLs map[string]string
17 }
18
19 type Credentials struct {
rog 2012/11/26 12:51:38 doc comment
20 URL string // The URL to authenticate against
21 User string // The username to authenticate as
22 Secrets string // The secrets to pass
23 Region string // Region to send requests to
24 TenantName string // The tenant information for this connection
25 }
26
27 type Authenticator interface {
rog 2012/11/26 12:51:38 doc comment - particularly crucial here.
28 Auth(creds *Credentials) (*AuthDetails, error)
29 }
30
31 func getConfig(envVars ...string) (value string) {
32 value = ""
33 for _, v := range envVars {
34 value = os.Getenv(v)
rog 2012/11/26 12:51:38 if value := os.Getenv(v); value != "" { return
35 if value != "" {
36 break
37 }
38 }
39 return
40 }
41
42 func CredentialsFromEnv() *Credentials {
rog 2012/11/26 12:51:38 doc comment. are some of these credentials option
43 return &Credentials{
44 URL: getConfig("OS_AUTH_URL"),
45 User: getConfig("OS_USERNAME", "NOVA_USERNAME"),
46 Secrets: getConfig("OS_PASSWORD", "NOVA_PASSWORD"),
47 Region: getConfig("OS_REGION_NAME", "NOVA_REGION"),
48 TenantName: getConfig("OS_TENANT_NAME", "NOVA_PROJECT_ID"),
49 }
50 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b