google-deployment-manager - 谷歌部署管理器使用 --properties 参数访问嵌套属性
问题描述
如果我使用 jinja 模板,我可以通过命令行覆盖属性,如下所示:
--properties zone:us-central1-a,machineType:n1-standard-1,image:debian-9
但是我没有看到使用标签或 environmentVariables 等嵌套属性执行此操作的文档或示例,例如:
resources:
- name: resource-name
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'
properties:
labels:
testlabel1: testlabel1value
testlabel2: testlabel2value
environmentVariables:
TEST: 'zzzzzzzzz'
如何设置这样的属性?这不起作用:--properties labels:testlabel1:newvalue
解决方案
这里的简短回答是,该--properties
标志并不意味着将属性值传递给模板。模板不能在没有配置文件的情况下运行,--properties 标志旨在替换配置文件。您传递的每个参数都与在配置文件中列出它们相同。
本质上 using--template my-template.py --properties zone:us-central1-f
相当于运行--config myConfig.yaml
YAML 定义如下:
进口: - 路径:我的模板.py 资源: - 名称:一些资源 类型:my-temaplte.py 特性: 区域:us-central1-f
该--properties
标志并不意味着传递原始数据来替换非变量。
尽管这不能直接回答您的问题,但您通常不需要在标志中定义嵌套值。您的模板通常会调用从对象中获取的直接变量properties
。
尽管如此,我还是尝试了一些测试,据我所知,你不能这样做。
推荐阅读
- java - 弹出窗口显示 IllegalStateException
- php - 如何在我的 Joomla 网站中删除 Zendesk Live Chat?
- php - 这个 php 登录系统安全吗/
- powershell - Rundeck 作业失败导致详细输出
- sql - 每天将日期添加到特定日期
- python - 如何使用 Python 向现有 PDF 添加高亮注释
- reactjs - 如何使用 Django Rest 管理移动和 Web 身份验证并做出反应/反应本机?
- c++ - 在 C++ 中对字符串使用#define
- python - 如何从不同的文件中提升 Tkinter 框架?
- android - 为什么'onShowFileChooser' 什么都不覆盖?