Skip to content
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

Fix/white list string #16

Open
wants to merge 3 commits into
base: humble
Choose a base branch
from
Open
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
28 changes: 25 additions & 3 deletions snap/local/config_from_content_snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,30 @@ if [ ! -f "$CONFIGURATION_FILE_PATH" ]; then
exit 1
fi

snapctl set port=$(yq '.port // 54321' $CONFIGURATION_FILE_PATH)
snapctl set address=$(yq '.address // "0.0.0.0"' $CONFIGURATION_FILE_PATH)
snapctl set topic-whitelist="$(yq '.topic-whitelist // "*"' $CONFIGURATION_FILE_PATH)"
OPTIONS="port
address
tls
certfile
keyfile
topic-whitelist
param-whitelist
service-whitelist
client-topic-whitelist
min-qos-depth
max-qos-depth
num-threads
send-buffer-limit
use-sim-time
use-compression
capabilities
include-hidden
asset-uri-allowlist"

for OPTION in ${OPTIONS}; do
VALUE="$(yq -e ".${OPTION}" $CONFIGURATION_FILE_PATH || true)"
if [ "${VALUE}" != null ]; then
snapctl set "${OPTION}"="${VALUE}"
fi
done

$SNAP/usr/bin/validate_config.sh
2 changes: 1 addition & 1 deletion snap/local/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ if [ "${LAUNCH_OPTIONS}" ]; then
logger -t ${SNAP_NAME} "Running with options: ${LAUNCH_OPTIONS}"
fi

ros2 launch foxglove_bridge foxglove_bridge_launch.xml "${LAUNCH_OPTIONS}"
ros2 launch foxglove_bridge foxglove_bridge_launch.xml ${LAUNCH_OPTIONS}
8 changes: 8 additions & 0 deletions snap/local/validate_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ for opt in tls include_hidden use_sim_time use_compression; do
fi
done

# Enforce bash list as a string synthax
for opt in topic-whitelist param-whitelist service-whitelist client-topic-whitelist; do
VALUE=$(snapctl get "${opt}")
if [ -n "${VALUE}" ]; then
snapctl set "${opt}"=$(echo ${VALUE} | tr -d ' ')
artivis marked this conversation as resolved.
Show resolved Hide resolved
fi
done

# @todo assert the rest of the parameters.
Loading