mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-04-28 21:01:16 -04:00
Update dependencies
This commit is contained in:
2
vendor/github.com/gophercloud/utils/openstack/clientconfig/doc.go
generated
vendored
2
vendor/github.com/gophercloud/utils/openstack/clientconfig/doc.go
generated
vendored
@@ -7,7 +7,7 @@ See https://docs.openstack.org/os-client-config/latest for details.
|
||||
Example to Create a Provider Client From clouds.yaml
|
||||
|
||||
opts := &clientconfig.ClientOpts{
|
||||
Name: "hawaii",
|
||||
Cloud: "hawaii",
|
||||
}
|
||||
|
||||
pClient, err := clientconfig.AuthenticatedClient(opts)
|
||||
|
||||
235
vendor/github.com/gophercloud/utils/openstack/clientconfig/requests.go
generated
vendored
235
vendor/github.com/gophercloud/utils/openstack/clientconfig/requests.go
generated
vendored
@@ -2,12 +2,13 @@ package clientconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack"
|
||||
"github.com/gophercloud/utils/env"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
@@ -56,11 +57,62 @@ type ClientOpts struct {
|
||||
// This will override a region in clouds.yaml or can be used
|
||||
// when authenticating directly with AuthInfo.
|
||||
RegionName string
|
||||
|
||||
// EndpointType specifies whether to use the public, internal, or
|
||||
// admin endpoint of a service.
|
||||
EndpointType string
|
||||
|
||||
// HTTPClient provides the ability customize the ProviderClient's
|
||||
// internal HTTP client.
|
||||
HTTPClient *http.Client
|
||||
|
||||
// YAMLOpts provides the ability to pass a customized set
|
||||
// of options and methods for loading the YAML file.
|
||||
// It takes a YAMLOptsBuilder interface that is defined
|
||||
// in this file. This is optional and the default behavior
|
||||
// is to call the local LoadCloudsYAML functions defined
|
||||
// in this file.
|
||||
YAMLOpts YAMLOptsBuilder
|
||||
}
|
||||
|
||||
// YAMLOptsBuilder defines an interface for customization when
|
||||
// loading a clouds.yaml file.
|
||||
type YAMLOptsBuilder interface {
|
||||
LoadCloudsYAML() (map[string]Cloud, error)
|
||||
LoadSecureCloudsYAML() (map[string]Cloud, error)
|
||||
LoadPublicCloudsYAML() (map[string]Cloud, error)
|
||||
}
|
||||
|
||||
// YAMLOpts represents options and methods to load a clouds.yaml file.
|
||||
type YAMLOpts struct {
|
||||
// By default, no options are specified.
|
||||
}
|
||||
|
||||
// LoadCloudsYAML defines how to load a clouds.yaml file.
|
||||
// By default, this calls the local LoadCloudsYAML function.
|
||||
func (opts YAMLOpts) LoadCloudsYAML() (map[string]Cloud, error) {
|
||||
return LoadCloudsYAML()
|
||||
}
|
||||
|
||||
// LoadSecureCloudsYAML defines how to load a secure.yaml file.
|
||||
// By default, this calls the local LoadSecureCloudsYAML function.
|
||||
func (opts YAMLOpts) LoadSecureCloudsYAML() (map[string]Cloud, error) {
|
||||
return LoadSecureCloudsYAML()
|
||||
}
|
||||
|
||||
// LoadPublicCloudsYAML defines how to load a public-secure.yaml file.
|
||||
// By default, this calls the local LoadPublicCloudsYAML function.
|
||||
func (opts YAMLOpts) LoadPublicCloudsYAML() (map[string]Cloud, error) {
|
||||
return LoadPublicCloudsYAML()
|
||||
}
|
||||
|
||||
// LoadCloudsYAML will load a clouds.yaml file and return the full config.
|
||||
// This is called by the YAMLOpts method. Calling this function directly
|
||||
// is supported for now but has only been retained for backwards
|
||||
// compatibility from before YAMLOpts was defined. This may be removed in
|
||||
// the future.
|
||||
func LoadCloudsYAML() (map[string]Cloud, error) {
|
||||
content, err := findAndReadCloudsYAML()
|
||||
_, content, err := FindAndReadCloudsYAML()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -75,10 +127,14 @@ func LoadCloudsYAML() (map[string]Cloud, error) {
|
||||
}
|
||||
|
||||
// LoadSecureCloudsYAML will load a secure.yaml file and return the full config.
|
||||
// This is called by the YAMLOpts method. Calling this function directly
|
||||
// is supported for now but has only been retained for backwards
|
||||
// compatibility from before YAMLOpts was defined. This may be removed in
|
||||
// the future.
|
||||
func LoadSecureCloudsYAML() (map[string]Cloud, error) {
|
||||
var secureClouds Clouds
|
||||
|
||||
content, err := findAndReadSecureCloudsYAML()
|
||||
_, content, err := FindAndReadSecureCloudsYAML()
|
||||
if err != nil {
|
||||
if err.Error() == "no secure.yaml file found" {
|
||||
// secure.yaml is optional so just ignore read error
|
||||
@@ -96,10 +152,14 @@ func LoadSecureCloudsYAML() (map[string]Cloud, error) {
|
||||
}
|
||||
|
||||
// LoadPublicCloudsYAML will load a public-clouds.yaml file and return the full config.
|
||||
// This is called by the YAMLOpts method. Calling this function directly
|
||||
// is supported for now but has only been retained for backwards
|
||||
// compatibility from before YAMLOpts was defined. This may be removed in
|
||||
// the future.
|
||||
func LoadPublicCloudsYAML() (map[string]Cloud, error) {
|
||||
var publicClouds PublicClouds
|
||||
|
||||
content, err := findAndReadPublicCloudsYAML()
|
||||
_, content, err := FindAndReadPublicCloudsYAML()
|
||||
if err != nil {
|
||||
if err.Error() == "no clouds-public.yaml file found" {
|
||||
// clouds-public.yaml is optional so just ignore read error
|
||||
@@ -119,7 +179,13 @@ func LoadPublicCloudsYAML() (map[string]Cloud, error) {
|
||||
|
||||
// GetCloudFromYAML will return a cloud entry from a clouds.yaml file.
|
||||
func GetCloudFromYAML(opts *ClientOpts) (*Cloud, error) {
|
||||
clouds, err := LoadCloudsYAML()
|
||||
if opts.YAMLOpts == nil {
|
||||
opts.YAMLOpts = new(YAMLOpts)
|
||||
}
|
||||
|
||||
yamlOpts := opts.YAMLOpts
|
||||
|
||||
clouds, err := yamlOpts.LoadCloudsYAML()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load clouds.yaml: %s", err)
|
||||
}
|
||||
@@ -138,7 +204,7 @@ func GetCloudFromYAML(opts *ClientOpts) (*Cloud, error) {
|
||||
envPrefix = opts.EnvPrefix
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "CLOUD"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "CLOUD"); v != "" {
|
||||
cloudName = v
|
||||
}
|
||||
|
||||
@@ -159,32 +225,33 @@ func GetCloudFromYAML(opts *ClientOpts) (*Cloud, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var cloudIsInCloudsYaml bool
|
||||
if cloud == nil {
|
||||
// not an immediate error as it might still be defined in secure.yaml
|
||||
cloudIsInCloudsYaml = false
|
||||
} else {
|
||||
cloudIsInCloudsYaml = true
|
||||
}
|
||||
if cloud != nil {
|
||||
// A profile points to a public cloud entry.
|
||||
// If one was specified, load a list of public clouds
|
||||
// and then merge the information with the current cloud data.
|
||||
profileName := defaultIfEmpty(cloud.Profile, cloud.Cloud)
|
||||
|
||||
publicClouds, err := LoadPublicCloudsYAML()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load clouds-public.yaml: %s", err)
|
||||
}
|
||||
if profileName != "" {
|
||||
publicClouds, err := yamlOpts.LoadPublicCloudsYAML()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load clouds-public.yaml: %s", err)
|
||||
}
|
||||
|
||||
var profileName = defaultIfEmpty(cloud.Profile, cloud.Cloud)
|
||||
if profileName != "" {
|
||||
publicCloud, ok := publicClouds[profileName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cloud %s does not exist in clouds-public.yaml", profileName)
|
||||
}
|
||||
cloud, err = mergeClouds(cloud, publicCloud)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not merge information from clouds.yaml and clouds-public.yaml for cloud %s", profileName)
|
||||
publicCloud, ok := publicClouds[profileName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cloud %s does not exist in clouds-public.yaml", profileName)
|
||||
}
|
||||
|
||||
cloud, err = mergeClouds(cloud, publicCloud)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not merge information from clouds.yaml and clouds-public.yaml for cloud %s", profileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
secureClouds, err := LoadSecureCloudsYAML()
|
||||
// Next, load a secure clouds file and see if a cloud entry
|
||||
// can be found or merged.
|
||||
secureClouds, err := yamlOpts.LoadSecureCloudsYAML()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load secure.yaml: %s", err)
|
||||
}
|
||||
@@ -192,12 +259,13 @@ func GetCloudFromYAML(opts *ClientOpts) (*Cloud, error) {
|
||||
if secureClouds != nil {
|
||||
// If no entry was found in clouds.yaml, no cloud name was specified,
|
||||
// and only one secureCloud entry exists, use that as the cloud entry.
|
||||
if !cloudIsInCloudsYaml && cloudName == "" && len(secureClouds) == 1 {
|
||||
if cloud == nil && cloudName == "" && len(secureClouds) == 1 {
|
||||
for _, v := range secureClouds {
|
||||
cloud = &v
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, see if the provided cloud name exists in the secure yaml file.
|
||||
secureCloud, ok := secureClouds[cloudName]
|
||||
if !ok && cloud == nil {
|
||||
// cloud == nil serves two purposes here:
|
||||
@@ -217,6 +285,12 @@ func GetCloudFromYAML(opts *ClientOpts) (*Cloud, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// As an extra precaution, do one final check to see if cloud is nil.
|
||||
// We shouldn't reach this point, though.
|
||||
if cloud == nil {
|
||||
return nil, fmt.Errorf("Could not find cloud %s", cloudName)
|
||||
}
|
||||
|
||||
// Default is to verify SSL API requests
|
||||
if cloud.Verify == nil {
|
||||
iTrue := true
|
||||
@@ -227,6 +301,17 @@ func GetCloudFromYAML(opts *ClientOpts) (*Cloud, error) {
|
||||
// clouds-public.yml
|
||||
// https://github.com/openstack/openstacksdk/tree/master/openstack/config/vendors
|
||||
|
||||
// Both Interface and EndpointType are valid settings in clouds.yaml,
|
||||
// but we want to standardize on EndpointType for simplicity.
|
||||
//
|
||||
// If only Interface was set, we copy that to EndpointType to use as the setting.
|
||||
// But in all other cases, EndpointType is used and Interface is cleared.
|
||||
if cloud.Interface != "" && cloud.EndpointType == "" {
|
||||
cloud.EndpointType = cloud.Interface
|
||||
}
|
||||
|
||||
cloud.Interface = ""
|
||||
|
||||
return cloud, nil
|
||||
}
|
||||
|
||||
@@ -260,7 +345,7 @@ func AuthOptions(opts *ClientOpts) (*gophercloud.AuthOptions, error) {
|
||||
envPrefix = opts.EnvPrefix
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "CLOUD"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "CLOUD"); v != "" {
|
||||
cloudName = v
|
||||
}
|
||||
|
||||
@@ -310,7 +395,7 @@ func determineIdentityAPI(cloud *Cloud, opts *ClientOpts) string {
|
||||
envPrefix = opts.EnvPrefix
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "IDENTITY_API_VERSION"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "IDENTITY_API_VERSION"); v != "" {
|
||||
identityAPI = v
|
||||
}
|
||||
|
||||
@@ -359,49 +444,49 @@ func v2auth(cloud *Cloud, opts *ClientOpts) (*gophercloud.AuthOptions, error) {
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.AuthURL == "" {
|
||||
if v := os.Getenv(envPrefix + "AUTH_URL"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "AUTH_URL"); v != "" {
|
||||
cloud.AuthInfo.AuthURL = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.Token == "" {
|
||||
if v := os.Getenv(envPrefix + "TOKEN"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "TOKEN"); v != "" {
|
||||
cloud.AuthInfo.Token = v
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "AUTH_TOKEN"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "AUTH_TOKEN"); v != "" {
|
||||
cloud.AuthInfo.Token = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.Username == "" {
|
||||
if v := os.Getenv(envPrefix + "USERNAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "USERNAME"); v != "" {
|
||||
cloud.AuthInfo.Username = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.Password == "" {
|
||||
if v := os.Getenv(envPrefix + "PASSWORD"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PASSWORD"); v != "" {
|
||||
cloud.AuthInfo.Password = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ProjectID == "" {
|
||||
if v := os.Getenv(envPrefix + "TENANT_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "TENANT_ID"); v != "" {
|
||||
cloud.AuthInfo.ProjectID = v
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "PROJECT_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PROJECT_ID"); v != "" {
|
||||
cloud.AuthInfo.ProjectID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ProjectName == "" {
|
||||
if v := os.Getenv(envPrefix + "TENANT_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "TENANT_NAME"); v != "" {
|
||||
cloud.AuthInfo.ProjectName = v
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "PROJECT_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PROJECT_NAME"); v != "" {
|
||||
cloud.AuthInfo.ProjectName = v
|
||||
}
|
||||
}
|
||||
@@ -427,115 +512,115 @@ func v3auth(cloud *Cloud, opts *ClientOpts) (*gophercloud.AuthOptions, error) {
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.AuthURL == "" {
|
||||
if v := os.Getenv(envPrefix + "AUTH_URL"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "AUTH_URL"); v != "" {
|
||||
cloud.AuthInfo.AuthURL = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.Token == "" {
|
||||
if v := os.Getenv(envPrefix + "TOKEN"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "TOKEN"); v != "" {
|
||||
cloud.AuthInfo.Token = v
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "AUTH_TOKEN"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "AUTH_TOKEN"); v != "" {
|
||||
cloud.AuthInfo.Token = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.Username == "" {
|
||||
if v := os.Getenv(envPrefix + "USERNAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "USERNAME"); v != "" {
|
||||
cloud.AuthInfo.Username = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.UserID == "" {
|
||||
if v := os.Getenv(envPrefix + "USER_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "USER_ID"); v != "" {
|
||||
cloud.AuthInfo.UserID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.Password == "" {
|
||||
if v := os.Getenv(envPrefix + "PASSWORD"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PASSWORD"); v != "" {
|
||||
cloud.AuthInfo.Password = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ProjectID == "" {
|
||||
if v := os.Getenv(envPrefix + "TENANT_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "TENANT_ID"); v != "" {
|
||||
cloud.AuthInfo.ProjectID = v
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "PROJECT_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PROJECT_ID"); v != "" {
|
||||
cloud.AuthInfo.ProjectID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ProjectName == "" {
|
||||
if v := os.Getenv(envPrefix + "TENANT_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "TENANT_NAME"); v != "" {
|
||||
cloud.AuthInfo.ProjectName = v
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "PROJECT_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PROJECT_NAME"); v != "" {
|
||||
cloud.AuthInfo.ProjectName = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.DomainID == "" {
|
||||
if v := os.Getenv(envPrefix + "DOMAIN_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "DOMAIN_ID"); v != "" {
|
||||
cloud.AuthInfo.DomainID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.DomainName == "" {
|
||||
if v := os.Getenv(envPrefix + "DOMAIN_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "DOMAIN_NAME"); v != "" {
|
||||
cloud.AuthInfo.DomainName = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.DefaultDomain == "" {
|
||||
if v := os.Getenv(envPrefix + "DEFAULT_DOMAIN"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "DEFAULT_DOMAIN"); v != "" {
|
||||
cloud.AuthInfo.DefaultDomain = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ProjectDomainID == "" {
|
||||
if v := os.Getenv(envPrefix + "PROJECT_DOMAIN_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PROJECT_DOMAIN_ID"); v != "" {
|
||||
cloud.AuthInfo.ProjectDomainID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ProjectDomainName == "" {
|
||||
if v := os.Getenv(envPrefix + "PROJECT_DOMAIN_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "PROJECT_DOMAIN_NAME"); v != "" {
|
||||
cloud.AuthInfo.ProjectDomainName = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.UserDomainID == "" {
|
||||
if v := os.Getenv(envPrefix + "USER_DOMAIN_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "USER_DOMAIN_ID"); v != "" {
|
||||
cloud.AuthInfo.UserDomainID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.UserDomainName == "" {
|
||||
if v := os.Getenv(envPrefix + "USER_DOMAIN_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "USER_DOMAIN_NAME"); v != "" {
|
||||
cloud.AuthInfo.UserDomainName = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ApplicationCredentialID == "" {
|
||||
if v := os.Getenv(envPrefix + "APPLICATION_CREDENTIAL_ID"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "APPLICATION_CREDENTIAL_ID"); v != "" {
|
||||
cloud.AuthInfo.ApplicationCredentialID = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ApplicationCredentialName == "" {
|
||||
if v := os.Getenv(envPrefix + "APPLICATION_CREDENTIAL_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "APPLICATION_CREDENTIAL_NAME"); v != "" {
|
||||
cloud.AuthInfo.ApplicationCredentialName = v
|
||||
}
|
||||
}
|
||||
|
||||
if cloud.AuthInfo.ApplicationCredentialSecret == "" {
|
||||
if v := os.Getenv(envPrefix + "APPLICATION_CREDENTIAL_SECRET"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "APPLICATION_CREDENTIAL_SECRET"); v != "" {
|
||||
cloud.AuthInfo.ApplicationCredentialSecret = v
|
||||
}
|
||||
}
|
||||
@@ -643,7 +728,7 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
|
||||
envPrefix = opts.EnvPrefix
|
||||
}
|
||||
|
||||
if v := os.Getenv(envPrefix + "CLOUD"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "CLOUD"); v != "" {
|
||||
cloudName = v
|
||||
}
|
||||
|
||||
@@ -663,10 +748,15 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If an HTTPClient was specified, use it.
|
||||
if opts.HTTPClient != nil {
|
||||
pClient.HTTPClient = *opts.HTTPClient
|
||||
}
|
||||
|
||||
// Determine the region to use.
|
||||
// First, check if the REGION_NAME environment variable is set.
|
||||
var region string
|
||||
if v := os.Getenv(envPrefix + "REGION_NAME"); v != "" {
|
||||
if v := env.Getenv(envPrefix + "REGION_NAME"); v != "" {
|
||||
region = v
|
||||
}
|
||||
|
||||
@@ -681,8 +771,27 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
|
||||
region = v
|
||||
}
|
||||
|
||||
// Determine the endpoint type to use.
|
||||
// First, check if the OS_INTERFACE environment variable is set.
|
||||
var endpointType string
|
||||
if v := env.Getenv(envPrefix + "INTERFACE"); v != "" {
|
||||
endpointType = v
|
||||
}
|
||||
|
||||
// Next, check if the cloud entry sets an endpoint type.
|
||||
if v := cloud.EndpointType; v != "" {
|
||||
endpointType = v
|
||||
}
|
||||
|
||||
// Finally, see if one was specified in the ClientOpts.
|
||||
// If so, this takes precedence.
|
||||
if v := opts.EndpointType; v != "" {
|
||||
endpointType = v
|
||||
}
|
||||
|
||||
eo := gophercloud.EndpointOpts{
|
||||
Region: region,
|
||||
Region: region,
|
||||
Availability: GetEndpointType(endpointType),
|
||||
}
|
||||
|
||||
switch service {
|
||||
@@ -692,6 +801,8 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
|
||||
return openstack.NewComputeV2(pClient, eo)
|
||||
case "container":
|
||||
return openstack.NewContainerV1(pClient, eo)
|
||||
case "container-infra":
|
||||
return openstack.NewContainerInfraV1(pClient, eo)
|
||||
case "database":
|
||||
return openstack.NewDBV1(pClient, eo)
|
||||
case "dns":
|
||||
|
||||
64
vendor/github.com/gophercloud/utils/openstack/clientconfig/results.go
generated
vendored
64
vendor/github.com/gophercloud/utils/openstack/clientconfig/results.go
generated
vendored
@@ -16,106 +16,112 @@ type Clouds struct {
|
||||
|
||||
// Cloud represents an entry in a clouds.yaml/public-clouds.yaml/secure.yaml file.
|
||||
type Cloud struct {
|
||||
Cloud string `yaml:"cloud" json:"cloud"`
|
||||
Profile string `yaml:"profile" json:"profile"`
|
||||
AuthInfo *AuthInfo `yaml:"auth" json:"auth"`
|
||||
AuthType AuthType `yaml:"auth_type" json:"auth_type"`
|
||||
RegionName string `yaml:"region_name" json:"region_name"`
|
||||
Regions []interface{} `yaml:"regions" json:"regions"`
|
||||
Cloud string `yaml:"cloud,omitempty" json:"cloud,omitempty"`
|
||||
Profile string `yaml:"profile,omitempty" json:"profile,omitempty"`
|
||||
AuthInfo *AuthInfo `yaml:"auth,omitempty" json:"auth,omitempty"`
|
||||
AuthType AuthType `yaml:"auth_type,omitempty" json:"auth_type,omitempty"`
|
||||
RegionName string `yaml:"region_name,omitempty" json:"region_name,omitempty"`
|
||||
Regions []interface{} `yaml:"regions,omitempty" json:"regions,omitempty"`
|
||||
|
||||
// EndpointType and Interface both specify whether to use the public, internal,
|
||||
// or admin interface of a service. They should be considered synonymous, but
|
||||
// EndpointType will take precedence when both are specified.
|
||||
EndpointType string `yaml:"endpoint_type,omitempty" json:"endpoint_type,omitempty"`
|
||||
Interface string `yaml:"interface,omitempty" json:"interface,omitempty"`
|
||||
|
||||
// API Version overrides.
|
||||
IdentityAPIVersion string `yaml:"identity_api_version" json:"identity_api_version"`
|
||||
VolumeAPIVersion string `yaml:"volume_api_version" json:"volume_api_version"`
|
||||
IdentityAPIVersion string `yaml:"identity_api_version,omitempty" json:"identity_api_version,omitempty"`
|
||||
VolumeAPIVersion string `yaml:"volume_api_version,omitempty" json:"volume_api_version,omitempty"`
|
||||
|
||||
// Verify whether or not SSL API requests should be verified.
|
||||
Verify *bool `yaml:"verify" json:"verify"`
|
||||
Verify *bool `yaml:"verify,omitempty" json:"verify,omitempty"`
|
||||
|
||||
// CACertFile a path to a CA Cert bundle that can be used as part of
|
||||
// verifying SSL API requests.
|
||||
CACertFile string `yaml:"cacert" json:"cacert"`
|
||||
CACertFile string `yaml:"cacert,omitempty" json:"cacert,omitempty"`
|
||||
|
||||
// ClientCertFile a path to a client certificate to use as part of the SSL
|
||||
// transaction.
|
||||
ClientCertFile string `yaml:"cert" json:"cert"`
|
||||
ClientCertFile string `yaml:"cert,omitempty" json:"cert,omitempty"`
|
||||
|
||||
// ClientKeyFile a path to a client key to use as part of the SSL
|
||||
// transaction.
|
||||
ClientKeyFile string `yaml:"key" json:"key"`
|
||||
ClientKeyFile string `yaml:"key,omitempty" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
// AuthInfo represents the auth section of a cloud entry or
|
||||
// auth options entered explicitly in ClientOpts.
|
||||
type AuthInfo struct {
|
||||
// AuthURL is the keystone/identity endpoint URL.
|
||||
AuthURL string `yaml:"auth_url" json:"auth_url"`
|
||||
AuthURL string `yaml:"auth_url,omitempty" json:"auth_url,omitempty"`
|
||||
|
||||
// Token is a pre-generated authentication token.
|
||||
Token string `yaml:"token" json:"token"`
|
||||
Token string `yaml:"token,omitempty" json:"token,omitempty"`
|
||||
|
||||
// Username is the username of the user.
|
||||
Username string `yaml:"username" json:"username"`
|
||||
Username string `yaml:"username,omitempty" json:"username,omitempty"`
|
||||
|
||||
// UserID is the unique ID of a user.
|
||||
UserID string `yaml:"user_id" json:"user_id"`
|
||||
UserID string `yaml:"user_id,omitempty" json:"user_id,omitempty"`
|
||||
|
||||
// Password is the password of the user.
|
||||
Password string `yaml:"password" json:"password"`
|
||||
Password string `yaml:"password,omitempty" json:"password,omitempty"`
|
||||
|
||||
// Application Credential ID to login with.
|
||||
ApplicationCredentialID string `yaml:"application_credential_id" json:"application_credential_id"`
|
||||
ApplicationCredentialID string `yaml:"application_credential_id,omitempty" json:"application_credential_id,omitempty"`
|
||||
|
||||
// Application Credential name to login with.
|
||||
ApplicationCredentialName string `yaml:"application_credential_name" json:"application_credential_name"`
|
||||
ApplicationCredentialName string `yaml:"application_credential_name,omitempty" json:"application_credential_name,omitempty"`
|
||||
|
||||
// Application Credential secret to login with.
|
||||
ApplicationCredentialSecret string `yaml:"application_credential_secret" json:"application_credential_secret"`
|
||||
ApplicationCredentialSecret string `yaml:"application_credential_secret,omitempty" json:"application_credential_secret,omitempty"`
|
||||
|
||||
// ProjectName is the common/human-readable name of a project.
|
||||
// Users can be scoped to a project.
|
||||
// ProjectName on its own is not enough to ensure a unique scope. It must
|
||||
// also be combined with either a ProjectDomainName or ProjectDomainID.
|
||||
// ProjectName cannot be combined with ProjectID in a scope.
|
||||
ProjectName string `yaml:"project_name" json:"project_name"`
|
||||
ProjectName string `yaml:"project_name,omitempty" json:"project_name,omitempty"`
|
||||
|
||||
// ProjectID is the unique ID of a project.
|
||||
// It can be used to scope a user to a specific project.
|
||||
ProjectID string `yaml:"project_id" json:"project_id"`
|
||||
ProjectID string `yaml:"project_id,omitempty" json:"project_id,omitempty"`
|
||||
|
||||
// UserDomainName is the name of the domain where a user resides.
|
||||
// It is used to identify the source domain of a user.
|
||||
UserDomainName string `yaml:"user_domain_name" json:"user_domain_name"`
|
||||
UserDomainName string `yaml:"user_domain_name,omitempty" json:"user_domain_name,omitempty"`
|
||||
|
||||
// UserDomainID is the unique ID of the domain where a user resides.
|
||||
// It is used to identify the source domain of a user.
|
||||
UserDomainID string `yaml:"user_domain_id" json:"user_domain_id"`
|
||||
UserDomainID string `yaml:"user_domain_id,omitempty" json:"user_domain_id,omitempty"`
|
||||
|
||||
// ProjectDomainName is the name of the domain where a project resides.
|
||||
// It is used to identify the source domain of a project.
|
||||
// ProjectDomainName can be used in addition to a ProjectName when scoping
|
||||
// a user to a specific project.
|
||||
ProjectDomainName string `yaml:"project_domain_name" json:"project_domain_name"`
|
||||
ProjectDomainName string `yaml:"project_domain_name,omitempty" json:"project_domain_name,omitempty"`
|
||||
|
||||
// ProjectDomainID is the name of the domain where a project resides.
|
||||
// It is used to identify the source domain of a project.
|
||||
// ProjectDomainID can be used in addition to a ProjectName when scoping
|
||||
// a user to a specific project.
|
||||
ProjectDomainID string `yaml:"project_domain_id" json:"project_domain_id"`
|
||||
ProjectDomainID string `yaml:"project_domain_id,omitempty" json:"project_domain_id,omitempty"`
|
||||
|
||||
// DomainName is the name of a domain which can be used to identify the
|
||||
// source domain of either a user or a project.
|
||||
// If UserDomainName and ProjectDomainName are not specified, then DomainName
|
||||
// is used as a default choice.
|
||||
// It can also be used be used to specify a domain-only scope.
|
||||
DomainName string `yaml:"domain_name" json:"domain_name"`
|
||||
DomainName string `yaml:"domain_name,omitempty" json:"domain_name,omitempty"`
|
||||
|
||||
// DomainID is the unique ID of a domain which can be used to identify the
|
||||
// source domain of eitehr a user or a project.
|
||||
// If UserDomainID and ProjectDomainID are not specified, then DomainID is
|
||||
// used as a default choice.
|
||||
// It can also be used be used to specify a domain-only scope.
|
||||
DomainID string `yaml:"domain_id" json:"domain_id"`
|
||||
DomainID string `yaml:"domain_id,omitempty" json:"domain_id,omitempty"`
|
||||
|
||||
// DefaultDomain is the domain ID to fall back on if no other domain has
|
||||
// been specified and a domain is required for scope.
|
||||
DefaultDomain string `yaml:"default_domain" json:"default_domain"`
|
||||
DefaultDomain string `yaml:"default_domain,omitempty" json:"default_domain,omitempty"`
|
||||
}
|
||||
|
||||
52
vendor/github.com/gophercloud/utils/openstack/clientconfig/utils.go
generated
vendored
52
vendor/github.com/gophercloud/utils/openstack/clientconfig/utils.go
generated
vendored
@@ -8,6 +8,9 @@ import (
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/utils/env"
|
||||
)
|
||||
|
||||
// defaultIfEmpty is a helper function to make it cleaner to set default value
|
||||
@@ -87,7 +90,7 @@ func mergeInterfaces(overridingInterface, inferiorInterface interface{}) interfa
|
||||
}
|
||||
}
|
||||
|
||||
// findAndReadCloudsYAML attempts to locate a clouds.yaml file in the following
|
||||
// FindAndReadCloudsYAML attempts to locate a clouds.yaml file in the following
|
||||
// locations:
|
||||
//
|
||||
// 1. OS_CLIENT_CONFIG_FILE
|
||||
@@ -96,35 +99,37 @@ func mergeInterfaces(overridingInterface, inferiorInterface interface{}) interfa
|
||||
// 4. unix-specific site_config_dir (/etc/openstack/clouds.yaml)
|
||||
//
|
||||
// If found, the contents of the file is returned.
|
||||
func findAndReadCloudsYAML() ([]byte, error) {
|
||||
func FindAndReadCloudsYAML() (string, []byte, error) {
|
||||
// OS_CLIENT_CONFIG_FILE
|
||||
if v := os.Getenv("OS_CLIENT_CONFIG_FILE"); v != "" {
|
||||
if v := env.Getenv("OS_CLIENT_CONFIG_FILE"); v != "" {
|
||||
if ok := fileExists(v); ok {
|
||||
return ioutil.ReadFile(v)
|
||||
content, err := ioutil.ReadFile(v)
|
||||
return v, content, err
|
||||
}
|
||||
}
|
||||
|
||||
return findAndReadYAML("clouds.yaml")
|
||||
return FindAndReadYAML("clouds.yaml")
|
||||
}
|
||||
|
||||
func findAndReadPublicCloudsYAML() ([]byte, error) {
|
||||
return findAndReadYAML("clouds-public.yaml")
|
||||
func FindAndReadPublicCloudsYAML() (string, []byte, error) {
|
||||
return FindAndReadYAML("clouds-public.yaml")
|
||||
}
|
||||
|
||||
func findAndReadSecureCloudsYAML() ([]byte, error) {
|
||||
return findAndReadYAML("secure.yaml")
|
||||
func FindAndReadSecureCloudsYAML() (string, []byte, error) {
|
||||
return FindAndReadYAML("secure.yaml")
|
||||
}
|
||||
|
||||
func findAndReadYAML(yamlFile string) ([]byte, error) {
|
||||
func FindAndReadYAML(yamlFile string) (string, []byte, error) {
|
||||
// current directory
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to determine working directory: %s", err)
|
||||
return "", nil, fmt.Errorf("unable to determine working directory: %s", err)
|
||||
}
|
||||
|
||||
filename := filepath.Join(cwd, yamlFile)
|
||||
if ok := fileExists(filename); ok {
|
||||
return ioutil.ReadFile(filename)
|
||||
content, err := ioutil.ReadFile(filename)
|
||||
return filename, content, err
|
||||
}
|
||||
|
||||
// unix user config directory: ~/.config/openstack.
|
||||
@@ -133,17 +138,20 @@ func findAndReadYAML(yamlFile string) ([]byte, error) {
|
||||
if homeDir != "" {
|
||||
filename := filepath.Join(homeDir, ".config/openstack/"+yamlFile)
|
||||
if ok := fileExists(filename); ok {
|
||||
return ioutil.ReadFile(filename)
|
||||
content, err := ioutil.ReadFile(filename)
|
||||
return filename, content, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unix-specific site config directory: /etc/openstack.
|
||||
if ok := fileExists("/etc/openstack/" + yamlFile); ok {
|
||||
return ioutil.ReadFile("/etc/openstack/" + yamlFile)
|
||||
filename = "/etc/openstack/" + yamlFile
|
||||
if ok := fileExists(filename); ok {
|
||||
content, err := ioutil.ReadFile(filename)
|
||||
return filename, content, err
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no " + yamlFile + " file found")
|
||||
return "", nil, fmt.Errorf("no " + yamlFile + " file found")
|
||||
}
|
||||
|
||||
// fileExists checks for the existence of a file at a given location.
|
||||
@@ -153,3 +161,15 @@ func fileExists(filename string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// GetEndpointType is a helper method to determine the endpoint type
|
||||
// requested by the user.
|
||||
func GetEndpointType(endpointType string) gophercloud.Availability {
|
||||
if endpointType == "internal" || endpointType == "internalURL" {
|
||||
return gophercloud.AvailabilityInternal
|
||||
}
|
||||
if endpointType == "admin" || endpointType == "adminURL" {
|
||||
return gophercloud.AvailabilityAdmin
|
||||
}
|
||||
return gophercloud.AvailabilityPublic
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user