-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add additional pubber opts #338
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
|
||
ROOT_DIR=$(realpath $(dirname $0)/..) | ||
|
||
if [ $# != 4 ]; then | ||
echo $0 SITE_PATH PROJECT_ID DEVICE_ID SERIAL_NO | ||
if [[ "${#}" -lt "4" ]]; then | ||
echo $0 SITE_PATH PROJECT_ID DEVICE_ID SERIAL_NO [options] ... | ||
false | ||
fi | ||
|
||
|
@@ -23,4 +23,35 @@ $ROOT_DIR/pubber/bin/build > /dev/null | |
|
||
echo Running tools version `(cd $ROOT_DIR; git describe)` | ||
|
||
$ROOT_DIR/pubber/bin/run $project_id $site_path $device_id $serial_no | ||
if [[ "${#}" -gt "0" ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would flip the if condition so the short branch is first, rather than after the else (just makes it easier to read) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. condition flipped |
||
declare -A options | ||
for option in $*; do | ||
if [[ $option == *"="* ]]; then | ||
k=$(echo $option | cut -d'=' -f1) | ||
v=$(echo $option | cut -d'=' -f2) | ||
options[$k]=$v | ||
else | ||
options[$option]=$option | ||
fi | ||
done | ||
|
||
extra_field="${options[extra_field]}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this used? I would expect somewhere in this PR to see how the added functionality is used... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
extra_point="${options[extra_point]}" | ||
|
||
cloud_region=`jq -r .cloud_region $site_path/cloud_iot_config.json` | ||
|
||
cat <<EOF > /tmp/pubber_config.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent seems too much? |
||
{ | ||
"projectId": "$project_id", | ||
"sitePath": "$site_path", | ||
"cloudRegion": "$cloud_region", | ||
"deviceId": "$device_id", | ||
"serialNo": "$serial", | ||
"extraField": "$extra_field", | ||
"extraPoint": "$extra_point" | ||
} | ||
EOF | ||
$ROOT_DIR/pubber/bin/run /tmp/pubber_config.json | ||
else | ||
$ROOT_DIR/pubber/bin/run $project_id $site_path $device_id $serial_no | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? $# is a lot easier to read! (Also, quotes are unnecessary with [[, since it's an explicit different parser to avoid the extra clutter!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use
((
instead as per style guide