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

Add namespaces for registries, topics, and k8s installs #747

Merged
merged 27 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
22 changes: 12 additions & 10 deletions .gencode_hash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ d3758eba2529d4a5f1dfd5ed3355a536936b02285ddde7cc75b1f41f4916203a gencode/docs/c
2067b2eab579b6f6667d6890dfeb72cb3ec6fbd779668c8ff7dc8f42e3f9a60b gencode/docs/config.html
d40bfc9f4a30c56986435dc08f1e5f42401e5ac043359a1e359011c913cad673 gencode/docs/config_mapping.html
08583688b20f892c0b453f41787ac01a46ac601663736bcd6ed6f57be0758e79 gencode/docs/configuration_endpoint.html
33846607c2c7241660b62b0ca1ef1f56cba922e6aa3b1a2813e3a4a0cc94a4ef gencode/docs/configuration_execution.html
e081e1438839467d3be35dd866d0cd00f4454fcc5d8e384ba03ca28cd439af87 gencode/docs/configuration_pod.html
c04311c06e142fc3bf878187f52aec10c9c88b2c538de928844db956a07ab638 gencode/docs/configuration_pubber.html
46682449ddb07a7c98e925af7854f93db9789768c479707bfb5af316e5adb403 gencode/docs/configuration_execution.html
f353c6f23baae7940ecf7a68203924d1217ffafb2802705e5f3e0498bc700e88 gencode/docs/configuration_pod.html
1f00351201985451aaa1a3e3247fc138b8bea7943b801c18cd5618f7600c872d gencode/docs/configuration_pubber.html
96186777da06f95eae1d16d73555445d23608a9301636ea1ccd17922b3fe4019 gencode/docs/event.html
587e048c161273b927de67b899204bf0e183db64e59ae513f833e5eff406b1ab gencode/docs/event_discovery.html
0f99534574718e07e655e33e76e06b56e6a96a7a42ae1457dc97dabc581d848f gencode/docs/event_mapping.html
Expand All @@ -27,6 +27,7 @@ f4a52cdad2cd9a9646da4d84cc1f3962ddd151a8d348255e5cff30eadfee283c gencode/docs/s
d39d7fe37a41c74a40080af7b0a429d201ab1fdff7444428c4b98eb7b38c332b gencode/java/udmi/schema/Asset.java
b405ce628f7819b46b19950aeaba89ee938fea54261000616bc534b9f81bd59c gencode/java/udmi/schema/Auth_provider.java
0825a5cec83003bb0a6488c4ed7010a04ae0d3848ef36fe01bb4e6718ba7b96d gencode/java/udmi/schema/Aux.java
a4fba115d3da74885b01f48e18a46dd9289858326236ccc023ae007e23ec5856 gencode/java/udmi/schema/BasePodConfiguration.java
ce2c747fab0d374987acc51474a52ca5b3d64659d51cffa671d5442b7114339a gencode/java/udmi/schema/Basic.java
566b998118ccc00ddf6a4d2f6e5f2c5afaa21a62a9562c885ec798d243770900 gencode/java/udmi/schema/BlobBlobsetConfig.java
c033a4b2c9920a4314801d1fbb7885b375a4bb890344de937ed30baf4f2c08e1 gencode/java/udmi/schema/BlobBlobsetState.java
Expand Down Expand Up @@ -54,7 +55,7 @@ dd2eb479a8e93a851c535c8b40fbd62e152bd60e0473f3b23800ec61f798bed0 gencode/java/u
06758aca1e0043ddf343b504030f47bb19260e99a82e2d66f12e86092a2434ca gencode/java/udmi/schema/Enumerate.java
05e3443f9a9da29ed561310b13be1d14459d9dfe292a438e42af2fbd2165a606 gencode/java/udmi/schema/Envelope.java
e9f5c77be81486b6b8c6d88f70f2d50583d8c3fafa2ac09ead80f44b8d5e751e gencode/java/udmi/schema/Event.java
f2edabfca68fa7bafa2679f4bc2c694465a7b19fbe2e5070e07e9996776a2a4d gencode/java/udmi/schema/ExecutionConfiguration.java
9b4f969f6ed9d9ebb1c32e1b44079c85325fea5656d68f4226cb83a40e8690f6 gencode/java/udmi/schema/ExecutionConfiguration.java
2e77a29988e6c17875d3f781be931e3b835bb310639f60d3bb28f24405a86bed gencode/java/udmi/schema/FamilyDiscoveryConfig.java
9643391d71c6bd206a4ec69ee7b46ba2bf061b85ccd0bc050046a84df85c8414 gencode/java/udmi/schema/FamilyDiscoveryEvent.java
5ad9bf328fa1500250ff8bc75f2044b3815c5c11cb368e1cc228ac8ca16639c2 gencode/java/udmi/schema/FamilyDiscoveryState.java
Expand Down Expand Up @@ -84,7 +85,7 @@ df64e4ddbf543ac70e7c2af9d3fbc20ffe3dff68c6718aa9ceadab7f64d3d171 gencode/java/u
b3b7ef6cae004d5fdb4052f860df0aa583df87bb798a027fc769aeaf16489789 gencode/java/udmi/schema/MonitoringMetric.java
3896bacd5b35b37f88bea402947aae7f2f7bab6e63bc30517381158ba0826602 gencode/java/udmi/schema/Operation.java
5e1c5411fae4d7c47391ceb5d19ae864fcd484df75ac6b6db39fd2d12647dec8 gencode/java/udmi/schema/Physical_tag.java
eb236dd759598b6af88320cd5856f4162ceb05d31fb5f6cf2adcae97bcc054d0 gencode/java/udmi/schema/PodConfiguration.java
3e331b3817cc87f2fe087aae3a1e599819ceda1ca086094d7f400f5f1c3bdbb9 gencode/java/udmi/schema/PodConfiguration.java
d808259db6bbcd26ecf438844ce286d15d4750906be24588d97acfbe8a4ae315 gencode/java/udmi/schema/PointEnumerationEvent.java
eb478a6ebd66b150da8d6dc8fdf05a10d09d6d0ea1df8a0578728703718c5551 gencode/java/udmi/schema/PointPointsetConfig.java
8f3fc1cdc2dcd3e524863f4675aebabc450a35f5fd1cdc3fd37289b5cab7f2ec gencode/java/udmi/schema/PointPointsetEvent.java
Expand All @@ -97,7 +98,7 @@ fc3a9415c04d8a06954dbdbfdff5d68ab113cce3948532c19df555778ffb04fa gencode/java/u
61afd6c9c0364b8982c90df7664147829bad8858408b2141299ee8bbc35f1612 gencode/java/udmi/schema/PointsetSummary.java
ca2e7566106818ca7e5190c8041eb86f0c9b3251b0bda8c3ea7ce11a0c891a0a gencode/java/udmi/schema/Position.java
3df66bb1a37a9e0b2b6cf392f8c64d404a73c83e5e13c02bb4844f09b9a04b70 gencode/java/udmi/schema/Properties.java
2f48b09437aab980a40ebf06c3334a7b33843b160d7618da20789e3d628e9650 gencode/java/udmi/schema/PubberConfiguration.java
d5e11dc354995681b894bcb62e4e21da7f0be68aaa3643a3dc5aa13610741f29 gencode/java/udmi/schema/PubberConfiguration.java
3583ac57d4e5e7e0fc01081bf08cae368c4b90cdb4b337c4a72bc3e69c26046e gencode/java/udmi/schema/PubberOptions.java
703ed0cecb60f284b52e76dc4d612eb798ba3e8781cc40698a46611b36e6b0c9 gencode/java/udmi/schema/SchemaValidationState.java
6da1708f597a0c64ce30dcbe739095fc7ebc091d63b98af88c73f70706af31ca gencode/java/udmi/schema/SequenceValidationState.java
Expand All @@ -121,7 +122,7 @@ ac6f8fd87c8986cce01e872460c15ff6fe71e3816f9bde610acfe25f7d38c8d4 gencode/java/u
63494b22585e54b5ccdf2f1e000774d2c0ccd447ebe165bc77d748828a54a872 gencode/java/udmi/schema/ValidationState.java
e007ddd1ceeae3603c85110c33e1bb4a418ff9c7a791ca0df25b7ea3caeafd36 gencode/java/udmi/schema/ValidationSummary.java
b77d953fd22e655c0f10ae32deeaa222769d971f8c38b3379eba45720fb910cc gencode/java/udmi/schema/VirtualEquipmentLinks.java
52ffdf97896cffb96cdd273abdd5fa385fadbd258355863c1110c48c3cf97687 gencode/python/udmi/schema/__init__.py
dd8966382f9a64497ad97c375b4904027dc2546ba3ba1992d91afd6158a73c7a gencode/python/udmi/schema/__init__.py
4550b708782ad9328d9d94c6d2d21c8079b4b40697547e6d7df3f45a596a9960 gencode/python/udmi/schema/access_iot.py
4b25dd95f863059b761269f93adcae7049507924a1c6e74d6856849203c179db gencode/python/udmi/schema/ancillary_properties.py
dab4f5fca272ec48c2881bca2b6bc43786ada47fa1f6dd935c35f7ce0eb6b0f6 gencode/python/udmi/schema/building_translation.py
Expand All @@ -144,10 +145,11 @@ ac3facbd96f7cb2f7e387e7497d6a36af379a2687329571f250c5670f9933244 gencode/python
cce623b34fd694880039a1c080214c33e00acaef5bc72276cf11a3bb2de40000 gencode/python/udmi/schema/config_system_testing.py
30b1809e364cb3f7070002bb4a9954b11b25543b099b4bbe450d280001e4de55 gencode/python/udmi/schema/config_udmi.py
ae3f2f71fc81b1cffc45ffe9d1c179fba8bb09a398a305e7ba42aa8aeabe125a gencode/python/udmi/schema/configuration_endpoint.py
3be0c215eb03ca90754de8c13cafbb66daa8f7791ab157d0e73698cefeb815d9 gencode/python/udmi/schema/configuration_execution.py
ade882bda81aa58fd2228d028e7bd8f5f4bf2bb9557fdaafc54b5aa01eeda903 gencode/python/udmi/schema/configuration_pod.py
29c41af0db2e510a12a9b567410eedbd0bbad988b7c92a1fb06c485461b65808 gencode/python/udmi/schema/configuration_execution.py
e30f937983f98673b3e67ac1369fe86964d785092964f7e95cd39611f9283d7c gencode/python/udmi/schema/configuration_pod.py
ccc43757750379f3c072f019b25b0ea8d970c48dd0b66e98ec2b0bfb1635a952 gencode/python/udmi/schema/configuration_pod_base.py
11c8841ed5c2a5bcaf4b44c943c8f70fcb5010f1027a025b46300435353b2432 gencode/python/udmi/schema/configuration_pod_bridge.py
7f4f8c1a6ead34bf72b9134b97a39001752eb0f9647fafaac82ced4bb2f46b88 gencode/python/udmi/schema/configuration_pubber.py
bed77c13436a192047a0dcdcaea7c5d7175e99a76c6c40409cce9e232ab5bc12 gencode/python/udmi/schema/configuration_pubber.py
fbb4b2c04c170c0da5cdd868612429fe920e44b591fcad2522b2e047d580d537 gencode/python/udmi/schema/entry.py
fcc75eec4263b11b378e30f929687cfb9619c8dfc524863b6bfb11b7e33be241 gencode/python/udmi/schema/enumeration_feature.py
5b9982e15ff770bc5af75b7891285aec956e873c9a855a29ea2122314a2b76c0 gencode/python/udmi/schema/envelope.py
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,6 @@ jobs:
run: bin/test_proxy $TARGET_PROJECT $MQTT_PROXY_HOST
- name: bin/test_redirect
run: bin/test_redirect $TARGET_PROJECT
- name: pubber.out.1
run: |
echo ::::::: pubber.out.1
cat out/pubber.out.1
- name: pubber.out.2
run: |
echo ::::::: pubber.out.2
cat out/pubber.out.2
- name: pubber.out
if: ${{ always() }}
run: more out/pubber.out* | cat
17 changes: 12 additions & 5 deletions bin/pubber
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ project_target=${project_id##*/}
if [[ -z $project_id ]]; then
true using config file based configuration
elif [[ $project_id =~ ^// ]]; then
no_project=${project_id%/*}
iot_provider=${no_project#//}
no_prefix=${project_id#//}
iot_provider=${no_prefix%%/*}
no_provider=${no_prefix#*/}
project_target=${no_provider%/*}
udmi_namespace=${no_provider#$project_target}
[[ -n $udmi_namespace ]] && udmi_prefix=${udmi_namespace#/}~
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
iot_provider=jwt
broker_hostname=${project_id#*@}
project_target=${project_id%@*}
else
Expand All @@ -102,10 +106,12 @@ elif [[ -z $broker_hostname ]]; then
broker_hostname=mqtt.googleapis.com
fi

registry_actual=${udmi_prefix}${registry_id}${registry_suffix}

if [[ ! -f /tmp/endpoint.json ]]; then
cat <<EOF > /tmp/endpoint.json
{
"client_id": "projects/$project_target/locations/$cloud_region/registries/$registry_id$registry_suffix/devices/$device_id",
"client_id": "projects/$project_target/locations/$cloud_region/registries/$registry_actual/devices/$device_id",
"hostname": "$broker_hostname"
}
EOF
Expand All @@ -117,7 +123,8 @@ if [[ -n $site_model ]]; then
{
"sitePath": "$site_model",
"deviceId": "$device_id",
"projectId": "$project_target",
"registryId": "$registry_actual",
"iotProject": "$project_target",
"serialNo": "$serial_no",
"options": $options_json
}
Expand Down
11 changes: 8 additions & 3 deletions bin/registrar
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ echo Running tools version `git describe`
# Format of cmdline project_id is [//PROVIDER/]PROJECT[@BRIDGE] (optional PROVIDER and BRIDGE)
# e.g. bos-testing-dev or //gcp/bos-testing-dev or bos-platform-dev@mqtt.bos.goog

quoted_namespace=null
quoted_bridge=null
iot_provider=null
if [[ $project_id =~ ^// ]]; then
sans_project=${project_id%/*}
iot_provider=\"${sans_project#//}\"
project_id=${project_id#*/}
no_prefix=${project_id#//}
iot_provider=\"${no_prefix%%/*}\"
no_provider=${no_prefix#*/}
project_id=${no_provider%/*}
udmi_namespace=${no_provider#$project_id}
[[ -n $udmi_namespace ]] && quoted_namespace=\"${udmi_namespace#/}\"
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
quoted_bridge=\"${project_id#*@}\"
Expand All @@ -69,6 +73,7 @@ else
{
"iot_provider": $iot_provider,
"project_id": $quoted_id,
"udmi_namespace": $quoted_namespace,
"bridge_host": $quoted_bridge,
"site_model": "$site_path",
"registry_suffix": $registry_suffix
Expand Down
10 changes: 8 additions & 2 deletions bin/reset_config
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ echo Setting config timestamp ${now_date}
jq < ${src_config} .timestamp=\"${now_date}\" |\
jq .system.testing.sequence_name=\"${config_file%.json}\" > ${dst_config}

quoted_namespace=null
quoted_bridge=null
iot_provider=null
if [[ $project_id =~ ^// ]]; then
sans_project=${project_id%/*}
iot_provider=\"${sans_project#//}\"
no_prefix=${project_id#//}
iot_provider=\"${no_prefix%%/*}\"
no_provider=${no_prefix#*/}
project_id=${no_provider%/*}
udmi_namespace=${no_provider#$project_id}
[[ -n $udmi_namespace ]] && quoted_namespace=\"${udmi_namespace#/}\"
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
quoted_bridge=\"${project_id#*@}\"
Expand All @@ -59,6 +64,7 @@ cat <<EOF > $REFLECTOR_CONFIG
{
"iot_provider": $iot_provider,
"project_id": $quoted_id,
"udmi_namespace": $quoted_namespace,
"bridge_host": $quoted_bridge,
"site_model": "$site_dir",
"device_id": "$device_id",
Expand Down
10 changes: 8 additions & 2 deletions bin/sequencer
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,16 @@ validator/bin/build
# Format of cmdline project_id is {//PROVIDER/}PROJECT (optional PROVIDER)
# e.g. bos-testing-dev or //gcp/bos-testing-dev

quoted_namespace=null
quoted_bridge=null
iot_provider=null
if [[ $project_id =~ ^// ]]; then
sans_project=${project_id%/*}
iot_provider=\"${sans_project#//}\"
no_prefix=${project_id#//}
iot_provider=\"${no_prefix%%/*}\"
no_provider=${no_prefix#*/}
project_id=${no_provider%/*}
udmi_namespace=${no_provider#$project_id}
[[ -n $udmi_namespace ]] && quoted_namespace=\"${udmi_namespace#/}\"
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
quoted_bridge=\"${project_id#*@}\"
Expand All @@ -132,6 +137,7 @@ cat <<EOF > $SEQUENCER_CONFIG
"iot_provider": $iot_provider,
"project_id": $quoted_id,
"bridge_host": $quoted_bridge,
"udmi_namespace": $quoted_namespace,
"site_model": "$site_model",
"device_id": "$device_id",
"alt_registry": $alt_registry,
Expand Down
4 changes: 2 additions & 2 deletions bin/test_redirect
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ if [[ $restarts -ne 2 ]]; then
fi

log Checks that a redirect happened and failed...
fgrep -q registries/ZZ-TRI-FECTA/devices $PUBBER_OUT.1 || bin/fail no ZZ-TRI-FECTA registry reference
egrep -q 'registries/(.*~)?ZZ-TRI-FECTA(_.*)?/devices' $PUBBER_OUT.1 || bin/fail no ZZ-TRI-FECTA registry reference
fgrep -q registries/missing/devices $PUBBER_OUT.1 || bin/fail no missing registry reference
fgrep -q 'While waiting for connection start: Connection error' $PUBBER_OUT.1 || bin/fail no connection error
fgrep -q 'Endpoint connection restored to last working endpoint' $PUBBER_OUT.1 || bin/fail no restore log message

log Check basic redirect-by-config setup...
fgrep -q registries/ZZ-TRI-FECTA/devices $PUBBER_OUT.2 || bin/fail no ZZ-TRI-FECTA registry reference
egrep -q 'registries/(.*~)?ZZ-TRI-FECTA(_.*)?/devices' $PUBBER_OUT.2 || bin/fail no ZZ-TRI-FECTA registry reference
fgrep -q registries/reconfigure/devices $PUBBER_OUT.2 || bin/fail no reconfigure registry reference
fgrep -q 'While waiting for connection start: Connection error' $PUBBER_OUT.2 || bin/fail no connection error
fgrep -q 'Endpoint connection restored to last working endpoint' $PUBBER_OUT.2 || bin/fail no connection restore
Expand Down
37 changes: 10 additions & 27 deletions bin/test_regclean
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ shift
echo "Run as: $0 $project_id"
echo "export UDMI_REGISTRY_SUFFIX=$UDMI_REGISTRY_SUFFIX"
echo "export UDMI_ALT_REGISTRY=$UDMI_ALT_REGISTRY"
echo "export UDMI_REFLECTOR_ENDPOINT='$UDMI_REFLECTOR_ENDPOINT'"
echo "export UDMI_PUBBER_ENDPOINT='$UDMI_PUBBER_ENDPOINT'"

site_path=sites/udmi_site_model
output_file=$site_path/out/registration_summary.json
Expand All @@ -44,26 +42,18 @@ fi
registry_id=`jq -r .registry_id $site_path/cloud_iot_config.json`
cloud_region=`jq -r .cloud_region $site_path/cloud_iot_config.json`

if [[ -n $UDMI_REFLECTOR_ENDPOINT ]]; then
endpoint=$(tr -d ' \n\r' <<< $UDMI_REFLECTOR_ENDPOINT | base64 --decode)
echo $endpoint
site_arg=out/cloud_iot_config-reflect.json
jq --argjson endpoint "$endpoint" '.reflector_endpoint = $endpoint' \
$site_path/cloud_iot_config.json > $site_arg
jq ".project_id = \"$project_id\"" $site_arg | sponge $site_arg
jq ".site_model = \"$site_path\"" $site_arg | sponge $site_arg
echo $site_arg:
cat $site_arg
registrar_project=
else
site_arg=$site_path
registrar_project=$project_id
fi
site_arg=$site_path
registrar_project=$project_id

registry_prefix=
project_target=${project_id##*/}
if [[ $project_id =~ ^// ]]; then
no_project=${project_id%/*}
iot_provider=${no_project#//}
no_prefix=${project_id#//}
iot_provider=${no_prefix%%/*}
no_provider=${no_prefix#*/}
project_target=${no_provider%/*}
udmi_namespace=${no_provider#$project_target}
[[ -n $udmi_namespace ]] && registry_prefix=${udmi_namespace#/}~
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
broker_hostname=${project_id#*@}
Expand All @@ -85,7 +75,7 @@ cat <<EOF > $pubber_config
{
"endpoint": {
"protocol": "mqtt",
"client_id": "projects/$project_target/locations/$cloud_region/registries/$registry_id$registry_suffix/devices/$device_id",
"client_id": "projects/$project_target/locations/$cloud_region/registries/$registry_prefix$registry_id$registry_suffix/devices/$device_id",
"hostname": "$broker_hostname"
},
"sitePath": "$site_path",
Expand All @@ -98,13 +88,6 @@ cat <<EOF > $pubber_config
}
EOF

if [[ -n $UDMI_PUBBER_ENDPOINT ]]; then
endpoint=$(tr -d ' \n\r' <<< $UDMI_PUBBER_ENDPOINT | base64 --decode)
echo $endpoint
jq --argjson endpoint "$endpoint" '.endpoint = $endpoint' \
$pubber_config | sponge $pubber_config
fi

echo Corrupting site model to check error handling...
mkdir -p $site_path/devices/XXX-1
echo { > $site_path/devices/XXX-1/metadata.json
Expand Down
27 changes: 19 additions & 8 deletions bin/update_udmis
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,39 @@ git_prefix=${git_url%.*}
git_prefix=${git_prefix#*.com/}
git_repo=${git_prefix#*.com:}

update_to=ghcr.io/$git_repo:g${full_hash:0:9}
update_to=ghcr.io/${git_repo}:g${full_hash:0:9}

echo Updating udmis install to $update_to

quoted_namespace=null
quoted_bridge=null
iot_provider=null
if [[ $project_id =~ ^// ]]; then
no_prefix=${project_id#//}
iot_provider=\"${no_prefix%%/*}\"
no_provider=${no_prefix#*/}
project_id=${no_provider%/*}
udmi_namespace=${no_provider#$project_id}
[[ -n $udmi_namespace ]] && quoted_namespace=\"${udmi_namespace#/}\"
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
quoted_bridge=\"${project_id#*@}\"
project_id=${project_id%@*}
fi

if [[ -n $project_id ]]; then
quoted_id=\"${project_id##*/}\"
else
quoted_id=null
fi

if [[ $project_id =~ ^// ]]; then
sans_project=${project_id%/*}
iot_provider=\"${sans_project#//}\"
else
iot_provider=null
fi

echo Writing config to $REFLECTOR_CONFIG
cat <<EOF > $REFLECTOR_CONFIG
{
"iot_provider": $iot_provider,
"project_id": $quoted_id,
"udmi_namespace": $quoted_namespace,
"bridge_host": $quoted_bridge,
"site_model": "$site_model",
"update_to": "$update_to"
}
Expand Down
10 changes: 8 additions & 2 deletions bin/validator
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ if [[ -n $1 && ! $1 =~ ^- ]]; then
shift
fi

quoted_namespace=null
quoted_bridge=null
iot_provider=null
if [[ $project_id =~ ^// ]]; then
sans_project=${project_id%/*}
iot_provider=\"${sans_project#//}\"
no_prefix=${project_id#//}
iot_provider=\"${no_prefix%%/*}\"
no_provider=${no_prefix#*/}
project_id=${no_provider%/*}
udmi_namespace=${no_provider#$project_id}
[[ -n $udmi_namespace ]] && quoted_namespace=\"${udmi_namespace#/}\"
elif [[ $project_id =~ @ ]]; then
iot_provider=\"jwt\"
quoted_bridge=\"${project_id#*@}\"
Expand Down Expand Up @@ -53,6 +58,7 @@ elif [[ -n $project_id ]]; then
"iot_provider": $iot_provider,
"project_id": $quoted_id,
"bridge_host": $quoted_bridge,
"udmi_namespace": $quoted_namespace,
"site_model": "$site_path",
"feed_name": "$subscription"
}
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/java/com/google/udmi/util/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public abstract class Common {
public static final String STATE_QUERY_TOPIC = "update/query";
public static final String EXCEPTION_KEY = "exception";
public static final String ERROR_KEY = "error";
public static final String DETAIL_KEY = "detail";
public static final String TRANSACTION_KEY = "transactionId";
public static final String PUBLISH_TIME_KEY = "publishTime";
public static final String MESSAGE_KEY = "message";
Expand All @@ -37,6 +38,8 @@ public abstract class Common {
public static final String REGISTRY_ID_PROPERTY_KEY = "deviceRegistryId";
public static final String NO_SITE = "--";
public static final String GCP_REFLECT_KEY_PKCS8 = "reflector/rsa_private.pkcs8";
public static final String PREFIX_SEPARATOR = "~";
public static final String CONDENSER_STRING = "^^";
private static final String UDMI_VERSION_ENV = "UDMI_VERSION";
public static final char DETAIL_SEPARATOR_CHAR = ';';
public static final String DETAIL_SEPARATOR = DETAIL_SEPARATOR_CHAR + " ";
Expand Down
6 changes: 5 additions & 1 deletion common/src/main/java/com/google/udmi/util/GeneralUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ public static void writeString(File metadataFile, String metadataString) {
}

public static String multiTrim(String message) {
return multiTrim(message, " ");
}

public static String multiTrim(String message, String delimiter) {
return Arrays.stream(ofNullable(message).orElse("").split("\n"))
.map(String::trim).collect(Collectors.joining(" "));
.map(String::trim).collect(Collectors.joining(delimiter));
}
}
Loading
Loading