Skip to content

Commit

Permalink
Merge branch 'endpoint-via-env' into 'main'
Browse files Browse the repository at this point in the history
Support endpoint via env var

See github pull request #1
  • Loading branch information
ldaneliukas authored and kjschubert committed Sep 29, 2023
2 parents 1fac7e8 + 526db1a commit f4c4b26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ description: |-

### Required

- `endpoint` (String) RGW Endpoint URL
- `endpoint` (String) RGW Endpoint URL. Can be set via env 'TF_PROVIDER_RGW_ENDPOINT'

### Optional

Expand Down
6 changes: 5 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (p *RgwProvider) Schema(ctx context.Context, req provider.SchemaRequest, re
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"endpoint": schema.StringAttribute{
MarkdownDescription: "RGW Endpoint URL",
MarkdownDescription: "RGW Endpoint URL. Can be set via env 'TF_PROVIDER_RGW_ENDPOINT'",
Required: true,
},
"access_key": schema.StringAttribute{
Expand All @@ -71,6 +71,10 @@ func (p *RgwProvider) Configure(ctx context.Context, req provider.ConfigureReque
return
}

if data.Endpoint.IsNull() {
data.Endpoint = types.StringValue(os.Getenv("TF_PROVIDER_RGW_ENDPOINT"))
}

if data.AccessKey.IsNull() {
data.AccessKey = types.StringValue(os.Getenv("TF_PROVIDER_RGW_ACCESS_KEY"))
}
Expand Down

0 comments on commit f4c4b26

Please sign in to comment.