Coder Social home page Coder Social logo

yaml-extender's People

Contributors

adunsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yaml-extender's Issues

Test "test_raw_value_ref" fails

The difference is:
{'advanced_list': ['a b', 'c']} != {'advanced_list': ['a', 'b', 'c']}

The " ".join happens in:

https://github.com/AdunSG/yaml-extender/blob/7f9414847397e17d25770302371dd1c68032c149/src/yaml_extender/resolver/reference_resolver.py#L104C25-L104C25

    @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

Naive parameter parsing fails on empty strings.

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.

arg_dict = dict(zip(args[:-1:2], args[1::2]))

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

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

for loops reverse order when member of array

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

Extending lists with xyml.for

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?

Cleaner syntax for incuding with passing parameters

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)

  • the line length grows
  • sorting the parameters is difficult

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.

Nested {{ }} fail

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.