From cf587cf525593cf840944ff54ad3a00b148eb313 Mon Sep 17 00:00:00 2001 From: "Md. Nure Alam Nahid" Date: Wed, 11 Jul 2018 08:29:29 -0700 Subject: [PATCH] Add additional config keys for swift (#4901) * Add additional config keys for swift * Add additional swift config keys in the doc page --- physical/swift/swift.go | 26 +++++++++++++++++++ physical/swift/swift_test.go | 6 +++++ .../docs/configuration/storage/swift.html.md | 17 ++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/physical/swift/swift.go b/physical/swift/swift.go index 3689d13f1c..37f5b4f4e8 100644 --- a/physical/swift/swift.go +++ b/physical/swift/swift.go @@ -85,6 +85,27 @@ func NewSwiftBackend(conf map[string]string, logger log.Logger) (physical.Backen projectDomain = conf["project-domain"] } + region := os.Getenv("OS_REGION_NAME") + if region == "" { + region = conf["region"] + } + tenantID := os.Getenv("OS_TENANT_ID") + if tenantID == "" { + tenantID = conf["tenant_id"] + } + trustID := os.Getenv("OS_TRUST_ID") + if trustID == "" { + trustID = conf["trust_id"] + } + storageUrl := os.Getenv("OS_STORAGE_URL") + if storageUrl == "" { + storageUrl = conf["storage_url"] + } + authToken := os.Getenv("OS_AUTH_TOKEN") + if authToken == "" { + authToken = conf["auth_token"] + } + c := swift.Connection{ Domain: domain, UserName: username, @@ -92,6 +113,11 @@ func NewSwiftBackend(conf map[string]string, logger log.Logger) (physical.Backen AuthUrl: authUrl, Tenant: project, TenantDomain: projectDomain, + Region: region, + TenantId: tenantID, + TrustId: trustID, + StorageUrl: storageUrl, + AuthToken: authToken, Transport: cleanhttp.DefaultPooledTransport(), } diff --git a/physical/swift/swift_test.go b/physical/swift/swift_test.go index 70980aed68..db0a075d86 100644 --- a/physical/swift/swift_test.go +++ b/physical/swift/swift_test.go @@ -25,6 +25,8 @@ func TestSwiftBackend(t *testing.T) { project := os.Getenv("OS_PROJECT_NAME") domain := os.Getenv("OS_USER_DOMAIN_NAME") projectDomain := os.Getenv("OS_PROJECT_DOMAIN_NAME") + region := os.Getenv("OS_REGION_NAME") + tenantID := os.Getenv("OS_TENANT_ID") ts := time.Now().UnixNano() container := fmt.Sprintf("vault-test-%d", ts) @@ -36,6 +38,8 @@ func TestSwiftBackend(t *testing.T) { AuthUrl: authUrl, Tenant: project, TenantDomain: projectDomain, + Region: region, + TenantId: tenantID, Transport: cleanhttp.DefaultPooledTransport(), } @@ -75,6 +79,8 @@ func TestSwiftBackend(t *testing.T) { "project": project, "domain": domain, "project-domain": projectDomain, + "tenant_id": tenantID, + "region": region, }, logger) if err != nil { t.Fatalf("err: %s", err) diff --git a/website/source/docs/configuration/storage/swift.html.md b/website/source/docs/configuration/storage/swift.html.md index f512bd9472..7c24bdf31e 100644 --- a/website/source/docs/configuration/storage/swift.html.md +++ b/website/source/docs/configuration/storage/swift.html.md @@ -33,8 +33,7 @@ storage "swift" { ## `swift` Parameters - `auth_url` `(string: )` – Specifies the OpenStack authentication - endpoint. Currently only v1.0 authentication endpoints are supported. This can - also be provided via the environment variable `OS_AUTH_URL`. + endpoint. This can also be provided via the environment variable `OS_AUTH_URL`. - `container` `(string: )` – Specifies the name of the Swift container. This can also be provided via the environment variable @@ -52,6 +51,20 @@ storage "swift" { - `username` `(string: )` – Specifies the OpenStack account/username. This can also be provided via the environment variable `OS_USERNAME`. +- `region` `(string: "")` – Specifies the name of the region. This can also be provided via the environment variable `OS_REGION_NAME`. + +- `tenant_id` `(string: "")` - Specifies the id of the tenant. This can also be provided via the environment variable `OS_TENANT_ID`. + +- `domain` `(string: "")` - Specifies the name of the user domain. This can also be provided via the environment variable `OS_USER_DOMAIN_NAME`. + +- `project-domain` `(string: "")` - Specifies the name of the project's domain. This can also be provided via the environment variable `OS_PROJECT_DOMAIN_NAME`. + +- `trust_id` `(string: "")` - Specifies the id of the trust. This can also be provided via the environment variable `OS_TRUST_ID`. + +- `storage_url` `(string: "")` - Specifies storage URL from alternate authentication. This can also be provided via the environment variable `OS_STORAGE_URL`. + +- `auth_token` `(string: "")` - Specifies auth token from alternate authentication. This can also be provided via the environment variable `OS_AUTH_TOKEN`. + ## `swift` Examples ### Default Example