...

Text file src/cuelang.org/go/cue/testdata/eval/merge.txtar

Documentation: cuelang.org/go/cue/testdata/eval

     1TODO: image field is not pre-evaluated (not a huge deal)
     2TODO: allow dynamic fields
     3
     4-- in.cue --
     5key: "app01"
     6manifests: [
     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
    18results: _
    19for _, manifest in manifests {
    20	results: manifest
    21}
    22-- out/eval/stats --
    23Leaks:  0
    24Freed:  22
    25Reused: 15
    26Allocs: 7
    27Retain: 0
    28
    29Unifications: 22
    30Conjuncts:    38
    31Disjuncts:    22
    32-- out/eval --
    33(struct){
    34  key: (string){ "app01" }
    35  manifests: (#list){
    36    0: (struct){
    37      deployment: (struct){
    38        #map: (#struct){
    39          app01: (#struct){
    40            name: (string){ "app01" }
    41            image: (string){ string }
    42            desc: (string){ string }
    43          }
    44        }
    45      }
    46    }
    47    1: (struct){
    48      deployment: (struct){
    49        #map: (#struct){
    50          app01: (#struct){
    51            image: (string){ "image01" }
    52          }
    53        }
    54      }
    55    }
    56  }
    57  results: (struct){
    58    deployment: (struct){
    59      #map: (#struct){
    60        app01: (#struct){
    61          image: (string){ "image01" }
    62          name: (string){ "app01" }
    63          desc: (string){ string }
    64        }
    65      }
    66    }
    67  }
    68}
    69-- out/compile --
    70--- in.cue
    71{
    72  key: "app01"
    73  manifests: [
    74    {
    75      deployment: {
    76        #map: {
    77          [string]: {
    78            name: string
    79            image: string
    80            desc: string
    81          }
    82        }
    83      }
    84      deployment: {
    85        #map: {
    86          "\(〈4;key〉)": {
    87            name: "app01"
    88          }
    89        }
    90      }
    91    },
    92    {
    93      deployment: {
    94        #map: {
    95          app01: {
    96            image: "image01"
    97          }
    98        }
    99      }
   100    },
   101  ]
   102  results: _
   103  for _, manifest in 〈0;manifests〉 {
   104    results: 〈1;manifest〉
   105  }
   106}

View as plain text