Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AKSKOptionsFromEnv ¶ added in v1.0.21
func AKSKOptionsFromEnv() (aksk.AKSKOptions, error)
AKSKOptionsFromEnv fills out an aksk.AKSKOptions structure with the settings found on the various HWCLOUD_* environment variables.
The following variables provide sources of truth: HWCLOUD_AUTH_URL, HWCLOUD_ACCESS_KEY, HWCLOUD_SECRET_KEY, HWCLOUD_ACCESS_KEY_STS_TOKEN, and HWCLOUD_PROJECT_ID,HWCLOUD_DOMAIN_ID,HWCLOUD_REGION,HWCLOUD_DOMAIN_NAME.
Of these, HWCLOUD_AUTH_URL, HWCLOUD_ACCESS_KEY, and HWCLOUD_SECRET_KEY must have settings, or an error will result.The rest of others are optional.
To use this function, first set the HWCLOUD_* environment variables (for example, by sourcing an `openrc` file), or use os.Setenv() function :
os.Setenv("HWCLOUD_AUTH_URL", "https://iam.xxx.yyy.com/v3") os.Setenv("HWCLOUD_ACCESS_KEY", "{your AK string}") os.Setenv("HWCLOUD_SECRET_KEY", "{your SK string}")
then:
opts, err := auth.AKSKOptionsFromEnv() if err != nil { if ue, ok := err.(*gophercloud.UnifiedError); ok { fmt.Println("ErrCode:", ue.ErrorCode()) fmt.Println("Message:", ue.Message()) } return } provider, err := openstack.AuthenticatedClient(opts)
Now use the provider, you can initialize the serviceClient.
func TokenOptionsFromEnv ¶
func TokenOptionsFromEnv() (token.TokenOptions, error)
TokenOptionsFromEnv fills out an token.TokenOptions structure with the settings found on the various OpenStack OS_* environment variables.
The following variables provide sources of truth: OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, OS_TENANT_ID, and OS_TENANT_NAME.
Of these, OS_USERNAME, OS_PASSWORD, and OS_AUTH_URL must have settings, or an error will result. OS_TENANT_ID, OS_TENANT_NAME, OS_PROJECT_ID, and OS_PROJECT_NAME are optional.
OS_TENANT_ID and OS_TENANT_NAME are mutually exclusive to OS_PROJECT_ID and OS_PROJECT_NAME. If OS_PROJECT_ID and OS_PROJECT_NAME are set, they will still be referred as "tenant" in Gophercloud.
To use this function, first set the OS_* environment variables (for example, by sourcing an `openrc` file),or use os.Setenv() function :
os.Setenv("OS_AUTH_URL", "https://iam.xxx.yyy.com/v3") os.Setenv("OS_USERNAME", "{your user name}") os.Setenv("OS_PASSWORD", "{your password }")
then:
opts, err := auth.TokenOptionsFromEnv() if err != nil { if ue, ok := err.(*gophercloud.UnifiedError); ok { fmt.Println("ErrCode:", ue.ErrorCode()) fmt.Println("Message:", ue.Message()) } return } provider, err := openstack.AuthenticatedClient(opts)
Now use the provider, you can initialize the serviceClient.
Types ¶
type AuthOptionsProvider ¶
type AuthOptionsProvider interface { GetIdentityEndpoint() string GetProjectId() string GetDomainId() string }
AuthOptionsProvider presents the base of an auth options implementation
Directories ¶
Path | Synopsis |
---|---|
Package signer providers functions for sign http request before request cloud.
|
Package signer providers functions for sign http request before request cloud. |
Package token providers functions for initial http request body before request cloud.
|
Package token providers functions for initial http request body before request cloud. |