Created
May 17, 2024 01:27
-
-
Save crdrost/ce08b2449d438a2c3b18fe64cad39095 to your computer and use it in GitHub Desktop.
Workaround for an issue in https://github.com/argoproj/argo-cd/issues/5715
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package parse_argo | |
import ( | |
"io" | |
"regexp" | |
"github.com/go-logfmt/logfmt" | |
"github.com/msoap/byline" | |
) | |
type ParseArgo struct { | |
dec *logfmt.Decoder | |
} | |
func NewParseArgo(r io.Reader) ParseArgo { | |
dropLines := byline.NewReader(r).GrepByRegexp(regexp.MustCompile(`^time=`)) | |
return ParseArgo{ dec: logfmt.NewDecoder(dropLines) } | |
} | |
func (p ParseArgo) NextLine() map[string]string, error { | |
var result map[string]string | |
dec := p.dec | |
if dec.ScanRecord() { | |
result = make(map[string]string) | |
for dec.ScanKeyval() { | |
result[string(dec.Key())] = string(dec.Value()) | |
} | |
} | |
return result, dec.Err() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment