Reputation: 41
in my gcloud compute instance create
command I'd like to set some metadata:
--metadata=listofstuff=thing1,thing2,thing3
It fails. I can't seem to find any mention of the rules with respect escaping.
Iv'e tried:
--metadata='listofstuff=thing1,thing2,thing3'
--metadata="listofstuff=thing1,thing2,thing3"
--metadata=listofstuff='thing1,thing2,thing3'
--metadata=listofstuff="thing1,thing2,thing3"
--metadata='listofstuff=thing1,thing2,thing3'
--metadata=listofstuff=thing1\,thing2\,thing3
Surly there is a dusty tome somewhere that covers this _very important topic.
Upvotes: 1
Views: 470
Reputation: 1032
Fastest approach would be gcloud topic escaping
gcloud compute instances create example-instance1 \
--metadata ^:^key1="value1":key2=value2:key3=value3Index1,value3Index2,valueIndex3:key4=value4
Upvotes: 1
Reputation: 40136
A couple of options:
value
:
thing1,thing2,thing3
Note: Be careful to avoid \n
etc.
gcloud compute instances add-metadata ${INSTANCE} \
--project=${PROJECT} \
--metadata-from-file=foo=value
flags.yaml
:
--metadata:
bar: "thing1,thing2,thing3"
gcloud compute instances add-metadata ${INSTANCE} \
--project=${PROJECT} \
--flags-file=flags.yaml
And:
gcloud compute instances describe ${INSTANCE} \
--project=${PROJECT} \
--format="json(metadata.items.filter(\"key\":\"foo OR bar\"))"
{
"metadata": {
"items": [
{
"key": "bar",
"value": "thing1,thing2,thing3"
},
{
"key": "foo",
"value": "thing1,thing2,thing3"
}
]
}
}
Upvotes: 1