Skip to content

Commit 4d98c54

Browse files
authored
health check updates (#288)
1 parent 18c1f24 commit 4d98c54

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ cypress/report.json
1111

1212
.eslintcache
1313
__debug_bin
14+
mage_output_file.go

pkg/github/datasource.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package github
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"github.com/grafana/github-datasource/pkg/dfutil"
89
githubclient "github.com/grafana/github-datasource/pkg/github/client"
@@ -183,10 +184,13 @@ func (d *Datasource) HandleWorkflowUsageQuery(ctx context.Context, query *models
183184
// CheckHealth is the health check for GitHub
184185
func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
185186
_, err := GetAllRepositories(ctx, d.client, models.ListRepositoriesOptions{
186-
Owner: "grafana",
187+
Owner: "grafana",
188+
Repository: "github-datasource",
187189
})
188-
189190
if err != nil {
191+
if strings.Contains(err.Error(), "401 Unauthorized") {
192+
return newHealthResult(backend.HealthStatusError, "401 Unauthorized. check your API key/Access token")
193+
}
190194
return newHealthResult(backend.HealthStatusError, "Health check failed")
191195
}
192196

0 commit comments

Comments
 (0)