Skip to content

Commit

Permalink
Allow comments in flavors
Browse files Browse the repository at this point in the history
Summary: allow comments in mcrouter flavors.

Test Plan: mcrouter unit tests

Reviewed By: @int

Differential Revision: D2040484
  • Loading branch information
Pavlo Kushnir authored and andreazevedo committed May 12, 2015
1 parent ec9b092 commit d711b1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions mcrouter/flavor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool readLibmcrouterFlavor(
const std::string& flavor_json,
std::unordered_map<std::string, std::string>& opts) {
try {
auto json = parseJsonString(flavor_json);
auto json = parseJsonString(folly::json::stripComments(flavor_json));
return parse_json_options(json, "options", opts);
} catch (...) {
return false;
Expand All @@ -88,7 +88,8 @@ bool readStandaloneFlavor(
std::unordered_map<std::string, std::string>& standalone_opts,
std::unordered_map<std::string, std::string>& libmcrouter_opts) {
try {
auto json = parseJsonString(standalone_flavor_json);
auto json = parseJsonString(
folly::json::stripComments(standalone_flavor_json));

if (!parse_json_options(json, "standalone_options", standalone_opts)) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions mcrouter/test/cpp_unit_tests/flavor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST(Flavor, readStandaloneFlavor) {
std::string flavorContents =
"{"
"\"libmcrouter_options\": {"
"\"default_route\": \"abc\""
"\"default_route\": \"abc\" /* comment */"
"},"
"\"standalone_options\": {"
"\"port\": \"11001\", "
Expand Down Expand Up @@ -99,7 +99,7 @@ TEST(Flavor, readFlavorFromTwoFiles) {
std::string flavorStandaloneContents =
"{"
"\"standalone_options\": {"
"\"port\": \"11001\", "
"\"port\": \"11001\", /* comment */"
"\"log_file\": \"mcrouter.log\""
"}"
"}";
Expand Down Expand Up @@ -164,6 +164,7 @@ TEST(Flavor, readFlavorFromTwoFilesShouldOverrideLibmcrouterOptions) {
std::string flavorContents =
"{"
"\"options\": {"
"// comment\n"
"\"default_route\": \"abc\""
"}"
"}";
Expand Down

0 comments on commit d711b1c

Please sign in to comment.