Skip to content

Commit e7fbbc0

Browse files
sebixaaronkaplan
authored andcommitted
Bash Completion: Adapt to YAML-style runtime configuration
fixes #2094
1 parent eb0f1a5 commit e7fbbc0

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Please refer to the [NEWS](NEWS.md) for a list of changes which have an affect o
7575
- `intelmq/lib/bot_debugger.py`: Fix overwriting the runtime logging level by command line parameter (PR#2603 by Sebastian Wagner, fixes #2563).
7676

7777
### Contrib
78+
- Bash Completion: Adapt to YAML-style runtime configuration (PR#2642 by Sebastian Wagner, fixes #2094).
7879

7980
### Known issues
8081

contrib/bash-completion/intelmqctl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2018 Sebastian Wagner
1+
# SPDX-FileCopyrightText: 2018-2020 nic.at GmbH, 2025 Institute for Common Good Technology
22
#
33
# SPDX-License-Identifier: AGPL-3.0-or-later
44
# bash completion for intelmqctl -*- shell-script -*-
@@ -18,6 +18,9 @@ _intelmqctl ()
1818
return 0
1919
fi
2020

21+
which yq >& /dev/null
22+
misses_yq=$?
23+
2124
#echo "posice: $COMP_CWORD $COMP_WORDS";
2225
case $COMP_CWORD in
2326
1)
@@ -26,19 +29,20 @@ _intelmqctl ()
2629
return 0
2730
;;
2831
2)
29-
pipeline='/opt/intelmq/etc/pipeline.conf';
30-
[ -f ${pipeline} ] || pipeline='/etc/intelmq/pipeline.conf';
32+
runtime='/opt/intelmq/etc/runtime.yaml';
33+
[ -f ${runtime} ] || runtime='/etc/intelmq/runtime.yaml';
3134
case "${COMP_WORDS[1]}" in
3235
start | stop | restart | status | reload | log | run | enable | disable)
33-
runtime='/opt/intelmq/etc/runtime.conf';
34-
[ -f ${runtime} ] || runtime='/etc/intelmq/runtime.conf';
35-
local bots=$(jq 'keys[]' $runtime);
36+
[[ "$misses_yq" -eq 1 ]] && return 0
37+
local bots=$(yq 'keys[]' $runtime | grep -v '^global$');
3638
COMPREPLY=($(compgen -W "${bots}" -- ${cur}));
3739
return 0
3840
;;
3941
clear)
40-
local bots=$(jq '.[] | .["source-queue"]' $pipeline | grep -v '^null$'; jq '.[] | .["destination-queues"]' $pipeline | grep -v '^null$' | jq '.[]');
41-
COMPREPLY=($(compgen -W "${bots}" -- ${cur}));
42+
[[ "$misses_yq" -eq 1 ]] && return 0
43+
local destination_queues=$(yq '.[] | .["parameters"] | .["destination_queues"] | .[] | .[]' $runtime);
44+
local source_queues=$(yq 'keys[]' $runtime | grep -v '^global$' | while read line; do echo "$line-queue"; done)
45+
COMPREPLY=($(compgen -W "${source_queues} ${destination_queues}" -- ${cur}));
4246
return 0
4347
;;
4448
list)

0 commit comments

Comments
 (0)