Skip to content

JobTracker reports enum values #12885

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

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ protected static Map<String, Object> configToMetadata(final String jsonPath, fin
* array) then returns a map of {null: toMetadataValue(config)}.
*/
private static Map<String, Object> configToMetadata(final JsonNode config, final JsonNode schema) {
if (schema.hasNonNull("const")) {
// If this schema is a const, then just dump it into a map:
if (schema.hasNonNull("const") || schema.hasNonNull("enum")) {
// If this schema is a const or an enum, then just dump it into a map:
// * If it's an object, flatten it
// * Otherwise, do some basic conversions to value-ish data.
// It would be a weird thing to declare const: null, but in that case we don't want to report null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}
},
"const_null": null,
"enum_string": "foo",
"additionalPropertiesUnset": {
"foo": "bar"
},
Expand All @@ -27,5 +28,6 @@
},
"additionalPropertiesConst": {
"foo": 42
}
},
"additionalPropertiesEnumString": "foo"
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"const_null": {
"const": null
},
"enum_string": {
"type": "string",
"enum": ["foo", "bar"]
},
"additionalPropertiesUnset": {
"type": "object"
},
Expand All @@ -62,6 +66,10 @@
"additionalProperties": {
"const": 42
}
},
"additionalPropertiesEnumString": {
"type": "string",
"enum": ["foo", "bar"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,12 @@ void testConfigToMetadata() throws IOException {
.put(JobTracker.CONFIG + ".const_object.sub_key", "bar")
.put(JobTracker.CONFIG + ".const_object.sub_array", "[1,2,3]")
.put(JobTracker.CONFIG + ".const_object.sub_object.sub_sub_key", "baz")
.put(JobTracker.CONFIG + ".enum_string", "foo")
.put(JobTracker.CONFIG + ".additionalPropertiesUnset.foo", JobTracker.SET)
.put(JobTracker.CONFIG + ".additionalPropertiesBoolean.foo", JobTracker.SET)
.put(JobTracker.CONFIG + ".additionalPropertiesSchema.foo", JobTracker.SET)
.put(JobTracker.CONFIG + ".additionalPropertiesConst.foo", 42)
.put(JobTracker.CONFIG + ".additionalPropertiesEnumString", "foo")
.build();

final Map<String, Object> actual = JobTracker.configToMetadata(JobTracker.CONFIG, config, schema);
Expand Down