[schemas] anchor patterns in the config/format json schemas

Also, add a check-local that runs a third-party validator
on the builtin configs/formats.
pull/1249/head
Tim Stack 2 months ago
parent 9a715fc439
commit b33713904e

@ -71,8 +71,11 @@ jobs:
libbz2-dev
libcurl4-openssl-dev
libreadline-dev
pipx
tshark
zlib1g-dev
- name: Install python packages
run: pipx install check-jsonschema
- name: autogen
run: ./autogen.sh
- name: configure

@ -56,6 +56,7 @@ AC_PATH_PROG(RE2C_CMD, [re2c])
AM_CONDITIONAL(HAVE_RE2C, test x"$RE2C_CMD" != x"")
AC_PATH_PROG(XZ_CMD, [xz])
AC_PATH_PROG(TSHARK_CMD, [tshark])
AC_PATH_PROG(CHECK_JSONSCHEMA, [check-jsonschema])
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)
@ -310,6 +311,7 @@ AM_CONDITIONAL(HAVE_CARGO, test x"$CARGO_CMD" != x"")
AM_CONDITIONAL(USE_INCLUDED_YAJL, test $HAVE_LOCAL_YAJL -eq 0)
AM_CONDITIONAL(HAVE_LIBCURL, test x"$LIBCURL" != x"")
AM_CONDITIONAL([CROSS_COMPILING], [ test x"$cross_compiling" != x"no" ])
AM_CONDITIONAL(HAVE_CHECK_JSONSCHEMA, test x"$CHECK_JSONSCHEMA" != x"")
AS_VAR_SET(USER_CXXFLAGS, ["$CXXFLAGS"])
AC_SUBST(USER_CXXFLAGS)

@ -140,7 +140,7 @@
"title": "/tuning/remote/ssh/options",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"title": "/tuning/remote/ssh/options/<option_name>",
"description": "Set an option to be passed to the SSH command",
"type": "string"
@ -153,7 +153,7 @@
"title": "/tuning/remote/ssh/config",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"title": "/tuning/remote/ssh/config/<config_name>",
"description": "Set an SSH configuration value",
"type": "string"
@ -177,7 +177,7 @@
"title": "/tuning/clipboard/impls",
"type": "object",
"patternProperties": {
"([\\w\\-]+)": {
"^([\\w\\-]+)$": {
"description": "Clipboard implementation",
"title": "/tuning/clipboard/impls/<clipboard_impl_name>",
"type": "object",
@ -214,7 +214,7 @@
"title": "/tuning/url-scheme",
"type": "object",
"patternProperties": {
"([a-z][\\w\\-\\+\\.]+)": {
"^([a-z][\\w\\-\\+\\.]+)$": {
"description": "Definition of a custom URL scheme",
"title": "/tuning/url-scheme/<url_scheme>",
"type": "object",
@ -272,7 +272,7 @@
"title": "/ui/theme-defs",
"type": "object",
"patternProperties": {
"([\\w\\-]+)": {
"^([\\w\\-]+)$": {
"description": "Theme definitions",
"title": "/ui/theme-defs/<theme_name>",
"type": "object",
@ -282,7 +282,7 @@
"title": "/ui/theme-defs/<theme_name>/vars",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"title": "/ui/theme-defs/<theme_name>/vars/<var_name>",
"description": "A theme variable definition",
"type": "string"
@ -694,7 +694,7 @@
"title": "/ui/theme-defs/<theme_name>/log-level-styles",
"type": "object",
"patternProperties": {
"(trace|debug5|debug4|debug3|debug2|debug|info|stats|notice|warning|error|critical|fatal|invalid)": {
"^(trace|debug5|debug4|debug3|debug2|debug|info|stats|notice|warning|error|critical|fatal|invalid)$": {
"title": "/ui/theme-defs/<theme_name>/log-level-styles/<level>",
"$ref": "#/definitions/style"
}
@ -706,7 +706,7 @@
"title": "/ui/theme-defs/<theme_name>/highlights",
"type": "object",
"patternProperties": {
"([\\w\\-]+)": {
"^([\\w\\-]+)$": {
"title": "/ui/theme-defs/<theme_name>/highlights/<highlight_name>",
"type": "object",
"properties": {
@ -758,12 +758,12 @@
"title": "/ui/keymap-defs",
"type": "object",
"patternProperties": {
"([\\w\\-]+)": {
"^([\\w\\-]+)$": {
"description": "The keymap definitions",
"title": "/ui/keymap-defs/<keymap_name>",
"type": "object",
"patternProperties": {
"((?:x[0-9a-f]{2})+)": {
"^((?:x[0-9a-f]{2})+)$": {
"description": "Map of key codes to commands to execute. The field names are the keys to be mapped using as a hexadecimal representation of the UTF-8 encoding. Each byte of the UTF-8 should start with an 'x' followed by the hexadecimal representation of the byte.",
"title": "/ui/keymap-defs/<keymap_name>/<key_seq>",
"type": "object",
@ -817,7 +817,7 @@
"title": "/log/watch-expressions",
"type": "object",
"patternProperties": {
"([\\w\\.\\-]+)": {
"^([\\w\\.\\-]+)$": {
"description": "A log message watch expression",
"title": "/log/watch-expressions/<watch_name>",
"type": "object",
@ -842,7 +842,7 @@
"title": "/log/annotations",
"type": "object",
"patternProperties": {
"([\\w\\.\\-]+)": {
"^([\\w\\.\\-]+)$": {
"title": "/log/annotations/<annotation_name>",
"type": "object",
"properties": {
@ -877,7 +877,7 @@
"title": "/global",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"title": "/global/<var_name>",
"description": "A global variable definition. Global variables can be referenced in scripts, SQL statements, or commands.",
"type": "string"

@ -41,7 +41,7 @@
"title": "/values",
"type": "object",
"patternProperties": {
"([\\w\\-]+)": {
"^([\\w\\-]+)$": {
"title": "/values/<name>",
"type": [
"boolean",

@ -10,7 +10,7 @@
}
},
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"description": "The definition of a log file format.",
"title": "/<format_name>",
"type": "object",
@ -20,7 +20,7 @@
"title": "/<format_name>/regex",
"type": "object",
"patternProperties": {
"([^/]+)": {
"^(.+)$": {
"description": "The set of patterns used to match log messages",
"title": "/<format_name>/regex/<pattern_name>",
"type": "object",
@ -95,7 +95,7 @@
"title": "/<format_name>/converter/header/expr",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"title": "/<format_name>/converter/header/expr/<header_expr_name>",
"description": "SQLite expression",
"type": "string"
@ -214,7 +214,7 @@
"title": "/<format_name>/opid/description",
"type": "object",
"patternProperties": {
"([\\w\\.\\-]+)": {
"^([\\w\\.\\-]+)$": {
"description": "A type of description for this operation",
"title": "/<format_name>/opid/description/<opid_descriptor>",
"type": "object",
@ -266,7 +266,7 @@
"title": "/<format_name>/opid/sub-description",
"type": "object",
"patternProperties": {
"([\\w\\.\\-]+)": {
"^([\\w\\.\\-]+)$": {
"description": "A type of description for this sub-operation",
"title": "/<format_name>/opid/sub-description/<subid_descriptor>",
"type": "object",
@ -326,7 +326,7 @@
"title": "/<format_name>/level",
"type": "object",
"patternProperties": {
"(trace|debug[2345]?|info|stats|notice|warning|error|critical|fatal)": {
"^(trace|debug[2345]?|info|stats|notice|warning|error|critical|fatal)$": {
"title": "/<format_name>/level/<level>",
"description": "The regular expression used to match the log text for this level. For JSON logs with numeric levels, this should be the number for the corresponding level.",
"type": [
@ -342,7 +342,7 @@
"title": "/<format_name>/value",
"type": "object",
"patternProperties": {
"([^/]+)": {
"^(.+)$": {
"description": "The set of values captured by the log message patterns",
"title": "/<format_name>/value/<value_name>",
"type": "object",
@ -382,7 +382,7 @@
"title": "/<format_name>/value/<value_name>/unit/scaling-factor",
"type": "object",
"patternProperties": {
"([^/]+)": {
"^(.+)$": {
"title": "/<format_name>/value/<value_name>/unit/scaling-factor/<scale>",
"type": "object",
"properties": {
@ -455,7 +455,7 @@
"title": "/<format_name>/tags",
"type": "object",
"patternProperties": {
"([\\w:;\\._\\-]+)": {
"^([\\w:;\\._\\-]+)$": {
"description": "The name of the tag to apply",
"title": "/<format_name>/tags/<tag_name>",
"type": "object",
@ -523,7 +523,7 @@
"title": "/<format_name>/partitions",
"type": "object",
"patternProperties": {
"([\\w:;\\._\\-]+)": {
"^([\\w:;\\._\\-]+)$": {
"description": "The type of partition to apply",
"title": "/<format_name>/partitions/<partition_type>",
"type": "object",
@ -590,7 +590,7 @@
"title": "/<format_name>/action",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"title": "/<format_name>/action/<action_name>",
"type": [
"string",
@ -751,7 +751,7 @@
"title": "/<format_name>/search-table",
"type": "object",
"patternProperties": {
"(\\w+)": {
"^(\\w+)$": {
"description": "The set of search tables to be automatically defined",
"title": "/<format_name>/search-table/<table_name>",
"type": "object",
@ -797,7 +797,7 @@
"title": "/<format_name>/highlights",
"type": "object",
"patternProperties": {
"([^/]+)": {
"^(.+)$": {
"description": "The definition of a highlight",
"title": "/<format_name>/highlights/<highlight_name>",
"type": "object",

@ -612,5 +612,11 @@ else
all-local: $(LNAV_BUILT_FILES) $(RUST_DEPS)
endif
check-local:
if HAVE_CHECK_JSONSCHEMA
$(CHECK_JSONSCHEMA) --schemafile $(top_srcdir)/docs/schemas/format-v1.schema.json $(FORMAT_FILES)
$(CHECK_JSONSCHEMA) --schemafile $(top_srcdir)/docs/schemas/config-v1.schema.json $(CONFIG_FILES)
endif
install-exec-hook:
bash $(srcdir)/alpha-release.sh

@ -3296,8 +3296,11 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
{
rescan_files(true);
gather_pipers();
rebuild_indexes(ui_clock::now() + 10ms);
if (lnav_data.ld_child_pollers.empty()) {
auto rebuild_res = rebuild_indexes(ui_clock::now() + 15ms);
if (rebuild_res.rir_completed
&& lnav_data.ld_child_pollers.empty())
{
rebuild_indexes_repeatedly();
if (lnav_data.ld_active_files.fc_files.empty()
|| lnav_data.ld_active_files.fc_files[0]->size() < 24)
{

@ -1529,6 +1529,7 @@ json_path_container::gen_schema(yajlpp_gen_context& ygc) const
void
json_path_container::gen_properties(yajlpp_gen_context& ygc) const
{
static const auto FWD_SLASH = lnav::pcre2pp::code::from_const(R"(\[\^/\])");
auto pattern_count = count_if(
this->jpc_children.begin(), this->jpc_children.end(), [](auto& jph) {
return jph.jph_is_pattern_property;
@ -1558,7 +1559,10 @@ json_path_container::gen_properties(yajlpp_gen_context& ygc) const
if (!child_handler.jph_is_pattern_property) {
continue;
}
properties.gen(child_handler.jph_property);
auto pattern = child_handler.jph_property;
pattern = FWD_SLASH.replace(pattern, ".");
properties.gen(fmt::format(FMT_STRING("^{}$"), pattern));
child_handler.gen_schema(ygc);
}
}

Loading…
Cancel
Save