From 0a95ecec9830c0cd9d0092927b0defe359ad3a35 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Wed, 3 Nov 2021 11:37:28 +0000 Subject: [PATCH] add support for kubernetes runner --- livelog/copy.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/livelog/copy.go b/livelog/copy.go index 6e787bc..70b92e5 100644 --- a/livelog/copy.go +++ b/livelog/copy.go @@ -6,15 +6,29 @@ package livelog import ( "bufio" + "encoding/base64" "io" + "io/ioutil" + "regexp" ) +var re = regexp.MustCompile("#((.*?)#)") + // Copy copies from src to dst and removes until either EOF // is reached on src or an error occurs. func Copy(dst io.Writer, src io.ReadCloser) error { r := bufio.NewReader(src) for { bytes, err := r.ReadBytes('\n') + // check logs for card data + card := re.FindStringSubmatch(string(bytes)) + if card != nil { + data, err := base64.StdEncoding.DecodeString(card[len(card)-1:][0]) + if err == nil { + _ = ioutil.WriteFile("/tmp/card.json", data, 0644) + } + continue + } if _, err := dst.Write(bytes); err != nil { return err }