Skip to content

Commit

Permalink
Remove support for YAML because it creates maps with interface{} for …
Browse files Browse the repository at this point in the history
…keys, instead of strings

Signed-off-by: Yuri Shkuro <ys@uber.com>
  • Loading branch information
Yuri Shkuro committed Oct 27, 2017
1 parent 8eefa3c commit b557609
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion cmd/query/app/builder/builder_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func AddFlags(flagSet *flag.FlagSet) {
flagSet.Int(queryPort, 16686, "The port for the query service")
flagSet.String(queryPrefix, "api", "The prefix for the url of the query service")
flagSet.String(queryStaticFiles, "jaeger-ui-build/build/", "The path for the static assets for the UI")
flagSet.String(queryUIConfig, "", "The path to the UI config file")
flagSet.String(queryUIConfig, "", "The path to the UI configuration file in JSON format")
flagSet.Int(queryHealthCheckHTTPPort, 16687, "The http port for the health check service")
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/query/app/fixture/ui-config-menu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"menu": [
{
"label": "GitHub",
"url": "https://github.com/jaegertracing/jaeger"
}
]
}
4 changes: 3 additions & 1 deletion cmd/query/app/fixture/ui-config.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{"x": "y"}
{
"x": "y"
}
4 changes: 0 additions & 4 deletions cmd/query/app/fixture/ui-config.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions cmd/query/app/fixture/ui-config.yml

This file was deleted.

9 changes: 3 additions & 6 deletions cmd/query/app/static_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/gorilla/mux"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)

const (
Expand Down Expand Up @@ -55,16 +54,16 @@ func NewStaticAssetsHandler(staticAssetsRoot string, uiConfig string) (*StaticAs
if err != nil {
return nil, errors.Wrap(err, "Cannot read UI static assets")
}
configString := "JAEGER_CONFIG = DEFAULT_CONFIG;"
configString := "JAEGER_CONFIG = DEFAULT_CONFIG"
if config, err := loadUIConfig(uiConfig); err != nil {
return nil, err
} else if config != nil {
bytes, _ := json.Marshal(config)
configString = fmt.Sprintf("JAEGER_CONFIG = %v;", string(bytes))
configString = fmt.Sprintf("JAEGER_CONFIG = %v", string(bytes))
}
return &StaticAssetsHandler{
staticAssetsRoot: staticAssetsRoot,
indexHTML: configPattern.ReplaceAll(indexBytes, []byte(configString)),
indexHTML: configPattern.ReplaceAll(indexBytes, []byte(configString+";")),
}, nil
}

Expand All @@ -82,8 +81,6 @@ func loadUIConfig(uiConfig string) (map[string]interface{}, error) {
var unmarshal func([]byte, interface{}) error

switch strings.ToLower(ext) {
case ".yaml", ".yml":
unmarshal = yaml.Unmarshal
case ".json":
unmarshal = json.Unmarshal
default:
Expand Down
25 changes: 11 additions & 14 deletions cmd/query/app/static_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,19 @@ func TestLoadUIConfig(t *testing.T) {
configFile: "fixture/ui-config-malformed.json",
expectedError: "Cannot parse UI config file fixture/ui-config-malformed.json: invalid character '=' after object key",
})
run("yaml", testCase{
configFile: "fixture/ui-config.yaml",
expected: map[string]interface{}{
"x": "abcd",
"z": []interface{}{"a", "b"},
},
})
run("yml", testCase{
configFile: "fixture/ui-config.yml",
expected: map[string]interface{}{
"x": "abcd",
"z": []interface{}{"a", "b"},
},
})
run("json", testCase{
configFile: "fixture/ui-config.json",
expected: map[string]interface{}{"x": "y"},
})
run("json-menu", testCase{
configFile: "fixture/ui-config-menu.json",
expected: map[string]interface{}{
"menu": []interface{}{
map[string]interface{}{
"label": "GitHub",
"url": "https://github.com/jaegertracing/jaeger",
},
},
},
})
}

0 comments on commit b557609

Please sign in to comment.