【问题标题】:Is it possible for an environment variable to hold an array value in cloud foundry manifest?环境变量是否可以在 Cloud Foundry 清单中保存数组值?
【发布时间】:2020-07-23 17:50:49
【问题描述】:

我正在尝试将应用程序推送到 Cloud Foundry,并通过环境变量传递一个数组值。 但我收到 yaml: unmarshal 错误: 第 7 行:不能将 !!seq 解组为字符串 失败

manifest.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      

请注意:我通过在线验证器验证了我的 yaml,它看起来不错。

【问题讨论】:

    标签: yaml manifest cloud-foundry pcf


    【解决方案1】:

    环境变量是一个操作系统概念,会被传递到您的应用程序中。它们必须是字符串。

    您可以使用 base64 编码对任意 JSON、YAML 或二进制数据进行编码作为 env var 值。

    在您的应用程序中,您可以将 base64 解码为原始字符串(例如 JSON 字符串)并将其解析为您想要的数据结构(在您的情况下为字符串数组)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-12
      • 2013-01-09
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多