Skip to content

Commit 8ee400c

Browse files
authored
fix: migrate yaml to github.com/ghodss/yaml (#5183)
1 parent 7d8851c commit 8ee400c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

core/printer.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
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

294294
func (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

313319
func (p *Printer) printTemplate(data any) error {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

3837
require (
@@ -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

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
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

1616
const (

0 commit comments

Comments
 (0)