mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Outdent code after if block that ends with return (golint)
This commit fixes the following golint warnings: pkg/bus/bus.go:64:9: if block ends with a return statement, so drop this else and outdent its block pkg/bus/bus.go:84:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:137:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:177:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:183:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:199:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:208:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/components/dynmap/dynmap.go:236:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:242:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:257:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:263:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:278:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:284:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:299:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:331:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:350:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:356:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:366:12: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:390:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:396:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:405:12: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:427:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:433:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:442:12: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:459:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:465:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:474:12: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:491:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:497:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:506:12: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:523:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:529:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:538:12: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:555:9: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:561:10: if block ends with a return statement, so drop this else and outdent its block pkg/components/dynmap/dynmap.go:570:12: if block ends with a return statement, so drop this else and outdent its block pkg/login/ldap.go:55:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/login/ldap_test.go:372:10: if block ends with a return statement, so drop this else and outdent its block pkg/middleware/middleware_test.go:213:12: if block ends with a return statement, so drop this else and outdent its block pkg/plugins/dashboard_importer.go:153:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/plugins/dashboards_updater.go:39:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/plugins/dashboards_updater.go:121:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/plugins/plugins.go:210:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/plugins/plugins.go:235:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/eval_context.go:111:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/notifier.go:92:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/notifier.go:98:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/notifier.go:122:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/rule.go:108:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/rule.go:118:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/rule.go:121:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/alerting/notifiers/telegram.go:94:10: if block ends with a return statement, so drop this else and outdent its block pkg/services/sqlstore/annotation.go:34:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/sqlstore/annotation.go:99:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/sqlstore/dashboard_test.go:107:13: if block ends with a return statement, so drop this else and outdent its block pkg/services/sqlstore/plugin_setting.go:78:10: if block ends with a return statement, so drop this else and outdent its block pkg/services/sqlstore/preferences.go:91:10: if block ends with a return statement, so drop this else and outdent its block pkg/services/sqlstore/user.go:50:10: if block ends with a return statement, so drop this else and outdent its block pkg/services/sqlstore/migrator/migrator.go:106:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/services/sqlstore/migrator/postgres_dialect.go:48:10: if block ends with a return statement, so drop this else and outdent its block pkg/tsdb/time_range.go:59:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/tsdb/time_range.go:67:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) pkg/tsdb/cloudwatch/metric_find_query.go:225:9: if block ends with a return statement, so drop this else and outdent its block pkg/util/filepath.go:68:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
This commit is contained in:
parent
b7adf28501
commit
de8696d5d3
@ -61,9 +61,8 @@ func (b *InProcBus) DispatchCtx(ctx context.Context, msg Msg) error {
|
|||||||
err := ret[0].Interface()
|
err := ret[0].Interface()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
return err.(error)
|
|
||||||
}
|
}
|
||||||
|
return err.(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *InProcBus) Dispatch(msg Msg) error {
|
func (b *InProcBus) Dispatch(msg Msg) error {
|
||||||
@ -81,9 +80,8 @@ func (b *InProcBus) Dispatch(msg Msg) error {
|
|||||||
err := ret[0].Interface()
|
err := ret[0].Interface()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
return err.(error)
|
|
||||||
}
|
}
|
||||||
|
return err.(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *InProcBus) Publish(msg Msg) error {
|
func (b *InProcBus) Publish(msg Msg) error {
|
||||||
|
@ -134,9 +134,8 @@ func (v *Value) get(key string) (*Value, error) {
|
|||||||
child, ok := obj.Map()[key]
|
child, ok := obj.Map()[key]
|
||||||
if ok {
|
if ok {
|
||||||
return child, nil
|
return child, nil
|
||||||
} else {
|
|
||||||
return nil, KeyNotFoundError{key}
|
|
||||||
}
|
}
|
||||||
|
return nil, KeyNotFoundError{key}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -174,17 +173,13 @@ func (v *Object) GetObject(keys ...string) (*Object, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
obj, err := child.Object()
|
obj, err := child.Object()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
return obj, nil
|
return obj, nil
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into a string.
|
// Gets the value at key path and attempts to typecast the value into a string.
|
||||||
@ -196,18 +191,17 @@ func (v *Object) GetString(keys ...string) (string, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
|
||||||
return child.String()
|
|
||||||
}
|
}
|
||||||
|
return child.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Object) MustGetString(path string, def string) string {
|
func (v *Object) MustGetString(path string, def string) string {
|
||||||
keys := strings.Split(path, ".")
|
keys := strings.Split(path, ".")
|
||||||
if str, err := v.GetString(keys...); err != nil {
|
str, err := v.GetString(keys...)
|
||||||
|
if err != nil {
|
||||||
return def
|
return def
|
||||||
} else {
|
|
||||||
return str
|
|
||||||
}
|
}
|
||||||
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into null.
|
// Gets the value at key path and attempts to typecast the value into null.
|
||||||
@ -233,16 +227,13 @@ func (v *Object) GetNumber(keys ...string) (json.Number, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
n, err := child.Number()
|
n, err := child.Number()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
}
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into a float64.
|
// Gets the value at key path and attempts to typecast the value into a float64.
|
||||||
@ -254,16 +245,13 @@ func (v *Object) GetFloat64(keys ...string) (float64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
n, err := child.Float64()
|
n, err := child.Float64()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into a float64.
|
// Gets the value at key path and attempts to typecast the value into a float64.
|
||||||
@ -275,16 +263,13 @@ func (v *Object) GetInt64(keys ...string) (int64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
n, err := child.Int64()
|
n, err := child.Int64()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into a float64.
|
// Gets the value at key path and attempts to typecast the value into a float64.
|
||||||
@ -296,9 +281,8 @@ func (v *Object) GetInterface(keys ...string) (interface{}, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return child.Interface(), nil
|
|
||||||
}
|
}
|
||||||
|
return child.Interface(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into a bool.
|
// Gets the value at key path and attempts to typecast the value into a bool.
|
||||||
@ -311,7 +295,6 @@ func (v *Object) GetBoolean(keys ...string) (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return child.Boolean()
|
return child.Boolean()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,11 +311,8 @@ func (v *Object) GetValueArray(keys ...string) ([]*Value, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
|
|
||||||
return child.Array()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return child.Array()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of objects.
|
// Gets the value at key path and attempts to typecast the value into an array of objects.
|
||||||
@ -347,14 +327,12 @@ func (v *Object) GetObjectArray(keys ...string) ([]*Object, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
typedArray := make([]*Object, len(array))
|
typedArray := make([]*Object, len(array))
|
||||||
|
|
||||||
for index, arrayItem := range array {
|
for index, arrayItem := range array {
|
||||||
@ -363,14 +341,10 @@ func (v *Object) GetObjectArray(keys ...string) ([]*Object, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
typedArray[index] = typedArrayItem
|
typedArray[index] = typedArrayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return typedArray, nil
|
return typedArray, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of string.
|
// Gets the value at key path and attempts to typecast the value into an array of string.
|
||||||
@ -387,14 +361,12 @@ func (v *Object) GetStringArray(keys ...string) ([]string, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
typedArray := make([]string, len(array))
|
typedArray := make([]string, len(array))
|
||||||
|
|
||||||
for index, arrayItem := range array {
|
for index, arrayItem := range array {
|
||||||
@ -402,14 +374,10 @@ func (v *Object) GetStringArray(keys ...string) ([]string, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
typedArray[index] = typedArrayItem
|
typedArray[index] = typedArrayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return typedArray, nil
|
return typedArray, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of numbers.
|
// Gets the value at key path and attempts to typecast the value into an array of numbers.
|
||||||
@ -424,14 +392,12 @@ func (v *Object) GetNumberArray(keys ...string) ([]json.Number, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
typedArray := make([]json.Number, len(array))
|
typedArray := make([]json.Number, len(array))
|
||||||
|
|
||||||
for index, arrayItem := range array {
|
for index, arrayItem := range array {
|
||||||
@ -439,14 +405,10 @@ func (v *Object) GetNumberArray(keys ...string) ([]json.Number, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
typedArray[index] = typedArrayItem
|
typedArray[index] = typedArrayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return typedArray, nil
|
return typedArray, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of floats.
|
// Gets the value at key path and attempts to typecast the value into an array of floats.
|
||||||
@ -456,14 +418,12 @@ func (v *Object) GetFloat64Array(keys ...string) ([]float64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
typedArray := make([]float64, len(array))
|
typedArray := make([]float64, len(array))
|
||||||
|
|
||||||
for index, arrayItem := range array {
|
for index, arrayItem := range array {
|
||||||
@ -471,14 +431,10 @@ func (v *Object) GetFloat64Array(keys ...string) ([]float64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
typedArray[index] = typedArrayItem
|
typedArray[index] = typedArrayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return typedArray, nil
|
return typedArray, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of ints.
|
// Gets the value at key path and attempts to typecast the value into an array of ints.
|
||||||
@ -488,14 +444,12 @@ func (v *Object) GetInt64Array(keys ...string) ([]int64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
typedArray := make([]int64, len(array))
|
typedArray := make([]int64, len(array))
|
||||||
|
|
||||||
for index, arrayItem := range array {
|
for index, arrayItem := range array {
|
||||||
@ -503,14 +457,10 @@ func (v *Object) GetInt64Array(keys ...string) ([]int64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
typedArray[index] = typedArrayItem
|
typedArray[index] = typedArrayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return typedArray, nil
|
return typedArray, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of bools.
|
// Gets the value at key path and attempts to typecast the value into an array of bools.
|
||||||
@ -520,14 +470,12 @@ func (v *Object) GetBooleanArray(keys ...string) ([]bool, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
typedArray := make([]bool, len(array))
|
typedArray := make([]bool, len(array))
|
||||||
|
|
||||||
for index, arrayItem := range array {
|
for index, arrayItem := range array {
|
||||||
@ -535,14 +483,10 @@ func (v *Object) GetBooleanArray(keys ...string) ([]bool, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
typedArray[index] = typedArrayItem
|
typedArray[index] = typedArrayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return typedArray, nil
|
return typedArray, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the value at key path and attempts to typecast the value into an array of nulls.
|
// Gets the value at key path and attempts to typecast the value into an array of nulls.
|
||||||
@ -552,14 +496,12 @@ func (v *Object) GetNullArray(keys ...string) (int64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
array, err := child.Array()
|
array, err := child.Array()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
var length int64 = 0
|
var length int64 = 0
|
||||||
|
|
||||||
for _, arrayItem := range array {
|
for _, arrayItem := range array {
|
||||||
@ -567,14 +509,10 @@ func (v *Object) GetNullArray(keys ...string) (int64, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else {
|
}
|
||||||
length++
|
length++
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return length, nil
|
return length, nil
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an error if the value is not actually null
|
// Returns an error if the value is not actually null
|
||||||
@ -590,9 +528,7 @@ func (v *Value) Null() error {
|
|||||||
if valid {
|
if valid {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return ErrNotNull
|
return ErrNotNull
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempts to typecast the current value into an array.
|
// Attempts to typecast the current value into an array.
|
||||||
@ -612,17 +548,13 @@ func (v *Value) Array() ([]*Value, error) {
|
|||||||
var slice []*Value
|
var slice []*Value
|
||||||
|
|
||||||
if valid {
|
if valid {
|
||||||
|
|
||||||
for _, element := range v.data.([]interface{}) {
|
for _, element := range v.data.([]interface{}) {
|
||||||
child := Value{element, true}
|
child := Value{element, true}
|
||||||
slice = append(slice, &child)
|
slice = append(slice, &child)
|
||||||
}
|
}
|
||||||
|
|
||||||
return slice, nil
|
return slice, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return slice, ErrNotArray
|
return slice, ErrNotArray
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempts to typecast the current value into a number.
|
// Attempts to typecast the current value into a number.
|
||||||
|
@ -50,15 +50,15 @@ func (a *ldapAuther) Dial() error {
|
|||||||
if a.server.RootCACert != "" {
|
if a.server.RootCACert != "" {
|
||||||
certPool = x509.NewCertPool()
|
certPool = x509.NewCertPool()
|
||||||
for _, caCertFile := range strings.Split(a.server.RootCACert, " ") {
|
for _, caCertFile := range strings.Split(a.server.RootCACert, " ") {
|
||||||
if pem, err := ioutil.ReadFile(caCertFile); err != nil {
|
pem, err := ioutil.ReadFile(caCertFile)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
if !certPool.AppendCertsFromPEM(pem) {
|
if !certPool.AppendCertsFromPEM(pem) {
|
||||||
return errors.New("Failed to append CA certificate " + caCertFile)
|
return errors.New("Failed to append CA certificate " + caCertFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for _, host := range strings.Split(a.server.Host, " ") {
|
for _, host := range strings.Split(a.server.Host, " ") {
|
||||||
address := fmt.Sprintf("%s:%d", host, a.server.Port)
|
address := fmt.Sprintf("%s:%d", host, a.server.Port)
|
||||||
if a.server.UseSSL {
|
if a.server.UseSSL {
|
||||||
|
@ -369,10 +369,9 @@ func (sc *scenarioContext) userQueryReturns(user *m.User) {
|
|||||||
bus.AddHandler("test", func(query *m.GetUserByAuthInfoQuery) error {
|
bus.AddHandler("test", func(query *m.GetUserByAuthInfoQuery) error {
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return m.ErrUserNotFound
|
return m.ErrUserNotFound
|
||||||
} else {
|
}
|
||||||
query.Result = user
|
query.Result = user
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
})
|
})
|
||||||
bus.AddHandler("test", func(query *m.SetAuthInfoCommand) error {
|
bus.AddHandler("test", func(query *m.SetAuthInfoCommand) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -210,9 +210,8 @@ func TestMiddlewareContext(t *testing.T) {
|
|||||||
if query.UserId > 0 {
|
if query.UserId > 0 {
|
||||||
query.Result = &m.SignedInUser{OrgId: 4, UserId: 33}
|
query.Result = &m.SignedInUser{OrgId: 4, UserId: 33}
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
return m.ErrUserNotFound
|
|
||||||
}
|
}
|
||||||
|
return m.ErrUserNotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
bus.AddHandler("test", func(cmd *m.UpsertUserCommand) error {
|
bus.AddHandler("test", func(cmd *m.UpsertUserCommand) error {
|
||||||
|
@ -148,11 +148,11 @@ func (this *DashTemplateEvaluator) evalValue(source *simplejson.Json) interface{
|
|||||||
switch v := sourceValue.(type) {
|
switch v := sourceValue.(type) {
|
||||||
case string:
|
case string:
|
||||||
interpolated := this.varRegex.ReplaceAllStringFunc(v, func(match string) string {
|
interpolated := this.varRegex.ReplaceAllStringFunc(v, func(match string) string {
|
||||||
if replacement, exists := this.variables[match]; exists {
|
replacement, exists := this.variables[match]
|
||||||
|
if exists {
|
||||||
return replacement
|
return replacement
|
||||||
} else {
|
|
||||||
return match
|
|
||||||
}
|
}
|
||||||
|
return match
|
||||||
})
|
})
|
||||||
return interpolated
|
return interpolated
|
||||||
case bool:
|
case bool:
|
||||||
|
@ -34,9 +34,10 @@ func (pm *PluginManager) updateAppDashboards() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func autoUpdateAppDashboard(pluginDashInfo *PluginDashboardInfoDTO, orgId int64) error {
|
func autoUpdateAppDashboard(pluginDashInfo *PluginDashboardInfoDTO, orgId int64) error {
|
||||||
if dash, err := loadPluginDashboard(pluginDashInfo.PluginId, pluginDashInfo.Path); err != nil {
|
dash, err := loadPluginDashboard(pluginDashInfo.PluginId, pluginDashInfo.Path)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
plog.Info("Auto updating App dashboard", "dashboard", dash.Title, "newRev", pluginDashInfo.Revision, "oldRev", pluginDashInfo.ImportedRevision)
|
plog.Info("Auto updating App dashboard", "dashboard", dash.Title, "newRev", pluginDashInfo.Revision, "oldRev", pluginDashInfo.ImportedRevision)
|
||||||
updateCmd := ImportDashboardCommand{
|
updateCmd := ImportDashboardCommand{
|
||||||
OrgId: orgId,
|
OrgId: orgId,
|
||||||
@ -50,7 +51,7 @@ func autoUpdateAppDashboard(pluginDashInfo *PluginDashboardInfoDTO, orgId int64)
|
|||||||
if err := bus.Dispatch(&updateCmd); err != nil {
|
if err := bus.Dispatch(&updateCmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ func handlePluginStateChanged(event *m.PluginStateChangedEvent) error {
|
|||||||
|
|
||||||
if err := bus.Dispatch(&query); err != nil {
|
if err := bus.Dispatch(&query); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
for _, dash := range query.Result {
|
for _, dash := range query.Result {
|
||||||
deleteCmd := m.DeleteDashboardCommand{OrgId: dash.OrgId, Id: dash.Id}
|
deleteCmd := m.DeleteDashboardCommand{OrgId: dash.OrgId, Id: dash.Id}
|
||||||
|
|
||||||
@ -129,7 +130,6 @@ func handlePluginStateChanged(event *m.PluginStateChangedEvent) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -205,11 +205,11 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var loader PluginLoader
|
var loader PluginLoader
|
||||||
if pluginGoType, exists := PluginTypes[pluginCommon.Type]; !exists {
|
pluginGoType, exists := PluginTypes[pluginCommon.Type]
|
||||||
|
if !exists {
|
||||||
return errors.New("Unknown plugin type " + pluginCommon.Type)
|
return errors.New("Unknown plugin type " + pluginCommon.Type)
|
||||||
} else {
|
|
||||||
loader = reflect.New(reflect.TypeOf(pluginGoType)).Interface().(PluginLoader)
|
|
||||||
}
|
}
|
||||||
|
loader = reflect.New(reflect.TypeOf(pluginGoType)).Interface().(PluginLoader)
|
||||||
|
|
||||||
reader.Seek(0, 0)
|
reader.Seek(0, 0)
|
||||||
return loader.Load(jsonParser, currentDir)
|
return loader.Load(jsonParser, currentDir)
|
||||||
@ -230,9 +230,9 @@ func GetPluginMarkdown(pluginId string, name string) ([]byte, error) {
|
|||||||
return make([]byte, 0), nil
|
return make([]byte, 0), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if data, err := ioutil.ReadFile(path); err != nil {
|
data, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return data, nil
|
|
||||||
}
|
}
|
||||||
|
return data, nil
|
||||||
}
|
}
|
||||||
|
@ -106,11 +106,11 @@ func (c *EvalContext) GetRuleUrl() (string, error) {
|
|||||||
return setting.AppUrl, nil
|
return setting.AppUrl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if ref, err := c.GetDashboardUID(); err != nil {
|
ref, err := c.GetDashboardUID()
|
||||||
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
|
||||||
return fmt.Sprintf(urlFormat, m.GetFullDashboardUrl(ref.Uid, ref.Slug), c.Rule.PanelId, c.Rule.OrgId), nil
|
|
||||||
}
|
}
|
||||||
|
return fmt.Sprintf(urlFormat, m.GetFullDashboardUrl(ref.Uid, ref.Slug), c.Rule.PanelId, c.Rule.OrgId), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *EvalContext) GetNewState() m.AlertStateType {
|
func (c *EvalContext) GetNewState() m.AlertStateType {
|
||||||
|
@ -87,17 +87,17 @@ func (n *notificationService) uploadImage(context *EvalContext) (err error) {
|
|||||||
IsAlertContext: true,
|
IsAlertContext: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ref, err := context.GetDashboardUID(); err != nil {
|
ref, err := context.GetDashboardUID()
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
renderOpts.Path = fmt.Sprintf("d-solo/%s/%s?panelId=%d", ref.Uid, ref.Slug, context.Rule.PanelId)
|
renderOpts.Path = fmt.Sprintf("d-solo/%s/%s?panelId=%d", ref.Uid, ref.Slug, context.Rule.PanelId)
|
||||||
}
|
|
||||||
|
|
||||||
if imagePath, err := renderer.RenderToPng(renderOpts); err != nil {
|
imagePath, err := renderer.RenderToPng(renderOpts)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
context.ImageOnDiskPath = imagePath
|
|
||||||
}
|
}
|
||||||
|
context.ImageOnDiskPath = imagePath
|
||||||
|
|
||||||
context.ImagePublicUrl, err = uploader.Upload(context.Ctx, context.ImageOnDiskPath)
|
context.ImagePublicUrl, err = uploader.Upload(context.Ctx, context.ImageOnDiskPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -117,14 +117,14 @@ func (n *notificationService) getNeededNotifiers(orgId int64, notificationIds []
|
|||||||
|
|
||||||
var result []Notifier
|
var result []Notifier
|
||||||
for _, notification := range query.Result {
|
for _, notification := range query.Result {
|
||||||
if not, err := n.createNotifierFor(notification); err != nil {
|
not, err := n.createNotifierFor(notification)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
}
|
||||||
if not.ShouldNotify(context) {
|
if not.ShouldNotify(context) {
|
||||||
result = append(result, not)
|
result = append(result, not)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,8 @@ func (this *TelegramNotifier) buildMessage(evalContext *alerting.EvalContext, se
|
|||||||
cmd, err := this.buildMessageInlineImage(evalContext)
|
cmd, err := this.buildMessageInlineImage(evalContext)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return cmd
|
return cmd
|
||||||
} else {
|
|
||||||
this.log.Error("Could not generate Telegram message with inline image.", "err", err)
|
|
||||||
}
|
}
|
||||||
|
this.log.Error("Could not generate Telegram message with inline image.", "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.buildMessageLinkedImage(evalContext)
|
return this.buildMessageLinkedImage(evalContext)
|
||||||
|
@ -103,26 +103,26 @@ func NewRuleFromDBAlert(ruleDef *m.Alert) (*Rule, error) {
|
|||||||
|
|
||||||
for _, v := range ruleDef.Settings.Get("notifications").MustArray() {
|
for _, v := range ruleDef.Settings.Get("notifications").MustArray() {
|
||||||
jsonModel := simplejson.NewFromAny(v)
|
jsonModel := simplejson.NewFromAny(v)
|
||||||
if id, err := jsonModel.Get("id").Int64(); err != nil {
|
id, err := jsonModel.Get("id").Int64()
|
||||||
|
if err != nil {
|
||||||
return nil, ValidationError{Reason: "Invalid notification schema", DashboardId: model.DashboardId, Alertid: model.Id, PanelId: model.PanelId}
|
return nil, ValidationError{Reason: "Invalid notification schema", DashboardId: model.DashboardId, Alertid: model.Id, PanelId: model.PanelId}
|
||||||
} else {
|
|
||||||
model.Notifications = append(model.Notifications, id)
|
|
||||||
}
|
}
|
||||||
|
model.Notifications = append(model.Notifications, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
for index, condition := range ruleDef.Settings.Get("conditions").MustArray() {
|
for index, condition := range ruleDef.Settings.Get("conditions").MustArray() {
|
||||||
conditionModel := simplejson.NewFromAny(condition)
|
conditionModel := simplejson.NewFromAny(condition)
|
||||||
conditionType := conditionModel.Get("type").MustString()
|
conditionType := conditionModel.Get("type").MustString()
|
||||||
if factory, exist := conditionFactories[conditionType]; !exist {
|
factory, exist := conditionFactories[conditionType]
|
||||||
|
if !exist {
|
||||||
return nil, ValidationError{Reason: "Unknown alert condition: " + conditionType, DashboardId: model.DashboardId, Alertid: model.Id, PanelId: model.PanelId}
|
return nil, ValidationError{Reason: "Unknown alert condition: " + conditionType, DashboardId: model.DashboardId, Alertid: model.Id, PanelId: model.PanelId}
|
||||||
} else {
|
}
|
||||||
if queryCondition, err := factory(conditionModel, index); err != nil {
|
queryCondition, err := factory(conditionModel, index)
|
||||||
|
if err != nil {
|
||||||
return nil, ValidationError{Err: err, DashboardId: model.DashboardId, Alertid: model.Id, PanelId: model.PanelId}
|
return nil, ValidationError{Err: err, DashboardId: model.DashboardId, Alertid: model.Id, PanelId: model.PanelId}
|
||||||
} else {
|
}
|
||||||
model.Conditions = append(model.Conditions, queryCondition)
|
model.Conditions = append(model.Conditions, queryCondition)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(model.Conditions) == 0 {
|
if len(model.Conditions) == 0 {
|
||||||
return nil, fmt.Errorf("Alert is missing conditions")
|
return nil, fmt.Errorf("Alert is missing conditions")
|
||||||
|
@ -29,16 +29,16 @@ func (r *SqlAnnotationRepo) Save(item *annotations.Item) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if item.Tags != nil {
|
if item.Tags != nil {
|
||||||
if tags, err := r.ensureTagsExist(sess, tags); err != nil {
|
tags, err := r.ensureTagsExist(sess, tags)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
if _, err := sess.Exec("INSERT INTO annotation_tag (annotation_id, tag_id) VALUES(?,?)", item.Id, tag.Id); err != nil {
|
if _, err := sess.Exec("INSERT INTO annotation_tag (annotation_id, tag_id) VALUES(?,?)", item.Id, tag.Id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -94,9 +94,10 @@ func (r *SqlAnnotationRepo) Update(item *annotations.Item) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if item.Tags != nil {
|
if item.Tags != nil {
|
||||||
if tags, err := r.ensureTagsExist(sess, models.ParseTagPairs(item.Tags)); err != nil {
|
tags, err := r.ensureTagsExist(sess, models.ParseTagPairs(item.Tags))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
if _, err := sess.Exec("DELETE FROM annotation_tag WHERE annotation_id = ?", existing.Id); err != nil {
|
if _, err := sess.Exec("DELETE FROM annotation_tag WHERE annotation_id = ?", existing.Id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -106,7 +107,6 @@ func (r *SqlAnnotationRepo) Update(item *annotations.Item) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
existing.Tags = item.Tags
|
existing.Tags = item.Tags
|
||||||
|
|
||||||
|
@ -104,9 +104,8 @@ func TestDashboardDataAccess(t *testing.T) {
|
|||||||
timesCalled += 1
|
timesCalled += 1
|
||||||
if timesCalled <= 2 {
|
if timesCalled <= 2 {
|
||||||
return savedDash.Uid
|
return savedDash.Uid
|
||||||
} else {
|
|
||||||
return util.GenerateShortUid()
|
|
||||||
}
|
}
|
||||||
|
return util.GenerateShortUid()
|
||||||
}
|
}
|
||||||
cmd := m.SaveDashboardCommand{
|
cmd := m.SaveDashboardCommand{
|
||||||
OrgId: 1,
|
OrgId: 1,
|
||||||
|
@ -97,17 +97,15 @@ func (mg *Migrator) Start() error {
|
|||||||
mg.Logger.Debug("Executing", "sql", sql)
|
mg.Logger.Debug("Executing", "sql", sql)
|
||||||
|
|
||||||
err := mg.inTransaction(func(sess *xorm.Session) error {
|
err := mg.inTransaction(func(sess *xorm.Session) error {
|
||||||
|
err := mg.exec(m, sess)
|
||||||
if err := mg.exec(m, sess); err != nil {
|
if err != nil {
|
||||||
mg.Logger.Error("Exec failed", "error", err, "sql", sql)
|
mg.Logger.Error("Exec failed", "error", err, "sql", sql)
|
||||||
record.Error = err.Error()
|
record.Error = err.Error()
|
||||||
sess.Insert(&record)
|
sess.Insert(&record)
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
record.Success = true
|
record.Success = true
|
||||||
sess.Insert(&record)
|
sess.Insert(&record)
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -45,9 +45,8 @@ func (b *Postgres) Default(col *Column) string {
|
|||||||
if col.Type == DB_Bool {
|
if col.Type == DB_Bool {
|
||||||
if col.Default == "0" {
|
if col.Default == "0" {
|
||||||
return "FALSE"
|
return "FALSE"
|
||||||
} else {
|
|
||||||
return "TRUE"
|
|
||||||
}
|
}
|
||||||
|
return "TRUE"
|
||||||
}
|
}
|
||||||
return col.Default
|
return col.Default
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ func UpdatePluginSetting(cmd *m.UpdatePluginSettingCmd) error {
|
|||||||
|
|
||||||
_, err = sess.Insert(&pluginSetting)
|
_, err = sess.Insert(&pluginSetting)
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
for key, data := range cmd.SecureJsonData {
|
for key, data := range cmd.SecureJsonData {
|
||||||
encryptedData, err := util.Encrypt([]byte(data), setting.SecretKey)
|
encryptedData, err := util.Encrypt([]byte(data), setting.SecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -102,7 +102,6 @@ func UpdatePluginSetting(cmd *m.UpdatePluginSettingCmd) error {
|
|||||||
|
|
||||||
_, err = sess.Id(pluginSetting.Id).Update(&pluginSetting)
|
_, err = sess.Id(pluginSetting.Id).Update(&pluginSetting)
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,14 +88,13 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
|
|||||||
}
|
}
|
||||||
_, err = sess.Insert(&prefs)
|
_, err = sess.Insert(&prefs)
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
prefs.HomeDashboardId = cmd.HomeDashboardId
|
prefs.HomeDashboardId = cmd.HomeDashboardId
|
||||||
prefs.Timezone = cmd.Timezone
|
prefs.Timezone = cmd.Timezone
|
||||||
prefs.Theme = cmd.Theme
|
prefs.Theme = cmd.Theme
|
||||||
prefs.Updated = time.Now()
|
prefs.Updated = time.Now()
|
||||||
prefs.Version += 1
|
prefs.Version += 1
|
||||||
_, err := sess.Id(prefs.Id).AllCols().Update(&prefs)
|
_, err = sess.Id(prefs.Id).AllCols().Update(&prefs)
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,9 @@ func getOrgIdForNewUser(cmd *m.CreateUserCommand, sess *DBSession) (int64, error
|
|||||||
}
|
}
|
||||||
if has {
|
if has {
|
||||||
return org.Id, nil
|
return org.Id, nil
|
||||||
} else {
|
}
|
||||||
org.Name = "Main Org."
|
org.Name = "Main Org."
|
||||||
org.Id = 1
|
org.Id = 1
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
org.Name = cmd.OrgName
|
org.Name = cmd.OrgName
|
||||||
if len(org.Name) == 0 {
|
if len(org.Name) == 0 {
|
||||||
|
@ -222,9 +222,8 @@ func parseMultiSelectValue(input string) []string {
|
|||||||
trimValues[i] = strings.TrimSpace(v)
|
trimValues[i] = strings.TrimSpace(v)
|
||||||
}
|
}
|
||||||
return trimValues
|
return trimValues
|
||||||
} else {
|
|
||||||
return []string{trimmedInput}
|
|
||||||
}
|
}
|
||||||
|
return []string{trimmedInput}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whenever this list is updated, frontend list should also be updated.
|
// Whenever this list is updated, frontend list should also be updated.
|
||||||
|
@ -54,19 +54,19 @@ func (tr *TimeRange) GetToAsTimeUTC() time.Time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tr *TimeRange) MustGetFrom() time.Time {
|
func (tr *TimeRange) MustGetFrom() time.Time {
|
||||||
if res, err := tr.ParseFrom(); err != nil {
|
res, err := tr.ParseFrom()
|
||||||
|
if err != nil {
|
||||||
return time.Unix(0, 0)
|
return time.Unix(0, 0)
|
||||||
} else {
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *TimeRange) MustGetTo() time.Time {
|
func (tr *TimeRange) MustGetTo() time.Time {
|
||||||
if res, err := tr.ParseTo(); err != nil {
|
res, err := tr.ParseTo()
|
||||||
|
if err != nil {
|
||||||
return time.Unix(0, 0)
|
return time.Unix(0, 0)
|
||||||
} else {
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func tryParseUnixMsEpoch(val string) (time.Time, bool) {
|
func tryParseUnixMsEpoch(val string) (time.Time, bool) {
|
||||||
|
@ -65,9 +65,8 @@ func walk(path string, info os.FileInfo, resolvedPath string, symlinkPathsFollow
|
|||||||
if _, ok := symlinkPathsFollowed[path2]; ok {
|
if _, ok := symlinkPathsFollowed[path2]; ok {
|
||||||
errMsg := "Potential SymLink Infinite Loop. Path: %v, Link To: %v"
|
errMsg := "Potential SymLink Infinite Loop. Path: %v, Link To: %v"
|
||||||
return fmt.Errorf(errMsg, resolvedPath, path2)
|
return fmt.Errorf(errMsg, resolvedPath, path2)
|
||||||
} else {
|
|
||||||
symlinkPathsFollowed[path2] = true
|
|
||||||
}
|
}
|
||||||
|
symlinkPathsFollowed[path2] = true
|
||||||
}
|
}
|
||||||
info2, err := os.Lstat(path2)
|
info2, err := os.Lstat(path2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user