Skip to content

Commit

Permalink
Replace the yaml implementation for one that uses the json tags
Browse files Browse the repository at this point in the history
So we don't have to:
1/ add yaml tags to all serialized struct
2/ add yaml tags to api.yaml schemas using a go-specific extension
  • Loading branch information
cvaroqui committed Sep 15, 2023
1 parent ebd5af1 commit 05c127d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/nodeaction/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/rs/zerolog/log"
"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"

"github.com/opensvc/om3/core/actionrouter"
"github.com/opensvc/om3/core/client"
Expand Down
19 changes: 7 additions & 12 deletions core/output/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
tabwriter "github.com/juju/ansiterm"
"github.com/opensvc/om3/util/render"
"github.com/opensvc/om3/util/render/palette"
"gopkg.in/yaml.v3"
"k8s.io/client-go/util/jsonpath"
"sigs.k8s.io/yaml"
)

type (
Expand Down Expand Up @@ -121,20 +121,15 @@ func (t Renderer) Sprint() (string, error) {
if t.Stream {
sep = "---\n"
}
b, err := yaml.Marshal(t.Data)
if err != nil {
return "", err
}
if color.NoColor {
b, err := yaml.Marshal(t.Data)
if err != nil {
return "", err
}
return string(b) + sep, nil
} else {
b := bytes.NewBuffer(nil)
enc := yaml.NewEncoder(b)
err := enc.Encode(t.Data)
if err != nil {
return "", err
}
s, err := highlight.Highlight(b)
buf := bytes.NewBuffer(b)
s, err := highlight.Highlight(buf)
if err != nil {
return "", err
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ require (
golang.org/x/time v0.3.0
gopkg.in/errgo.v2 v2.1.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/client-go v0.28.0
sigs.k8s.io/yaml v1.3.0
software.sslmate.com/src/go-pkcs12 v0.2.0
)

Expand Down Expand Up @@ -156,6 +155,8 @@ require (
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.2.2 // indirect
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -900,5 +900,7 @@ sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
software.sslmate.com/src/go-pkcs12 v0.2.0 h1:nlFkj7bTysH6VkC4fGphtjXRbezREPgrHuJG20hBGPE=
software.sslmate.com/src/go-pkcs12 v0.2.0/go.mod h1:23rNcYsMabIc1otwLpTkCCPwUq6kQsTyowttG/as0kQ=

0 comments on commit 05c127d

Please sign in to comment.