-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.go
45 lines (39 loc) · 771 Bytes
/
entry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"io"
"log"
"gopkg.in/yaml.v3"
)
type Change struct {
Ref string
Old string
New string
Log string
}
type TLogEntry struct {
Service string
Repo string
User string
GitPushCertStatus string `yaml:"git_push_cert_status"`
Changes []Change
}
func DecodeTLogEntry(r io.Reader) (*TLogEntry, error) {
var tlog TLogEntry
reader := yaml.NewDecoder(r)
err := reader.Decode(&tlog)
if err != nil {
return nil, err
}
return &tlog, nil
}
func (t *TLogEntry) Encode(w io.Writer) error {
writer := yaml.NewEncoder(w)
// This doesn't work :c
// The log blob should have 4 indents, but rest has 2
writer.SetIndent(2)
err := writer.Encode(t)
if err != nil {
log.Fatal(err)
}
return nil
}