cuelang.org/go@v0.10.1/cue/testdata/comprehensions/issue1732.txtar (about)

     1  -- in.cue --
     2  package config
     3  
     4  networkingv1: {
     5  	metav1: {
     6  		#LabelSelector: {
     7  			matchLabels: {[string]: string}
     8  		}
     9  	}
    10  
    11  	#NetworkPolicy: {
    12  		spec: #NetworkPolicySpec
    13  	}
    14  
    15  	#NetworkPolicySpec: {
    16  		ingress: [...#NetworkPolicyIngressRule]
    17  		egress: [...#NetworkPolicyEgressRule]
    18  	}
    19  
    20  	#NetworkPolicyIngressRule: {
    21  		from: [...#NetworkPolicyPeer]
    22  	}
    23  
    24  	#NetworkPolicyEgressRule: {
    25  		to: [...#NetworkPolicyPeer]
    26  	}
    27  
    28  	#NetworkPolicyPeer: {
    29  		namespaceSelector: null | metav1.#LabelSelector
    30  	}
    31  }
    32  
    33  global_config: {
    34  	#GlobalConfig: {
    35  		auth0: {
    36  			enabled: bool
    37  		}
    38  	}
    39  }
    40  common: {
    41  	#SomeConfig: {
    42  		enabled: bool
    43  		if enabled {
    44  			foo: string
    45  		}
    46  	}
    47  }
    48  
    49  foo: {
    50  	#Values: {
    51  		global: global_config.#GlobalConfig
    52  	}
    53  }
    54  
    55  #Config: R={
    56  	tenant: id: string
    57  
    58  	auth0: common.#SomeConfig & {
    59  		enabled: bool
    60  		if (enabled) {
    61  			foo: "\(tenant.id)-value"
    62  		}
    63  	}
    64  
    65  	charts: {
    66  		"foo": foo.#Values & {
    67  			global: R.global
    68  		}
    69  	}
    70  
    71  	global: global_config.#GlobalConfig & {
    72  		auth0: enabled: R.auth0.enabled
    73  	}
    74  }
    75  
    76  #NetworkPolicy: networkingv1.#NetworkPolicy
    77  
    78  #Flux: R={
    79  	#Config
    80  
    81  	charts: _
    82  
    83  	formatOutput: {...}
    84  
    85  	_outputs: {...}
    86  
    87  	for _chartName, _chartValues in charts {
    88  		_outputs: "\(_chartName)": {}
    89  	}
    90  
    91  	_outputs: {
    92  		for ns in ["ns"] {
    93  			"\(ns)/network": #NetworkPolicy & {
    94  				spec: {
    95  					ingress: [
    96  						{
    97  							from: [{
    98  								namespaceSelector: matchLabels: {
    99  									tenant: R.tenant.id
   100  								}
   101  							}]
   102  						},
   103  					]
   104  					egress: [
   105  						{
   106  							to: [{
   107  								namespaceSelector: matchLabels: {
   108  									tenant: R.tenant.id
   109  								}
   110  							}]
   111  						},
   112  					]
   113  				}
   114  			}
   115  		}
   116  	}
   117  
   118  	for ns in ["ns"] {
   119  		for k, v in _outputs {
   120  			formatOutput: "\(k)": v
   121  		}
   122  	}
   123  }
   124  -- out/eval/stats --
   125  Leaks:  3
   126  Freed:  118
   127  Reused: 103
   128  Allocs: 18
   129  Retain: 10
   130  
   131  Unifications: 111
   132  Conjuncts:    249
   133  Disjuncts:    126
   134  -- out/evalalpha --
   135  (struct){
   136    networkingv1: (struct){
   137      metav1: (struct){
   138        #LabelSelector: (#struct){
   139          matchLabels: (#struct){
   140          }
   141        }
   142      }
   143      #NetworkPolicy: (#struct){
   144        spec: (#struct){
   145          ingress: (list){
   146          }
   147          egress: (list){
   148          }
   149        }
   150      }
   151      #NetworkPolicySpec: (#struct){
   152        ingress: (list){
   153        }
   154        egress: (list){
   155        }
   156      }
   157      #NetworkPolicyIngressRule: (#struct){
   158        from: (list){
   159        }
   160      }
   161      #NetworkPolicyEgressRule: (#struct){
   162        to: (list){
   163        }
   164      }
   165      #NetworkPolicyPeer: (#struct){
   166        namespaceSelector: ((null|struct)){ |((null){ null }, (#struct){
   167            matchLabels: (#struct){
   168            }
   169          }) }
   170      }
   171    }
   172    global_config: (struct){
   173      #GlobalConfig: (#struct){
   174        auth0: (#struct){
   175          enabled: (bool){ bool }
   176        }
   177      }
   178    }
   179    common: (struct){
   180      #SomeConfig: (_|_){
   181        // [incomplete] common.#SomeConfig: incomplete bool: bool:
   182        //     ./in.cue:41:12
   183        enabled: (bool){ bool }
   184      }
   185    }
   186    foo: (struct){
   187      #Values: (#struct){
   188        global: (#struct){
   189          auth0: (#struct){
   190            enabled: (bool){ bool }
   191          }
   192        }
   193      }
   194    }
   195    #Config: (#struct){
   196      tenant: (#struct){
   197        id: (string){ string }
   198      }
   199      auth0: (_|_){
   200        // [incomplete] #Config.auth0: incomplete bool: bool:
   201        //     ./in.cue:58:12
   202        enabled: (bool){ bool }
   203      }
   204      charts: (#struct){
   205        foo: (#struct){
   206          global: (#struct){
   207            auth0: (#struct){
   208              enabled: (_|_){
   209                // [incomplete] #Config.auth0: incomplete bool: bool:
   210                //     ./in.cue:58:12
   211              }
   212            }
   213          }
   214        }
   215      }
   216      global: (#struct){
   217        auth0: (#struct){
   218          enabled: (_|_){
   219            // [incomplete] #Config.auth0: incomplete bool: bool:
   220            //     ./in.cue:58:12
   221          }
   222        }
   223      }
   224    }
   225    #NetworkPolicy: (#struct){
   226      spec: (#struct){
   227        ingress: (list){
   228        }
   229        egress: (list){
   230        }
   231      }
   232    }
   233    #Flux: (#struct){
   234      charts: (#struct){
   235        foo: (#struct){
   236          global: (#struct){
   237            auth0: (#struct){
   238              enabled: (bool){ bool }
   239            }
   240          }
   241        }
   242      }
   243      formatOutput: (#struct){
   244        foo: (#struct){
   245        }
   246        "ns/network": (#struct){
   247          spec: (#struct){
   248            ingress: (#list){
   249              0: (#struct){
   250                from: (#list){
   251                  0: (#struct){
   252                    namespaceSelector: (#struct){
   253                      matchLabels: (#struct){
   254                        tenant: (string){ string }
   255                      }
   256                    }
   257                  }
   258                }
   259              }
   260            }
   261            egress: (#list){
   262              0: (#struct){
   263                to: (#list){
   264                  0: (#struct){
   265                    namespaceSelector: (#struct){
   266                      matchLabels: (#struct){
   267                        tenant: (string){ string }
   268                      }
   269                    }
   270                  }
   271                }
   272              }
   273            }
   274          }
   275        }
   276      }
   277      _outputs(:config): (#struct){
   278        foo: (#struct){
   279        }
   280        "ns/network": (#struct){
   281          spec: (#struct){
   282            ingress: (#list){
   283              0: (#struct){
   284                from: (#list){
   285                  0: (#struct){
   286                    namespaceSelector: (#struct){
   287                      matchLabels: (#struct){
   288                        tenant: (string){ string }
   289                      }
   290                    }
   291                  }
   292                }
   293              }
   294            }
   295            egress: (#list){
   296              0: (#struct){
   297                to: (#list){
   298                  0: (#struct){
   299                    namespaceSelector: (#struct){
   300                      matchLabels: (#struct){
   301                        tenant: (string){ string }
   302                      }
   303                    }
   304                  }
   305                }
   306              }
   307            }
   308          }
   309        }
   310      }
   311      tenant: (#struct){
   312        id: (string){ string }
   313      }
   314      auth0: (_|_){
   315        // [incomplete] #Flux.auth0: incomplete bool: bool:
   316        //     ./in.cue:58:12
   317        enabled: (bool){ bool }
   318      }
   319      global: (#struct){
   320        auth0: (#struct){
   321          enabled: (_|_){
   322            // [incomplete] #Flux.auth0: incomplete bool: bool:
   323            //     ./in.cue:58:12
   324          }
   325        }
   326      }
   327    }
   328  }
   329  -- diff/-out/evalalpha<==>+out/eval --
   330  diff old new
   331  --- old
   332  +++ new
   333  @@ -64,7 +64,7 @@
   334       }
   335       auth0: (_|_){
   336         // [incomplete] #Config.auth0: incomplete bool: bool:
   337  -      //     ./in.cue:41:12
   338  +      //     ./in.cue:58:12
   339         enabled: (bool){ bool }
   340       }
   341       charts: (#struct){
   342  @@ -73,7 +73,7 @@
   343             auth0: (#struct){
   344               enabled: (_|_){
   345                 // [incomplete] #Config.auth0: incomplete bool: bool:
   346  -              //     ./in.cue:41:12
   347  +              //     ./in.cue:58:12
   348               }
   349             }
   350           }
   351  @@ -83,7 +83,7 @@
   352         auth0: (#struct){
   353           enabled: (_|_){
   354             // [incomplete] #Config.auth0: incomplete bool: bool:
   355  -          //     ./in.cue:41:12
   356  +          //     ./in.cue:58:12
   357           }
   358         }
   359       }
   360  @@ -97,31 +97,12 @@
   361       }
   362     }
   363     #Flux: (#struct){
   364  -    tenant: (#struct){
   365  -      id: (string){ string }
   366  -    }
   367  -    auth0: (_|_){
   368  -      // [incomplete] #Flux.auth0: incomplete bool: bool:
   369  -      //     ./in.cue:41:12
   370  -      enabled: (bool){ bool }
   371  -    }
   372  -    charts: (#struct){
   373  -      foo: (#struct){
   374  -        global: (#struct){
   375  -          auth0: (#struct){
   376  -            enabled: (_|_){
   377  -              // [incomplete] #Flux.auth0: incomplete bool: bool:
   378  -              //     ./in.cue:41:12
   379  -            }
   380  -          }
   381  -        }
   382  -      }
   383  -    }
   384  -    global: (#struct){
   385  -      auth0: (#struct){
   386  -        enabled: (_|_){
   387  -          // [incomplete] #Flux.auth0: incomplete bool: bool:
   388  -          //     ./in.cue:41:12
   389  +    charts: (#struct){
   390  +      foo: (#struct){
   391  +        global: (#struct){
   392  +          auth0: (#struct){
   393  +            enabled: (bool){ bool }
   394  +          }
   395           }
   396         }
   397       }
   398  @@ -193,5 +174,21 @@
   399           }
   400         }
   401       }
   402  +    tenant: (#struct){
   403  +      id: (string){ string }
   404  +    }
   405  +    auth0: (_|_){
   406  +      // [incomplete] #Flux.auth0: incomplete bool: bool:
   407  +      //     ./in.cue:58:12
   408  +      enabled: (bool){ bool }
   409  +    }
   410  +    global: (#struct){
   411  +      auth0: (#struct){
   412  +        enabled: (_|_){
   413  +          // [incomplete] #Flux.auth0: incomplete bool: bool:
   414  +          //     ./in.cue:58:12
   415  +        }
   416  +      }
   417  +    }
   418     }
   419   }
   420  -- diff/todo/p2 --
   421  #Flux.charts.foo.global.auth0.enabled: missing error
   422    The error messages should say which expression was incomplete!!!
   423  -- out/eval --
   424  (struct){
   425    networkingv1: (struct){
   426      metav1: (struct){
   427        #LabelSelector: (#struct){
   428          matchLabels: (#struct){
   429          }
   430        }
   431      }
   432      #NetworkPolicy: (#struct){
   433        spec: (#struct){
   434          ingress: (list){
   435          }
   436          egress: (list){
   437          }
   438        }
   439      }
   440      #NetworkPolicySpec: (#struct){
   441        ingress: (list){
   442        }
   443        egress: (list){
   444        }
   445      }
   446      #NetworkPolicyIngressRule: (#struct){
   447        from: (list){
   448        }
   449      }
   450      #NetworkPolicyEgressRule: (#struct){
   451        to: (list){
   452        }
   453      }
   454      #NetworkPolicyPeer: (#struct){
   455        namespaceSelector: ((null|struct)){ |((null){ null }, (#struct){
   456            matchLabels: (#struct){
   457            }
   458          }) }
   459      }
   460    }
   461    global_config: (struct){
   462      #GlobalConfig: (#struct){
   463        auth0: (#struct){
   464          enabled: (bool){ bool }
   465        }
   466      }
   467    }
   468    common: (struct){
   469      #SomeConfig: (_|_){
   470        // [incomplete] common.#SomeConfig: incomplete bool: bool:
   471        //     ./in.cue:41:12
   472        enabled: (bool){ bool }
   473      }
   474    }
   475    foo: (struct){
   476      #Values: (#struct){
   477        global: (#struct){
   478          auth0: (#struct){
   479            enabled: (bool){ bool }
   480          }
   481        }
   482      }
   483    }
   484    #Config: (#struct){
   485      tenant: (#struct){
   486        id: (string){ string }
   487      }
   488      auth0: (_|_){
   489        // [incomplete] #Config.auth0: incomplete bool: bool:
   490        //     ./in.cue:41:12
   491        enabled: (bool){ bool }
   492      }
   493      charts: (#struct){
   494        foo: (#struct){
   495          global: (#struct){
   496            auth0: (#struct){
   497              enabled: (_|_){
   498                // [incomplete] #Config.auth0: incomplete bool: bool:
   499                //     ./in.cue:41:12
   500              }
   501            }
   502          }
   503        }
   504      }
   505      global: (#struct){
   506        auth0: (#struct){
   507          enabled: (_|_){
   508            // [incomplete] #Config.auth0: incomplete bool: bool:
   509            //     ./in.cue:41:12
   510          }
   511        }
   512      }
   513    }
   514    #NetworkPolicy: (#struct){
   515      spec: (#struct){
   516        ingress: (list){
   517        }
   518        egress: (list){
   519        }
   520      }
   521    }
   522    #Flux: (#struct){
   523      tenant: (#struct){
   524        id: (string){ string }
   525      }
   526      auth0: (_|_){
   527        // [incomplete] #Flux.auth0: incomplete bool: bool:
   528        //     ./in.cue:41:12
   529        enabled: (bool){ bool }
   530      }
   531      charts: (#struct){
   532        foo: (#struct){
   533          global: (#struct){
   534            auth0: (#struct){
   535              enabled: (_|_){
   536                // [incomplete] #Flux.auth0: incomplete bool: bool:
   537                //     ./in.cue:41:12
   538              }
   539            }
   540          }
   541        }
   542      }
   543      global: (#struct){
   544        auth0: (#struct){
   545          enabled: (_|_){
   546            // [incomplete] #Flux.auth0: incomplete bool: bool:
   547            //     ./in.cue:41:12
   548          }
   549        }
   550      }
   551      formatOutput: (#struct){
   552        foo: (#struct){
   553        }
   554        "ns/network": (#struct){
   555          spec: (#struct){
   556            ingress: (#list){
   557              0: (#struct){
   558                from: (#list){
   559                  0: (#struct){
   560                    namespaceSelector: (#struct){
   561                      matchLabels: (#struct){
   562                        tenant: (string){ string }
   563                      }
   564                    }
   565                  }
   566                }
   567              }
   568            }
   569            egress: (#list){
   570              0: (#struct){
   571                to: (#list){
   572                  0: (#struct){
   573                    namespaceSelector: (#struct){
   574                      matchLabels: (#struct){
   575                        tenant: (string){ string }
   576                      }
   577                    }
   578                  }
   579                }
   580              }
   581            }
   582          }
   583        }
   584      }
   585      _outputs(:config): (#struct){
   586        foo: (#struct){
   587        }
   588        "ns/network": (#struct){
   589          spec: (#struct){
   590            ingress: (#list){
   591              0: (#struct){
   592                from: (#list){
   593                  0: (#struct){
   594                    namespaceSelector: (#struct){
   595                      matchLabels: (#struct){
   596                        tenant: (string){ string }
   597                      }
   598                    }
   599                  }
   600                }
   601              }
   602            }
   603            egress: (#list){
   604              0: (#struct){
   605                to: (#list){
   606                  0: (#struct){
   607                    namespaceSelector: (#struct){
   608                      matchLabels: (#struct){
   609                        tenant: (string){ string }
   610                      }
   611                    }
   612                  }
   613                }
   614              }
   615            }
   616          }
   617        }
   618      }
   619    }
   620  }
   621  -- out/compile --
   622  --- in.cue
   623  {
   624    networkingv1: {
   625      metav1: {
   626        #LabelSelector: {
   627          matchLabels: {
   628            [string]: string
   629          }
   630        }
   631      }
   632      #NetworkPolicy: {
   633        spec: 〈1;#NetworkPolicySpec〉
   634      }
   635      #NetworkPolicySpec: {
   636        ingress: [
   637          ...〈2;#NetworkPolicyIngressRule〉,
   638        ]
   639        egress: [
   640          ...〈2;#NetworkPolicyEgressRule〉,
   641        ]
   642      }
   643      #NetworkPolicyIngressRule: {
   644        from: [
   645          ...〈2;#NetworkPolicyPeer〉,
   646        ]
   647      }
   648      #NetworkPolicyEgressRule: {
   649        to: [
   650          ...〈2;#NetworkPolicyPeer〉,
   651        ]
   652      }
   653      #NetworkPolicyPeer: {
   654        namespaceSelector: (null|〈1;metav1〉.#LabelSelector)
   655      }
   656    }
   657    global_config: {
   658      #GlobalConfig: {
   659        auth0: {
   660          enabled: bool
   661        }
   662      }
   663    }
   664    common: {
   665      #SomeConfig: {
   666        enabled: bool
   667        if 〈0;enabled〉 {
   668          foo: string
   669        }
   670      }
   671    }
   672    foo: {
   673      #Values: {
   674        global: 〈2;global_config〉.#GlobalConfig
   675      }
   676    }
   677    #Config: {
   678      tenant: {
   679        id: string
   680      }
   681      auth0: (〈1;common〉.#SomeConfig & {
   682        enabled: bool
   683        if 〈0;enabled〉 {
   684          foo: "\(〈2;tenant〉.id)-value"
   685        }
   686      })
   687      charts: {
   688        foo: (〈2;foo〉.#Values & {
   689          global: 〈3〉.global
   690        })
   691      }
   692      global: (〈1;global_config〉.#GlobalConfig & {
   693        auth0: {
   694          enabled: 〈3〉.auth0.enabled
   695        }
   696      })
   697    }
   698    #NetworkPolicy: 〈0;networkingv1〉.#NetworkPolicy
   699    #Flux: {
   700      〈1;#Config〉
   701      charts: _
   702      formatOutput: {
   703        ...
   704      }
   705      _outputs: {
   706        ...
   707      }
   708      for _chartName, _chartValues in 〈0;charts〉 {
   709        _outputs: {
   710          "\(〈2;_chartName〉)": {}
   711        }
   712      }
   713      _outputs: {
   714        for _, ns in [
   715          "ns",
   716        ] {
   717          "\(〈1;ns〉)/network": (〈4;#NetworkPolicy〉 & {
   718            spec: {
   719              ingress: [
   720                {
   721                  from: [
   722                    {
   723                      namespaceSelector: {
   724                        matchLabels: {
   725                          tenant: 〈12〉.tenant.id
   726                        }
   727                      }
   728                    },
   729                  ]
   730                },
   731              ]
   732              egress: [
   733                {
   734                  to: [
   735                    {
   736                      namespaceSelector: {
   737                        matchLabels: {
   738                          tenant: 〈12〉.tenant.id
   739                        }
   740                      }
   741                    },
   742                  ]
   743                },
   744              ]
   745            }
   746          })
   747        }
   748      }
   749      for _, ns in [
   750        "ns",
   751      ] {
   752        for k, v in 〈2;_outputs〉 {
   753          formatOutput: {
   754            "\(〈2;k〉)": 〈2;v〉
   755          }
   756        }
   757      }
   758    }
   759  }