()
| 195 | } |
| 196 | |
| 197 | func (*networkLib) CompileOptions() []cel.EnvOption { |
| 198 | return []cel.EnvOption{ |
| 199 | // 1. Register Types |
| 200 | cel.Types( |
| 201 | IPType, |
| 202 | CIDRType, |
| 203 | ), |
| 204 | |
| 205 | // 2. Register Functions |
| 206 | cel.Function(cidrFunc, |
| 207 | // K8s Parity: Following the pattern, this is "string_to_cidr" |
| 208 | cel.Overload("string_to_cidr", []*cel.Type{cel.StringType}, CIDRType, |
| 209 | cel.UnaryBinding(netCIDRString)), |
| 210 | ), |
| 211 | cel.Function(cidrToString, |
| 212 | cel.Overload("cidr_to_string", []*cel.Type{CIDRType}, cel.StringType, |
| 213 | cel.UnaryBinding(netCIDRToString)), |
| 214 | ), |
| 215 | cel.Function(containsCIDRFunc, |
| 216 | cel.MemberOverload("cidr_contains_cidr", []*cel.Type{CIDRType, CIDRType}, cel.BoolType, |
| 217 | cel.BinaryBinding(netCIDRContainsCIDR)), |
| 218 | cel.MemberOverload("cidr_contains_cidr_string", []*cel.Type{CIDRType, cel.StringType}, cel.BoolType, |
| 219 | cel.BinaryBinding(netCIDRContainsCIDRString)), |
| 220 | ), |
| 221 | cel.Function(containsIPFunc, |
| 222 | cel.MemberOverload("cidr_contains_ip_ip", []*cel.Type{CIDRType, IPType}, cel.BoolType, |
| 223 | cel.BinaryBinding(netCIDRContainsIP)), |
| 224 | cel.MemberOverload("cidr_contains_ip_string", []*cel.Type{CIDRType, cel.StringType}, cel.BoolType, |
| 225 | cel.BinaryBinding(netCIDRContainsIPString)), |
| 226 | ), |
| 227 | cel.Function(familyFunc, |
| 228 | cel.MemberOverload("ip_family", []*cel.Type{IPType}, cel.IntType, |
| 229 | cel.UnaryBinding(netIPFamily)), |
| 230 | ), |
| 231 | cel.Function(ipFunc, |
| 232 | // K8s Parity: The global overload is named "string_to_ip" |
| 233 | cel.Overload("string_to_ip", []*cel.Type{cel.StringType}, IPType, |
| 234 | cel.UnaryBinding(netIPString)), |
| 235 | // K8s Parity: The member overload is named "cidr_ip" |
| 236 | cel.MemberOverload("cidr_ip", []*cel.Type{CIDRType}, IPType, |
| 237 | cel.UnaryBinding(netCIDRIP)), |
| 238 | ), |
| 239 | cel.Function(ipToString, |
| 240 | cel.Overload("ip_to_string", []*cel.Type{IPType}, cel.StringType, |
| 241 | cel.UnaryBinding(netIPToString)), |
| 242 | ), |
| 243 | cel.Function(isCanonicalFunc, |
| 244 | cel.Overload("ip_is_canonical", []*cel.Type{cel.StringType}, cel.BoolType, |
| 245 | cel.UnaryBinding(netIPIsCanonical)), |
| 246 | ), |
| 247 | cel.Function(isCIDRFunc, |
| 248 | cel.Overload("is_cidr", []*cel.Type{cel.StringType}, cel.BoolType, |
| 249 | cel.UnaryBinding(netIsCIDR)), |
| 250 | ), |
| 251 | cel.Function(isGlobalUnicastFunc, |
| 252 | cel.MemberOverload("ip_is_global_unicast", []*cel.Type{IPType}, cel.BoolType, |
| 253 | cel.UnaryBinding(netIPIsGlobalUnicast)), |
| 254 | ), |
nothing calls this directly
no test coverage detected