Skip to content

Commit e36f9fa

Browse files
committed
Merge branch 'master' into alerting_influxdb
2 parents 522d40f + a3c9145 commit e36f9fa

File tree

82 files changed

+406
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+406
-88
lines changed

build.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55
import (
66
"bytes"
77
"crypto/md5"
8+
"crypto/sha1"
89
"encoding/json"
910
"flag"
1011
"fmt"
@@ -85,17 +86,21 @@ func main() {
8586
case "package":
8687
grunt(gruntBuildArg("release")...)
8788
createLinuxPackages()
89+
sha1FilesInDist()
8890

8991
case "pkg-rpm":
9092
grunt(gruntBuildArg("release")...)
9193
createRpmPackages()
94+
sha1FilesInDist()
9295

9396
case "pkg-deb":
9497
grunt(gruntBuildArg("release")...)
9598
createDebPackages()
99+
sha1FilesInDist()
96100

97101
case "latest":
98102
makeLatestDistCopies()
103+
sha1FilesInDist()
99104

100105
case "clean":
101106
clean()
@@ -501,3 +506,38 @@ func md5File(file string) error {
501506

502507
return out.Close()
503508
}
509+
510+
func sha1FilesInDist() {
511+
filepath.Walk("./dist", func(path string, f os.FileInfo, err error) error {
512+
if strings.Contains(path, ".sha1") == false {
513+
sha1File(path)
514+
}
515+
return nil
516+
})
517+
}
518+
519+
func sha1File(file string) error {
520+
fd, err := os.Open(file)
521+
if err != nil {
522+
return err
523+
}
524+
defer fd.Close()
525+
526+
h := sha1.New()
527+
_, err = io.Copy(h, fd)
528+
if err != nil {
529+
return err
530+
}
531+
532+
out, err := os.Create(file + ".sha1")
533+
if err != nil {
534+
return err
535+
}
536+
537+
_, err = fmt.Fprintf(out, "%x\n", h.Sum(nil))
538+
if err != nil {
539+
return err
540+
}
541+
542+
return out.Close()
543+
}

conf/defaults.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ auto_sign_up = true
267267
[auth.ldap]
268268
enabled = false
269269
config_file = /etc/grafana/ldap.toml
270+
allow_sign_up = true
270271

271272
#################################### SMTP / Emailing #####################
272273
[smtp]
@@ -292,6 +293,9 @@ mode = console, file
292293
# Either "debug", "info", "warn", "error", "critical", default is "info"
293294
level = info
294295

296+
# optional settings to set different levels for specific loggers. Ex filters = sqlstore:debug
297+
filters =
298+
295299
# For "console" mode only
296300
[log.console]
297301
level =
@@ -421,7 +425,7 @@ url = https://grafana.net
421425
#################################### External Image Storage ##############
422426
[external_image_storage]
423427
# You can choose between (s3, webdav)
424-
provider = s3
428+
provider =
425429

426430
[external_image_storage.s3]
427431
bucket_url =

conf/sample.ini

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
[auth.ldap]
253253
;enabled = false
254254
;config_file = /etc/grafana/ldap.toml
255+
;allow_sign_up = true
255256

256257
#################################### SMTP / Emailing ##########################
257258
[smtp]
@@ -276,6 +277,10 @@
276277
# Either "trace", "debug", "info", "warn", "error", "critical", default is "info"
277278
;level = info
278279

280+
# optional settings to set different levels for specific loggers. Ex filters = sqlstore:debug
281+
;filters =
282+
283+
279284
# For "console" mode only
280285
[log.console]
281286
;level =
@@ -375,8 +380,8 @@
375380
#################################### External image storage ##########################
376381
[external_image_storage]
377382
# Used for uploading images to public servers so they can be included in slack/email messages.
378-
# you can choose between (s3, webdav or internal)
379-
;provider = s3
383+
# you can choose between (s3, webdav)
384+
;provider =
380385

381386
[external_image_storage.s3]
382387
;bucket_url =

docs/sources/installation/configuration.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ using environment variables using the syntax:
3030
Where the section name is the text within the brackets. Everything
3131
should be upper case, `.` should be replaced by `_`. For example, given these configuration settings:
3232

33+
# default section
34+
instance_name = ${HOSTNAME}
35+
3336
[security]
3437
admin_user = admin
3538

@@ -39,6 +42,7 @@ should be upper case, `.` should be replaced by `_`. For example, given these co
3942

4043
Then you can override them using:
4144

45+
export GF_DEFAULT_INSTANCE_NAME=my-instance
4246
export GF_SECURITY_ADMIN_USER=true
4347
export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey
4448

@@ -528,7 +532,7 @@ Use space to separate multiple modes, e.g. "console file"
528532
### level
529533
Either "debug", "info", "warn", "error", "critical", default is "info"
530534

531-
### filter
535+
### filters
532536
optional settings to set different levels for specific loggers.
533537
Ex `filters = sqlstore:debug`
534538

pkg/components/imguploader/imguploader.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ type ImageUploader interface {
1010
Upload(path string) (string, error)
1111
}
1212

13+
type NopImageUploader struct {
14+
}
15+
16+
func (NopImageUploader) Upload(path string) (string, error) {
17+
return "", nil
18+
}
19+
1320
func NewImageUploader() (ImageUploader, error) {
1421

1522
switch setting.ImageUploadProvider {
@@ -53,5 +60,5 @@ func NewImageUploader() (ImageUploader, error) {
5360
return NewWebdavImageUploader(url, username, password)
5461
}
5562

56-
return nil, fmt.Errorf("could not find specified provider")
63+
return NopImageUploader{}, nil
5764
}

pkg/login/ldap.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/grafana/grafana/pkg/bus"
1414
"github.com/grafana/grafana/pkg/log"
1515
m "github.com/grafana/grafana/pkg/models"
16+
"github.com/grafana/grafana/pkg/setting"
1617
)
1718

1819
type ldapAuther struct {
@@ -132,8 +133,10 @@ func (a *ldapAuther) getGrafanaUserFor(ldapUser *ldapUserInfo) (*m.User, error)
132133
// get user from grafana db
133134
userQuery := m.GetUserByLoginQuery{LoginOrEmail: ldapUser.Username}
134135
if err := bus.Dispatch(&userQuery); err != nil {
135-
if err == m.ErrUserNotFound {
136+
if err == m.ErrUserNotFound && setting.LdapAllowSignup {
136137
return a.createGrafanaUser(ldapUser)
138+
} else if err == m.ErrUserNotFound {
139+
return nil, ErrInvalidCredentials
137140
} else {
138141
return nil, err
139142
}

pkg/setting/setting.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ var (
134134
GoogleTagManagerId string
135135

136136
// LDAP
137-
LdapEnabled bool
138-
LdapConfigFile string
137+
LdapEnabled bool
138+
LdapConfigFile string
139+
LdapAllowSignup bool = true
139140

140141
// SMTP email settings
141142
Smtp SmtpSettings
@@ -551,6 +552,7 @@ func NewConfigContext(args *CommandLineArgs) error {
551552
ldapSec := Cfg.Section("auth.ldap")
552553
LdapEnabled = ldapSec.Key("enabled").MustBool(false)
553554
LdapConfigFile = ldapSec.Key("config_file").String()
555+
LdapAllowSignup = ldapSec.Key("allow_sign_up").MustBool(true)
554556

555557
alerting := Cfg.Section("alerting")
556558
AlertingEnabled = alerting.Key("enabled").MustBool(false)

pkg/tsdb/testdata/scenarios.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ func init() {
9090
queryRes := tsdb.NewQueryResult()
9191

9292
stringInput := query.Model.Get("stringInput").MustString()
93-
values := []float64{}
93+
values := []null.Float{}
9494
for _, strVal := range strings.Split(stringInput, ",") {
95+
if strVal == "null" {
96+
values = append(values, null.FloatFromPtr(nil))
97+
}
9598
if val, err := strconv.ParseFloat(strVal, 64); err == nil {
96-
values = append(values, val)
99+
values = append(values, null.FloatFrom(val))
97100
}
98101
}
99102

@@ -107,7 +110,7 @@ func init() {
107110
step := (endTime - startTime) / int64(len(values)-1)
108111

109112
for _, val := range values {
110-
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(val), float64(startTime)))
113+
series.Points = append(series.Points, tsdb.TimePoint{val, null.FloatFrom(float64(startTime))})
111114
startTime += step
112115
}
113116

public/app/core/directives/metric_segment.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,27 @@ function (_, $, coreModule) {
186186

187187
$scope.getOptionsInternal = function() {
188188
if ($scope.options) {
189-
var optionSegments = _.map($scope.options, function(option) {
189+
cachedOptions = _.map($scope.options, function(option) {
190190
return uiSegmentSrv.newSegment({value: option.text});
191191
});
192-
return $q.when(optionSegments);
192+
return $q.when(cachedOptions);
193193
} else {
194194
return $scope.getOptions().then(function(options) {
195-
cachedOptions = options;
196-
return _.map(options, function(option) {
195+
cachedOptions =_.map(options, function(option) {
196+
if (option.html) {
197+
return option;
198+
}
197199
return uiSegmentSrv.newSegment({value: option.text});
198200
});
201+
return cachedOptions;
199202
});
200203
}
201204
};
202205

203206
$scope.onSegmentChange = function() {
204-
var options = $scope.options || cachedOptions;
205207

206-
if (options) {
207-
var option = _.find(options, {text: $scope.segment.value});
208+
if (cachedOptions) {
209+
var option = _.find(cachedOptions, {value: $scope.segment.value});
208210
if (option && option.value !== $scope.property) {
209211
$scope.property = option.value;
210212
} else if (attrs.custom !== 'false') {

0 commit comments

Comments
 (0)