adunsg / yaml-extender Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
The difference is:
{'advanced_list': ['a b', 'c']} != {'advanced_list': ['a', 'b', 'c']}
The " ".join happens in:
@patch("yaml_extender.yaml_loader.load")
def test_raw_value_ref(loader_mock):
# Test Lists
content = yaml.safe_load(
"""
my_list:
- a
- b
advanced_list:
- "{{ my_list }}"
- c
"""
)
loader_mock.return_value = content
file = XYmlFile(Path.cwd())
expected = yaml.safe_load(
"""
my_list:
- a
- b
advanced_list:
- a
- b
- c
"""
)
> assert file.content == expected
E AssertionError: assert {'advanced_li...': ['a', 'b']} == {'advanced_li...': ['a', 'b']}
E Omitting 1 identical items, use -vv to show
E Differing items:
E {'advanced_list': ['a b', 'c']} != {'advanced_list': ['a', 'b', 'c']}
E Use -v to get more diff
tests/resolver_test/test_ref_resolver.py:371: AssertionError
Hi, we have the problem, that in jenkins parameters might be "" (an empty string).
In the call preparation this gets converted in to --param1 (two spaces)--param2 value2
Yaml-Extender is then getting a off by one error and takes "--param2" as the value of param1.
yaml-extender/src/yaml_extender/cli.py
Line 35 in 7f94148
Maybe we could check for --
infront of params.
I am not sure if empty params should be treated as a flag and be counted as boolean True, or as empty string.
We will filter out those empty strings, on our side, for now, but that has other consequences.
Should we provide a pullrequest for this issue?
Include statements at root level break other include statements
For demonstrating that you can see:
As note, please comment first line and check the diferences
xyml.include: prop.yaml
pipelines:
node:
name: "sss"
stages:
- xyml.include: file-a.yaml
- xyml.include: file-b.yaml<<order=23>>
# prop.yaml
VAR_NAME: My name is
VAR_BR_NAME: master
# file-a.yaml
name: "VENV"
order: 12
steps:
- cmd: ..\venv.bat create pipfile
- cmd: ..\venv.bat python --version
# file-b.yaml
name: "ASTREE"
order: "{{xyml.param.order}}"
steps:
- cmd: bla bla
name: Some work
array:
- value: 1
- value: 2
- value: 3
- value: 4
commands:
- value: x
- xyml.for: element:array
value: "{{element.value}}"
expected:
commands:
- value: x
- value: 1
- value: 2
- value: 3
- value: 4
actual:
commands:
- value: x
- value: 4
- value: 3
- value: 2
- value: 1
Hi, some early users tried to extend a list with a for loop. they tried:
parallelBuild:
- name: test1
buildTarget: BUILD
- name: test2
buildTarget: BUILD
pipelines:
- nodes:
- label: Should stay
executionOrder: 0
stages:
- name: "Should stay stage"
executionOrder: 0
xyml.for: build_config:parallelBuild
xyml.content:
- label: "{{build_config.name}}"
executionOrder: 1
stages:
- name: "{{build_config.buildTarget}}"
executionOrder: 0
This swallows the node and results in:
parallelBuild:
- name: test1
buildTarget: BUILD
- name: test2
buildTarget: BUILD
pipelines:
- label: test1
executionOrder: 1
stages:
- name: BUILD
executionOrder: 0
- label: test2
executionOrder: 1
stages:
- name: BUILD
executionOrder: 0
If we indent the xyml.for etc. into a list it works as expected.
parallelBuild:
- name: test1
buildTarget: BUILD
- name: test2
buildTarget: BUILD
pipelines:
- nodes:
- label: Should stay
executionOrder: 0
stages:
- name: "Should stay stage"
executionOrder: 0
- xyml.for: build_config:parallelBuild
xyml.content:
- label: "{{build_config.name}}"
executionOrder: 1
stages:
- name: "{{build_config.buildTarget}}"
executionOrder: 0
Creates the expected
parallelBuild:
- name: test1
buildTarget: BUILD
- name: test2
buildTarget: BUILD
pipelines:
- nodes:
- label: Should stay
executionOrder: 0
stages:
- name: Should stay stage
executionOrder: 0
- label: test1
executionOrder: 1
stages:
- name: BUILD
executionOrder: 0
- label: test2
executionOrder: 1
stages:
- name: BUILD
executionOrder: 0
Is this the expected behavior?
Should we maybe extend the documentation on how to extend lists?
The current syntax for including other files with parameters is:
xyml.include:
- file1.yaml<<ref_1=456>>
- file2.yaml
when passing more than a few parameters this quickly gets hard to read (and maintain)
Therfore a cleaner syntax like the one below would be beneficial
xyml.include:
- path: file1.yaml
values: # Probably a better name for this ;)
ref_1: 456
ref_2: {{ another_ref:some-default }}
- path: file2.yaml
For includes without parameters the one-line syntax xyml.include: file1.yaml
still should be possible. But for more complex setups a cleaner syntax would be beneficial.
Consider This input file:
default_value: XXXX
config_value: ZZZZ
cmd: python -m pla --variant {{config_value:{{default_value}}}}
This will result in:
default_value: XXXX
config_value: ZZZZ
cmd: python -m pla --variant ZZZZ}}
Notice the }}.
The Regex does not ensure that the correct corresponding brackets are used.
Maybe iterating over the values and only resolving the inner most brackets (ensure no other "{{" is in the capture group) first might solve this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.