kcl-lang / kcl

KCL Programming Language (CNCF Sandbox Project). https://kcl-lang.io
https://kcl-lang.io
Apache License 2.0
1.41k stars 110 forks source link

Conditional checks on imported resources #1420

Closed dennybaa closed 1 week ago

dennybaa commented 2 weeks ago

Hello, there. There's a bug when importing CRDS with conditional values.

Should be actually as bellow or similar, but at the moment there's no condition to check that value is defined..

schema NetworkingIstioIoV1VirtualServiceSpecHTTPItems0:
    mirrorPercent?: int
    mirror_percent?: int
    check:
        mirrorPercent <= 4.294967295e+09 if mirrorPercent is not Undefined
        mirrorPercent >= 0 if mirrorPercent is not Undefined
        mirror_percent <= 4.294967295e+09 if mirror_percent is not Undefined
        mirror_percent >= 0 if mirror_percent is not Undefined

0.9.1beta1

Peefy commented 1 week ago

fixed in