Search code examples
google-cloud-platformtagsgcloudgoogle-cloud-runrevision

A list of values (multiple values) with gcloud (GCP)


I'm trying to remove two tags "green" and "yellow" from the latest revision "editor-v2-0-0" on Cloud Run:

enter image description here

But when I ran the command with a list of two values "green" and "yellow" as shown below to remove two tags "green" and "yellow" from the latest revision "editor-v2-0-0":

gcloud run services update-traffic editor /
  --remove-tags=[green,yellow]
              // A list of 2 values

These two tags were not removed:

enter image description here

Even though the documentation says as shown below:

--remove-tags=[TAG,…]

List of tags to be removed.

But when I ran the command with one value "green" as shown below to remove one tag "green" from the latest revision "editor-v2-0-0":

gcloud run services update-traffic editor \
  --remove-tags=green
             // One value

I could remove one tag "green":

enter image description here

So, is it possible to remove two tags "green" and "yellow" from the latest revision "editor-v2-0-0" with the command which has a list of two values "green" and "yellow"? If possible, how can I do this?


Solution

  • Run the command without using square brackets "[]" as shown below:

    gcloud run services update-traffic editor \
      --remove-tags=green,yellow
                // "[]" are removed
    

    Then, two tags "green" and "yellow" are removed from the latest revision "editor-v2-0-0":

    enter image description here

    In addition, if there are one or more empty strings before or after a comma in a list, there is an error.

    So, if an empty string is before a comma:

    gcloud run services update-traffic editor \
      --remove-tags=green ,yellow
                      // An empty string before a comma  
    

    Then, there is an error:

    ERROR: (gcloud.run.services.update-traffic) unrecognized arguments: ,yellow

    And if an empty string is after a comma:

    gcloud run services update-traffic editor 
      --remove-tags=green, yellow
                       // An empty string after a comma
    

    Then, there is an error:

    ERROR: (gcloud.run.services.update-traffic) unrecognized arguments: yellow

    So, don't put one or more empty strings before or after a comma in a list:

    gcloud run services update-traffic editor \
      --remove-tags=green,yellow
                      // No empty strings 
                      // before or after a comma
    

    In addition again, you can remove "=" just right to "--remove-tags" but it still works:

    gcloud run services update-traffic editor \
      --remove-tags green,yellow
               // "=" is removed 
               // but it still works