diff options
author | Sascha Roloff <sascha.roloff@huawei.com> | 2025-05-15 12:45:42 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2025-05-15 14:32:54 +0200 |
commit | 4d989f85bde4788f456305db2e046b3ec364db08 (patch) | |
tree | c68e0f250e1792e6cfa8ab3cf7e102ef5c8e6b70 /doc/invocations-http-server | |
parent | 60bf640b927fe383002b1af9512e9d84f1b27f81 (diff) | |
download | justbuild-4d989f85bde4788f456305db2e046b3ec364db08.tar.gz |
Invocation server: add target filter
Diffstat (limited to 'doc/invocations-http-server')
-rwxr-xr-x | doc/invocations-http-server/server.py | 32 | ||||
-rw-r--r-- | doc/invocations-http-server/templates/invocation.html | 4 | ||||
-rw-r--r-- | doc/invocations-http-server/templates/invocations.html | 11 |
3 files changed, 43 insertions, 4 deletions
diff --git a/doc/invocations-http-server/server.py b/doc/invocations-http-server/server.py index 19985d3a..26920a8a 100755 --- a/doc/invocations-http-server/server.py +++ b/doc/invocations-http-server/server.py @@ -77,6 +77,8 @@ class InvocationServer: methods=("GET",), endpoint="filter_remote_prop"), rule("/filterinvocations/remote/address/<hexidentifier:value>", methods=("GET",), endpoint="filter_remote_address"), + rule("/filterinvocations/target/<hexidentifier:value>", + methods=("GET",), endpoint="filter_target"), rule("/blob/<hashidentifier:blob>", methods=("GET",), endpoint="get_blob"), @@ -120,6 +122,7 @@ class InvocationServer: context_filters = {} remote_props_filters = {} remote_address_filters = set() + target_filters = set() def add_filter(data, filters): if isinstance(filters, set): filters.add(json.dumps(data)) @@ -169,6 +172,7 @@ class InvocationServer: add_filter(context, context_filters) add_filter(remote_props, remote_props_filters) add_filter(remote_address, remote_address_filters) + add_filter(target, target_filters) invocation = { "name": e, "subcommand": profile_data.get("subcommand"), @@ -238,7 +242,8 @@ class InvocationServer: "filter_info": filter_info, "context_filters": convert_filters(context_filters), "remote_props_filters": convert_filters(remote_props_filters), - "remote_address_filters": convert_filters(remote_address_filters)}) + "remote_address_filters": convert_filters(remote_address_filters), + "target_filters": convert_filters(target_filters)}) def do_filter_remote_prop(self, key, value): filter_info = "remote-execution property" @@ -297,6 +302,23 @@ class InvocationServer: metadata_filter = check_prop, ) + def do_filter_target(self, value): + filter_info = "target" + try: + value_string = json.loads(bytes.fromhex(value).decode('utf-8')) + filter_info += " " + json.dumps(value_string) + except: + pass + + def check_prop(p): + v = p.get('target') + return (json.dumps(v).encode().hex() == value) + + return self.do_list_invocations( + filter_info = filter_info, + profile_filter = check_prop, + ) + def do_filter_noncached(self): def check_noncached(p): for v in p.get('actions', {}).values(): @@ -454,8 +476,12 @@ class InvocationServer: if profile.get('subcommand'): params["cmd"] = json.dumps( [profile.get('subcommand')] + profile.get('subcommand args', [])) - if profile.get('target'): - params["target"] = json.dumps(profile.get('target')) + target = profile.get('target') + if target: + params["target"] = { + "value": json.dumps(target), + "value_hex": json.dumps(target).encode().hex() + } if profile.get('configuration') is not None: params["config"] = json.dumps(core_config( profile.get('configuration'))) diff --git a/doc/invocations-http-server/templates/invocation.html b/doc/invocations-http-server/templates/invocation.html index c7cba837..a155e9e1 100644 --- a/doc/invocations-http-server/templates/invocation.html +++ b/doc/invocations-http-server/templates/invocation.html @@ -115,7 +115,9 @@ Inocations {{invocation | e}} </li> {% endif %} {% if target %} - <li> Target: <tt>{{ target | e }}</tt></li> + <li> Target: + <a href="/filterinvocations/target/{{ target["value_hex"] | e }}"><tt>{{ target["value"] | e }}</tt></a> + </li> {% endif %} {% if config %} <li> Target configuration: <tt>{{ config | e }}</tt></li> diff --git a/doc/invocations-http-server/templates/invocations.html b/doc/invocations-http-server/templates/invocations.html index 18f90129..607b9a7a 100644 --- a/doc/invocations-http-server/templates/invocations.html +++ b/doc/invocations-http-server/templates/invocations.html @@ -49,6 +49,17 @@ Filter by: {% endfor %} </details> {% endif %} + {% if target_filters %} + <details> + <summary>Target</summary> + {% for entry in target_filters %} + {% if loop.index > 1 %} + , + {% endif %} + <a href="/filterinvocations/target/{{ entry["value_hex"] | e }}"><tt>{{ entry["value"] | e }}</tt></a> + {% endfor %} + </details> + {% endif %} {% endif %} {% if full_invocations %} <div id="invocation-list"> |