mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-15 13:53:58 +02:00
* Add support for loki datasource --------- Co-authored-by: Mathieu Lecarme <mathieu@garambrogne.net> Co-authored-by: Sebastien Blot <sebastien@crowdsec.net> Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
29 lines
490 B
Go
29 lines
490 B
Go
package loki
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type timestamp time.Time
|
|
|
|
func (t *timestamp) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
var tt time.Time
|
|
err := unmarshal(&tt)
|
|
if err == nil {
|
|
*t = timestamp(tt)
|
|
return nil
|
|
}
|
|
var d time.Duration
|
|
err = unmarshal(&d)
|
|
if err == nil {
|
|
*t = timestamp(time.Now().Add(-d))
|
|
fmt.Println("t", time.Time(*t).Format(time.RFC3339))
|
|
return nil
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (t *timestamp) IsZero() bool {
|
|
return time.Time(*t).IsZero()
|
|
}
|