Skip to content

Commit 4c1f05b

Browse files
committed
fix: create certs dir before writing integration token file
1 parent 36f8665 commit 4c1f05b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • collectors/forwarder/listeners

collectors/forwarder/listeners/auth.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
stdhttp "net/http"
1111
"os"
12+
"path/filepath"
1213
"strings"
1314
)
1415

@@ -88,6 +89,11 @@ func GenerateTokenFile(path string) (string, error) {
8889
return "", fmt.Errorf("generate token: %w", err)
8990
}
9091
token := hex.EncodeToString(b)
92+
if dir := filepath.Dir(path); dir != "" {
93+
if err := os.MkdirAll(dir, 0700); err != nil {
94+
return "", fmt.Errorf("write token file: create dir: %w", err)
95+
}
96+
}
9197
if err := os.WriteFile(path, []byte(token+"\n"), 0600); err != nil {
9298
return "", fmt.Errorf("write token file: %w", err)
9399
}

0 commit comments

Comments
 (0)