Skip to content

Commit e5d89bc

Browse files
authored
Go CRD Comment Updates for Counters and Lists (#3536)
Updated some comments on the Counter and Lists with an aim to make the generated reference document more readable and provide more context of the operations therein. Work on #2716
1 parent 735e1cf commit e5d89bc

File tree

4 files changed

+1868
-1817
lines changed

4 files changed

+1868
-1817
lines changed

pkg/apis/agones/v1/common.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ func (ao *AllocationOverflow) Apply(gs *GameServer) {
174174
}
175175

176176
// Priority is a sorting option for GameServers with Counters or Lists based on the Capacity.
177-
// Type: Sort by a "Counter" or a "List".
178-
// Key: The name of the Counter or List. If not found on the GameServer, has no impact.
179-
// Order: Sort by "Ascending" or "Descending". "Descending" a bigger Capacity is preferred.
180-
// "Ascending" would be smaller Capacity is preferred.
181177
type Priority struct {
182-
Type string `json:"type"`
183-
Key string `json:"key"`
178+
// Type: Sort by a "Counter" or a "List".
179+
Type string `json:"type"`
180+
// Key: The name of the Counter or List. If not found on the GameServer, has no impact.
181+
Key string `json:"key"`
182+
// Order: Sort by "Ascending" or "Descending". "Descending" a bigger Capacity is preferred.
183+
// "Ascending" would be smaller Capacity is preferred.
184184
Order string `json:"order"`
185185
}

pkg/apis/agones/v1/gameserver.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,14 @@ type GameServerSpec struct {
213213
// (Alpha, PlayerTracking feature flag) Players provides the configuration for player tracking features.
214214
// +optional
215215
Players *PlayersSpec `json:"players,omitempty"`
216-
// (Alpha, CountsAndLists feature flag) Counters and Lists provides the configuration for generic tracking features.
216+
// (Alpha, CountsAndLists feature flag) Counters provides the configuration for tracking of int64 values against a GameServer.
217+
// Keys must be declared at GameServer creation time.
217218
// +optional
218219
Counters map[string]CounterStatus `json:"counters,omitempty"`
219-
Lists map[string]ListStatus `json:"lists,omitempty"`
220+
// (Alpha, CountsAndLists feature flag) Lists provides the configuration for tracking of lists of up to 1000 values against a GameServer.
221+
// Keys must be declared at GameServer creation time.
222+
// +optional
223+
Lists map[string]ListStatus `json:"lists,omitempty"`
220224
// Eviction specifies the eviction tolerance of the GameServer. Defaults to "Never".
221225
// +optional
222226
Eviction *Eviction `json:"eviction,omitempty"`
@@ -321,13 +325,13 @@ type PlayerStatus struct {
321325
IDs []string `json:"ids"`
322326
}
323327

324-
// CounterStatus stores the current counter values
328+
// CounterStatus stores the current counter values and maximum capacity
325329
type CounterStatus struct {
326330
Count int64 `json:"count"`
327331
Capacity int64 `json:"capacity"`
328332
}
329333

330-
// ListStatus stores the current list values
334+
// ListStatus stores the current list values and maximum capacity
331335
type ListStatus struct {
332336
Capacity int64 `json:"capacity"`
333337
Values []string `json:"values"`

pkg/apis/allocation/v1/gameserverallocation.go

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import (
2121
"agones.dev/agones/pkg/apis"
2222
agonesv1 "agones.dev/agones/pkg/apis/agones/v1"
2323
"agones.dev/agones/pkg/util/runtime"
24-
hashstructure "github.com/mitchellh/hashstructure/v2"
24+
"github.com/mitchellh/hashstructure/v2"
2525
corev1 "k8s.io/api/core/v1"
2626
apivalidation "k8s.io/apimachinery/pkg/api/validation"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
metav1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
2929
"k8s.io/apimachinery/pkg/labels"
30-
field "k8s.io/apimachinery/pkg/util/validation/field"
30+
"k8s.io/apimachinery/pkg/util/validation/field"
3131
)
3232

3333
const (
@@ -105,11 +105,12 @@ type GameServerAllocationSpec struct {
105105
// You can use this to tell the server necessary session data
106106
MetaPatch MetaPatch `json:"metadata,omitempty" hash:"ignore"`
107107

108-
// (Alpha, CountsAndLists feature flag) Counters and Lists provide a set of actions to perform
109-
// on Counters and Lists during allocation.
108+
// (Alpha, CountsAndLists feature flag) Counter actions to perform during allocation.
110109
// +optional
111110
Counters map[string]CounterAction `json:"counters,omitempty" hash:"ignore"`
112-
Lists map[string]ListAction `json:"lists,omitempty" hash:"ignore"`
111+
// (Alpha, CountsAndLists feature flag) List actions to perform during allocation.
112+
// +optional
113+
Lists map[string]ListAction `json:"lists,omitempty" hash:"ignore"`
113114
}
114115

115116
// GameServerSelector contains all the filter options for selecting
@@ -146,40 +147,56 @@ type PlayerSelector struct {
146147
}
147148

148149
// CounterSelector is the filter options for a GameServer based on the count and/or available capacity.
149-
// 0 for MaxCount or MaxAvailable means unlimited maximum. Default for all fields: 0
150150
type CounterSelector struct {
151-
MinCount int64 `json:"minCount"`
152-
MaxCount int64 `json:"maxCount"`
151+
// MinCount is the minimum current value. Defaults to 0.
152+
// +optional
153+
MinCount int64 `json:"minCount"`
154+
// MaxCount is the maximum current value. Defaults to 0, which translates as max(in64).
155+
// +optional
156+
MaxCount int64 `json:"maxCount"`
157+
// MinAvailable specifies the minimum capacity (current capacity - current count) available on a GameServer. Defaults to 0.
158+
// +optional
153159
MinAvailable int64 `json:"minAvailable"`
160+
// MaxAvailable specifies the maximum capacity (current capacity - current count) available on a GameServer. Defaults to 0, which translates to max(int64).
161+
// +optional
154162
MaxAvailable int64 `json:"maxAvailable"`
155163
}
156164

157165
// ListSelector is the filter options for a GameServer based on List available capacity and/or the
158166
// existence of a value in a List.
159-
// 0 for MaxAvailable means unlimited maximum. Default for integer fields: 0
160-
// "" for ContainsValue means ignore field. Default for string field: ""
161167
type ListSelector struct {
168+
// ContainsValue says to only match GameServers who has this value in the list. Defaults to "", which is all.
169+
// +optional
162170
ContainsValue string `json:"containsValue"`
163-
MinAvailable int64 `json:"minAvailable"`
164-
MaxAvailable int64 `json:"maxAvailable"`
171+
// MinAvailable specifies the minimum capacity (current capacity - current count) available on a GameServer. Defaults to 0.
172+
// +optional
173+
MinAvailable int64 `json:"minAvailable"`
174+
// MaxAvailable specifies the maximum capacity (current capacity - current count) available on a GameServer. Defaults to 0, which is translated as max(int64).
175+
// +optional
176+
MaxAvailable int64 `json:"maxAvailable"`
165177
}
166178

167179
// CounterAction is an optional action that can be performed on a Counter at allocation.
168-
// Action: "Increment" or "Decrement" the Counter's Count (optional). Must also define the Amount.
169-
// Amount: The amount to increment or decrement the Count (optional). Must be a positive integer.
170-
// Capacity: Update the maximum capacity of the Counter to this number (optional). Min 0, Max int64.
171180
type CounterAction struct {
172-
Action *string `json:"action,omitempty"`
173-
Amount *int64 `json:"amount,omitempty"`
174-
Capacity *int64 `json:"capacity,omitempty"`
181+
// Action must to either "Increment" or "Decrement" the Counter's Count. Must also define the Amount.
182+
// +optional
183+
Action *string `json:"action,omitempty"`
184+
// Amount is the amount to increment or decrement the Count. Must be a positive integer.
185+
// +optional
186+
Amount *int64 `json:"amount,omitempty"`
187+
// Capacity is the amount to update the maximum capacity of the Counter to this number. Min 0, Max int64.
188+
// +optional
189+
Capacity *int64 `json:"capacity,omitempty"`
175190
}
176191

177192
// ListAction is an optional action that can be performed on a List at allocation.
178-
// AddValues: Append values to a List's Values array (optional). Any duplicate values will be ignored.
179-
// Capacity: Update the maximum capacity of the Counter to this number (optional). Min 0, Max 1000.
180193
type ListAction struct {
194+
// AddValues appends values to a List's Values array. Any duplicate values will be ignored.
195+
// +optional
181196
AddValues []string `json:"addValues,omitempty"`
182-
Capacity *int64 `json:"capacity,omitempty"`
197+
// Capacity updates the maximum capacity of the Counter to this number. Min 0, Max 1000.
198+
// +optional
199+
Capacity *int64 `json:"capacity,omitempty"`
183200
}
184201

185202
// ApplyDefaults applies default values

0 commit comments

Comments
 (0)