Skip to content

router: add opaque config#494

Merged
mattklein123 merged 13 commits intomasterfrom
opaqueconfig
Mar 2, 2017
Merged

router: add opaque config#494
mattklein123 merged 13 commits intomasterfrom
opaqueconfig

Conversation

@wgallagher
Copy link
Copy Markdown

@wgallagher wgallagher commented Feb 17, 2017

fixes #413

rate_limit_policy_(route), shadow_policy_(route),
priority_(ConfigUtility::parsePriority(route)) {
priority_(ConfigUtility::parsePriority(route)),
opaque_config_(route.getObject("opaque_config")) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that is safe. The main JSON file gets blown away and your are going to point to nothing. This is just a weak pointer. Your test doesn't cover this because you keep the JSON parent alive. I would try switching your test to destroy the loader before you run the tests and it will probably crash.

With that said, I'm not crazy about returning raw JSON here. Can we potentially just do std::unordered_map<std::string, std::string>? Is that general enough for now?

@mattklein123
Copy link
Copy Markdown
Member

For whatever the final solution ends up being you need to add config docs.

.. code-block:: json

[
{"name": "...", "value": "..."}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird to do this instead of just a JSON object. Does order matter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally supported Json objects but matt and I decided to move to this for simplicity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought Matt's comment was about how the JSON is returned. An unorderd map would be a flat JSON Object where all values are strings. That's a bit different from an array of JSON objects with name and value pairs. This format seems like it's the same structure represented in a more obtuse way.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to figure out how to get the schema to support what you are describing. @mattklein123 thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.17 I think you want additionalProperties or patternProperties.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{"type": "object",
 "additionalProperties": {"type": "string"}}

^ maybe that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a way to do it in the schema, I agree that a JSON dictionary of strings is better. I'm just not sure how to do it. If the above works then that's fine.

@RyanMcG
Copy link
Copy Markdown
Contributor

RyanMcG commented Feb 22, 2017

👍 assuming this config will this be easily accessible in BearerTokenAuthFilter::getLyftToken and BearerTokenAuthFilter::failure.

}
}

std::string asString() const {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add dedicated test for this function, including the exception part.

@RyanMcG
Copy link
Copy Markdown
Contributor

RyanMcG commented Feb 27, 2017

👍 looks good to me.

if (key == "name1") {
EXPECT_EQ("value1", value.asString());
} else {
EXPECT_THROW(value.asString(), Exception);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should throw a JsonException

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, sorry

@wgallagher
Copy link
Copy Markdown
Author

🔨

@mattklein123 mattklein123 reopened this Mar 1, 2017
Copy link
Copy Markdown
Contributor

@RyanMcG RyanMcG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think my opinion matters here anymore, but 👍

@RyanMcG
Copy link
Copy Markdown
Contributor

RyanMcG commented Mar 1, 2017

@wgallagher should probably add "Fix #413" to the description.

@wgallagher wgallagher changed the title opaque config fix #413: opaque config Mar 1, 2017
@mattklein123 mattklein123 changed the title fix #413: opaque config router: add opaque config Mar 2, 2017
@mattklein123 mattklein123 merged commit d162bcc into master Mar 2, 2017
@mattklein123 mattklein123 deleted the opaqueconfig branch March 2, 2017 01:06
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
wolfguoliang pushed a commit to wolfguoliang/envoy that referenced this pull request Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support opaque configuration settings on route

3 participants