github.com/solo-io/cue@v0.4.7/cue/testdata/fulleval/016_struct_comprehension_with_template.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: struct comprehension with template
     4  #evalFull
     5  -- in.cue --
     6  result: [ for _, v in service {v}]
     7  
     8  service: [Name=string]: {
     9  	name: *Name | string
    10  	type: "service"
    11  	port: *7080 | int
    12  }
    13  service: foo: {}
    14  service: bar: {port: 8000}
    15  service: baz: {name: "foobar"}
    16  -- out/def --
    17  result: [{
    18  	name: *"foo" | string
    19  	type: "service"
    20  	port: *7080 | int
    21  }, {
    22  	name: *"bar" | string
    23  	type: "service"
    24  	port: 8000
    25  }, {
    26  	name: "foobar"
    27  	type: "service"
    28  	port: *7080 | int
    29  }]
    30  service: {
    31  	{[Name=string]: {
    32  		name: *Name | string, type: "service", port: *7080 | int
    33  	}}
    34  	foo: {
    35  		name: *"foo" | string
    36  		type: "service"
    37  		port: *7080 | int
    38  	}
    39  	bar: {
    40  		name: *"bar" | string
    41  		type: "service"
    42  		port: 8000
    43  	}
    44  	baz: {
    45  		name: "foobar"
    46  		type: "service"
    47  		port: *7080 | int
    48  	}
    49  }
    50  -- out/export --
    51  result: [{
    52  	name: "foo"
    53  	type: "service"
    54  	port: 7080
    55  }, {
    56  	name: "bar"
    57  	type: "service"
    58  	port: 8000
    59  }, {
    60  	name: "foobar"
    61  	type: "service"
    62  	port: 7080
    63  }]
    64  service: {
    65  	foo: {
    66  		name: "foo"
    67  		type: "service"
    68  		port: 7080
    69  	}
    70  	bar: {
    71  		name: "bar"
    72  		type: "service"
    73  		port: 8000
    74  	}
    75  	baz: {
    76  		name: "foobar"
    77  		type: "service"
    78  		port: 7080
    79  	}
    80  }
    81  -- out/yaml --
    82  result:
    83  - name: foo
    84    type: service
    85    port: 7080
    86  - name: bar
    87    type: service
    88    port: 8000
    89  - name: foobar
    90    type: service
    91    port: 7080
    92  service:
    93    foo:
    94      name: foo
    95      type: service
    96      port: 7080
    97    bar:
    98      name: bar
    99      type: service
   100      port: 8000
   101    baz:
   102      name: foobar
   103      type: service
   104      port: 7080
   105  -- out/json --
   106  {"result":[{"name":"foo","type":"service","port":7080},{"name":"bar","type":"service","port":8000},{"name":"foobar","type":"service","port":7080}],"service":{"foo":{"name":"foo","type":"service","port":7080},"bar":{"name":"bar","type":"service","port":8000},"baz":{"name":"foobar","type":"service","port":7080}}}
   107  -- out/legacy-debug --
   108  <0>{result: [<1>{name: "foo", type: "service", port: 7080},<2>{name: "bar", type: "service", port: 8000},<3>{name: "foobar", type: "service", port: 7080}], service: <4>{[]: <5>(Name: string)-><6>{name: (*<5>.Name | string), type: "service", port: (*7080 | int)}, foo: <7>{name: "foo", type: "service", port: 7080}, bar: <8>{name: "bar", type: "service", port: 8000}, baz: <9>{name: "foobar", type: "service", port: 7080}}}
   109  -- out/compile --
   110  --- in.cue
   111  {
   112    result: [
   113      for _, v in 〈0;service〉 {
   114        〈1;v〉
   115      },
   116    ]
   117    service: {
   118      [string]: {
   119        name: (*〈1;-〉|string)
   120        type: "service"
   121        port: (*7080|int)
   122      }
   123    }
   124    service: {
   125      foo: {}
   126    }
   127    service: {
   128      bar: {
   129        port: 8000
   130      }
   131    }
   132    service: {
   133      baz: {
   134        name: "foobar"
   135      }
   136    }
   137  }
   138  -- out/eval --
   139  (struct){
   140    result: (#list){
   141      0: (struct){
   142        name: (string){ |(*(string){ "foo" }, (string){ string }) }
   143        type: (string){ "service" }
   144        port: (int){ |(*(int){ 7080 }, (int){ int }) }
   145      }
   146      1: (struct){
   147        port: (int){ 8000 }
   148        name: (string){ |(*(string){ "bar" }, (string){ string }) }
   149        type: (string){ "service" }
   150      }
   151      2: (struct){
   152        name: (string){ "foobar" }
   153        type: (string){ "service" }
   154        port: (int){ |(*(int){ 7080 }, (int){ int }) }
   155      }
   156    }
   157    service: (struct){
   158      foo: (struct){
   159        name: (string){ |(*(string){ "foo" }, (string){ string }) }
   160        type: (string){ "service" }
   161        port: (int){ |(*(int){ 7080 }, (int){ int }) }
   162      }
   163      bar: (struct){
   164        port: (int){ 8000 }
   165        name: (string){ |(*(string){ "bar" }, (string){ string }) }
   166        type: (string){ "service" }
   167      }
   168      baz: (struct){
   169        name: (string){ "foobar" }
   170        type: (string){ "service" }
   171        port: (int){ |(*(int){ 7080 }, (int){ int }) }
   172      }
   173    }
   174  }