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/removed message #300

Closed
Closed
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
11 changes: 11 additions & 0 deletions .github/workflows/monthly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Monthly
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
main:
uses: ubuntu-robotics/ros-foxglove-bridge/.github/workflows/snap.yaml@main
with:
branch-name: "main"
25 changes: 25 additions & 0 deletions .github/workflows/snap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: snap
on:
push:
branches:
- feature/snap
pull_request:
branches:
- feature/snap
workflow_dispatch:
workflow_call:
inputs:
branch-name:
required: false
type: string
default: ''

jobs:
snap:
uses: ubuntu-robotics/snap_workflows/.github/workflows/snap.yaml@main
secrets:
store-login: ${{ secrets.STORE_LOGIN }}
with:
branch-name: ${{ inputs.branch-name == '' && github.ref || inputs.branch-name }}
snap-name: foxglove-bridge
publish: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
8 changes: 8 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

$SNAP/usr/bin/validate_config.sh

# Service was already enabled, just restart it
# to make sure the new config values are picked up
snapctl restart ${SNAP_NAME}.${SNAP_NAME} 2>&1 || true

12 changes: 12 additions & 0 deletions snap/hooks/connect-plug-configuration-read
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -e

CONFIGURATION_FILE_PATH=$SNAP_COMMON/configuration/foxglove-bridge.yaml

if [ ! -f "$CONFIGURATION_FILE_PATH" ]; then
echo "Configuration file '$CONFIGURATION_FILE_PATH' does not exist."
exit 1
fi

snapctl start --enable ${SNAP_NAME}.config-from-content-snap 2>&1
snapctl restart ${SNAP_NAME} 2>&1 || true

5 changes: 5 additions & 0 deletions snap/hooks/disconnect-plug-configuration-read
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -e

snapctl stop --disable ${SNAP_NAME}.config-from-content-snap 2>&1
snapctl restart ${SNAP_NAME} 2>&1 || true

3 changes: 3 additions & 0 deletions snap/hooks/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

. $SNAP/usr/bin/reset_config.sh
15 changes: 15 additions & 0 deletions snap/local/config_from_content_snap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

CONFIGURATION_FILE_PATH=$SNAP_COMMON/configuration/foxglove-bridge.yaml

if [ ! -f "$CONFIGURATION_FILE_PATH" ]; then
echo "Configuration file '$CONFIGURATION_FILE_PATH' does not exist."
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)

$SNAP/usr/bin/validate_config.sh

38 changes: 38 additions & 0 deletions snap/local/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/sh -e

LAUNCH_OPTIONS=""

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="$(snapctl get ${OPTION})"
if [ -n "${VALUE}" ]; then
LAUNCH_OPTIONS="${LAUNCH_OPTIONS} ${OPTION}:=${VALUE}"
fi
done

# Replace '-' with '_'
LAUNCH_OPTIONS=$(echo ${LAUNCH_OPTIONS} | tr - _)

if [ "${LAUNCH_OPTIONS}" ]; then
logger -t ${SNAP_NAME} "Running with options: ${LAUNCH_OPTIONS}"
fi

ros2 launch foxglove_bridge foxglove_bridge_launch.xml ${LAUNCH_OPTIONS}
23 changes: 23 additions & 0 deletions snap/local/reset_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh -e

# All parameters are unset
# leaving the default values up to the launchfile.

snapctl set port!
snapctl set address!
snapctl set tls!
snapctl set certfile!
snapctl set keyfile!
snapctl set topic-whitelist!
snapctl set param-whitelist!
snapctl set service-whitelist!
snapctl set client-topic-whitelist!
snapctl set min-qos-depth!
snapctl set max-qos-depth!
snapctl set num-threads!
snapctl set send-buffer-limit!
snapctl set use-sim-time!
snapctl set use-compression!
snapctl set capabilities!
snapctl set include-hidden!
snapctl set asset-uri-allowlist!
62 changes: 62 additions & 0 deletions snap/local/validate_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash -e

# Here we can assert that the parameters value set by the user are proper.

# Get the parameters values.
# They may be 'unset' as per the install hook.
port="$(snapctl get port)"
address="$(snapctl get address)"
tls="$(snapctl get tls)"
certfile="$(snapctl get certfile)"
keyfile="$(snapctl get keyfile)"
topic_whitelist="$(snapctl get topic-whitelist)"
param_whitelist="$(snapctl get param-whitelist)"
service_whitelist="$(snapctl get service-whitelist)"
client_topic_whitelist="$(snapctl get client-topic-whitelist)"
min_qos_depth="$(snapctl get min-qos-depth)"
max_qos_depth="$(snapctl get max-qos-depth)"
num_threads="$(snapctl get num-threads)"
send_buffer_limit="$(snapctl get send-buffer-limit)"
use_sim_time="$(snapctl get use-sim-time)"
use_compression="$(snapctl get use-compression)"
capabilities="$(snapctl get capabilities)"
include_hidden="$(snapctl get include-hidden)"
asset_uri_allowlist="$(snapctl get asset-uri-allowlist)"

# If the parameter has been explicitely set by the user
if [ -n "${port}" ]; then
# Check that it is a valid value
if ! expr "${port}" : '^[0-9]\+$' > /dev/null; then
logger -t ${SNAP_NAME} "'${opt}' is not a valid port value."
echo "'${port}' is not a valid port value" >&2
return 1
fi
fi

for opt in max_qos_depth num_threads send_buffer_limit; do
if [ -n "${!opt}" ]; then
# Check that it is a valid value
if ! expr "${!opt}" : '^[0-9]\+$' > /dev/null; then
logger -t ${SNAP_NAME} "'${!opt}' is not a valid value for ${opt}."
echo "'${!opt}' is not a valid value for ${opt}." >&2
return 1
fi
fi
done

for opt in tls include_hidden use_sim_time use_compression; do
if [ -n "${!opt}" ]; then
case "${!opt}" in
True) ;;
False) ;;
*)
logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'."
echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." >&2
return 1
;;
esac
fi
done

# @todo assert the rest of the parameters.

Loading
Loading