Skip to content

Commit 5f16203

Browse files
capri-xiyuerobscott
authored andcommitted
fixed linter
1 parent 389aa61 commit 5f16203

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

api/v1/inferencepool_types.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type InferencePool struct {
4343
// Status defines the observed state of the InferencePool.
4444
//
4545
// +optional
46-
Status InferencePoolStatus `json:"status,omitempty"`
46+
Status *InferencePoolStatus `json:"status,omitempty"`
4747
}
4848

4949
// InferencePoolList contains a list of InferencePools.
@@ -75,7 +75,7 @@ type InferencePoolSpec struct {
7575
// +kubebuilder:validation:MaxItems=1
7676
// +listType=atomic
7777
// +required
78-
TargetPorts []Port `json:"targetPorts,omitzero"`
78+
TargetPorts []Port `json:"targetPorts,omitempty"`
7979

8080
// EndpointPickerRef is a reference to the Endpoint Picker extension and its
8181
// associated configuration.
@@ -90,7 +90,7 @@ type Port struct {
9090
// The number must be in the range 1 to 65535.
9191
//
9292
// +required
93-
Number PortNumber `json:"number,omitzero"`
93+
Number PortNumber `json:"number,omitempty"`
9494
}
9595

9696
// EndpointPickerRef specifies a reference to an Endpoint Picker extension and its
@@ -117,25 +117,28 @@ type EndpointPickerRef struct {
117117
//
118118
// +optional
119119
// +kubebuilder:default=Service
120+
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
120121
Kind *Kind `json:"kind,omitempty"`
121122

122123
// Name is the name of the referent API object.
123124
//
124125
// +required
125-
Name ObjectName `json:"name,omitzero"`
126+
Name ObjectName `json:"name,omitempty"`
126127

127128
// PortNumber is the port number of the Endpoint Picker extension service. When unspecified,
128129
// implementations SHOULD infer a default value of 9002 when the kind field is "Service" or
129130
// unspecified (defaults to "Service").
130131
//
131132
// +optional
133+
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
132134
PortNumber *PortNumber `json:"portNumber,omitempty"`
133135

134136
// FailureMode configures how the parent handles the case when the Endpoint Picker extension
135137
// is non-responsive. When unspecified, defaults to "FailClose".
136138
//
137139
// +optional
138140
// +kubebuilder:default="FailClose"
141+
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
139142
FailureMode *EndpointPickerFailureMode `json:"failureMode,omitempty"`
140143
}
141144

@@ -186,8 +189,6 @@ type ParentStatus struct {
186189
// +optional
187190
// +listType=map
188191
// +listMapKey=type
189-
// +patchStrategy=merge
190-
// +patchMergeKey=type
191192
// +kubebuilder:validation:MaxItems=8
192193
Conditions []metav1.Condition `json:"conditions,omitempty"`
193194

@@ -284,12 +285,13 @@ type ParentReference struct {
284285
//
285286
// +optional
286287
// +kubebuilder:default=Gateway
288+
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
287289
Kind *Kind `json:"kind,omitempty"`
288290

289291
// Name is the name of the referent API object.
290292
//
291293
// +required
292-
Name ObjectName `json:"name,omitzero"`
294+
Name ObjectName `json:"name,omitempty"`
293295

294296
// Namespace is the namespace of the referenced object. When unspecified, the local
295297
// namespace is inferred.
@@ -300,5 +302,6 @@ type ParentReference struct {
300302
// documentation for details: https://gateway-api.sigs.k8s.io/api-types/referencegrant/
301303
//
302304
// +optional
305+
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
303306
Namespace *Namespace `json:"namespace,omitempty"`
304307
}

api/v1/shared_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,5 @@ type LabelSelector struct {
139139
// +required
140140
// +kubebuilder:validation:MinItems=1
141141
// +kubebuilder:validation:MaxItems=64
142-
MatchLabels map[LabelKey]LabelValue `json:"matchLabels,omitzero"`
142+
MatchLabels map[LabelKey]LabelValue `json:"matchLabels,omitempty"`
143143
}

api/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apix/v1alpha2/inferencepool_conversion.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (src *InferencePool) ConvertTo(dst *v1.InferencePool) error {
4747
dst.ObjectMeta = src.ObjectMeta
4848
dst.Spec.TargetPorts = []v1.Port{{Number: v1.PortNumber(src.Spec.TargetPortNumber)}}
4949
dst.Spec.EndpointPickerRef = endpointPickRef
50-
dst.Status = *v1Status
50+
dst.Status = v1Status
5151

5252
if src.Spec.Selector != nil {
5353
dst.Spec.Selector.MatchLabels = make(map[v1.LabelKey]v1.LabelValue, len(src.Spec.Selector))
@@ -67,7 +67,7 @@ func (dst *InferencePool) ConvertFrom(src *v1.InferencePool) error {
6767
if err != nil {
6868
return err
6969
}
70-
status, err := convertStatusFromV1(&src.Status)
70+
status, err := convertStatusFromV1(src.Status)
7171
if err != nil {
7272
return err
7373
}
@@ -95,6 +95,9 @@ func convertStatusToV1(src *InferencePoolStatus) (*v1.InferencePoolStatus, error
9595
if src == nil {
9696
return nil, errors.New("src cannot be nil")
9797
}
98+
if src.Parents == nil {
99+
return &v1.InferencePoolStatus{}, nil
100+
}
98101
out := &v1.InferencePoolStatus{
99102
Parents: make([]v1.ParentStatus, 0, len(src.Parents)),
100103
}
@@ -121,6 +124,9 @@ func convertStatusFromV1(src *v1.InferencePoolStatus) (*InferencePoolStatus, err
121124
if src == nil {
122125
return nil, errors.New("src cannot be nil")
123126
}
127+
if src.Parents == nil {
128+
return &InferencePoolStatus{}, nil
129+
}
124130
out := &InferencePoolStatus{
125131
Parents: make([]PoolStatus, 0, len(src.Parents)),
126132
}

apix/v1alpha2/inferencepool_conversion_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestInferencePoolConvertTo(t *testing.T) {
108108
FailureMode: &v1FailureMode,
109109
},
110110
},
111-
Status: v1.InferencePoolStatus{
111+
Status: &v1.InferencePoolStatus{
112112
Parents: []v1.ParentStatus{
113113
{
114114
ParentRef: v1.ParentReference{Name: "my-gateway"},
@@ -176,7 +176,7 @@ func TestInferencePoolConvertTo(t *testing.T) {
176176
},
177177
TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8080))}},
178178
},
179-
Status: v1.InferencePoolStatus{
179+
Status: &v1.InferencePoolStatus{
180180
Parents: []v1.ParentStatus{
181181
{
182182
ParentRef: v1.ParentReference{Name: "my-gateway"},
@@ -243,7 +243,7 @@ func TestInferencePoolConvertFrom(t *testing.T) {
243243
FailureMode: &v1FailureMode,
244244
},
245245
},
246-
Status: v1.InferencePoolStatus{
246+
Status: &v1.InferencePoolStatus{
247247
Parents: []v1.ParentStatus{
248248
{
249249
ParentRef: v1.ParentReference{Name: "my-gateway"},
@@ -318,7 +318,7 @@ func TestInferencePoolConvertFrom(t *testing.T) {
318318
},
319319
TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8080))}},
320320
},
321-
Status: v1.InferencePoolStatus{
321+
Status: &v1.InferencePoolStatus{
322322
Parents: []v1.ParentStatus{
323323
{
324324
ParentRef: v1.ParentReference{Name: "my-gateway"},

0 commit comments

Comments
 (0)