Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional config keys for swift #4901

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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