more linting fixes
This commit is contained in:
parent
fe68914628
commit
e6cad40ac4
|
@ -22,11 +22,6 @@ type TestFile struct {
|
||||||
Results []types.Event `yaml:"results,omitempty"`
|
Results []types.Event `yaml:"results,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBucketStates() {
|
|
||||||
//same as a scenario, but load a bucket state first ?
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBucket(t *testing.T) {
|
func TestBucket(t *testing.T) {
|
||||||
|
|
||||||
var envSetting = os.Getenv("TEST_ONLY")
|
var envSetting = os.Getenv("TEST_ONLY")
|
||||||
|
@ -261,7 +256,5 @@ POLL_AGAIN:
|
||||||
log.Warningf("entry valid at end of loop")
|
log.Warningf("entry valid at end of loop")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Errorf("failed test")
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
||||||
/* load grok statics */
|
/* load grok statics */
|
||||||
if len(n.Grok.Statics) > 0 {
|
if len(n.Grok.Statics) > 0 {
|
||||||
//compile expr statics if present
|
//compile expr statics if present
|
||||||
for idx, _ := range n.Grok.Statics {
|
for idx := range n.Grok.Statics {
|
||||||
if n.Grok.Statics[idx].ExpValue != "" {
|
if n.Grok.Statics[idx].ExpValue != "" {
|
||||||
n.Grok.Statics[idx].RunTimeValue, err = expr.Compile(n.Grok.Statics[idx].ExpValue,
|
n.Grok.Statics[idx].RunTimeValue, err = expr.Compile(n.Grok.Statics[idx].ExpValue,
|
||||||
expr.Env(exprhelpers.GetExprEnv(map[string]interface{}{"evt": &types.Event{}})))
|
expr.Env(exprhelpers.GetExprEnv(map[string]interface{}{"evt": &types.Event{}})))
|
||||||
|
@ -412,7 +412,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
||||||
}
|
}
|
||||||
/* compile leafs if present */
|
/* compile leafs if present */
|
||||||
if len(n.SuccessNodes) > 0 {
|
if len(n.SuccessNodes) > 0 {
|
||||||
for idx, _ := range n.SuccessNodes {
|
for idx := range n.SuccessNodes {
|
||||||
/*propagate debug/stats to child nodes*/
|
/*propagate debug/stats to child nodes*/
|
||||||
if !n.SuccessNodes[idx].Debug && n.Debug {
|
if !n.SuccessNodes[idx].Debug && n.Debug {
|
||||||
n.SuccessNodes[idx].Debug = true
|
n.SuccessNodes[idx].Debug = true
|
||||||
|
@ -432,7 +432,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
||||||
valid = true
|
valid = true
|
||||||
}
|
}
|
||||||
/* load statics if present */
|
/* load statics if present */
|
||||||
for idx, _ := range n.Statics {
|
for idx := range n.Statics {
|
||||||
if n.Statics[idx].ExpValue != "" {
|
if n.Statics[idx].ExpValue != "" {
|
||||||
n.Statics[idx].RunTimeValue, err = expr.Compile(n.Statics[idx].ExpValue, expr.Env(exprhelpers.GetExprEnv(map[string]interface{}{"evt": &types.Event{}})))
|
n.Statics[idx].RunTimeValue, err = expr.Compile(n.Statics[idx].ExpValue, expr.Env(exprhelpers.GetExprEnv(map[string]interface{}{"evt": &types.Event{}})))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -128,11 +128,11 @@ func ProcessStatics(statics []types.ExtraField, p *types.Event, clog *logrus.Ent
|
||||||
clog.Warningf("failed to run RunTimeValue : %v", err)
|
clog.Warningf("failed to run RunTimeValue : %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch output.(type) {
|
switch out := output.(type) {
|
||||||
case string:
|
case string:
|
||||||
value = output.(string)
|
value = out
|
||||||
case int:
|
case int:
|
||||||
value = strconv.Itoa(output.(int))
|
value = strconv.Itoa(out)
|
||||||
default:
|
default:
|
||||||
clog.Fatalf("unexpected return type for RunTimeValue : %T", output)
|
clog.Fatalf("unexpected return type for RunTimeValue : %T", output)
|
||||||
return errors.New("unexpected return type for RunTimeValue")
|
return errors.New("unexpected return type for RunTimeValue")
|
||||||
|
|
|
@ -107,7 +107,7 @@ func (c *Context) GetBansAt(at time.Time) ([]map[string]string, error) {
|
||||||
bancom["source"] = ba.MeasureSource
|
bancom["source"] = ba.MeasureSource
|
||||||
bancom["events_count"] = "0"
|
bancom["events_count"] = "0"
|
||||||
bancom["action"] = ba.MeasureType
|
bancom["action"] = ba.MeasureType
|
||||||
bancom["until"] = fmt.Sprintf("%s", ba.Until.Sub(time.Now()).Round(time.Second))
|
bancom["until"] = time.Until(ba.Until).Round(time.Second).String()
|
||||||
bancom["reason"] = ba.Reason
|
bancom["reason"] = ba.Reason
|
||||||
rets = append(rets, bancom)
|
rets = append(rets, bancom)
|
||||||
continue
|
continue
|
||||||
|
@ -134,7 +134,7 @@ func (c *Context) GetBansAt(at time.Time) ([]map[string]string, error) {
|
||||||
bancom["scenario"] = "?"
|
bancom["scenario"] = "?"
|
||||||
bancom["events_count"] = "0"
|
bancom["events_count"] = "0"
|
||||||
bancom["action"] = ba.MeasureType
|
bancom["action"] = ba.MeasureType
|
||||||
bancom["until"] = fmt.Sprintf("%s", ba.Until.Sub(time.Now()).Round(time.Second))
|
bancom["until"] = time.Until(ba.Until).Round(time.Second).String()
|
||||||
bancom["reason"] = ba.Reason
|
bancom["reason"] = ba.Reason
|
||||||
rets = append(rets, bancom)
|
rets = append(rets, bancom)
|
||||||
continue
|
continue
|
||||||
|
@ -155,7 +155,7 @@ func (c *Context) GetBansAt(at time.Time) ([]map[string]string, error) {
|
||||||
bancom["events_count"] = fmt.Sprintf("%d", evtCount)
|
bancom["events_count"] = fmt.Sprintf("%d", evtCount)
|
||||||
bancom["action"] = ba.MeasureType
|
bancom["action"] = ba.MeasureType
|
||||||
bancom["source"] = ba.MeasureSource
|
bancom["source"] = ba.MeasureSource
|
||||||
bancom["until"] = fmt.Sprintf("%s", ba.Until.Sub(time.Now()).Round(time.Second))
|
bancom["until"] = time.Until(ba.Until).Round(time.Second).String()
|
||||||
bancom["reason"] = so.Scenario
|
bancom["reason"] = so.Scenario
|
||||||
rets = append(rets, bancom)
|
rets = append(rets, bancom)
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,7 +400,7 @@ type wait struct {
|
||||||
func runWait(t *testing.T, lim *Limiter, w wait) {
|
func runWait(t *testing.T, lim *Limiter, w wait) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
err := lim.WaitN(w.ctx, w.n)
|
err := lim.WaitN(w.ctx, w.n)
|
||||||
delay := time.Now().Sub(start)
|
delay := time.Since(start)
|
||||||
if (w.nilErr && err != nil) || (!w.nilErr && err == nil) || w.delay != dFromDuration(delay) {
|
if (w.nilErr && err != nil) || (!w.nilErr && err == nil) || w.delay != dFromDuration(delay) {
|
||||||
errString := "<nil>"
|
errString := "<nil>"
|
||||||
if !w.nilErr {
|
if !w.nilErr {
|
||||||
|
|
Loading…
Reference in a new issue