天道酬勤,学无止境

yaml

How to reuse anchored entry under already unwrapped anchor?

I am trying to write a CircleCI config that will allow me to reuse both whole list/mapping(?) entries and its properties. Having the following: image_definitions: docker: - &default_localstack_image image: localstack/localstack:0.10.3 environment: KINESIS_LATENCY: 0 defaults_env: &defaults_env environment: PG_PORT: 5432 PG_USER: root I would like to be able to replace: test: &test docker: - image: localstack/localstack:0.10.3 <<: *defaults_env with something like: test: &test docker: - *default_localstack_image <<: *defaults_env but it doesn't work this way. I've also tried: test: &test docker

2021-09-25 05:08:54    分类:问答    continuous-integration   yaml   circleci

Play 框架,每个 Model 插入超过 20 项的初始数据(Play framework, inserting initial-data more than 20 items per one Model)

问题 在Play框架的开发模式下,我通过Global.java插入了我的initial-data.yml。 然而,如果一个模型有超过 20 个项目,自动生成的 ID 就会变得疯狂。 例如,如果我有: computers: - !!models.Computer name: apple01 - !!models.Computer name: apple02 - !!models.Computer name: apple03 - !!models.Computer name: apple04 ... - !!models.Computer name: apple20 - !!models.Computer name: apple21 - !!models.Computer name: apple22 从 1 到 20,他们按照我插入的顺序获得了正确的自动生成的 ID。 但是,20 岁之后,我无法获得我想要的 ID。 例如,名称为“apple22”的项目的自动生成的 ID 是 34。这很奇怪。 有没有人知道为什么会这样? 回答1 我希望它批量获取序列(第 10 节)和多个线程/连接,但问题中没有足够的信息来说明。 然而,一个更有用的答案可能是问 - 你为什么关心? 有差距并不意味着不正确。 像这样顺序生成的 ID 应该是内部不透明标识符,仅用于连接和完整性等。

2021-09-24 22:20:09    分类:技术分享    playframework-2.0   yaml   ebean

Python ruamel.yaml dumps tags with quotes

I'm trying to use ruamel.yaml to modify an AWS CloudFormation template on the fly using python. I added the following code to make the safe_load working with CloudFormation functions such as !Ref. However, when I dump them out, those values with !Ref (or any other functions) will be wrapped by quotes. CloudFormation is not able to identify that. See example below: import sys, json, io, boto3 import ruamel.yaml def funcparse(loader, node): node.value = { ruamel.yaml.ScalarNode: loader.construct_scalar, ruamel.yaml.SequenceNode: loader.construct_sequence, ruamel.yaml.MappingNode: loader

2021-09-24 15:36:02    分类:问答    python   yaml   pyyaml   ruamel.yaml

AWS CFN error "The parameter groupName cannot be used with the parameter subnet"

I get error by using the following yaml. I have checked the code but I dont think there's any problem. My structure is planned to have a VPC with 2 public subnet and 2 private subnet. One web server instance will be placed in public subnet 2. I think the problem maybe related to instance creation, coz the error appear during the instance creation process. Parameters: EnvironmentName: Description: An environment name that is prefixed to resource names Type: String KeyName: Description: Name of an existing EC2 KeyPair to enable SSH access to the instances Type: AWS::EC2::KeyPair::KeyName

2021-09-24 06:23:55    分类:问答    amazon-web-services   yaml   amazon-cloudformation

Play framework, inserting initial-data more than 20 items per one Model

In the development mode of Play framework, I inserted my initial-data.yml through Global.java. However, if one model has more than 20 items, autu-generated IDs is going crazy. For example, if I had: computers: - !!models.Computer name: apple01 - !!models.Computer name: apple02 - !!models.Computer name: apple03 - !!models.Computer name: apple04 ... - !!models.Computer name: apple20 - !!models.Computer name: apple21 - !!models.Computer name: apple22 From 1 to 20, they got correct auto-generated IDs by the order that I inserted. However, after 20, I could not get IDs that I intended. For example

2021-09-24 06:19:15    分类:问答    playframework-2.0   yaml   ebean

Unmarshal dynamic YAML to map of structs

I'm trying to unmarshal the following YAML (using gopkg.in/yaml.v2): m: - unit: km formula: magnitude / 1000 testFixtures: - input: 1000 expected: 1 l: - unit: ml formula: magnitude * 1000 testFixtures: - input: 1 expected: 1000 With the following code: type ConversionTestFixture struct { Input float64 `yaml:"input"` Expected float64 `yaml:"expected"` } type conversionGroup struct { Unit string `yaml:"unit"` Formula string `yaml:"formula"` TestFixtures []ConversionTestFixture `yaml:"testFixtures"` } conversionGroups := make(map[string]conversionGroup) err = yaml.Unmarshal([]byte(raw),

2021-09-24 04:58:19    分类:问答    go   yaml   unmarshalling

Adding decodeSlash using Feign @RequestLine

I am currently using a YAML file to generate the models and the API clients using the swagger plugin and I am using Feign OkHttpClient to make requests to the API, the problem here is the client encodes the URL but ignores the Slash(es) with this the API call fails. Is there a way to add decodeSlash parameter in the client? Or can this be achieved using an interceptor? Here is the sample path param where I am running into this issue. QgKuK2DU/0%3D where as it should be QgKuK2DU%2F0%3D

2021-09-23 23:01:28    分类:问答    java   yaml   okhttp3   rest-client   Feign

Doctrine2 cannot make '2' one-to-many relations

I'm trying to make 3 entities (Item, Agree, Disagree) with following relations. Item one-to-many Agree Item one-to-many Disagree But only one relation (declared later) out of two has made. Here're my .yml files. Entities\Item: type: entity fields: id: type: integer id: true generator: strategy: AUTO oneToMany: agrees: targetEntity: Agree mappedBy: items oneToMany: disagrees: targetEntity: Disagree mappedBy: items Entities\Agree: type: entity fields: id: type: integer id: true generator: strategy: AUTO manyToOne: items: targetEntity: Item inversedBy: agrees Entities\Disagree: type: entity

2021-09-23 19:33:19    分类:问答    doctrine-orm   doctrine   yaml   one-to-many

如何在 Python 中向 YAML 文件添加注释(How can I add a comment to a YAML file in Python)

问题 我正在使用 https://pypi.python.org/pypi/ruamel.yaml 编写 YAML 文件 代码是这样的: import ruamel.yaml from ruamel.yaml.comments import CommentedSeq d = {} for m in ['B1', 'B2', 'B3']: d2 = {} for f in ['A1', 'A2', 'A3']: d2[f] = CommentedSeq(['test', 'test2']) if f != 'A2': d2[f].fa.set_flow_style() d[m] = d2 with open('test.yml', "w") as f: ruamel.yaml.dump( d, f, Dumper=ruamel.yaml.RoundTripDumper, default_flow_style=False, width=50, indent=8) 我只想在顶部添加评论,例如: # Data for Class A 在 YAML 数据之前。 回答1 在with块中,您可以向文件中写入任何内容。 由于您只需要在顶部添加注释,请在调用f.write()之前添加对f.write()调用: with open('test.yml', "w") as f: f.write('#

2021-09-21 17:43:50    分类:技术分享    python   yaml   ruamel.yaml

反序列化 YAML 数据“表”(Deserialize a YAML “Table” of data)

问题 我正在使用 yamldotnet 和 c# 来反序列化由第三方软件应用程序创建的文件。 以下 YAML 文件示例均在应用程序中有效: #File1 Groups: - Name: ATeam FirstName, LastName, Age, Height: - [Joe, Soap, 21, 184] - [Mary, Ryan, 20, 169] - [Alex, Dole, 24, 174] #File2 Groups: - Name: ATeam FirstName, LastName, Height: - [Joe, Soap, 184] - [Mary, Ryan, 169] - [Alex, Dole, 174] 请注意, File2 没有任何 Age 列,但反序列化器仍必须识别出每行上的第三个值是高度而不是年龄。 这个数据应该代表一张人表。 以 File1 为例,Mary Ryan 20 岁,身高 169 厘米。 解串器需要了解它的列(对于 File2,它只有名字、姓氏和高度)并将数据相应地存储在正确的对象中:Mary Ryan 身高 169 厘米。 同样,程序文档指出列的顺序并不重要,因此下面的 File3 是表示 File2 中数据的同样有效的方式,即使 Height 现在是第一个: #File3 Groups: - Name: ATeam Height

2021-09-21 15:18:45    分类:技术分享    c#   yaml   yamldotnet