func (c *Client) Authenticate(d *openstack.Driver) error {
	if c.Provider != nil {
		return nil
	}

	log.Debug("Authenticating to Rackspace.", map[string]string{
		"Username": d.Username,
	})

	apiKey := c.driver.APIKey
	opts := gophercloud.AuthOptions{
		Username: d.Username,
		APIKey:   apiKey,
	}

	provider, err := rackspace.NewClient(rackspace.RackspaceUSIdentity)
	if err != nil {
		return err
	}

	provider.UserAgent.Prepend(fmt.Sprintf("docker-machine/v%d", version.APIVersion))

	err = rackspace.Authenticate(provider, opts)
	if err != nil {
		return err
	}

	c.Provider = provider

	return nil
}
func (c *Client) Authenticate(d *openstack.Driver) error {
	if c.Provider != nil {
		return nil
	}

	log.Debug("Authenticating to Rackspace.", map[string]string{
		"Username": d.Username,
	})

	apiKey := c.driver.APIKey
	opts := gophercloud.AuthOptions{
		Username: d.Username,
		APIKey:   apiKey,
	}

	provider, err := rackspace.NewClient(rackspace.RackspaceUSIdentity)
	if err != nil {
		return err
	}

	provider.UserAgent.Prepend(fmt.Sprintf("docker-machine/v%d", version.APIVersion))

	err = rackspace.Authenticate(provider, opts)
	if err != nil {
		return err
	}

	c.Provider = provider

	return nil
}
func ( c * Client ) Authenticate ( d * openstack . Driver ) error { if c . Provider != nil { return nil } log . Debug ( " " , map [ string ] string { " " : d . Username , } ) apiKey := c . driver . APIKey opts := gophercloud . AuthOptions { Username : d . Username , APIKey : apiKey , } provider , err := rackspace . NewClient ( rackspace . RackspaceUSIdentity ) if err != nil { return err } provider . UserAgent . Prepend ( fmt . Sprintf ( " " , version . APIVersion ) ) err = rackspace . Authenticate ( provider , opts ) if err != nil { return err } c . Provider = provider return nil }
// Authenticate creates a Rackspace-specific Gophercloud client.
Authenticate creates a Rackspace - specific Gophercloud client .