Skip to content

Commit

Permalink
add debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
briangann committed Jan 25, 2025
1 parent 1b53feb commit 876074f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/kiosk/apikey_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ func GrafanaKioskAPIKey(cfg *Config, messages chan string) {
// handle both scheme/host, and subpath with query
if strings.HasPrefix(ev.Request.URL, u.Scheme+"://"+u.Host) &&
strings.Contains(ev.Request.URL, "/api/ds/query?") {
log.Println("Appending Content-Type Header for Metric Query")
if cfg.General.DebugEnabled {
log.Println("Appending Content-Type Header for Metric Query")
}
fetchReq.Headers = append(
fetchReq.Headers,
&fetch.HeaderEntry{Name: "content-type", Value: "application/json"},
)
}
// if they match, append the Bearer token
if requestURL.Host == u.Host {
log.Println("Appending Header Authorization: Bearer REDACTED")
if cfg.General.DebugEnabled {
log.Println("Appending Header Authorization: Bearer REDACTED")
}
fetchReq.Headers = append(
fetchReq.Headers,
&fetch.HeaderEntry{Name: "Authorization", Value: "Bearer " + cfg.APIKey.APIKey},
Expand All @@ -90,6 +94,11 @@ func GrafanaKioskAPIKey(cfg *Config, messages chan string) {
taskCtx,
fetch.Enable().WithPatterns([]*fetch.RequestPattern{{URLPattern: u.Scheme + "://" + u.Host + "/*"}}),
chromedp.Navigate(generatedURL),
chromedp.ActionFunc(func(context.Context) error {
log.Printf("Sleeping %d MS before continuing", cfg.General.PageLoadDelayMS)
time.Sleep(time.Duration(cfg.General.PageLoadDelayMS) * time.Millisecond)
return nil
}),
chromedp.WaitVisible(`//div[@class="main-view"]`, chromedp.BySearch),
); err != nil {
panic(err)
Expand Down

0 comments on commit 876074f

Please sign in to comment.