Skip to content

Commit 30507ef

Browse files
committed
Chore: Enable style check linter
Signed-off-by: Arve Knudsen <[email protected]>
1 parent c87fc20 commit 30507ef

22 files changed

+145
-157
lines changed

.golangci.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enable = [
3232
"exportloopref",
3333
"staticcheck",
3434
"structcheck",
35-
#"stylecheck",
35+
"stylecheck",
3636
"typecheck",
3737
"unconvert",
3838
"unused",

admin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ func (c *Client) CreateUser(user User) (int64, error) {
2222
}
2323

2424
created := struct {
25-
Id int64 `json:"id"`
25+
ID int64 `json:"id"`
2626
}{}
2727

2828
err = c.request("POST", "/api/admin/users", nil, bytes.NewBuffer(data), &created)
2929
if err != nil {
3030
return id, err
3131
}
3232

33-
return created.Id, err
33+
return created.ID, err
3434
}
3535

3636
// DeleteUser deletes a Grafana user.

alertnotification.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
// AlertNotification represents a Grafana alert notification.
1010
type AlertNotification struct {
11-
Id int64 `json:"id,omitempty"`
12-
Uid string `json:"uid"`
11+
ID int64 `json:"id,omitempty"`
12+
UID string `json:"uid"`
1313
Name string `json:"name"`
1414
Type string `json:"type"`
1515
IsDefault bool `json:"isDefault"`
@@ -50,20 +50,20 @@ func (c *Client) NewAlertNotification(a *AlertNotification) (int64, error) {
5050
return 0, err
5151
}
5252
result := struct {
53-
Id int64 `json:"id"`
53+
ID int64 `json:"id"`
5454
}{}
5555

5656
err = c.request("POST", "/api/alert-notifications", nil, bytes.NewBuffer(data), &result)
5757
if err != nil {
5858
return 0, err
5959
}
6060

61-
return result.Id, err
61+
return result.ID, err
6262
}
6363

6464
// UpdateAlertNotification updates a Grafana alert notification.
6565
func (c *Client) UpdateAlertNotification(a *AlertNotification) error {
66-
path := fmt.Sprintf("/api/alert-notifications/%d", a.Id)
66+
path := fmt.Sprintf("/api/alert-notifications/%d", a.ID)
6767
data, err := json.Marshal(a)
6868
if err != nil {
6969
return err

alertnotification_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestAlertNotifications(t *testing.T) {
8989
if len(alertnotifications) != 1 {
9090
t.Error("Length of returned alert notifications should be 1")
9191
}
92-
if alertnotifications[0].Id != 1 || alertnotifications[0].Name != "Team A" {
92+
if alertnotifications[0].ID != 1 || alertnotifications[0].Name != "Team A" {
9393
t.Error("Not correctly parsing returned alert notifications.")
9494
}
9595
}
@@ -106,7 +106,7 @@ func TestAlertNotification(t *testing.T) {
106106

107107
t.Log(pretty.PrettyFormat(resp))
108108

109-
if resp.Id != alertnotification || resp.Name != "Team A" {
109+
if resp.ID != alertnotification || resp.Name != "Team A" {
110110
t.Error("Not correctly parsing returned alert notification.")
111111
}
112112
}
@@ -143,7 +143,7 @@ func TestUpdateAlertNotification(t *testing.T) {
143143
defer server.Close()
144144

145145
an := &AlertNotification{
146-
Id: 1,
146+
ID: 1,
147147
Name: "Team A",
148148
Type: "email",
149149
IsDefault: false,

dashboard.go

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ type DashboardMeta struct {
1717
// DashboardSaveResponse represents the Grafana API response to creating or saving a dashboard.
1818
type DashboardSaveResponse struct {
1919
Slug string `json:"slug"`
20-
Id int64 `json:"id"`
21-
Uid string `json:"uid"`
20+
ID int64 `json:"id"`
21+
UID string `json:"uid"`
2222
Status string `json:"status"`
2323
Version int64 `json:"version"`
2424
}
2525

2626
// DashboardSearchResponse represents the Grafana API dashboard search response.
2727
type DashboardSearchResponse struct {
28-
Id uint `json:"id"`
29-
Uid string `json:"uid"`
28+
ID uint `json:"id"`
29+
UID string `json:"uid"`
3030
Title string `json:"title"`
31-
Uri string `json:"uri"`
32-
Url string `json:"url"`
31+
URI string `json:"uri"`
32+
URL string `json:"url"`
3333
Slug string `json:"slug"`
3434
Type string `json:"type"`
3535
Tags []string `json:"tags"`
3636
IsStarred bool `json:"isStarred"`
37-
FolderId uint `json:"folderId"`
38-
FolderUid string `json:"folderUid"`
37+
FolderID uint `json:"folderId"`
38+
FolderUID string `json:"folderUid"`
3939
FolderTitle string `json:"folderTitle"`
40-
FolderUrl string `json:"folderUrl"`
40+
FolderURL string `json:"folderUrl"`
4141
}
4242

4343
// Dashboard represents a Grafana dashboard.
@@ -100,19 +100,13 @@ func (c *Client) Dashboards() ([]DashboardSearchResponse, error) {
100100
return dashboards, err
101101
}
102102

103-
// DashboardByUid fetches and returns the dashboard whose UID is passed.
104-
func (c *Client) DashboardByUid(uid string) (*Dashboard, error) {
105-
return c.dashboard(fmt.Sprintf("/api/dashboards/uid/%s", uid))
106-
}
107-
108103
// Dashboard will be removed.
109-
// Deprecated: Starting from Grafana v5.0. Use DashboardByUid instead.
104+
// Deprecated: Starting from Grafana v5.0. Use DashboardByUID instead.
110105
func (c *Client) Dashboard(slug string) (*Dashboard, error) {
111106
return c.dashboard(fmt.Sprintf("/api/dashboards/db/%s", slug))
112107
}
113108

114-
// DashboardByUID will be removed.
115-
// Deprecated: Interface typo. Use DashboardByUid instead.
109+
// DashboardByUID gets a dashboard by UID.
116110
func (c *Client) DashboardByUID(uid string) (*Dashboard, error) {
117111
return c.dashboard(fmt.Sprintf("/api/dashboards/uid/%s", uid))
118112
}
@@ -128,19 +122,13 @@ func (c *Client) dashboard(path string) (*Dashboard, error) {
128122
return result, err
129123
}
130124

131-
// DeleteDashboardByUid deletes the dashboard whose UID it's passed.
132-
func (c *Client) DeleteDashboardByUid(uid string) error {
133-
return c.deleteDashboard(fmt.Sprintf("/api/dashboards/uid/%s", uid))
134-
}
135-
136125
// DeleteDashboard will be removed.
137-
// Deprecated: Starting from Grafana v5.0. Use DeleteDashboardByUid instead.
126+
// Deprecated: Starting from Grafana v5.0. Use DeleteDashboardByUID instead.
138127
func (c *Client) DeleteDashboard(slug string) error {
139128
return c.deleteDashboard(fmt.Sprintf("/api/dashboards/db/%s", slug))
140129
}
141130

142-
// DeleteDashboardByUID will be removed.
143-
// Deprecated: Interface typo. Use DeleteDashboardByUid instead.
131+
// DeleteDashboardByUID deletes a dashboard by UID.
144132
func (c *Client) DeleteDashboardByUID(uid string) error {
145133
return c.deleteDashboard(fmt.Sprintf("/api/dashboards/uid/%s", uid))
146134
}

dashboard_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func TestDashboardCreateAndUpdate(t *testing.T) {
6363

6464
t.Log(pretty.PrettyFormat(resp))
6565

66-
if resp.Uid != "nErXDvCkzz" {
67-
t.Errorf("Invalid uid - %s, Expected %s", resp.Uid, "nErXDvCkzz")
66+
if resp.UID != "nErXDvCkzz" {
67+
t.Errorf("Invalid uid - %s, Expected %s", resp.UID, "nErXDvCkzz")
6868
}
6969

7070
for _, code := range []int{400, 401, 403, 412} {
@@ -89,7 +89,7 @@ func TestDashboardGet(t *testing.T) {
8989
t.Errorf("Invalid uid - %s, Expected %s", uid, "cIBgcSjkk")
9090
}
9191

92-
resp, err = client.DashboardByUid("cIBgcSjkk")
92+
resp, err = client.DashboardByUID("cIBgcSjkk")
9393
if err != nil {
9494
t.Error(err)
9595
}
@@ -105,7 +105,7 @@ func TestDashboardGet(t *testing.T) {
105105
t.Errorf("%d not detected", code)
106106
}
107107

108-
_, err = client.DashboardByUid("cIBgcSjkk")
108+
_, err = client.DashboardByUID("cIBgcSjkk")
109109
if err == nil {
110110
t.Errorf("%d not detected", code)
111111
}
@@ -121,7 +121,7 @@ func TestDashboardDelete(t *testing.T) {
121121
t.Error(err)
122122
}
123123

124-
err = client.DeleteDashboardByUid("cIBgcSjkk")
124+
err = client.DeleteDashboardByUID("cIBgcSjkk")
125125
if err != nil {
126126
t.Error(err)
127127
}
@@ -134,7 +134,7 @@ func TestDashboardDelete(t *testing.T) {
134134
t.Errorf("%d not detected", code)
135135
}
136136

137-
err = client.DeleteDashboardByUid("cIBgcSjkk")
137+
err = client.DeleteDashboardByUID("cIBgcSjkk")
138138
if err == nil {
139139
t.Errorf("%d not detected", code)
140140
}
@@ -156,7 +156,7 @@ func TestDashboards(t *testing.T) {
156156
t.Error("Length of returned dashboards should be 1")
157157
}
158158

159-
if dashboards[0].Id != 1 || dashboards[0].Title != "Grafana Stats" {
159+
if dashboards[0].ID != 1 || dashboards[0].Title != "Grafana Stats" {
160160
t.Error("Not correctly parsing returned dashboards.")
161161
}
162162
}

datasource.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// DataSource represents a Grafana data source.
1010
type DataSource struct {
11-
Id int64 `json:"id,omitempty"`
11+
ID int64 `json:"id,omitempty"`
1212
Name string `json:"name"`
1313
Type string `json:"type"`
1414
URL string `json:"url"`
@@ -19,7 +19,7 @@ type DataSource struct {
1919
// Deprecated: Use secureJsonData.password instead.
2020
Password string `json:"password,omitempty"`
2121

22-
OrgId int64 `json:"orgId,omitempty"`
22+
OrgID int64 `json:"orgId,omitempty"`
2323
IsDefault bool `json:"isDefault"`
2424

2525
BasicAuth bool `json:"basicAuth"`
@@ -34,9 +34,9 @@ type DataSource struct {
3434
// JSONData is a representation of the datasource `jsonData` property
3535
type JSONData struct {
3636
// Used by all datasources
37-
TlsAuth bool `json:"tlsAuth,omitempty"`
38-
TlsAuthWithCACert bool `json:"tlsAuthWithCACert,omitempty"`
39-
TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"`
37+
TLSAuth bool `json:"tlsAuth,omitempty"`
38+
TLSAuthWithCACert bool `json:"tlsAuthWithCACert,omitempty"`
39+
TLSSkipVerify bool `json:"tlsSkipVerify,omitempty"`
4040

4141
// Used by Graphite
4242
GraphiteVersion string `json:"graphiteVersion,omitempty"`
@@ -75,22 +75,22 @@ type JSONData struct {
7575
ConnMaxLifetime int64 `json:"connMaxLifetime,omitempty"`
7676

7777
// Used by Prometheus
78-
HttpMethod string `json:"httpMethod,omitempty"`
78+
HTTPMethod string `json:"httpMethod,omitempty"`
7979
QueryTimeout string `json:"queryTimeout,omitempty"`
8080

8181
// Used by Stackdriver
8282
AuthenticationType string `json:"authenticationType,omitempty"`
8383
ClientEmail string `json:"clientEmail,omitempty"`
8484
DefaultProject string `json:"defaultProject,omitempty"`
85-
TokenUri string `json:"tokenUri,omitempty"`
85+
TokenURI string `json:"tokenUri,omitempty"`
8686
}
8787

8888
// SecureJSONData is a representation of the datasource `secureJsonData` property
8989
type SecureJSONData struct {
9090
// Used by all datasources
91-
TlsCACert string `json:"tlsCACert,omitempty"`
92-
TlsClientCert string `json:"tlsClientCert,omitempty"`
93-
TlsClientKey string `json:"tlsClientKey,omitempty"`
91+
TLSCACert string `json:"tlsCACert,omitempty"`
92+
TLSClientCert string `json:"tlsClientCert,omitempty"`
93+
TLSClientKey string `json:"tlsClientKey,omitempty"`
9494
Password string `json:"password,omitempty"`
9595
BasicAuthPassword string `json:"basicAuthPassword,omitempty"`
9696

@@ -110,20 +110,20 @@ func (c *Client) NewDataSource(s *DataSource) (int64, error) {
110110
}
111111

112112
result := struct {
113-
Id int64 `json:"id"`
113+
ID int64 `json:"id"`
114114
}{}
115115

116116
err = c.request("POST", "/api/datasources", nil, bytes.NewBuffer(data), &result)
117117
if err != nil {
118118
return 0, err
119119
}
120120

121-
return result.Id, err
121+
return result.ID, err
122122
}
123123

124124
// UpdateDataSource updates a Grafana data source.
125125
func (c *Client) UpdateDataSource(s *DataSource) error {
126-
path := fmt.Sprintf("/api/datasources/%d", s.Id)
126+
path := fmt.Sprintf("/api/datasources/%d", s.ID)
127127
data, err := json.Marshal(s)
128128
if err != nil {
129129
return err

datasource_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestNewDataSource(t *testing.T) {
2525
AuthType: "keys",
2626
CustomMetricsNamespaces: "SomeNamespace",
2727
DefaultRegion: "us-east-1",
28-
TlsSkipVerify: true,
28+
TLSSkipVerify: true,
2929
},
3030
SecureJSONData: SecureJSONData{
3131
AccessKey: "123",
@@ -56,7 +56,7 @@ func TestNewPrometheusDataSource(t *testing.T) {
5656
Access: "access",
5757
IsDefault: true,
5858
JSONData: JSONData{
59-
HttpMethod: "POST",
59+
HTTPMethod: "POST",
6060
QueryTimeout: "60s",
6161
TimeInterval: "1m",
6262
},

folder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
// Folder represents a Grafana folder.
1010
type Folder struct {
11-
Id int64 `json:"id"`
12-
Uid string `json:"uid"`
11+
ID int64 `json:"id"`
12+
UID string `json:"uid"`
1313
Title string `json:"title"`
1414
}
1515

folder_permissions.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
// FolderPermission has information such as a folder, user, team, role and permission.
1010
type FolderPermission struct {
11-
Id int64 `json:"id"`
12-
FolderUid string `json:"uid"`
13-
UserId int64 `json:"userId"`
14-
TeamId int64 `json:"teamId"`
11+
ID int64 `json:"id"`
12+
FolderUID string `json:"uid"`
13+
UserID int64 `json:"userId"`
14+
TeamID int64 `json:"teamId"`
1515
Role string `json:"role"`
1616
IsFolder bool `json:"isFolder"`
1717

@@ -23,8 +23,8 @@ type FolderPermission struct {
2323
PermissionName string `json:"permissionName"`
2424

2525
// optional fields
26-
FolderId int64 `json:"folderId,omitempty"`
27-
DashboardId int64 `json:"dashboardId,omitempty"`
26+
FolderID int64 `json:"folderId,omitempty"`
27+
DashboardID int64 `json:"dashboardId,omitempty"`
2828
}
2929

3030
// PermissionItems represents Grafana folder permission items.
@@ -34,11 +34,11 @@ type PermissionItems struct {
3434

3535
// PermissionItem represents a Grafana folder permission item.
3636
type PermissionItem struct {
37-
// As you can see the docs, each item has a pair of [Role|TeamId|UserId] and Permission.
37+
// As you can see the docs, each item has a pair of [Role|TeamID|UserID] and Permission.
3838
// unnecessary fields are omitted.
3939
Role string `json:"role,omitempty"`
40-
TeamId int64 `json:"teamId,omitempty"`
41-
UserId int64 `json:"userId,omitempty"`
40+
TeamID int64 `json:"teamId,omitempty"`
41+
UserID int64 `json:"userId,omitempty"`
4242
Permission int64 `json:"permission"`
4343
}
4444

0 commit comments

Comments
 (0)