~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/openstack/credentials.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
        "fmt"
8
8
        "os"
9
9
        "path/filepath"
 
10
        "regexp"
10
11
 
11
12
        "github.com/juju/errors"
12
13
        "github.com/juju/utils"
22
23
func (OpenstackCredentials) CredentialSchemas() map[cloud.AuthType]cloud.CredentialSchema {
23
24
        return map[cloud.AuthType]cloud.CredentialSchema{
24
25
                cloud.UserPassAuthType: {
25
 
                        "username": {
26
 
                                Description: "The username to authenticate with.",
27
 
                        },
28
 
                        "password": {
29
 
                                Description: "The password for the specified username.",
30
 
                                Hidden:      true,
31
 
                        },
32
 
                        "tenant-name": {
33
 
                                Description: "The OpenStack tenant name.",
 
26
                        {
 
27
                                "username", cloud.CredentialAttr{Description: "The username to authenticate with."},
 
28
                        }, {
 
29
                                "password", cloud.CredentialAttr{
 
30
                                        Description: "The password for the specified username.",
 
31
                                        Hidden:      true,
 
32
                                },
 
33
                        }, {
 
34
                                "tenant-name", cloud.CredentialAttr{Description: "The OpenStack tenant name."},
 
35
                        }, {
 
36
                                "domain-name", cloud.CredentialAttr{
 
37
                                        Description: "The OpenStack domain name.",
 
38
                                        Optional:    true,
 
39
                                },
34
40
                        },
35
41
                },
36
42
                cloud.AccessKeyAuthType: {
37
 
                        "access-key": {
38
 
                                Description: "The access key to authenticate with.",
39
 
                        },
40
 
                        "secret-key": {
41
 
                                Description: "The secret key to authenticate with.",
42
 
                                Hidden:      true,
43
 
                        },
44
 
                        "tenant-name": {
45
 
                                Description: "The OpenStack tenant name.",
 
43
                        {
 
44
                                "access-key", cloud.CredentialAttr{Description: "The access key to authenticate with."},
 
45
                        }, {
 
46
                                "secret-key", cloud.CredentialAttr{
 
47
                                        Description: "The secret key to authenticate with.",
 
48
                                        Hidden:      true,
 
49
                                },
 
50
                        }, {
 
51
                                "tenant-name", cloud.CredentialAttr{Description: "The OpenStack tenant name."},
46
52
                        },
47
53
                },
48
54
        }
67
73
        if err != nil {
68
74
                return nil, errors.Annotate(err, "loading novarc file")
69
75
        }
 
76
        stripExport := regexp.MustCompile(`(?i)^\s*export\s*`)
70
77
        keyValues := novaInfo.Section(ini.DEFAULT_SECTION).KeysHash()
71
78
        if len(keyValues) > 0 {
72
79
                for k, v := range keyValues {
 
80
                        k = stripExport.ReplaceAllString(k, "")
73
81
                        os.Setenv(k, v)
74
82
                }
75
83
                creds, user, region, err := c.detectCredential()
111
119
                                "username":    creds.User,
112
120
                                "password":    creds.Secrets,
113
121
                                "tenant-name": creds.TenantName,
 
122
                                "domain-name": creds.DomainName,
114
123
                        },
115
124
                )
116
125
        } else {