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