-
Notifications
You must be signed in to change notification settings - Fork 22
refactor that decouples opa-evaluator from Jackson #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,9 +83,11 @@ public void serialize(RegoNull value, JsonGenerator gen, SerializerProvider seri | |
| }; | ||
|
|
||
| static { | ||
| JSON_MAPPER = new ObjectMapper(); | ||
| // findAndRegisterModules picks up RegoValueModule (from opa-jackson) via SPI so | ||
| // RegoString/RegoArray/RegoObject etc. (de)serialize without annotations on the AST types. | ||
| JSON_MAPPER = new ObjectMapper().findAndRegisterModules(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it'd be possible to add a simple serialize/deserialize SPI to cover all of the explicit jackson dependencies, or if there are things in here that need that strict coupling?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There does seem to be some strict coupling, so this won't be straight forward change. Maybe a separate PR? |
||
|
|
||
| // Register custom serializers for Rego numeric types | ||
| // Register custom serializers for Rego numeric types (overrides RegoValueModule defaults). | ||
| SimpleModule module = new SimpleModule(); | ||
| module.addSerializer(RegoDecimal.class, REGO_DECIMAL_SERIALIZER); | ||
| module.addSerializer(RegoBigInt.class, REGO_BIG_INT_SERIALIZER); | ||
|
|
@@ -101,7 +103,8 @@ public void serialize(RegoNull value, JsonGenerator gen, SerializerProvider seri | |
|
|
||
| YAML_MAPPER = | ||
| new ObjectMapper( | ||
| YAMLFactory.builder().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER).build()); | ||
| YAMLFactory.builder().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER).build()) | ||
| .findAndRegisterModules(); | ||
| YAML_MAPPER.registerModule(yamlModule); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,9 @@ public class TokenBuiltins implements BuiltinProvider { | |
| private static final RegoString CERT_PROPERTY = new RegoString("cert"); | ||
| private static final RegoString SECRET_PROPERTY = new RegoString("secret"); | ||
| private static final RegoObject BLANK_OBJECT = new RegoObject(); | ||
| private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); | ||
| // Auto-register RegoValueModule (and any other Jackson modules on the classpath) via SPI so | ||
| // RegoObject (de)serialization works without the AST types carrying Jackson annotations. | ||
| private static final ObjectMapper JSON_MAPPER = new ObjectMapper().findAndRegisterModules(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice if we didn't have this explicit Jackson dependency here, and could just SPI-ify it. |
||
|
|
||
| static { | ||
| Security.addProvider(new BouncyCastleProvider()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?