@@ -275,24 +275,23 @@ type Config struct {
275275
276276type MaximumMaxReplicasPerGroup struct {
277277 // ServiceGroupName refers to one ServiceGroup at Config.ServiceGroups
278- // If nil, this MaximumMaxReplica would apply to all services.
279278 ServiceGroupName * string `yaml:"ServiceGroupName"`
280279
281280 MaximumMaxReplica int32 `yaml:"MaximumMaxReplica"`
282281}
283282
284- // Namespace represents a Kubernetes namespace and its associated label selectors .
285- type Namespace struct {
286- Name string `yaml:"name"` // Namespace name
287- LabelSelectors []* metav1.LabelSelector `yaml:"labelSelectors "` // Slice of label selectors within this namespace
283+ // Selector selects a group of pods by matching its namespace and labels .
284+ type Selector struct {
285+ Namespace string `yaml:"Namespace"` // Namespace name
286+ LabelSelectors []* metav1.LabelSelector `yaml:"Labels,omitempty "` // Slice of label selectors within this namespace
288287}
289288
290289// ServiceGroup represents a collection of services grouped together with namespace awareness.
291290type ServiceGroup struct {
292291 // Name is the group's name (e.g., big-service, fintech-service, etc).
293- Name string `yaml:"name "`
294- // Namespaces represent multiple namespaces with their label selectors .
295- Namespaces []Namespace `yaml:"namespaces "` // A slice of Namespace structs
292+ Name string `yaml:"Name "`
293+ // Selectors represent multiple pod groups that belong to this ServiceGroup .
294+ Selectors []Selector `yaml:"Selectors "` // Slice of namespaces and labels within this service group
296295}
297296
298297func defaultConfig () * Config {
@@ -402,11 +401,18 @@ func validate(config *Config) error {
402401 seenServiceGroups := make (map [string ]bool )
403402 for _ , sg := range config .ServiceGroups {
404403 if seenServiceGroups [sg .Name ] {
405- return fmt .Errorf ("Duplicate ServiceGroupName found: %s" , sg .Name )
404+ return fmt .Errorf ("duplicate ServiceGroupName found: %s" , sg .Name )
406405 }
407406 seenServiceGroups [sg .Name ] = true
408407 }
409408
409+ // Check all entries in MaximumMaxReplicasPerService have non-nil ServiceGroupName
410+ for _ , maxReplicas := range config .MaximumMaxReplicasPerService {
411+ if maxReplicas .ServiceGroupName == nil {
412+ return fmt .Errorf ("ServiceGroupName should not be nil in MaximumMaxReplicasPerService entries" )
413+ }
414+ }
415+
410416 if config .MaximumMinReplicas > minOfMaximumMaxReplicas {
411417 return fmt .Errorf ("MaximumMinReplicas should be less than or equal to MaximumMaxReplicas" )
412418 }
0 commit comments