@@ -66,6 +66,8 @@ const (
6666
6767// ServerGroupSpec contains the specification for all servers in a specific group (e.g. all agents)
6868type ServerGroupSpec struct {
69+ group ServerGroup `json:"-"`
70+
6971 // Count holds the requested number of servers
7072 Count * int `json:"count,omitempty"`
7173 // MinCount specifies a lower limit for count
@@ -343,7 +345,7 @@ func (s ServerGroupSpec) GetOverrideDetectedTotalMemory() bool {
343345 return * s .OverrideDetectedTotalMemory
344346}
345347
346- // OverrideDetectedNumberOfCores returns OverrideDetectedNumberOfCores with default value (false)
348+ // GetOverrideDetectedNumberOfCores returns OverrideDetectedNumberOfCores with default value (false)
347349func (s ServerGroupSpec ) GetOverrideDetectedNumberOfCores () bool {
348350 if s .OverrideDetectedNumberOfCores == nil {
349351 return true
@@ -354,6 +356,10 @@ func (s ServerGroupSpec) GetOverrideDetectedNumberOfCores() bool {
354356
355357// Validate the given group spec
356358func (s ServerGroupSpec ) Validate (group ServerGroup , used bool , mode DeploymentMode , env Environment ) error {
359+ if s .group != group {
360+ return errors .WithStack (errors .Wrapf (ValidationError , "Group is not set" ))
361+ }
362+
357363 if used {
358364 minCount := 1
359365 if env == EnvironmentProduction {
@@ -484,8 +490,27 @@ func (s *ServerGroupSpec) validateVolumes() error {
484490 return nil
485491}
486492
493+ // WithGroup copy deployment with missing group
494+ func (s ServerGroupSpec ) WithGroup (group ServerGroup ) ServerGroupSpec {
495+ s .group = group
496+ return s
497+ }
498+
499+ // WithDefaults copy deployment with missing defaults
500+ func (s ServerGroupSpec ) WithDefaults (group ServerGroup , used bool , mode DeploymentMode ) ServerGroupSpec {
501+ q := s .DeepCopy ()
502+ q .SetDefaults (group , used , mode )
503+ return * q
504+ }
505+
487506// SetDefaults fills in missing defaults
488507func (s * ServerGroupSpec ) SetDefaults (group ServerGroup , used bool , mode DeploymentMode ) {
508+ if s == nil {
509+ return
510+ }
511+
512+ s .group = group
513+
489514 if s .GetCount () == 0 && used {
490515 switch group {
491516 case ServerGroupSingle :
@@ -636,3 +661,11 @@ func (s ServerGroupSpec) GetExternalPortEnabled() bool {
636661 return * v
637662 }
638663}
664+
665+ func (s * ServerGroupSpec ) Group () ServerGroup {
666+ if s == nil {
667+ return ServerGroupUnknown
668+ }
669+
670+ return s .group
671+ }
0 commit comments