YAML

Building an array of dictionary items in YAML?

China☆狼群 提交于 2021-02-06 09:35:13
问题 Basically trying to something in yaml that could be done using this json: { models: [ { model: "a" type: "x" #bunch of properties... }, { model: "b" type: "y" #bunch of properties... } ] } So far this is what I have, it does not work because I am repeating my model key but what can be a proper way to do that by keeping that model key word? models: model: type: "x" #bunch of properties... model: type: "y" #bunch of properties... 回答1: Use a dash to start a new list element: models: - model: "a"

Preserving following comments when removing last dict key with ruamel.yaml

℡╲_俬逩灬. 提交于 2021-02-05 11:52:53
问题 I'm trying to use the ruamel.yaml Python library to remove some keys/value pairs from nested dictionaries within a large YAML file, while retaining surrounding comments. Here's a simplified version of the code I'm using: import sys import ruamel.yaml with open(sys.argv[1], 'r') as doc: parsed = ruamel.yaml.round_trip_load(doc, preserve_quotes=True) for item in parsed['items']: if item['color'] == 'blue': del item['color'] yaml = ruamel.yaml.YAML(typ='rt') yaml.indent(sequence=4, offset=2)

how to parse a YAML containing a simple list together with a key-value list (associative array)

淺唱寂寞╮ 提交于 2021-02-05 11:52:47
问题 I have the following YAML: build: - step 1 - step 2 - name: step 3 do: something - name: step 4 get: fetch ... - name: step 5 put: upload something And for parsing it I am trying with this #[derive(Debug, Deserialize, PartialEq)] struct Config { build: Option<Vec<Steps>> } #[derive(Debug, Deserialize, PartialEq)] struct Build { #[serde(flatten)] item: String, steps: Steps, } #[derive(Debug, Deserialize, PartialEq)] struct Steps { name: String, r#do: Option<String>, put: Option<String>, get:

how to parse a YAML containing a simple list together with a key-value list (associative array)

落爺英雄遲暮 提交于 2021-02-05 11:52:03
问题 I have the following YAML: build: - step 1 - step 2 - name: step 3 do: something - name: step 4 get: fetch ... - name: step 5 put: upload something And for parsing it I am trying with this #[derive(Debug, Deserialize, PartialEq)] struct Config { build: Option<Vec<Steps>> } #[derive(Debug, Deserialize, PartialEq)] struct Build { #[serde(flatten)] item: String, steps: Steps, } #[derive(Debug, Deserialize, PartialEq)] struct Steps { name: String, r#do: Option<String>, put: Option<String>, get:

Preserving following comments when removing last dict key with ruamel.yaml

僤鯓⒐⒋嵵緔 提交于 2021-02-05 11:52:01
问题 I'm trying to use the ruamel.yaml Python library to remove some keys/value pairs from nested dictionaries within a large YAML file, while retaining surrounding comments. Here's a simplified version of the code I'm using: import sys import ruamel.yaml with open(sys.argv[1], 'r') as doc: parsed = ruamel.yaml.round_trip_load(doc, preserve_quotes=True) for item in parsed['items']: if item['color'] == 'blue': del item['color'] yaml = ruamel.yaml.YAML(typ='rt') yaml.indent(sequence=4, offset=2)

Can you pass a file to an azure pipeline?

末鹿安然 提交于 2021-02-05 11:30:49
问题 I have a website written in Typescript that has a button which triggers an azure pipeline to run. I would like to pass something from the website to the pipeline as a parameter and I saw here that you can pass a .yaml structure as object to a pipeline. Is it possible to pass a .yaml that was converted from an .xlsx file to the pipeline and how would one go about that? For clearance: The website has a file upload and I need the content of the .xlsx-file the user passes in one of the steps in

Can you pass a file to an azure pipeline?

我们两清 提交于 2021-02-05 11:30:13
问题 I have a website written in Typescript that has a button which triggers an azure pipeline to run. I would like to pass something from the website to the pipeline as a parameter and I saw here that you can pass a .yaml structure as object to a pipeline. Is it possible to pass a .yaml that was converted from an .xlsx file to the pipeline and how would one go about that? For clearance: The website has a file upload and I need the content of the .xlsx-file the user passes in one of the steps in

How to stop azure dev ops yaml validation build from running for each branch?

て烟熏妆下的殇ゞ 提交于 2021-02-05 09:44:39
问题 We are using azure dev ops for CICD and validating PR's. Yesterday I decided to start making yaml files for validation builds. I created the pipeline. I set the branch policy for 'development' fine and the validation build ran okay. However, something I see is that each time ANY branch gets a change to the files of the directory I've set the validation build for a build triggers. So, let's say I've made a yaml pipeline(CI only) for project Main(src/Main) and i've set a branch policy on branch

Dumping values with quotes with SnakeYaml

ⅰ亾dé卋堺 提交于 2021-02-05 07:45:07
问题 Having a simple yml file test.yml as follows color: 'red' I load and dump the file as follows final DumperOptions yamlOptions = new DumperOptions(); yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); Yaml yaml = new Yaml(yamlOptions); Object result = yaml.load(new FileInputStream(new File("test.yml"))); System.out.println(yaml.dump(result)); I expect to get color: 'red' However, the during the dump, the serializer leaves out the quotes and prints color: red How can I make the

一文读懂云上DevOps能力体系

你说的曾经没有我的故事 提交于 2021-02-04 12:46:36
简介: 阿里云ECS自动化运维套件架构师,深度拆解云上运维能力体系建设:自动化运维等级金字塔、自动化运维的进阶模式、DevOps的基础核心、云上标准化部署三大能力…… 序言 云计算行业已经有十多年的发展了,话题早已从“要不要上云”转向“如何用好云”。“要不要”其实是一个决策性的话题,直到决策出来一个结果了,话题就算结束了。而“如何用好云”却是一个持续性的话题。 一般来说,在规划阶段开始,企业就会开始思考“如何用好云”,这个话题会伴随用云的整个过程。如果简单地从工作类型划分,除了业务代码的研发(Dev),其他的部分都可以称为运维(Ops),包含资源创建(环境部署)、应用部署、资源管理、资源监控、报警、故障排查等工作。 笔者从事云计算工作超过五年时间,参与开发过多款云产品,可以说既是云计算产品的消费者,也是云计算产品的生产者。在这里,笔者谈一谈对云上DevOps能力体系的多年思考和总结,希望对准备上云或是已经上云的运维人员有所帮助。 1 自动化运维等级金字塔 从运维自动化等级和程度来看,DevOps其实是一种非常高级的自动化,不仅自动化程度比较高,而且对于自动化的完成方式有着非常严格的定义。关于运维自动化与DevOps的关系,其实可以非常好地参考汽车自动驾驶技术分级标准,笔者做了个对比图,如图1。 图1:自动化运维等级金字塔 如图1,自动化运维可分为5个等级, 分别是手动运维、半手工