Skip to content

Commit adb441e

Browse files
huydxhuydx
authored andcommitted
(format) run go fmt in pkg
1 parent 63bf332 commit adb441e

File tree

12 files changed

+78
-79
lines changed

12 files changed

+78
-79
lines changed

pkg/api/login_oauth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func OAuthLogin(ctx *middleware.Context) {
5555
ctx.Session.Set(middleware.SESS_KEY_OAUTH_STATE, state)
5656
if setting.OAuthService.OAuthInfos[name].HostedDomain == "" {
5757
ctx.Redirect(connect.AuthCodeURL(state, oauth2.AccessTypeOnline))
58-
}else{
59-
ctx.Redirect(connect.AuthCodeURL(state, oauth2.SetParam("hd", setting.OAuthService.OAuthInfos[name].HostedDomain), oauth2.AccessTypeOnline));
58+
} else {
59+
ctx.Redirect(connect.AuthCodeURL(state, oauth2.SetParam("hd", setting.OAuthService.OAuthInfos[name].HostedDomain), oauth2.AccessTypeOnline))
6060
}
6161
return
6262
}
@@ -90,8 +90,8 @@ func OAuthLogin(ctx *middleware.Context) {
9090
tr := &http.Transport{
9191
TLSClientConfig: &tls.Config{
9292
InsecureSkipVerify: true,
93-
Certificates: []tls.Certificate{cert},
94-
RootCAs: caCertPool,
93+
Certificates: []tls.Certificate{cert},
94+
RootCAs: caCertPool,
9595
},
9696
}
9797
sslcli := &http.Client{Transport: tr}

pkg/bus/bus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
type HandlerFunc interface{}
10-
type CtxHandlerFunc func()
10+
type CtxHandlerFunc func()
1111
type Msg interface{}
1212

1313
type Bus interface {

pkg/middleware/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
SESS_KEY_USERID = "uid"
15+
SESS_KEY_USERID = "uid"
1616
SESS_KEY_OAUTH_STATE = "state"
1717
)
1818

pkg/services/sqlstore/migrator/mysql_dialect.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ func (db *Mysql) AutoIncrStr() string {
3131

3232
func (db *Mysql) BooleanStr(value bool) string {
3333
if value {
34-
return "1"
35-
}
36-
return "0"
34+
return "1"
35+
}
36+
return "0"
3737
}
3838

3939
func (db *Mysql) SqlType(c *Column) string {

pkg/services/sqlstore/sqlstore.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ import (
2323
_ "github.com/mattn/go-sqlite3"
2424
)
2525

26-
2726
type DatabaseConfig struct {
28-
Type, Host, Name, User, Pwd, Path, SslMode string
29-
CaCertPath string
30-
ClientKeyPath string
31-
ClientCertPath string
32-
ServerCertName string
27+
Type, Host, Name, User, Pwd, Path, SslMode string
28+
CaCertPath string
29+
ClientKeyPath string
30+
ClientCertPath string
31+
ServerCertName string
3332
}
3433

3534
var (
@@ -38,10 +37,10 @@ var (
3837

3938
HasEngine bool
4039

41-
DbCfg DatabaseConfig
40+
DbCfg DatabaseConfig
4241

43-
UseSQLite3 bool
44-
sqlog log.Logger = log.New("sqlstore")
42+
UseSQLite3 bool
43+
sqlog log.Logger = log.New("sqlstore")
4544
)
4645

4746
func EnsureAdminUser() {
@@ -187,9 +186,9 @@ func LoadConfig() {
187186
UseSQLite3 = true
188187
}
189188
DbCfg.SslMode = sec.Key("ssl_mode").String()
190-
DbCfg.CaCertPath = sec.Key("ca_cert_path").String()
191-
DbCfg.ClientKeyPath = sec.Key("client_key_path").String()
192-
DbCfg.ClientCertPath = sec.Key("client_cert_path").String()
193-
DbCfg.ServerCertName = sec.Key("server_cert_name").String()
189+
DbCfg.CaCertPath = sec.Key("ca_cert_path").String()
190+
DbCfg.ClientKeyPath = sec.Key("client_key_path").String()
191+
DbCfg.ClientCertPath = sec.Key("client_cert_path").String()
192+
DbCfg.ServerCertName = sec.Key("server_cert_name").String()
194193
DbCfg.Path = sec.Key("path").MustString("data/grafana.db")
195194
}

pkg/social/generic_oauth.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) {
181181
}
182182

183183
userInfo := &BasicUserInfo{
184-
Name: data.Name,
185-
Login: data.Login,
186-
Email: data.Email,
184+
Name: data.Name,
185+
Login: data.Login,
186+
Email: data.Email,
187187
}
188188

189-
if (userInfo.Email == "" && data.Attributes["email:primary"] != nil) {
189+
if userInfo.Email == "" && data.Attributes["email:primary"] != nil {
190190
userInfo.Email = data.Attributes["email:primary"][0]
191191
}
192192

@@ -197,11 +197,11 @@ func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) {
197197
}
198198
}
199199

200-
if (userInfo.Login == "" && data.Username != "") {
200+
if userInfo.Login == "" && data.Username != "" {
201201
userInfo.Login = data.Username
202202
}
203203

204-
if (userInfo.Login == "") {
204+
if userInfo.Login == "" {
205205
userInfo.Login = data.Email
206206
}
207207

pkg/social/github_oauth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ func (s *SocialGithub) UserInfo(client *http.Client) (*BasicUserInfo, error) {
187187
}
188188

189189
userInfo := &BasicUserInfo{
190-
Name: data.Login,
191-
Login: data.Login,
192-
Email: data.Email,
190+
Name: data.Login,
191+
Login: data.Login,
192+
Email: data.Email,
193193
}
194194

195195
if !s.IsTeamMember(client) {

pkg/social/google_oauth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func (s *SocialGoogle) UserInfo(client *http.Client) (*BasicUserInfo, error) {
4545
return nil, err
4646
}
4747
return &BasicUserInfo{
48-
Name: data.Name,
49-
Email: data.Email,
50-
Login: data.Email,
48+
Name: data.Name,
49+
Email: data.Email,
50+
Login: data.Email,
5151
}, nil
5252
}

pkg/social/grafananet_oauth.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func (s *SocialGrafanaNet) IsOrganizationMember(organizations []OrgRecord) bool
5050

5151
func (s *SocialGrafanaNet) UserInfo(client *http.Client) (*BasicUserInfo, error) {
5252
var data struct {
53-
Name string `json:"name"`
54-
Login string `json:"username"`
55-
Email string `json:"email"`
56-
Role string `json:"role"`
53+
Name string `json:"name"`
54+
Login string `json:"username"`
55+
Email string `json:"email"`
56+
Role string `json:"role"`
5757
Orgs []OrgRecord `json:"orgs"`
5858
}
5959

@@ -70,10 +70,10 @@ func (s *SocialGrafanaNet) UserInfo(client *http.Client) (*BasicUserInfo, error)
7070
}
7171

7272
userInfo := &BasicUserInfo{
73-
Name: data.Name,
74-
Login: data.Login,
75-
Email: data.Email,
76-
Role: data.Role,
73+
Name: data.Name,
74+
Login: data.Login,
75+
Email: data.Email,
76+
Role: data.Role,
7777
}
7878

7979
if !s.IsOrganizationMember(data.Orgs) {

pkg/social/social.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
type BasicUserInfo struct {
14-
Name string
15-
Email string
16-
Login string
17-
Company string
18-
Role string
14+
Name string
15+
Email string
16+
Login string
17+
Company string
18+
Role string
1919
}
2020

2121
type SocialConnector interface {
@@ -91,11 +91,11 @@ func NewOAuthService() {
9191
// Google.
9292
if name == "google" {
9393
SocialMap["google"] = &SocialGoogle{
94-
Config: &config,
95-
allowedDomains: info.AllowedDomains,
96-
hostedDomain: info.HostedDomain,
97-
apiUrl: info.ApiUrl,
98-
allowSignup: info.AllowSignup,
94+
Config: &config,
95+
allowedDomains: info.AllowedDomains,
96+
hostedDomain: info.HostedDomain,
97+
apiUrl: info.ApiUrl,
98+
allowSignup: info.AllowSignup,
9999
}
100100
}
101101

@@ -115,12 +115,12 @@ func NewOAuthService() {
115115
config = oauth2.Config{
116116
ClientID: info.ClientId,
117117
ClientSecret: info.ClientSecret,
118-
Endpoint: oauth2.Endpoint{
119-
AuthURL: setting.GrafanaNetUrl + "/oauth2/authorize",
120-
TokenURL: setting.GrafanaNetUrl + "/api/oauth2/token",
118+
Endpoint: oauth2.Endpoint{
119+
AuthURL: setting.GrafanaNetUrl + "/oauth2/authorize",
120+
TokenURL: setting.GrafanaNetUrl + "/api/oauth2/token",
121121
},
122-
RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name,
123-
Scopes: info.Scopes,
122+
RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name,
123+
Scopes: info.Scopes,
124124
}
125125

126126
SocialMap["grafananet"] = &SocialGrafanaNet{

pkg/tsdb/opentsdb/opentsdb_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package opentsdb
33
import (
44
"testing"
55

6+
"github.com/grafana/grafana/pkg/components/simplejson"
67
"github.com/grafana/grafana/pkg/tsdb"
78
. "github.com/smartystreets/goconvey/convey"
8-
"github.com/grafana/grafana/pkg/components/simplejson"
99
)
1010

1111
func TestOpenTsdbExecutor(t *testing.T) {
@@ -23,8 +23,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
2323
query.Model.Set("aggregator", "avg")
2424
query.Model.Set("disableDownsampling", false)
2525
query.Model.Set("downsampleInterval", "")
26-
query.Model.Set("downsampleAggregator","avg")
27-
query.Model.Set("downsampleFillPolicy","none")
26+
query.Model.Set("downsampleAggregator", "avg")
27+
query.Model.Set("downsampleFillPolicy", "none")
2828

2929
metric := exec.buildMetric(query)
3030

@@ -45,15 +45,15 @@ func TestOpenTsdbExecutor(t *testing.T) {
4545
query.Model.Set("aggregator", "avg")
4646
query.Model.Set("disableDownsampling", true)
4747
query.Model.Set("downsampleInterval", "")
48-
query.Model.Set("downsampleAggregator","avg")
49-
query.Model.Set("downsampleFillPolicy","none")
48+
query.Model.Set("downsampleAggregator", "avg")
49+
query.Model.Set("downsampleFillPolicy", "none")
5050

5151
metric := exec.buildMetric(query)
5252

5353
So(len(metric), ShouldEqual, 2)
5454
So(metric["metric"], ShouldEqual, "cpu.average.percent")
5555
So(metric["aggregator"], ShouldEqual, "avg")
56-
56+
5757
})
5858

5959
Convey("Build metric with downsampling enabled with params", func() {
@@ -66,8 +66,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
6666
query.Model.Set("aggregator", "avg")
6767
query.Model.Set("disableDownsampling", false)
6868
query.Model.Set("downsampleInterval", "5m")
69-
query.Model.Set("downsampleAggregator","sum")
70-
query.Model.Set("downsampleFillPolicy","null")
69+
query.Model.Set("downsampleAggregator", "sum")
70+
query.Model.Set("downsampleFillPolicy", "null")
7171

7272
metric := exec.buildMetric(query)
7373

@@ -87,8 +87,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
8787
query.Model.Set("aggregator", "avg")
8888
query.Model.Set("disableDownsampling", true)
8989
query.Model.Set("downsampleInterval", "5m")
90-
query.Model.Set("downsampleAggregator","sum")
91-
query.Model.Set("downsampleFillPolicy","null")
90+
query.Model.Set("downsampleAggregator", "sum")
91+
query.Model.Set("downsampleFillPolicy", "null")
9292

9393
tags := simplejson.New()
9494
tags.Set("env", "prod")
@@ -117,8 +117,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
117117
query.Model.Set("aggregator", "avg")
118118
query.Model.Set("disableDownsampling", true)
119119
query.Model.Set("shouldComputeRate", true)
120-
query.Model.Set("isCounter",false)
121-
120+
query.Model.Set("isCounter", false)
121+
122122
tags := simplejson.New()
123123
tags.Set("env", "prod")
124124
tags.Set("app", "grafana")
@@ -147,9 +147,9 @@ func TestOpenTsdbExecutor(t *testing.T) {
147147
query.Model.Set("aggregator", "avg")
148148
query.Model.Set("disableDownsampling", true)
149149
query.Model.Set("shouldComputeRate", true)
150-
query.Model.Set("isCounter",true)
151-
query.Model.Set("counterMax",45)
152-
query.Model.Set("counterResetValue",60)
150+
query.Model.Set("isCounter", true)
151+
query.Model.Set("counterMax", 45)
152+
query.Model.Set("counterResetValue", 60)
153153

154154
tags := simplejson.New()
155155
tags.Set("env", "prod")
@@ -173,4 +173,4 @@ func TestOpenTsdbExecutor(t *testing.T) {
173173
})
174174

175175
})
176-
}
176+
}

pkg/tsdb/opentsdb/types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package opentsdb
22

33
type OpenTsdbQuery struct {
4-
Start int64 `json:"start"`
5-
End int64 `json:"end"`
6-
Queries []map[string]interface{} `json:"queries"`
4+
Start int64 `json:"start"`
5+
End int64 `json:"end"`
6+
Queries []map[string]interface{} `json:"queries"`
77
}
88

99
type OpenTsdbResponse struct {
10-
Metric string `json:"metric"`
11-
DataPoints map[string]float64 `json:"dps"`
12-
}
10+
Metric string `json:"metric"`
11+
DataPoints map[string]float64 `json:"dps"`
12+
}

0 commit comments

Comments
 (0)