Skip to content

Commit 182f4ee

Browse files
committed
merge conflicts
2 parents 4ccccfe + bc242de commit 182f4ee

File tree

15 files changed

+166
-124
lines changed

15 files changed

+166
-124
lines changed

.custom-gcl.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: v2.3.1
2+
name: golangci-kube-api-linter
3+
destination: ./bin
4+
plugins:
5+
- module: 'sigs.k8s.io/kube-api-linter'
6+
version: 'v0.0.0-20250808120943-48643eb2563d' # Pin to a commit while there's no tag

.github/workflows/kal.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PR golangci-lint
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
# Remove all permissions from GITHUB_TOKEN except metadata.
8+
permissions: {}
9+
10+
jobs:
11+
golangci:
12+
name: kube-api-lint
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
18+
name: Checkout code
19+
with:
20+
persist-credentials: false
21+
- name: Set up Go
22+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # tag=v5.5.0
23+
- name: Install Golang CI Lint
24+
run: go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
25+
- name: Build KAL
26+
run: golangci-lint custom
27+
- name: run api linter
28+
run: ./bin/golangci-kube-api-linter run -c ./.golangci-kal.yml ./...

.golangci-kal.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- kubeapilinter
6+
settings:
7+
custom:
8+
kubeapilinter:
9+
type: module
10+
description: Kube API LInter lints Kube like APIs based on API conventions and best practices.
11+
settings:
12+
linters:
13+
enable:
14+
- "*"
15+
disable:
16+
- "commentstart"
17+
lintersConfig:
18+
conflictingmarkers:
19+
conflicts:
20+
- name: "default_vs_required"
21+
sets:
22+
- ["default", "kubebuilder:default"]
23+
- ["required", "kubebuilder:validation:Required", "k8s:required"]
24+
description: "A field with a default value cannot be required"
25+
conditions:
26+
isFirstField: Warn # Require conditions to be the first field in the status struct.
27+
usePatchStrategy: Forbid # Forbid patchStrategy markers on the Conditions field.
28+
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
29+
optionalfields:
30+
pointers:
31+
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
32+
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
33+
omitempty:
34+
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
35+
exclusions:
36+
generated: strict
37+
paths:
38+
- conformance/
39+
paths-except:
40+
- api/
41+
issues:
42+
max-issues-per-linter: 0
43+
max-same-issues: 0
44+
run:
45+
timeout: 5m
46+
tests: false

api/v1/inferencepool_types.go

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ import (
2929
// +kubebuilder:storageversion
3030
// +genclient
3131
type InferencePool struct {
32-
metav1.TypeMeta `json:",inline"`
32+
metav1.TypeMeta `json:",inline"`
33+
34+
// +optional
3335
metav1.ObjectMeta `json:"metadata,omitempty"`
3436

35-
Spec InferencePoolSpec `json:"spec,omitempty"`
37+
// +required
38+
Spec InferencePoolSpec `json:"spec,omitzero"`
3639

3740
// Status defines the observed state of InferencePool.
3841
//
3942
// +kubebuilder:default={parent: {{parentRef: {kind: "Status", name: "default"}, conditions: {{type: "Accepted", status: "Unknown", reason: "Pending", message: "Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}}}
40-
Status InferencePoolStatus `json:"status,omitempty"`
43+
// +optional
44+
Status InferencePoolStatus `json:"status,omitzero"`
4145
}
4246

4347
// InferencePoolList contains a list of InferencePool.
@@ -59,30 +63,20 @@ type InferencePoolSpec struct {
5963
// with Kubernetes Service selectors, as some implementations may translate
6064
// this configuration into a Service resource.
6165
//
62-
// +kubebuilder:validation:Required
63-
Selector LabelSelector `json:"selector"`
64-
65-
// TargetPorts defines the ports to access the selected model server Pods.
66-
//
67-
// +kubebuilder:validation:Required
68-
// +kubebuilder:validation:MinItems=1
69-
// +kubebuilder:validation:MaxItems=1
70-
// +listType=map
71-
// +listMapKey=number
72-
TargetPorts []Port `json:"targetPorts"`
73-
74-
// Extension configures an endpoint picker as an extension service.
75-
ExtensionRef *Extension `json:"extensionRef,omitempty"`
76-
}
66+
// +required
67+
Selector LabelSelector `json:"selector,omitempty,omitzero"`
7768

78-
type Port struct {
79-
// Number defines the port number to access the selected model server Pods.
69+
// TargetPortNumber defines the port number to access the selected model server Pods.
8070
// The number must be in the range 1 to 65535.
8171
//
8272
// +kubebuilder:validation:Minimum=1
8373
// +kubebuilder:validation:Maximum=65535
84-
// +kubebuilder:validation:Required
85-
Number PortNumber `json:"number"`
74+
// +required
75+
TargetPortNumber int32 `json:"targetPortNumber,omitempty"`
76+
77+
// Extension configures an endpoint picker as an extension service.
78+
// +optional
79+
ExtensionRef Extension `json:"extensionRef,omitempty,omitzero"`
8680
}
8781

8882
// Extension specifies how to configure an extension that runs the endpoint picker.
@@ -106,26 +100,26 @@ type Extension struct {
106100
//
107101
// +optional
108102
// +kubebuilder:default=Service
109-
Kind *Kind `json:"kind,omitempty"`
103+
Kind Kind `json:"kind,omitempty"`
110104

111105
// Name is the name of the referent.
112106
//
113-
// +kubebuilder:validation:Required
114-
Name ObjectName `json:"name"`
107+
// +required
108+
Name ObjectName `json:"name,omitempty"`
115109

116110
// The port number on the service running the extension. When unspecified,
117111
// implementations SHOULD infer a default value of 9002 when the Kind is
118112
// Service.
119113
//
120114
// +optional
121-
PortNumber *PortNumber `json:"portNumber,omitempty"`
115+
PortNumber PortNumber `json:"portNumber,omitempty"`
122116

123117
// Configures how the gateway handles the case when the extension is not responsive.
124118
// Defaults to failClose.
125119
//
126120
// +optional
127121
// +kubebuilder:default="FailClose"
128-
FailureMode *ExtensionFailureMode `json:"failureMode"`
122+
FailureMode ExtensionFailureMode `json:"failureMode,omitempty"`
129123
}
130124

131125
// ExtensionFailureMode defines the options for how the gateway handles the case when the extension is not
@@ -141,6 +135,7 @@ const (
141135
)
142136

143137
// InferencePoolStatus defines the observed state of InferencePool.
138+
// +kubebuilder:validation:MinProperties=1
144139
type InferencePoolStatus struct {
145140
// Parents is a list of parent resources (usually Gateways) that are
146141
// associated with the InferencePool, and the status of the InferencePool with respect to
@@ -155,14 +150,13 @@ type InferencePoolStatus struct {
155150
// and no other parents exist.
156151
//
157152
// +kubebuilder:validation:MaxItems=32
153+
// +optional
154+
// +listType=atomic
158155
Parents []PoolStatus `json:"parent,omitempty"`
159156
}
160157

161158
// PoolStatus defines the observed state of InferencePool from a Gateway.
162159
type PoolStatus struct {
163-
// GatewayRef indicates the gateway that observed state of InferencePool.
164-
GatewayRef ParentGatewayReference `json:"parentRef"`
165-
166160
// Conditions track the state of the InferencePool.
167161
//
168162
// Known condition types are:
@@ -176,6 +170,10 @@ type PoolStatus struct {
176170
// +kubebuilder:validation:MaxItems=8
177171
// +kubebuilder:default={{type: "Accepted", status: "Unknown", reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}
178172
Conditions []metav1.Condition `json:"conditions,omitempty"`
173+
174+
// GatewayRef indicates the gateway that observed state of InferencePool.
175+
// +required
176+
GatewayRef ParentGatewayReference `json:"parentRef,omitzero"`
179177
}
180178

181179
// InferencePoolConditionType is a type of condition for the InferencePool
@@ -245,7 +243,7 @@ const (
245243
InferencePoolReasonResolvedRefs InferencePoolReason = "ResolvedRefs"
246244

247245
// This reason is used with the "ResolvedRefs" condition when the
248-
// ExtensionRef is invalid in some way. This can include an unsupported kind
246+
// Extension is invalid in some way. This can include an unsupported kind
249247
// or API group, or a reference to a resource that can not be found.
250248
InferencePoolReasonInvalidExtensionRef InferencePoolReason = "InvalidExtensionRef"
251249
)
@@ -257,21 +255,22 @@ type ParentGatewayReference struct {
257255
//
258256
// +optional
259257
// +kubebuilder:default="gateway.networking.k8s.io"
260-
Group *Group `json:"group"`
258+
Group *Group `json:"group,omitempty"`
261259

262260
// Kind is kind of the referent. For example "Gateway".
263261
//
264262
// +optional
265263
// +kubebuilder:default=Gateway
266-
Kind *Kind `json:"kind"`
264+
Kind Kind `json:"kind,omitempty"`
267265

268266
// Name is the name of the referent.
269-
Name ObjectName `json:"name"`
267+
// +required
268+
Name ObjectName `json:"name,omitempty"`
270269

271270
// Namespace is the namespace of the referent. If not present,
272271
// the namespace of the referent is assumed to be the same as
273272
// the namespace of the referring object.
274273
//
275274
// +optional
276-
Namespace *Namespace `json:"namespace,omitempty"`
275+
Namespace Namespace `json:"namespace,omitempty"`
277276
}

api/v1/shared_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package v1
3232
//
3333
// * "example.com/bar" - "/" is an invalid character
3434
//
35+
// +kubebuilder:validation:MinLength=0
3536
// +kubebuilder:validation:MaxLength=253
3637
// +kubebuilder:validation:Pattern=`^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
3738
type Group string
@@ -135,7 +136,7 @@ type LabelSelector struct {
135136
// An object must match every label in this map to be selected.
136137
// The matching logic is an AND operation on all entries.
137138
//
138-
// +kubebuilder:validation:Required
139+
// +required
139140
// +kubebuilder:validation:MaxItems=64
140141
MatchLabels map[LabelKey]LabelValue `json:"matchLabels,omitempty" protobuf:"bytes,1,rep,name=matchLabels"`
141142
}

api/v1/zz_generated.deepcopy.go

Lines changed: 2 additions & 51 deletions
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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (dst *InferencePool) ConvertFrom(src *v1.InferencePool) error {
5858
if src == nil {
5959
return errors.New("src cannot be nil")
6060
}
61-
extensionRef, err := convertExtensionRefFromV1(src.Spec.ExtensionRef)
61+
extensionRef, err := convertExtensionRefFromV1(&src.Spec.ExtensionRef)
6262
if err != nil {
6363
return err
6464
}
@@ -102,15 +102,19 @@ func convertStatusFromV1(src *v1.InferencePoolStatus) (*InferencePoolStatus, err
102102
return convert[InferencePoolStatus](u)
103103
}
104104

105-
func convertExtensionRefToV1(src *Extension) (*v1.Extension, error) {
105+
func convertExtensionRefToV1(src *Extension) (v1.Extension, error) {
106106
if src == nil {
107-
return nil, nil
107+
return v1.Extension{}, nil
108108
}
109109
u, err := toUnstructured(src)
110110
if err != nil {
111-
return nil, err
111+
return v1.Extension{}, err
112+
}
113+
out, err := convert[v1.Extension](u)
114+
if err != nil {
115+
return v1.Extension{}, err
112116
}
113-
return convert[v1.Extension](u)
117+
return *out, nil
114118
}
115119

116120
func convertExtensionRefFromV1(src *v1.Extension) (*Extension, error) {

0 commit comments

Comments
 (0)