github.com/solo-io/cue@v0.4.7/cue/testdata/eval/merge.txtar (about)

     1  TODO: image field is not pre-evaluated (not a huge deal)
     2  TODO: allow dynamic fields
     3  
     4  -- in.cue --
     5  key: "app01"
     6  manifests: [
     7      {
     8      deployment: #map: [string]: { name: string, image: string, desc: string }
     9      deployment: #map: "\(key)": name: "app01"
    10      },
    11      {
    12          deployment: #map: app01: image: "image01"
    13          // TODO: allow
    14          // deployment: #map: "\("app03")": image: "image01"
    15      }
    16  ]
    17  // unify
    18  results: _
    19  for _, manifest in manifests {
    20      results: manifest
    21  }
    22  -- out/eval --
    23  (struct){
    24    key: (string){ "app01" }
    25    manifests: (#list){
    26      0: (struct){
    27        deployment: (struct){
    28          #map: (#struct){
    29            app01: (#struct){
    30              name: (string){ "app01" }
    31              image: (string){ string }
    32              desc: (string){ string }
    33            }
    34          }
    35        }
    36      }
    37      1: (struct){
    38        deployment: (struct){
    39          #map: (#struct){
    40            app01: (#struct){
    41              image: (string){ "image01" }
    42            }
    43          }
    44        }
    45      }
    46    }
    47    results: (struct){
    48      deployment: (struct){
    49        #map: (#struct){
    50          app01: (#struct){
    51            image: (string){ "image01" }
    52            name: (string){ "app01" }
    53            desc: (string){ string }
    54          }
    55        }
    56      }
    57    }
    58  }
    59  -- out/compile --
    60  --- in.cue
    61  {
    62    key: "app01"
    63    manifests: [
    64      {
    65        deployment: {
    66          #map: {
    67            [string]: {
    68              name: string
    69              image: string
    70              desc: string
    71            }
    72          }
    73        }
    74        deployment: {
    75          #map: {
    76            "\(〈3;key〉)": {
    77              name: "app01"
    78            }
    79          }
    80        }
    81      },
    82      {
    83        deployment: {
    84          #map: {
    85            app01: {
    86              image: "image01"
    87            }
    88          }
    89        }
    90      },
    91    ]
    92    results: _
    93    for _, manifest in 〈0;manifests〉 {
    94      results: 〈1;manifest〉
    95    }
    96  }