Skip to content

Commit b80f946

Browse files
authored
fix: default value with k8s x-order extension (#123)
fix: default value with k8s x-order extention Signed-off-by: Peefy <[email protected]>
1 parent 75ebea0 commit b80f946

File tree

7 files changed

+6384
-4
lines changed

7 files changed

+6384
-4
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ build-local-linux:
2828
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
2929
go build -o ./_build/linux/kcl-openapi \
3030
-ldflags="-s -w" .
31+
3132
build:
3233
-rm -rf ./_build/local/
3334
mkdir -p ./_build/local/

pkg/kube_resource/generator/testdata/default_value/crd.golden.yaml

Lines changed: 5923 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
"""
2+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
3+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
4+
"""
5+
import regex
6+
import k8s.apimachinery.pkg.apis.meta.v1
7+
_regex_match = regex.match
8+
9+
10+
schema GatewayClass:
11+
r"""
12+
GatewayClass describes a class of Gateways available to the user for creating Gateway resources.
13+
It is recommended that this resource be used as a template for Gateways. This means that a Gateway is based on the state of the GatewayClass at the time it was created and changes to the GatewayClass or associated parameters are not propagated down to existing Gateways. This recommendation is intended to limit the blast radius of changes to GatewayClass or associated parameters. If implementations choose to propagate GatewayClass changes to existing Gateways, that MUST be clearly documented by the implementation.
14+
Whenever one or more Gateways are using a GatewayClass, implementations SHOULD add the `gateway-exists-finalizer.gateway.networking.k8s.io` finalizer on the associated GatewayClass. This ensures that a GatewayClass associated with a Gateway is not deleted while in use.
15+
GatewayClass is a Cluster level resource.
16+
17+
Attributes
18+
----------
19+
apiVersion : str, default is "gateway.networking.k8s.io/v1alpha2", required
20+
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
21+
kind : str, default is "GatewayClass", required
22+
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
23+
metadata : v1.ObjectMeta, default is Undefined, optional
24+
metadata
25+
spec : GatewayNetworkingK8sIoV1alpha2GatewayClassSpec, default is Undefined, required
26+
spec
27+
status : GatewayNetworkingK8sIoV1alpha2GatewayClassStatus, default is Undefined, optional
28+
status
29+
"""
30+
31+
32+
apiVersion: "gateway.networking.k8s.io/v1alpha2" = "gateway.networking.k8s.io/v1alpha2"
33+
34+
kind: "GatewayClass" = "GatewayClass"
35+
36+
metadata?: v1.ObjectMeta
37+
38+
spec: GatewayNetworkingK8sIoV1alpha2GatewayClassSpec
39+
40+
status?: GatewayNetworkingK8sIoV1alpha2GatewayClassStatus
41+
42+
43+
schema GatewayNetworkingK8sIoV1alpha2GatewayClassSpec:
44+
r"""
45+
Spec defines the desired state of GatewayClass.
46+
47+
Attributes
48+
----------
49+
controllerName : str, default is Undefined, required
50+
ControllerName is the name of the controller that is managing Gateways of this class. The value of this field MUST be a domain prefixed path.
51+
Example: "example.net/gateway-controller".
52+
This field is not mutable and cannot be empty.
53+
Support: Core
54+
description : str, default is Undefined, optional
55+
Description helps describe a GatewayClass with more details.
56+
parametersRef : GatewayNetworkingK8sIoV1alpha2GatewayClassSpecParametersRef, default is Undefined, optional
57+
parameters ref
58+
"""
59+
60+
61+
controllerName: str
62+
63+
description?: str
64+
65+
parametersRef?: GatewayNetworkingK8sIoV1alpha2GatewayClassSpecParametersRef
66+
67+
68+
check:
69+
len(controllerName) <= 253
70+
len(controllerName) >= 1
71+
_regex_match(str(controllerName), r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$")
72+
len(description) <= 64 if description
73+
74+
75+
schema GatewayNetworkingK8sIoV1alpha2GatewayClassSpecParametersRef:
76+
r"""
77+
ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration.
78+
ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped.
79+
If the referent cannot be found, the GatewayClass's "InvalidParameters" status condition will be true.
80+
Support: Implementation-specific
81+
82+
Attributes
83+
----------
84+
group : str, default is Undefined, required
85+
Group is the group of the referent.
86+
kind : str, default is Undefined, required
87+
Kind is kind of the referent.
88+
name : str, default is Undefined, required
89+
Name is the name of the referent.
90+
namespace : str, default is Undefined, optional
91+
Namespace is the namespace of the referent. This field is required when referring to a Namespace-scoped resource and MUST be unset when referring to a Cluster-scoped resource.
92+
"""
93+
94+
95+
group: str
96+
97+
kind: str
98+
99+
name: str
100+
101+
namespace?: str
102+
103+
104+
check:
105+
len(group) <= 253
106+
_regex_match(str(group), r"^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$")
107+
len(kind) <= 63
108+
len(kind) >= 1
109+
_regex_match(str(kind), r"^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$")
110+
len(name) <= 253
111+
len(name) >= 1
112+
len(namespace) <= 63 if namespace
113+
len(namespace) >= 1 if namespace
114+
_regex_match(str(namespace), r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") if namespace
115+
116+
117+
schema GatewayNetworkingK8sIoV1alpha2GatewayClassStatus:
118+
r"""
119+
Status defines the current state of GatewayClass.
120+
121+
Attributes
122+
----------
123+
conditions : [GatewayNetworkingK8sIoV1alpha2GatewayClassStatusConditionsItems0], default is [{"lastTransitionTime": "1970-01-01T00:00:00Z", "message": "Waiting for controller", "reason": "Pending", "status": "Unknown", "type": "Accepted"}], optional
124+
Conditions is the current status from the controller for this GatewayClass.
125+
Controllers should prefer to publish conditions using values of GatewayClassConditionType for the type of each Condition.
126+
"""
127+
128+
129+
conditions?: [GatewayNetworkingK8sIoV1alpha2GatewayClassStatusConditionsItems0] = [{"lastTransitionTime": "1970-01-01T00:00:00Z", "message": "Waiting for controller", "reason": "Pending", "status": "Unknown", "type": "Accepted"}]
130+
131+
132+
check:
133+
len(conditions) <= 8 if conditions
134+
135+
136+
schema GatewayNetworkingK8sIoV1alpha2GatewayClassStatusConditionsItems0:
137+
r"""
138+
Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example,
139+
type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: "Available", "Progressing", and "Degraded" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
140+
// other fields }
141+
142+
Attributes
143+
----------
144+
lastTransitionTime : str, default is Undefined, required
145+
lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
146+
message : str, default is Undefined, required
147+
message is a human readable message indicating details about the transition. This may be an empty string.
148+
observedGeneration : int, default is Undefined, optional
149+
observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
150+
reason : str, default is Undefined, required
151+
reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
152+
status : str, default is Undefined, required
153+
status of the condition, one of True, False, Unknown.
154+
$type : str, default is Undefined, required
155+
type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
156+
"""
157+
158+
159+
lastTransitionTime: str
160+
161+
message: str
162+
163+
observedGeneration?: int
164+
165+
reason: str
166+
167+
status: "True" | "False" | "Unknown"
168+
169+
$type: str
170+
171+
172+
check:
173+
len(message) <= 32768
174+
observedGeneration >= 0 if observedGeneration not in [None, Undefined]
175+
len(reason) <= 1024
176+
len(reason) >= 1
177+
_regex_match(str(reason), r"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$")
178+
len($type) <= 316
179+
_regex_match(str($type), r"^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$")
180+
181+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
This is the managed_fields_entry module in k8s.apimachinery.pkg.apis.meta.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema ManagedFieldsEntry:
9+
r"""
10+
ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.
11+
12+
Attributes
13+
----------
14+
apiVersion : str, default is Undefined, optional
15+
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.
16+
fieldsType : str, default is Undefined, optional
17+
FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1"
18+
fieldsV1 : any, default is Undefined, optional
19+
FieldsV1 holds the first JSON version format as described in the "FieldsV1" type.
20+
manager : str, default is Undefined, optional
21+
Manager is an identifier of the workflow managing these fields.
22+
operation : str, default is Undefined, optional
23+
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.
24+
time : str, default is Undefined, optional
25+
Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply'
26+
"""
27+
28+
29+
apiVersion?: str
30+
31+
fieldsType?: str
32+
33+
fieldsV1?: any
34+
35+
manager?: str
36+
37+
operation?: str
38+
39+
time?: str
40+
41+

0 commit comments

Comments
 (0)