...

Text file src/cuelang.org/go/cue/testdata/comprehensions/issue1732.txtar

Documentation: cuelang.org/go/cue/testdata/comprehensions

     1-- in.cue --
     2package config
     3
     4networkingv1: {
     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
    33global_config: {
    34	#GlobalConfig: {
    35		auth0: {
    36			enabled: bool
    37		}
    38	}
    39}
    40common: {
    41	#SomeConfig: {
    42		enabled: bool
    43		if enabled {
    44			foo: string
    45		}
    46	}
    47}
    48
    49foo: {
    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 --
   125Leaks:  3
   126Freed:  118
   127Reused: 103
   128Allocs: 18
   129Retain: 10
   130
   131Unifications: 111
   132Conjuncts:    249
   133Disjuncts:    126
   134-- out/eval --
   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:41: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:41:12
   211            }
   212          }
   213        }
   214      }
   215    }
   216    global: (#struct){
   217      auth0: (#struct){
   218        enabled: (_|_){
   219          // [incomplete] #Config.auth0: incomplete bool: bool:
   220          //     ./in.cue:41: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    tenant: (#struct){
   235      id: (string){ string }
   236    }
   237    auth0: (_|_){
   238      // [incomplete] #Flux.auth0: incomplete bool: bool:
   239      //     ./in.cue:41:12
   240      enabled: (bool){ bool }
   241    }
   242    charts: (#struct){
   243      foo: (#struct){
   244        global: (#struct){
   245          auth0: (#struct){
   246            enabled: (_|_){
   247              // [incomplete] #Flux.auth0: incomplete bool: bool:
   248              //     ./in.cue:41:12
   249            }
   250          }
   251        }
   252      }
   253    }
   254    global: (#struct){
   255      auth0: (#struct){
   256        enabled: (_|_){
   257          // [incomplete] #Flux.auth0: incomplete bool: bool:
   258          //     ./in.cue:41:12
   259        }
   260      }
   261    }
   262    formatOutput: (#struct){
   263      foo: (#struct){
   264      }
   265      "ns/network": (#struct){
   266        spec: (#struct){
   267          ingress: (#list){
   268            0: (#struct){
   269              from: (#list){
   270                0: (#struct){
   271                  namespaceSelector: (#struct){
   272                    matchLabels: (#struct){
   273                      tenant: (string){ string }
   274                    }
   275                  }
   276                }
   277              }
   278            }
   279          }
   280          egress: (#list){
   281            0: (#struct){
   282              to: (#list){
   283                0: (#struct){
   284                  namespaceSelector: (#struct){
   285                    matchLabels: (#struct){
   286                      tenant: (string){ string }
   287                    }
   288                  }
   289                }
   290              }
   291            }
   292          }
   293        }
   294      }
   295    }
   296    _outputs(:config): (#struct){
   297      foo: (#struct){
   298      }
   299      "ns/network": (#struct){
   300        spec: (#struct){
   301          ingress: (#list){
   302            0: (#struct){
   303              from: (#list){
   304                0: (#struct){
   305                  namespaceSelector: (#struct){
   306                    matchLabels: (#struct){
   307                      tenant: (string){ string }
   308                    }
   309                  }
   310                }
   311              }
   312            }
   313          }
   314          egress: (#list){
   315            0: (#struct){
   316              to: (#list){
   317                0: (#struct){
   318                  namespaceSelector: (#struct){
   319                    matchLabels: (#struct){
   320                      tenant: (string){ string }
   321                    }
   322                  }
   323                }
   324              }
   325            }
   326          }
   327        }
   328      }
   329    }
   330  }
   331}
   332-- out/compile --
   333--- in.cue
   334{
   335  networkingv1: {
   336    metav1: {
   337      #LabelSelector: {
   338        matchLabels: {
   339          [string]: string
   340        }
   341      }
   342    }
   343    #NetworkPolicy: {
   344      spec: 〈1;#NetworkPolicySpec〉
   345    }
   346    #NetworkPolicySpec: {
   347      ingress: [
   348        ...〈2;#NetworkPolicyIngressRule〉,
   349      ]
   350      egress: [
   351        ...〈2;#NetworkPolicyEgressRule〉,
   352      ]
   353    }
   354    #NetworkPolicyIngressRule: {
   355      from: [
   356        ...〈2;#NetworkPolicyPeer〉,
   357      ]
   358    }
   359    #NetworkPolicyEgressRule: {
   360      to: [
   361        ...〈2;#NetworkPolicyPeer〉,
   362      ]
   363    }
   364    #NetworkPolicyPeer: {
   365      namespaceSelector: (null|〈1;metav1〉.#LabelSelector)
   366    }
   367  }
   368  global_config: {
   369    #GlobalConfig: {
   370      auth0: {
   371        enabled: bool
   372      }
   373    }
   374  }
   375  common: {
   376    #SomeConfig: {
   377      enabled: bool
   378      if 〈0;enabled〉 {
   379        foo: string
   380      }
   381    }
   382  }
   383  foo: {
   384    #Values: {
   385      global: 〈2;global_config〉.#GlobalConfig
   386    }
   387  }
   388  #Config: {
   389    tenant: {
   390      id: string
   391    }
   392    auth0: (〈1;common〉.#SomeConfig & {
   393      enabled: bool
   394      if 〈0;enabled〉 {
   395        foo: "\(〈2;tenant〉.id)-value"
   396      }
   397    })
   398    charts: {
   399      foo: (〈2;foo〉.#Values & {
   400        global: 〈3〉.global
   401      })
   402    }
   403    global: (〈1;global_config〉.#GlobalConfig & {
   404      auth0: {
   405        enabled: 〈3〉.auth0.enabled
   406      }
   407    })
   408  }
   409  #NetworkPolicy: 〈0;networkingv1〉.#NetworkPolicy
   410  #Flux: {
   411    〈1;#Config〉
   412    charts: _
   413    formatOutput: {
   414      ...
   415    }
   416    _outputs: {
   417      ...
   418    }
   419    for _chartName, _chartValues in 〈0;charts〉 {
   420      _outputs: {
   421        "\(〈2;_chartName〉)": {}
   422      }
   423    }
   424    _outputs: {
   425      for _, ns in [
   426        "ns",
   427      ] {
   428        "\(〈1;ns〉)/network": (〈4;#NetworkPolicy〉 & {
   429          spec: {
   430            ingress: [
   431              {
   432                from: [
   433                  {
   434                    namespaceSelector: {
   435                      matchLabels: {
   436                        tenant: 〈12〉.tenant.id
   437                      }
   438                    }
   439                  },
   440                ]
   441              },
   442            ]
   443            egress: [
   444              {
   445                to: [
   446                  {
   447                    namespaceSelector: {
   448                      matchLabels: {
   449                        tenant: 〈12〉.tenant.id
   450                      }
   451                    }
   452                  },
   453                ]
   454              },
   455            ]
   456          }
   457        })
   458      }
   459    }
   460    for _, ns in [
   461      "ns",
   462    ] {
   463      for k, v in 〈2;_outputs〉 {
   464        formatOutput: {
   465          "\(〈2;k〉)": 〈2;v〉
   466        }
   467      }
   468    }
   469  }
   470}

View as plain text