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

     1  -- in.cue --
     2  // Label aliases
     3  
     4  // direct
     5  a: [X=string]: X
     6  a: bar: _
     7  
     8  // in struct
     9  b: [X=string]: {X}
    10  b: bar: _
    11  
    12  // in structs
    13  c: [X=string]: X
    14  c: [Y=string]: {{{Y}}}
    15  c: bar: _
    16  
    17  // in sub field
    18  d: [X=string]: name: X
    19  d: bar: {}
    20  
    21  // nested
    22  e: [X=string]: [Y=string]: X + Y
    23  e: foo: bar: _
    24  
    25  // Field aliases
    26  
    27  bar: 3
    28  f1: C="foo\(bar)": {
    29      name: "xx"
    30      foo: C.name
    31  }
    32  
    33  // nested
    34  f1: D="foo\(bar)": E="foo\(bar)baz": {
    35      name: "xx"
    36      a: D["foo\(bar)baz"].name
    37      b: E.name
    38  }
    39  
    40  // Combo
    41  
    42  c1: C="foo\(bar)": [D=string]: {
    43      name: D
    44      foo: C.x.name
    45  }
    46  c1: foo3: x: _
    47  
    48  emptyLabel: {
    49      "": 1
    50      a: emptyLabel[""]
    51  }
    52  
    53  // TODO: support. Also not yet supported in old implementation.
    54  // c10: {
    55  // 	C=[string]: {
    56  // 		name: "x"
    57  // 		foo: C.name
    58  // 	}
    59  // }
    60  // c2: c1 & { x: _ }
    61  
    62  -- out/eval --
    63  (struct){
    64    a: (struct){
    65      bar: (string){ "bar" }
    66    }
    67    b: (struct){
    68      bar: (string){ "bar" }
    69    }
    70    c: (struct){
    71      bar: (string){ "bar" }
    72    }
    73    d: (struct){
    74      bar: (struct){
    75        name: (string){ "bar" }
    76      }
    77    }
    78    e: (struct){
    79      foo: (struct){
    80        bar: (string){ "foobar" }
    81      }
    82    }
    83    bar: (int){ 3 }
    84    f1: (struct){
    85      foo3: (struct){
    86        name: (string){ "xx" }
    87        foo: (string){ "xx" }
    88        foo3baz: (struct){
    89          name: (string){ "xx" }
    90          a: (string){ "xx" }
    91          b: (string){ "xx" }
    92        }
    93      }
    94    }
    95    c1: (struct){
    96      foo3: (struct){
    97        x: (struct){
    98          name: (string){ "x" }
    99          foo: (string){ "x" }
   100        }
   101      }
   102    }
   103    emptyLabel: (struct){
   104      "": (int){ 1 }
   105      a: (int){ 1 }
   106    }
   107  }
   108  -- out/compile --
   109  --- in.cue
   110  {
   111    a: {
   112      [string]: 〈0;-〉
   113    }
   114    a: {
   115      bar: _
   116    }
   117    b: {
   118      [string]: {
   119        〈1;-〉
   120      }
   121    }
   122    b: {
   123      bar: _
   124    }
   125    c: {
   126      [string]: 〈0;-〉
   127    }
   128    c: {
   129      [string]: {
   130        {
   131          {
   132            〈3;-〉
   133          }
   134        }
   135      }
   136    }
   137    c: {
   138      bar: _
   139    }
   140    d: {
   141      [string]: {
   142        name: 〈1;-〉
   143      }
   144    }
   145    d: {
   146      bar: {}
   147    }
   148    e: {
   149      [string]: {
   150        [string]: (〈1;-〉 + 〈0;-〉)
   151      }
   152    }
   153    e: {
   154      foo: {
   155        bar: _
   156      }
   157    }
   158    bar: 3
   159    f1: {
   160      "foo\(〈1;bar〉)": {
   161        name: "xx"
   162        foo: 〈1;("foo\(〈1;bar〉)")〉.name
   163      }
   164    }
   165    f1: {
   166      "foo\(〈1;bar〉)": {
   167        "foo\(〈2;bar〉)baz": {
   168          name: "xx"
   169          a: 〈2;("foo\(〈1;bar〉)")〉["foo\(〈3;bar〉)baz"].name
   170          b: 〈1;("foo\(〈2;bar〉)baz")〉.name
   171        }
   172      }
   173    }
   174    c1: {
   175      "foo\(〈1;bar〉)": {
   176        [string]: {
   177          name: 〈1;-〉
   178          foo: 〈2;("foo\(〈1;bar〉)")〉.x.name
   179        }
   180      }
   181    }
   182    c1: {
   183      foo3: {
   184        x: _
   185      }
   186    }
   187    emptyLabel: {
   188      "": 1
   189      a: 〈1;emptyLabel〉[""]
   190    }
   191  }