Skip to content

Commit c6d56c4

Browse files
authored
Merge pull request #380 from databacker/native-yaml-support
native yaml support based on api
2 parents 5308017 + fc136f2 commit c6d56c4

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
)
3232

3333
require (
34-
github.com/databacker/api/go/api v0.0.0-20241107135529-dabd5b1d3c68
34+
github.com/databacker/api/go/api v0.0.0-20241128084006-ed33dc044eaa
3535
github.com/google/go-cmp v0.6.0
3636
go.opentelemetry.io/otel v1.31.0
3737
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
7070
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
7171
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
7272
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
73-
github.com/databacker/api/go/api v0.0.0-20241107135529-dabd5b1d3c68 h1:xxLIWTReBE6tS0TrVbrGIPhuoaIbtB9hHOhe887EUTQ=
74-
github.com/databacker/api/go/api v0.0.0-20241107135529-dabd5b1d3c68/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
73+
github.com/databacker/api/go/api v0.0.0-20241128084006-ed33dc044eaa h1:cDI48+AG1mPMdvgGWz/SLpNKhzDiGZwfSSww9VvvWuI=
74+
github.com/databacker/api/go/api v0.0.0-20241128084006-ed33dc044eaa/go.mod h1:bQhbl71Lk1ATni0H+u249hjoQ8ShAdVNcNjnw6z+SbE=
7575
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7676
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
7777
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

pkg/config/process.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package config
22

33
import (
4-
"encoding/json"
54
"errors"
65
"fmt"
76
"io"
@@ -47,8 +46,7 @@ func ProcessConfig(r io.Reader) (actualConfig *api.ConfigSpec, err error) {
4746
// is incorrect.
4847
// We fix this by converting the spec part of the config into json,
4948
// as yaml is a valid subset of json, and then unmarshalling that.
50-
jsonBytes := yamlToJSON(specBytes)
51-
if err := json.Unmarshal(jsonBytes, &spec); err != nil {
49+
if err := yaml.Unmarshal(specBytes, &spec); err != nil {
5250
return nil, fmt.Errorf("parsed yaml had kind local, but spec invalid")
5351
}
5452
actualConfig = &spec
@@ -93,15 +91,3 @@ func getRemoteConfig(spec api.RemoteSpec) (conf api.Config, err error) {
9391

9492
return baseConf, nil
9593
}
96-
97-
func yamlToJSON(yamlBytes []byte) []byte {
98-
var m map[string]interface{}
99-
if err := yaml.Unmarshal(yamlBytes, &m); err != nil {
100-
return nil
101-
}
102-
jsonBytes, err := json.Marshal(m)
103-
if err != nil {
104-
return nil
105-
}
106-
return jsonBytes
107-
}

0 commit comments

Comments
 (0)