简体   繁体   English

环境变量是否可以在 Cloud Foundry 清单中保存数组值?

[英]Is it possible for an environment variable to hold an array value in cloud foundry manifest?

I am trying to push an app into cloud foundry, and pass an array value via environment variable.我正在尝试将应用程序推送到 Cloud Foundry,并通过环境变量传递一个数组值。 But I receive yaml: unmarshal errors: line 7: cannot unmarshal !!seq into string FAILED但我收到yaml: unmarshal errors: line 7: cannot unmarshal !!seq into string FAILED

manifest.yml:清单.yml:

---
applications:
- name: my-app1     # A default name for Cloud Foundry to give your app
  memory: 128M         # The amount of RAM required for each instance
  disk_quota: 256M    # How much disk space the application needs
  no-route: true
  health-check-type: none
  buildpacks:
    - https://github.com/cloudfoundry/nodejs-buildpack
  env: 
    countries: 
      - america
      - australia
      - japan
      - nertherland      

please Note: I validated my yaml via online validators and it looks good.请注意:我通过在线验证器验证了我的 yaml,它看起来不错。

Environment variables are an operating system concept and are passed into your application.环境变量是一个操作系统概念,并被传递到您的应用程序中。 They must be strings.它们必须是字符串。

You can encode arbitrary JSON, YAML or binary data with base64 encoding as your env var value.您可以使用 base64 编码将任意 JSON、YAML 或二进制数据编码为您的环境变量值。

Inside your app, you would decode the base64 into your original string (say JSON string) and the parse it into the data structure you want (an array of strings in your case)在您的应用程序中,您将 base64 解码为原始字符串(例如 JSON 字符串)并将其解析为您想要的数据结构(在您的情况下为字符串数组)

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

相关问题 Cloud Foundry Yaml解析错误 - Cloud Foundry yaml parse error 使用环境变量获取另一个环境变量的值 - Using an Environment Variable to get the Value of Another Environment Variable 我的Go服务器无法在Cloud Foundry中启动 - My Go server fails to start in cloud foundry 如何将环境变量值添加到 YAML 文件? - How to add environment variable value to YAML file? 将应用程序推送到 Cloud Foundry 时出现 mux 未知修订错误 - mux unknown revision error while pushing application to cloud foundry 使用环境变量在 docker-compose.yaml 中设置布尔值 - Setting boolean value in docker-compose.yaml using environment variable 如何在 ENTRYPOINT 数组中使用 Docker 环境变量? Kubernetes 中面临的问题,未获取 env 变量, - How do I use Docker environment variable in ENTRYPOINT array? issue facing in Kubernetes ,not fetching the env variable, 从 manifest.yaml 文件中解析一个值并将其对应的块名称存储到一个数组中 - Parse a value from manifest.yaml file and store it's corresponding block name into an array 仅当变量具有值时才可以设置Ansible事实吗? - Is it possible to set an Ansible fact only if a variable has a value? Hasura 端点作为环境变量 - Hasura endpoint as environment variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM