-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Bug Report
When a property name in CustomerResourceDefinition ends with Protocol it conflicts with allowed name pattern of KCL.
As Protocol is a reserved keyword it fails to compile.
I have seen this problem with the traefik CRDs. I am aware there is an predefined module, but it looks like it just ignored the references and it has been just removed as workaround.
1. Minimal reproduce step (Required)
- fetch https://raw.githubusercontent.com/traefik/traefik/refs/heads/master/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml
- kcl import -m crd kubernetes-crd-definition-v1.yml
- kcl run models/v1alpha1/
Problematic code:
schema TraefikIoV1alpha1ServersTransportTCPSpec:
r"""
ServersTransportTCPSpec defines the desired state of a ServersTransportTCP.
Attributes
----------
dialKeepAlive : int | str, default is Undefined, optional
DialKeepAlive is the interval between keep-alive probes for an active network connection. If zero, keep-alive probes are sent with a default value (currently 15 seconds), if supported by the protocol and operating system. Network protocols or operating systems that do not support keep-alives ignore this field. If negative, keep-alive probes are disabled.
dialTimeout : int | str, default is Undefined, optional
DialTimeout is the amount of time to wait until a connection to a backend server can be established.
proxyProtocol : TraefikIoV1alpha1ServersTransportTCPSpecProxyProtocol, default is Undefined, optional
proxy protocol
terminationDelay : int | str, default is Undefined, optional
TerminationDelay defines the delay to wait before fully terminating the connection, after one connected peer has closed its writing capability.
tls : TraefikIoV1alpha1ServersTransportTCPSpecTLS, default is Undefined, optional
tls
"""
dialKeepAlive?: int | str
dialTimeout?: int | str
proxyProtocol?: TraefikIoV1alpha1ServersTransportTCPSpecProxyProtocol
terminationDelay?: int | str
tls?: TraefikIoV1alpha1ServersTransportTCPSpecTLS
check:
_regex_match(str(dialKeepAlive), r"^([0-9]+(ns|us|µs|ms|s|m|h)?)+$") if dialKeepAlive
_regex_match(str(dialTimeout), r"^([0-9]+(ns|us|µs|ms|s|m|h)?)+$") if dialTimeout
_regex_match(str(terminationDelay), r"^([0-9]+(ns|us|µs|ms|s|m|h)?)+$") if terminationDelay
schema TraefikIoV1alpha1ServersTransportTCPSpecProxyProtocol:
r"""
ProxyProtocol holds the PROXY Protocol configuration.
Attributes
----------
version : int, default is Undefined, optional
Version defines the PROXY Protocol version to use.
"""
version?: int
check:
version <= 2 if version not in [None, Undefined]
version >= 1 if version not in [None, Undefined]
2. What did you expect to see? (Required)
valid code that can be imported
3. What did you see instead (Required)
error[E2L23]: CompileError
--> /home/richard/data/code/git/github.com/flowers-software/f8s/tmp/models/v1alpha1/traefik_io_v1alpha1_ingress_route_tcp.k:183:8
|
183 | schema TraefikIoV1alpha1IngressRouteTCPSpecRoutesItems0ServicesItems0ProxyProtocol:
| ^ a protocol is only allowed to define attributes in it
|
error[E2L23]: CompileError
--> /home/richard/data/code/git/github.com/flowers-software/f8s/tmp/models/v1alpha1/traefik_io_v1alpha1_servers_transport_tcp.k:75:8
|
75 | schema TraefikIoV1alpha1ServersTransportTCPSpecProxyProtocol:
| ^ a protocol is only allowed to define attributes in it
|
4. What is your KCL components version? (Required)
kcl version 0.11.4
Metadata
Metadata
Assignees
Labels
No labels