Commit 38d8ba8f by Carl Bergquist Committed by GitHub

Merge pull request #6952 from huydx/format-gofmt

(format) run go fmt in pkg
parents 9cd04768 adb441e5
......@@ -55,8 +55,8 @@ func OAuthLogin(ctx *middleware.Context) {
ctx.Session.Set(middleware.SESS_KEY_OAUTH_STATE, state)
if setting.OAuthService.OAuthInfos[name].HostedDomain == "" {
ctx.Redirect(connect.AuthCodeURL(state, oauth2.AccessTypeOnline))
}else{
ctx.Redirect(connect.AuthCodeURL(state, oauth2.SetParam("hd", setting.OAuthService.OAuthInfos[name].HostedDomain), oauth2.AccessTypeOnline));
} else {
ctx.Redirect(connect.AuthCodeURL(state, oauth2.SetParam("hd", setting.OAuthService.OAuthInfos[name].HostedDomain), oauth2.AccessTypeOnline))
}
return
}
......@@ -90,8 +90,8 @@ func OAuthLogin(ctx *middleware.Context) {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
},
}
sslcli := &http.Client{Transport: tr}
......
......@@ -7,7 +7,7 @@ import (
)
type HandlerFunc interface{}
type CtxHandlerFunc func()
type CtxHandlerFunc func()
type Msg interface{}
type Bus interface {
......
......@@ -12,7 +12,7 @@ import (
)
const (
SESS_KEY_USERID = "uid"
SESS_KEY_USERID = "uid"
SESS_KEY_OAUTH_STATE = "state"
)
......
......@@ -31,9 +31,9 @@ func (db *Mysql) AutoIncrStr() string {
func (db *Mysql) BooleanStr(value bool) string {
if value {
return "1"
}
return "0"
return "1"
}
return "0"
}
func (db *Mysql) SqlType(c *Column) string {
......
......@@ -23,13 +23,12 @@ import (
_ "github.com/mattn/go-sqlite3"
)
type DatabaseConfig struct {
Type, Host, Name, User, Pwd, Path, SslMode string
CaCertPath string
ClientKeyPath string
ClientCertPath string
ServerCertName string
Type, Host, Name, User, Pwd, Path, SslMode string
CaCertPath string
ClientKeyPath string
ClientCertPath string
ServerCertName string
}
var (
......@@ -38,10 +37,10 @@ var (
HasEngine bool
DbCfg DatabaseConfig
DbCfg DatabaseConfig
UseSQLite3 bool
sqlog log.Logger = log.New("sqlstore")
UseSQLite3 bool
sqlog log.Logger = log.New("sqlstore")
)
func EnsureAdminUser() {
......@@ -187,9 +186,9 @@ func LoadConfig() {
UseSQLite3 = true
}
DbCfg.SslMode = sec.Key("ssl_mode").String()
DbCfg.CaCertPath = sec.Key("ca_cert_path").String()
DbCfg.ClientKeyPath = sec.Key("client_key_path").String()
DbCfg.ClientCertPath = sec.Key("client_cert_path").String()
DbCfg.ServerCertName = sec.Key("server_cert_name").String()
DbCfg.CaCertPath = sec.Key("ca_cert_path").String()
DbCfg.ClientKeyPath = sec.Key("client_key_path").String()
DbCfg.ClientCertPath = sec.Key("client_cert_path").String()
DbCfg.ServerCertName = sec.Key("server_cert_name").String()
DbCfg.Path = sec.Key("path").MustString("data/grafana.db")
}
......@@ -181,12 +181,12 @@ func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) {
}
userInfo := &BasicUserInfo{
Name: data.Name,
Login: data.Login,
Email: data.Email,
Name: data.Name,
Login: data.Login,
Email: data.Email,
}
if (userInfo.Email == "" && data.Attributes["email:primary"] != nil) {
if userInfo.Email == "" && data.Attributes["email:primary"] != nil {
userInfo.Email = data.Attributes["email:primary"][0]
}
......@@ -197,11 +197,11 @@ func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) {
}
}
if (userInfo.Login == "" && data.Username != "") {
if userInfo.Login == "" && data.Username != "" {
userInfo.Login = data.Username
}
if (userInfo.Login == "") {
if userInfo.Login == "" {
userInfo.Login = data.Email
}
......
......@@ -187,9 +187,9 @@ func (s *SocialGithub) UserInfo(client *http.Client) (*BasicUserInfo, error) {
}
userInfo := &BasicUserInfo{
Name: data.Login,
Login: data.Login,
Email: data.Email,
Name: data.Login,
Login: data.Login,
Email: data.Email,
}
if !s.IsTeamMember(client) {
......
......@@ -45,8 +45,8 @@ func (s *SocialGoogle) UserInfo(client *http.Client) (*BasicUserInfo, error) {
return nil, err
}
return &BasicUserInfo{
Name: data.Name,
Email: data.Email,
Login: data.Email,
Name: data.Name,
Email: data.Email,
Login: data.Email,
}, nil
}
......@@ -50,10 +50,10 @@ func (s *SocialGrafanaNet) IsOrganizationMember(organizations []OrgRecord) bool
func (s *SocialGrafanaNet) UserInfo(client *http.Client) (*BasicUserInfo, error) {
var data struct {
Name string `json:"name"`
Login string `json:"username"`
Email string `json:"email"`
Role string `json:"role"`
Name string `json:"name"`
Login string `json:"username"`
Email string `json:"email"`
Role string `json:"role"`
Orgs []OrgRecord `json:"orgs"`
}
......@@ -70,10 +70,10 @@ func (s *SocialGrafanaNet) UserInfo(client *http.Client) (*BasicUserInfo, error)
}
userInfo := &BasicUserInfo{
Name: data.Name,
Login: data.Login,
Email: data.Email,
Role: data.Role,
Name: data.Name,
Login: data.Login,
Email: data.Email,
Role: data.Role,
}
if !s.IsOrganizationMember(data.Orgs) {
......
......@@ -11,11 +11,11 @@ import (
)
type BasicUserInfo struct {
Name string
Email string
Login string
Company string
Role string
Name string
Email string
Login string
Company string
Role string
}
type SocialConnector interface {
......@@ -91,11 +91,11 @@ func NewOAuthService() {
// Google.
if name == "google" {
SocialMap["google"] = &SocialGoogle{
Config: &config,
allowedDomains: info.AllowedDomains,
hostedDomain: info.HostedDomain,
apiUrl: info.ApiUrl,
allowSignup: info.AllowSignup,
Config: &config,
allowedDomains: info.AllowedDomains,
hostedDomain: info.HostedDomain,
apiUrl: info.ApiUrl,
allowSignup: info.AllowSignup,
}
}
......@@ -115,12 +115,12 @@ func NewOAuthService() {
config = oauth2.Config{
ClientID: info.ClientId,
ClientSecret: info.ClientSecret,
Endpoint: oauth2.Endpoint{
AuthURL: setting.GrafanaNetUrl + "/oauth2/authorize",
TokenURL: setting.GrafanaNetUrl + "/api/oauth2/token",
Endpoint: oauth2.Endpoint{
AuthURL: setting.GrafanaNetUrl + "/oauth2/authorize",
TokenURL: setting.GrafanaNetUrl + "/api/oauth2/token",
},
RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name,
Scopes: info.Scopes,
RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name,
Scopes: info.Scopes,
}
SocialMap["grafananet"] = &SocialGrafanaNet{
......
......@@ -3,9 +3,9 @@ package opentsdb
import (
"testing"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/tsdb"
. "github.com/smartystreets/goconvey/convey"
"github.com/grafana/grafana/pkg/components/simplejson"
)
func TestOpenTsdbExecutor(t *testing.T) {
......@@ -23,8 +23,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
query.Model.Set("aggregator", "avg")
query.Model.Set("disableDownsampling", false)
query.Model.Set("downsampleInterval", "")
query.Model.Set("downsampleAggregator","avg")
query.Model.Set("downsampleFillPolicy","none")
query.Model.Set("downsampleAggregator", "avg")
query.Model.Set("downsampleFillPolicy", "none")
metric := exec.buildMetric(query)
......@@ -45,15 +45,15 @@ func TestOpenTsdbExecutor(t *testing.T) {
query.Model.Set("aggregator", "avg")
query.Model.Set("disableDownsampling", true)
query.Model.Set("downsampleInterval", "")
query.Model.Set("downsampleAggregator","avg")
query.Model.Set("downsampleFillPolicy","none")
query.Model.Set("downsampleAggregator", "avg")
query.Model.Set("downsampleFillPolicy", "none")
metric := exec.buildMetric(query)
So(len(metric), ShouldEqual, 2)
So(metric["metric"], ShouldEqual, "cpu.average.percent")
So(metric["aggregator"], ShouldEqual, "avg")
})
Convey("Build metric with downsampling enabled with params", func() {
......@@ -66,8 +66,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
query.Model.Set("aggregator", "avg")
query.Model.Set("disableDownsampling", false)
query.Model.Set("downsampleInterval", "5m")
query.Model.Set("downsampleAggregator","sum")
query.Model.Set("downsampleFillPolicy","null")
query.Model.Set("downsampleAggregator", "sum")
query.Model.Set("downsampleFillPolicy", "null")
metric := exec.buildMetric(query)
......@@ -87,8 +87,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
query.Model.Set("aggregator", "avg")
query.Model.Set("disableDownsampling", true)
query.Model.Set("downsampleInterval", "5m")
query.Model.Set("downsampleAggregator","sum")
query.Model.Set("downsampleFillPolicy","null")
query.Model.Set("downsampleAggregator", "sum")
query.Model.Set("downsampleFillPolicy", "null")
tags := simplejson.New()
tags.Set("env", "prod")
......@@ -117,8 +117,8 @@ func TestOpenTsdbExecutor(t *testing.T) {
query.Model.Set("aggregator", "avg")
query.Model.Set("disableDownsampling", true)
query.Model.Set("shouldComputeRate", true)
query.Model.Set("isCounter",false)
query.Model.Set("isCounter", false)
tags := simplejson.New()
tags.Set("env", "prod")
tags.Set("app", "grafana")
......@@ -147,9 +147,9 @@ func TestOpenTsdbExecutor(t *testing.T) {
query.Model.Set("aggregator", "avg")
query.Model.Set("disableDownsampling", true)
query.Model.Set("shouldComputeRate", true)
query.Model.Set("isCounter",true)
query.Model.Set("counterMax",45)
query.Model.Set("counterResetValue",60)
query.Model.Set("isCounter", true)
query.Model.Set("counterMax", 45)
query.Model.Set("counterResetValue", 60)
tags := simplejson.New()
tags.Set("env", "prod")
......@@ -173,4 +173,4 @@ func TestOpenTsdbExecutor(t *testing.T) {
})
})
}
\ No newline at end of file
}
package opentsdb
type OpenTsdbQuery struct {
Start int64 `json:"start"`
End int64 `json:"end"`
Queries []map[string]interface{} `json:"queries"`
Start int64 `json:"start"`
End int64 `json:"end"`
Queries []map[string]interface{} `json:"queries"`
}
type OpenTsdbResponse struct {
Metric string `json:"metric"`
DataPoints map[string]float64 `json:"dps"`
}
\ No newline at end of file
Metric string `json:"metric"`
DataPoints map[string]float64 `json:"dps"`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment