简体   繁体   English

列表中的 Escaping 字符作为环境变量发送到 GCP Cloud Run

[英]Escaping characters in a list sent as environment variable to GCP Cloud Run

I am trying to create a Github workflow about deploying a GCP Cloud Run service with a list of strings as environment variable and need help defining the environment variable properly with regards to the the escaping of characters.我正在尝试创建一个 Github 工作流,以部署 GCP Cloud Run 服务,并将字符串列表作为环境变量,并且需要帮助正确定义与字符 escaping 相关的环境变量。

Here's my gcloud command:这是我的 gcloud 命令:

gcloud run deploy my-service --image \
       europe-west1-docker.pkg.dev/projectName/containers/my-service:$(echo ${GITHUB_SHA} | cut -c1-8) \
       --project PROJECT --platform managed --region europe-west3 \
       --memory 4Gi \
       --timeout 900 \
       --set-env-vars="my_list=["one", "two", "three"]" 

I would appreciate some help defining the syntax of the environment variable my_list .我将不胜感激定义环境变量my_list的语法的一些帮助。

Many thanks in advance.提前谢谢了。

You could make use of an environment variable file as described here.您可以使用此处描述的环境变量文件。 Doing so would replace --set-env-vars with --env-vars-file and use an environment variable file to specify the value for my_list .这样做会将--set-env-vars替换为--env-vars-file并使用环境变量文件来指定my_list的值。

An example of how the command would change:命令将如何更改的示例:

--env-vars-file=variable.yaml

An example of how the variable would be defined in the file:如何在文件中定义变量的示例:

my_list:["one", "two", "three"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM