Why can't I use a comma with gcloud
?
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
I've been trying to call a Google Cloud Run Job with the following arguments:
[[{"platform":"...","organisation":"...","repo":"..."}]]
I've done this with the following invocation:
job_name="..."
region="..."
project="..."
event='[[{"platform":"...","organisation":"...","repo":"..."}]]'
gcloud run jobs execute $job_name --region $region --project=$project --args "$event"
However, each time this made its way up to Google Cloud, the Job failed to run, as the input was being remapped to:
[[{"platform":"..." "organisation":"..." "repo":"..."}]]
^ ^
^ missing commas ^
After some awkward searching around, this StackOverflow answer led me to the gcloud
docs for escaping which seems a bit complicated for what I wanted to do, but it seems reasonable for some of the more complex use-cases the docs shared.
This is required as the gcloud run jobs execute
docs note that --args
requires Comma-separated arguments
.
This results in the following tweak to our script:
event='[[{"platform":"...","organisation":"...","repo":"..."}]]'
# use the escaping
gcloud run jobs execute $job_name --region $region --project=$project --args "^#^$event"
# ^^^
# ^^^
# ^^^
This makes sure that we delimit based on the #
, which should never exist in the event we're processing.