forked from faucetsdn/udmi
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into documentation
- Loading branch information
Showing
44 changed files
with
5,817 additions
and
1,517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash -e | ||
# | ||
# For simple debugging, just run in a shell loop: | ||
# while true; do bin/pull_message PROJECT_ID; done | ||
# | ||
|
||
ROOT=$(realpath $(dirname $0)/..) | ||
|
||
kubectl config current-context | tr _ ' ' > /tmp/namespace_tmp | ||
# Result is something like: gke bos-platform-dev us-central1 main grafnu | ||
read < /tmp/namespace_tmp gcp project_id region cluster namespace | ||
|
||
subscription=$namespace~debug | ||
tmp_file=/tmp/captured.json | ||
|
||
while true; do | ||
gcloud --format=json --project=$project_id pubsub subscriptions pull $subscription --auto-ack > $tmp_file || true | ||
|
||
subType=$(jq -r '.[0].message.attributes.subType' $tmp_file 2> /dev/null) | ||
subFolder=$(jq -r '.[0].message.attributes.subFolder' $tmp_file 2> /dev/null) | ||
deviceId=$(jq -r '.[0].message.attributes.deviceId' $tmp_file 2> /dev/null) | ||
registryId=$(jq -r '.[0].message.attributes.deviceRegistryId' $tmp_file 2> /dev/null) | ||
timestamp=$(jq -r '.[0].message.publishTime' $tmp_file 2> /dev/null) | ||
raw_data=$(jq -r .[0].message.data $tmp_file) | ||
# There's two different base64 formats, so replace - with + to handle both. | ||
data=$(echo $raw_data | tr - + | base64 --decode) | ||
|
||
if [[ $raw_data == null ]]; then | ||
continue | ||
fi | ||
|
||
if [[ -z $data ]]; then | ||
echo Bad/empty message data: $raw_data | ||
fi | ||
|
||
if [[ $subType == null ]]; then | ||
subType=event | ||
fi | ||
|
||
if [[ $subFolder != null ]]; then | ||
out_file=$ROOT/out/registries/$registryId/devices/$deviceId/${timestamp}_${subFolder}_${subType}.json | ||
echo $out_file | ||
mkdir -p $(dirname $out_file) | ||
echo $data | jq . > $out_file | ||
else | ||
echo No matching messages found. | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.