Skip to content

Commit

Permalink
Update file backend to allow optional http headers
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavyHorst committed Nov 1, 2019
1 parent a2558a4 commit 82eedfb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/content/config/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ See the example configuration to see how global default values can be set for in

- **filepath(string):**
- The filepath to a yaml or json file containing the key-value pairs. This can be a local file or a remote http/https location.
- **httpheader(map[string]string):**
- Optional HTTP-headers to append to the request if the file path is a remote http/https location.
</details>

<details>
Expand Down
1 change: 1 addition & 0 deletions docs/content/config/sample-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ log_file = "/var/log/remco.log"
keys = ["/"]
[resource.backend.file]
httpheader = { X-Test-Token = "XXX", X-Test-Token2 = "YYY" }
filepath = "/etc/remco/test.yml"
watch = true
keys = ["/prefix"]
Expand Down
1 change: 1 addition & 0 deletions integration/file/file.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ log_format = "text"
[resource.backend.file]
onetime = true
filepath = "./integration/file/config.yml"
httpheader = { X-Test-Token = "XXX", X-Test-Token2 = "YYY" }
keys = ["/"]
5 changes: 4 additions & 1 deletion pkg/backends/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type FileConfig struct {
// The filepath to a yaml or json file containing the key-value pairs.
// This can be a local file or a remote http/https location.
Filepath string

// Optional HTTP headers to append to the request if the file path is a remote http/https location.
HTTPHeader map[string]string
template.Backend
}

Expand All @@ -36,7 +39,7 @@ func (c *FileConfig) Connect() (template.Backend, error) {
"filepath": c.Filepath,
}).Info("set file path")

client, err := file.New(c.Filepath)
client, err := file.New(c.Filepath, file.WithHeaders(c.HTTPHeader))
if err != nil {
return c.Backend, err
}
Expand Down

0 comments on commit 82eedfb

Please sign in to comment.