Why can't I use a comma with gcloud?

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.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #google-cloud.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.