File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed
Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 99 "strings"
1010 "text/template"
1111
12+ "github.com/ghodss/yaml"
1213 "github.com/scaleway/scaleway-cli/v2/core/human"
1314 "github.com/scaleway/scaleway-cli/v2/internal/gofields"
14- "gopkg.in/yaml.v3"
1515)
1616
1717// Type defines an formatter format.
@@ -292,10 +292,9 @@ func (p *Printer) printJSON(data any) error {
292292}
293293
294294func (p * Printer ) printYAML (data any ) error {
295- _ , implementMarshaler := data .(yaml.Marshaler )
296295 err , isError := data .(error )
297296
298- if isError && ! implementMarshaler {
297+ if isError {
299298 data = map [string ]string {
300299 "error" : err .Error (),
301300 }
@@ -305,9 +304,16 @@ func (p *Printer) printYAML(data any) error {
305304 if isError {
306305 writer = p .stderr
307306 }
308- encoder := yaml .NewEncoder (writer )
307+ bytes , err := yaml .Marshal (data )
308+ if err != nil {
309+ return err
310+ }
311+ _ , err = writer .Write (bytes )
312+ if err != nil {
313+ return err
314+ }
309315
310- return encoder . Encode ( data )
316+ return nil
311317}
312318
313319func (p * Printer ) printTemplate (data any ) error {
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ require (
3232 golang.org/x/sync v0.18.0
3333 golang.org/x/term v0.37.0
3434 golang.org/x/text v0.31.0
35- gopkg.in/yaml.v3 v3.0.1
3635)
3736
3837require (
@@ -213,6 +212,7 @@ require (
213212 gopkg.in/dnaeon/go-vcr.v4 v4.0.6 // indirect
214213 gopkg.in/warnings.v0 v0.1.2 // indirect
215214 gopkg.in/yaml.v2 v2.4.0 // indirect
215+ gopkg.in/yaml.v3 v3.0.1 // indirect
216216 gotest.tools/gotestsum v1.12.3 // indirect
217217)
218218
Original file line number Diff line number Diff line change 88 "runtime"
99 "text/template"
1010
11+ "github.com/ghodss/yaml"
1112 "github.com/scaleway/scaleway-cli/v2/internal/alias"
1213 "github.com/scaleway/scaleway-sdk-go/scw"
13- "gopkg.in/yaml.v3"
1414)
1515
1616const (
You can’t perform that action at this time.
0 commit comments