1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/juju/cloud"
8
"github.com/juju/juju/provider/openstack"
11
// Credentials represents openstack credentials specifically tailored
12
// to rackspace. Mostly this means that they're appropriate for the v2 API, and
13
// thus there's no domain name.
14
type Credentials struct {
15
openstack.OpenstackCredentials
18
// CredentialSchemas is part of the environs.ProviderCredentials interface.
19
func (c Credentials) CredentialSchemas() map[cloud.AuthType]cloud.CredentialSchema {
20
m := c.OpenstackCredentials.CredentialSchemas()
21
schema := m[cloud.UserPassAuthType]
22
// remove domain name from attributes.
23
for i, attr := range schema {
24
if attr.Name == openstack.CredAttrDomainName {
25
m[cloud.UserPassAuthType] = append(schema[:i], schema[i+1:]...)
32
// DetectCredentials is part of the environs.ProviderCredentials interface.
33
func (c Credentials) DetectCredentials() (*cloud.CloudCredential, error) {
34
result, err := c.OpenstackCredentials.DetectCredentials()
38
// delete domain name from creds, since rackspace doesn't use it, and it
40
for k, v := range result.AuthCredentials {
41
attr := v.Attributes()
42
if _, ok := attr[openstack.CredAttrDomainName]; ok {
43
delete(attr, openstack.CredAttrDomainName)
44
result.AuthCredentials[k] = cloud.NewCredential(v.AuthType(), attr)