Skip to content

Commit

Permalink
Remove secret file existence check in Validate for headers
Browse files Browse the repository at this point in the history
This commit removes the check for the existence of the secret file for
headers in the `Validate` function. The check is not valid for relative
paths since `Validate` is called before `SetDirectory`, which is
responsible for setting up the environment. This change aligns with the
handling of other secret files, which are not checked during config
validation.

Signed-off-by: Julien <[email protected]>
  • Loading branch information
roidelapluie committed Sep 3, 2024
1 parent 06c2425 commit d64a747
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
9 changes: 1 addition & 8 deletions config/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,10 @@ func (h *Headers) SetDirectory(dir string) {

// Validate validates the Headers config.
func (h *Headers) Validate() error {
for n, header := range h.Headers {
for n := range h.Headers {
if _, ok := reservedHeaders[http.CanonicalHeaderKey(n)]; ok {
return fmt.Errorf("setting header %q is not allowed", http.CanonicalHeaderKey(n))
}
for _, v := range header.Files {
f := JoinDir(h.dir, v)
_, err := os.ReadFile(f)
if err != nil {
return fmt.Errorf("unable to read header %q from file %s: %w", http.CanonicalHeaderKey(n), f, err)
}
}
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion config/http_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ type basicAuthRoundTripper struct {

// NewBasicAuthRoundTripper will apply a BASIC auth authorization header to a request unless it has
// already been set.
func NewBasicAuthRoundTripper(username SecretReader, password SecretReader, rt http.RoundTripper) http.RoundTripper {
func NewBasicAuthRoundTripper(username, password SecretReader, rt http.RoundTripper) http.RoundTripper {
return &basicAuthRoundTripper{username, password, rt}
}

Expand Down
2 changes: 1 addition & 1 deletion config/http_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ func getCertificateBlobs(t *testing.T) map[string][]byte {
return bs
}

func writeCertificate(bs map[string][]byte, src string, dst string) {
func writeCertificate(bs map[string][]byte, src, dst string) {
b, ok := bs[src]
if !ok {
panic(fmt.Sprintf("Couldn't find %q in bs", src))
Expand Down

0 comments on commit d64a747

Please sign in to comment.