Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit ab37cb6

Browse files
committed
Change OrgID from string to int64
1 parent 0221d94 commit ab37cb6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

client.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/url"
1212
"os"
1313
"path"
14+
"strconv"
1415

1516
"github.com/hashicorp/go-cleanhttp"
1617
)
@@ -31,7 +32,7 @@ type Config struct {
3132
// Client provides an optional HTTP client, otherwise a default will be used.
3233
Client *http.Client
3334
// OrgID provides an optional organization ID, ignored when using APIKey, BasicAuth defaults to last used org
34-
OrgID string
35+
OrgID int64
3536
}
3637

3738
// New creates a new Grafana client.
@@ -105,8 +106,8 @@ func (c *Client) newRequest(method, requestPath string, query url.Values, body i
105106

106107
if c.config.APIKey != "" {
107108
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.config.APIKey))
108-
} else if c.config.OrgID != "" {
109-
req.Header.Add("X-Grafana-Org-Id", c.config.OrgID)
109+
} else if c.config.OrgID != 0 {
110+
req.Header.Add("X-Grafana-Org-Id", strconv.FormatInt(c.config.OrgID, 10))
110111
}
111112

112113
if os.Getenv("GF_LOG") != "" {

client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestNew_tokenAuth(t *testing.T) {
3737
}
3838

3939
func TestNew_orgId(t *testing.T) {
40-
const orgID = "456"
40+
const orgID = 456
4141
c, err := New("http://my-grafana.com", Config{OrgID: orgID})
4242
if err != nil {
4343
t.Fatalf("expected error to be nil; got: %s", err.Error())
@@ -49,7 +49,7 @@ func TestNew_orgId(t *testing.T) {
4949
}
5050

5151
if c.config.OrgID != orgID {
52-
t.Errorf("expected error: %s; got: %s", orgID, c.config.OrgID)
52+
t.Errorf("expected error: %d; got: %d", orgID, c.config.OrgID)
5353
}
5454
}
5555

0 commit comments

Comments
 (0)