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

     1  -- in.cue --
     2  deployment: [string]: #Deployment
     3  
     4  deployment: foo: spec: replicas: 1
     5  
     6  #Deployment: {
     7  	#TypeMeta
     8  
     9  	spec: #Spec
    10  }
    11  
    12  #Spec: replicas: int
    13  
    14  #TypeMeta: {}
    15  
    16  recloseSimple: {
    17    #foo: {}
    18    a: {#foo} & {b: int}
    19  }
    20  
    21  // Reclosing
    22  reclose1: {
    23    #D: {
    24      x: int
    25      y: int
    26    }
    27    #a: {
    28      #D
    29      b: {
    30        c: int
    31      }
    32    }
    33  
    34    z: #a.b
    35    z: d: 3 // don't allow this
    36  }
    37  
    38  reclose2: {
    39    #D: {
    40      x: int
    41      y: int
    42    }
    43    a: {
    44      #D
    45      b: { // keep open
    46        c: int
    47      }
    48    }
    49  
    50    z: a.b
    51    z: d: 3 // allow this
    52  }
    53  
    54  reclose3: {
    55    #Step: {
    56      (#A | #B)
    57      #Common
    58    }
    59    #Common: {
    60      Name: string
    61    }
    62    #A: {
    63      #Common
    64      Something: int
    65    }
    66    #B: {
    67      #Common
    68      Else: int
    69    }
    70    x: #Step
    71    x: #A & {
    72      Name:      "a"
    73      Something: 4
    74    }
    75  }
    76  
    77  -- out/eval --
    78  Errors:
    79  reclose1.z: field not allowed: d:
    80      ./in.cue:28:8
    81      ./in.cue:33:6
    82      ./in.cue:34:6
    83  recloseSimple.a: field not allowed: b:
    84      ./in.cue:16:9
    85      ./in.cue:17:6
    86      ./in.cue:17:7
    87      ./in.cue:17:16
    88  
    89  Result:
    90  (_|_){
    91    // [eval]
    92    deployment: (struct){
    93      foo: (#struct){
    94        spec: (#struct){
    95          replicas: (int){ 1 }
    96        }
    97      }
    98    }
    99    #Deployment: (#struct){
   100      spec: (#struct){
   101        replicas: (int){ int }
   102      }
   103    }
   104    #Spec: (#struct){
   105      replicas: (int){ int }
   106    }
   107    #TypeMeta: (#struct){
   108    }
   109    recloseSimple: (_|_){
   110      // [eval]
   111      #foo: (#struct){
   112      }
   113      a: (_|_){
   114        // [eval]
   115        b: (_|_){
   116          // [eval] recloseSimple.a: field not allowed: b:
   117          //     ./in.cue:16:9
   118          //     ./in.cue:17:6
   119          //     ./in.cue:17:7
   120          //     ./in.cue:17:16
   121        }
   122      }
   123    }
   124    reclose1: (_|_){
   125      // [eval]
   126      #D: (#struct){
   127        x: (int){ int }
   128        y: (int){ int }
   129      }
   130      #a: (#struct){
   131        x: (int){ int }
   132        y: (int){ int }
   133        b: (#struct){
   134          c: (int){ int }
   135        }
   136      }
   137      z: (_|_){
   138        // [eval]
   139        c: (int){ int }
   140        d: (_|_){
   141          // [eval] reclose1.z: field not allowed: d:
   142          //     ./in.cue:28:8
   143          //     ./in.cue:33:6
   144          //     ./in.cue:34:6
   145        }
   146      }
   147    }
   148    reclose2: (struct){
   149      #D: (#struct){
   150        x: (int){ int }
   151        y: (int){ int }
   152      }
   153      a: (#struct){
   154        x: (int){ int }
   155        y: (int){ int }
   156        b: (struct){
   157          c: (int){ int }
   158        }
   159      }
   160      z: (struct){
   161        c: (int){ int }
   162        d: (int){ 3 }
   163      }
   164    }
   165    reclose3: (struct){
   166      #Step: (#struct){ |((#struct){
   167          Name: (string){ string }
   168          Something: (int){ int }
   169        }, (#struct){
   170          Name: (string){ string }
   171          Else: (int){ int }
   172        }) }
   173      #Common: (#struct){
   174        Name: (string){ string }
   175      }
   176      #A: (#struct){
   177        Name: (string){ string }
   178        Something: (int){ int }
   179      }
   180      #B: (#struct){
   181        Name: (string){ string }
   182        Else: (int){ int }
   183      }
   184      x: (#struct){
   185        Name: (string){ "a" }
   186        Something: (int){ 4 }
   187      }
   188    }
   189  }
   190  -- out/compile --
   191  --- in.cue
   192  {
   193    deployment: {
   194      [string]: 〈1;#Deployment〉
   195    }
   196    deployment: {
   197      foo: {
   198        spec: {
   199          replicas: 1
   200        }
   201      }
   202    }
   203    #Deployment: {
   204      〈1;#TypeMeta〉
   205      spec: 〈1;#Spec〉
   206    }
   207    #Spec: {
   208      replicas: int
   209    }
   210    #TypeMeta: {}
   211    recloseSimple: {
   212      #foo: {}
   213      a: ({
   214        〈1;#foo〉
   215      } & {
   216        b: int
   217      })
   218    }
   219    reclose1: {
   220      #D: {
   221        x: int
   222        y: int
   223      }
   224      #a: {
   225        〈1;#D〉
   226        b: {
   227          c: int
   228        }
   229      }
   230      z: 〈0;#a〉.b
   231      z: {
   232        d: 3
   233      }
   234    }
   235    reclose2: {
   236      #D: {
   237        x: int
   238        y: int
   239      }
   240      a: {
   241        〈1;#D〉
   242        b: {
   243          c: int
   244        }
   245      }
   246      z: 〈0;a〉.b
   247      z: {
   248        d: 3
   249      }
   250    }
   251    reclose3: {
   252      #Step: {
   253        (〈1;#A〉|〈1;#B〉)
   254        〈1;#Common〉
   255      }
   256      #Common: {
   257        Name: string
   258      }
   259      #A: {
   260        〈1;#Common〉
   261        Something: int
   262      }
   263      #B: {
   264        〈1;#Common〉
   265        Else: int
   266      }
   267      x: 〈0;#Step〉
   268      x: (〈0;#A〉 & {
   269        Name: "a"
   270        Something: 4
   271      })
   272    }
   273  }