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

     1  # Allow otherField
     2  
     3  -- in.cue --
     4  #T: {
     5  	#Schema: [_]: #D
     6  	concrete: #Schema
     7  }
     8  #D: {
     9  	fieldWithDefault: *0 | int
    10  	...
    11  }
    12  s: #T & {
    13  	#Schema: {
    14  		foo: otherField: string
    15  	}
    16  	concrete: foo: otherField: "hello"
    17  }
    18  
    19  #Container: {
    20  	Env: [Name=string]: {
    21  			name:  string
    22  			value: string
    23  	}
    24  }
    25  #Deployment: {
    26          #Containers: [Name=string]: #Container
    27          containers: [ for c in #Containers { c } ] // Problem is here.
    28  }
    29  Something: {
    30          #Deployment
    31          #Containers: {
    32                  // Does not allow entries other than value. Either add ... or embed
    33                  "a thing": Env: foobar: value: "foo"
    34          }
    35  }
    36  x: Something & #Deployment
    37  
    38  -- out/eval --
    39  (struct){
    40    #T: (#struct){
    41      #Schema: (#struct){
    42      }
    43      concrete: (#struct){
    44      }
    45    }
    46    #D: (#struct){
    47      fieldWithDefault: (int){ |(*(int){ 0 }, (int){ int }) }
    48    }
    49    s: (#struct){
    50      #Schema: (#struct){
    51        foo: (#struct){
    52          otherField: (string){ string }
    53          fieldWithDefault: (int){ |(*(int){ 0 }, (int){ int }) }
    54        }
    55      }
    56      concrete: (#struct){
    57        foo: (#struct){
    58          otherField: (string){ "hello" }
    59          fieldWithDefault: (int){ |(*(int){ 0 }, (int){ int }) }
    60        }
    61      }
    62    }
    63    #Container: (#struct){
    64      Env: (#struct){
    65      }
    66    }
    67    #Deployment: (#struct){
    68      #Containers: (#struct){
    69      }
    70      containers: (#list){
    71      }
    72    }
    73    Something: (#struct){
    74      #Containers: (#struct){
    75        "a thing": (#struct){
    76          Env: (#struct){
    77            foobar: (#struct){
    78              value: (string){ "foo" }
    79              name: (string){ string }
    80            }
    81          }
    82        }
    83      }
    84      containers: (#list){
    85        0: (#struct){
    86          Env: (#struct){
    87            foobar: (#struct){
    88              value: (string){ "foo" }
    89              name: (string){ string }
    90            }
    91          }
    92        }
    93      }
    94    }
    95    x: (#struct){
    96      #Containers: (#struct){
    97        "a thing": (#struct){
    98          Env: (#struct){
    99            foobar: (#struct){
   100              value: (string){ "foo" }
   101              name: (string){ string }
   102            }
   103          }
   104        }
   105      }
   106      containers: (#list){
   107        0: (#struct){
   108          Env: (#struct){
   109            foobar: (#struct){
   110              value: (string){ "foo" }
   111              name: (string){ string }
   112            }
   113          }
   114        }
   115      }
   116    }
   117  }
   118  -- out/export --
   119  #T: {
   120  	#Schema: [_]: #D
   121  	concrete: #Schema
   122  }
   123  #D: {
   124  	fieldWithDefault: *0 | int
   125  	...
   126  }
   127  s: #T & {
   128  	#Schema: {
   129  		foo: otherField: string
   130  	}
   131  	concrete: foo: otherField: "hello"
   132  }
   133  
   134  #Container: {
   135  	Env: [Name=string]: {
   136  		name:  string
   137  		value: string
   138  	}
   139  }
   140  #Deployment: {
   141  	#Containers: [Name=string]: #Container
   142  
   143  	containers: [ for c in #Containers {c}] // Problem is here.
   144  }
   145  Something: {
   146  	#Deployment
   147  	#Containers: {
   148  		// Does not allow entries other than value. Either add ... or embed
   149  		"a thing": Env: foobar: value: "foo"
   150  	}
   151  }
   152  x: Something & #Deployment
   153  
   154  -- out/compile --
   155  --- in.cue
   156  {
   157    #T: {
   158      #Schema: {
   159        [_]: 〈2;#D〉
   160      }
   161      concrete: 〈0;#Schema〉
   162    }
   163    #D: {
   164      fieldWithDefault: (*0|int)
   165      ...
   166    }
   167    s: (〈0;#T〉 & {
   168      #Schema: {
   169        foo: {
   170          otherField: string
   171        }
   172      }
   173      concrete: {
   174        foo: {
   175          otherField: "hello"
   176        }
   177      }
   178    })
   179    #Container: {
   180      Env: {
   181        [string]: {
   182          name: string
   183          value: string
   184        }
   185      }
   186    }
   187    #Deployment: {
   188      #Containers: {
   189        [string]: 〈2;#Container〉
   190      }
   191      containers: [
   192        for _, c in 〈0;#Containers〉 {
   193          〈1;c〉
   194        },
   195      ]
   196    }
   197    Something: {
   198      〈1;#Deployment〉
   199      #Containers: {
   200        "a thing": {
   201          Env: {
   202            foobar: {
   203              value: "foo"
   204            }
   205          }
   206        }
   207      }
   208    }
   209    x: (〈0;Something〉 & 〈0;#Deployment〉)
   210  }