Skip to content

Commit f1293f9

Browse files
authored
fix(internal/sidekick): remove github.com/ghodss/yaml dependency (#1574)
Replace use of github.com/ghodss/yaml with a small function since the needed functionality is only a few lines of code. Fixes #1545
1 parent caaee72 commit f1293f9

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
cloud.google.com/go/iam v1.5.2
77
cloud.google.com/go/longrunning v0.6.7
88
github.com/cbroglie/mustache v1.4.0
9-
github.com/ghodss/yaml v1.0.0
109
github.com/go-git/go-git/v5 v5.16.1
1110
github.com/google/go-cmp v0.7.0
1211
github.com/google/go-github/v69 v69.2.0
@@ -52,5 +51,4 @@ require (
5251
golang.org/x/text v0.27.0 // indirect
5352
google.golang.org/grpc v1.74.2 // indirect
5453
gopkg.in/warnings.v0 v0.1.2 // indirect
55-
gopkg.in/yaml.v2 v2.4.0 // indirect
5654
)

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o
3131
github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
3232
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
3333
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
34-
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
35-
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
3634
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
3735
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
3836
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
@@ -164,7 +162,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
164162
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
165163
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
166164
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
167-
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
168165
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
169166
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
170167
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/sidekick/internal/parser/service_config.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
package parser
1616

1717
import (
18+
"encoding/json"
1819
"fmt"
1920
"os"
2021
"path"
2122

22-
"github.com/ghodss/yaml"
2323
"github.com/googleapis/librarian/internal/sidekick/internal/config"
2424
"google.golang.org/genproto/googleapis/api/serviceconfig"
2525
"google.golang.org/protobuf/encoding/protojson"
26+
"gopkg.in/yaml.v3"
2627
)
2728

2829
func readServiceConfig(serviceConfigPath string) (*serviceconfig.Service, error) {
@@ -31,7 +32,11 @@ func readServiceConfig(serviceConfigPath string) (*serviceconfig.Service, error)
3132
return nil, fmt.Errorf("error reading service config [%s]: %w", serviceConfigPath, err)
3233
}
3334

34-
j, err := yaml.YAMLToJSON(y)
35+
var yamlData interface{}
36+
if err := yaml.Unmarshal(y, &yamlData); err != nil {
37+
return nil, fmt.Errorf("error parsing YAML [%s]: %w", serviceConfigPath, err)
38+
}
39+
j, err := json.Marshal(yamlData)
3540
if err != nil {
3641
return nil, fmt.Errorf("error converting YAML to JSON [%s]: %w", serviceConfigPath, err)
3742
}

0 commit comments

Comments
 (0)