0

I am trying to declare a repeatable part of the list, but it seems that I misunderstand the yaml syntax.

_test:
  _const: &const
  - a: a
    b: b
  - c: c
    d: d    
data:
  list_ef:
  -
    <<: *const
  - e: e
    f: f
  list_gh:
  -
    <<: *const
  - g: g
    h: h

so, i need to get data section like this:

data:
  list_ef:
  - a: a
    b: b
  - c: c
    d: d  
  - e: e
    f: f
  list_gh:
  - a: a
    b: b
  - c: c
    d: d
  - g: g
    h: h

but all I get is either error меssages or a nested list or something like this (nested too):

--- 
_test: 
  _const: 
    - 
      a: a
      b: b
    - 
      c: c
      d: d
data: 
  list_ef: 
    - 
      ? "<<"
      : 
        - 
          a: a
          b: b
        - 
          c: c
          d: d
    - 
      e: e
      f: f
  list_gh: 
    - 
      ? "<<"
      : 
        - 
          a: a
          b: b
        - 
          c: c
          d: d
    - 
      g: g
      h: h

What should be the correct syntax for this?

EugenOS
  • 31
  • 5
  • I believe this is a duplicate of the above question. The `< – Iguananaut Sep 01 '21 at 14:30
  • In fact, in the case of GitLab, I'm not even sure they support any special syntax. Instead you may need a little additional logic in parsing your data structures. For example, I've done something like `key: [*array1, *array2]` where `*arrayN` is an anchor to an array. You then need to modify your handling of the value of `key` to support flattening of nested arrays. – Iguananaut Sep 01 '21 at 14:32

0 Answers0