mirror of https://github.com/grafana/grafana
Conflicts: pkg/services/sqlstore/migrations/migrations.gopull/3712/head
commit
69d0e82453
@ -0,0 +1,16 @@ |
|||||||
|
package migrations |
||||||
|
|
||||||
|
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" |
||||||
|
|
||||||
|
func addSessionMigration(mg *Migrator) { |
||||||
|
var sessionV1 = Table{ |
||||||
|
Name: "session", |
||||||
|
Columns: []*Column{ |
||||||
|
{Name: "key", Type: DB_Char, IsPrimaryKey: true, Length: 16}, |
||||||
|
{Name: "data", Type: DB_Blob}, |
||||||
|
{Name: "expiry", Type: DB_Integer, Length: 255, Nullable: false}, |
||||||
|
}, |
||||||
|
} |
||||||
|
|
||||||
|
mg.AddMigration("create session table", NewAddTableMigration(sessionV1)) |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
package sqlstore |
||||||
|
|
||||||
|
import ( |
||||||
|
"crypto/tls" |
||||||
|
"crypto/x509" |
||||||
|
"fmt" |
||||||
|
"io/ioutil" |
||||||
|
) |
||||||
|
|
||||||
|
func makeCert(tlsPoolName string, config MySQLConfig) (*tls.Config, error) { |
||||||
|
rootCertPool := x509.NewCertPool() |
||||||
|
pem, err := ioutil.ReadFile(config.CaCertPath) |
||||||
|
if err != nil { |
||||||
|
return nil, fmt.Errorf("Could not read DB CA Cert path: %v", config.CaCertPath) |
||||||
|
} |
||||||
|
if ok := rootCertPool.AppendCertsFromPEM(pem); !ok { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
clientCert := make([]tls.Certificate, 0, 1) |
||||||
|
if config.ClientCertPath != "" && config.ClientKeyPath != "" { |
||||||
|
|
||||||
|
certs, err := tls.LoadX509KeyPair(config.ClientCertPath, config.ClientKeyPath) |
||||||
|
if err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
clientCert = append(clientCert, certs) |
||||||
|
} |
||||||
|
tlsConfig := &tls.Config{ |
||||||
|
RootCAs: rootCertPool, |
||||||
|
Certificates: clientCert, |
||||||
|
} |
||||||
|
tlsConfig.ServerName = config.ServerCertName |
||||||
|
if config.SslMode == "skip-verify" { |
||||||
|
tlsConfig.InsecureSkipVerify = true |
||||||
|
} |
||||||
|
// Return more meaningful error before it is too late
|
||||||
|
if config.ServerCertName == "" && !tlsConfig.InsecureSkipVerify { |
||||||
|
return nil, fmt.Errorf("server_cert_name is missing. Consider using ssl_mode = skip-verify.") |
||||||
|
} |
||||||
|
return tlsConfig, nil |
||||||
|
} |
@ -1,44 +0,0 @@ |
|||||||
define([ |
|
||||||
"angular", |
|
||||||
"lodash", |
|
||||||
"moment", |
|
||||||
],function (angular, _, moment) { |
|
||||||
'use strict'; |
|
||||||
|
|
||||||
angular. |
|
||||||
module("grafana.directives"). |
|
||||||
directive('inputDatetime', function () { |
|
||||||
return { |
|
||||||
restrict: 'A', |
|
||||||
require: 'ngModel', |
|
||||||
link: function ($scope, $elem, attrs, ngModel) { |
|
||||||
var format = 'YYYY-MM-DD HH:mm:ss'; |
|
||||||
|
|
||||||
var fromUser = function (text) { |
|
||||||
if (text.indexOf('now') !== -1) { |
|
||||||
return text; |
|
||||||
} |
|
||||||
var parsed; |
|
||||||
if ($scope.ctrl.isUtc) { |
|
||||||
parsed = moment.utc(text, format); |
|
||||||
} else { |
|
||||||
parsed = moment(text, format); |
|
||||||
} |
|
||||||
|
|
||||||
return parsed.isValid() ? parsed : undefined; |
|
||||||
}; |
|
||||||
|
|
||||||
var toUser = function (currentValue) { |
|
||||||
if (moment.isMoment(currentValue)) { |
|
||||||
return currentValue.format(format); |
|
||||||
} else { |
|
||||||
return currentValue; |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
ngModel.$parsers.push(fromUser); |
|
||||||
ngModel.$formatters.push(toUser); |
|
||||||
} |
|
||||||
}; |
|
||||||
}); |
|
||||||
}); |
|
@ -0,0 +1,41 @@ |
|||||||
|
///<reference path="../../../headers/common.d.ts" />
|
||||||
|
|
||||||
|
import _ from 'lodash'; |
||||||
|
import angular from 'angular'; |
||||||
|
import moment from 'moment'; |
||||||
|
|
||||||
|
export function inputDateDirective() { |
||||||
|
return { |
||||||
|
restrict: 'A', |
||||||
|
require: 'ngModel', |
||||||
|
link: function ($scope, $elem, attrs, ngModel) { |
||||||
|
var format = 'YYYY-MM-DD HH:mm:ss'; |
||||||
|
|
||||||
|
var fromUser = function (text) { |
||||||
|
if (text.indexOf('now') !== -1) { |
||||||
|
return text; |
||||||
|
} |
||||||
|
var parsed; |
||||||
|
if ($scope.ctrl.isUtc) { |
||||||
|
parsed = moment.utc(text, format); |
||||||
|
} else { |
||||||
|
parsed = moment(text, format); |
||||||
|
} |
||||||
|
|
||||||
|
return parsed.isValid() ? parsed : undefined; |
||||||
|
}; |
||||||
|
|
||||||
|
var toUser = function (currentValue) { |
||||||
|
if (moment.isMoment(currentValue)) { |
||||||
|
return currentValue.format(format); |
||||||
|
} else { |
||||||
|
return currentValue; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
ngModel.$parsers.push(fromUser); |
||||||
|
ngModel.$formatters.push(toUser); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue