Skip to content

Commit

Permalink
Add additional config keys for swift (#4901)
Browse files Browse the repository at this point in the history
* Add additional config keys for swift

* Add additional swift config keys in the doc page
  • Loading branch information
Md. Nure Alam Nahid authored and briankassouf committed Jul 11, 2018
1 parent ff8becc commit cf587cf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
26 changes: 26 additions & 0 deletions physical/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,39 @@ 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,
ApiKey: password,
AuthUrl: authUrl,
Tenant: project,
TenantDomain: projectDomain,
Region: region,
TenantId: tenantID,
TrustId: trustID,
StorageUrl: storageUrl,
AuthToken: authToken,
Transport: cleanhttp.DefaultPooledTransport(),
}

Expand Down
6 changes: 6 additions & 0 deletions physical/swift/swift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,6 +38,8 @@ func TestSwiftBackend(t *testing.T) {
AuthUrl: authUrl,
Tenant: project,
TenantDomain: projectDomain,
Region: region,
TenantId: tenantID,
Transport: cleanhttp.DefaultPooledTransport(),
}

Expand Down Expand Up @@ -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)
Expand Down
17 changes: 15 additions & 2 deletions website/source/docs/configuration/storage/swift.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ storage "swift" {
## `swift` Parameters

- `auth_url` `(string: <required>)` – 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: <required>)` – Specifies the name of the Swift
container. This can also be provided via the environment variable
Expand All @@ -52,6 +51,20 @@ storage "swift" {
- `username` `(string: <required>)` – 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
Expand Down

0 comments on commit cf587cf

Please sign in to comment.