Skip to content

Commit 695d23a

Browse files
authored
Merge pull request #22 from xmudrii/fix-update-rules
Add indent when marshalling YAML in update-rules
2 parents 5e3abb8 + 1a1b2b6 commit 695d23a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cmd/update-rules/main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"bytes"
2021
"flag"
2122
"fmt"
2223
"os"
2324
"path/filepath"
2425

2526
"github.com/golang/glog"
26-
"gopkg.in/yaml.v2"
27+
"gopkg.in/yaml.v3"
2728
"k8s.io/publishing-bot/cmd/publishing-bot/config"
2829
)
2930

@@ -96,10 +97,14 @@ func main() {
9697
glog.Fatalf("update failed, found invalid rules after update: %v", err)
9798
}
9899

99-
data, err := yaml.Marshal(rules)
100-
if err != nil {
100+
var buf bytes.Buffer
101+
enc := yaml.NewEncoder(&buf)
102+
enc.SetIndent(2)
103+
if err := enc.Encode(rules); err != nil {
101104
glog.Fatalf("error marshaling rules %v", err)
102105
}
106+
_ = enc.Close()
107+
data := buf.Bytes()
103108

104109
if o.out != "" {
105110
err = exportRules(o.out, data)

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
golang.org/x/oauth2 v0.31.0
1414
gopkg.in/natefinch/lumberjack.v2 v2.2.1
1515
gopkg.in/yaml.v2 v2.4.0
16+
gopkg.in/yaml.v3 v3.0.1
1617
)
1718

1819
require (

0 commit comments

Comments
 (0)