diff --git a/.gitignore b/.gitignore index 382f3498..6cbe4306 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ cypress/report.json .eslintcache __debug_bin +mage_output_file.go \ No newline at end of file diff --git a/pkg/github/datasource.go b/pkg/github/datasource.go index 82196194..32eb0108 100644 --- a/pkg/github/datasource.go +++ b/pkg/github/datasource.go @@ -3,6 +3,7 @@ package github import ( "context" "fmt" + "strings" "github.com/grafana/github-datasource/pkg/dfutil" githubclient "github.com/grafana/github-datasource/pkg/github/client" @@ -183,10 +184,13 @@ func (d *Datasource) HandleWorkflowUsageQuery(ctx context.Context, query *models // CheckHealth is the health check for GitHub func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) { _, err := GetAllRepositories(ctx, d.client, models.ListRepositoriesOptions{ - Owner: "grafana", + Owner: "grafana", + Repository: "github-datasource", }) - if err != nil { + if strings.Contains(err.Error(), "401 Unauthorized") { + return newHealthResult(backend.HealthStatusError, "401 Unauthorized. check your API key/Access token") + } return newHealthResult(backend.HealthStatusError, "Health check failed") }