Skip to content

Commit

Permalink
Populate headers from config differently (#79)
Browse files Browse the repository at this point in the history
Seems that `.String()` additional quotes on the string it returns. We
should use `StringValue()`, but it's not available on the elements.
`ElementsAs()` should resolve this.
  • Loading branch information
tdabasinskas committed Jan 5, 2024
2 parents d270781 + 5826951 commit 85cf4ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions backstage/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ func (p *backstageProvider) Configure(ctx context.Context, req provider.Configur
}
} else {
if !config.Headers.IsNull() {
for k, v := range config.Headers.Elements() {
headers[k] = v.String()
}
config.Headers.ElementsAs(ctx, &headers, true)
}
}

Expand Down
3 changes: 3 additions & 0 deletions backstage/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (

const testAccProviderConfig = `
provider "backstage" {
headers = {
"Custom-Header" = "header_value"
}
}
`

Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ provider "backstage" {
base_url = "https://demo.backstage.io"
# Override the name of default namespace:
default_namespace = "custom-default"
# Set custom headers (might be useful for authentication):
headers = {
"Custom-Header" = "header_value"
}
}
```

Expand Down
4 changes: 4 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ provider "backstage" {
base_url = "https://demo.backstage.io"
# Override the name of default namespace:
default_namespace = "custom-default"
# Set custom headers (might be useful for authentication):
headers = {
"Custom-Header" = "header_value"
}
}

0 comments on commit 85cf4ed

Please sign in to comment.