@@ -60,37 +60,37 @@ func (c *Compartment) AddNode(node SkyhookNode) {
6060 c .Nodes = append (c .Nodes , node )
6161}
6262
63- // strategyType represents the type of deployment strategy
64- type strategyType int
65-
66- const (
67- strategyFixed strategyType = iota
68- strategyLinear
69- strategyExponential
70- strategyUnknown
71- )
63+ // strategySafetyOrder defines the safety ordering of strategies
64+ // Lower values indicate safer strategies (less aggressive rollout)
65+ // Strategy safety order: Fixed (0) > Linear (1) > Exponential (2)
66+ var strategySafetyOrder = map [v1alpha1. StrategyType ] int {
67+ v1alpha1 . StrategyTypeFixed : 0 ,
68+ v1alpha1 . StrategyTypeLinear : 1 ,
69+ v1alpha1 . StrategyTypeExponential : 2 ,
70+ v1alpha1 . StrategyTypeUnknown : 999 , // Unknown is least safe
71+ }
7272
7373// getStrategyType returns the strategy type for a compartment
74- func getStrategyType (strategy * v1alpha1.DeploymentStrategy ) strategyType {
74+ func getStrategyType (strategy * v1alpha1.DeploymentStrategy ) v1alpha1. StrategyType {
7575 if strategy == nil {
76- return strategyUnknown
76+ return v1alpha1 . StrategyTypeUnknown
7777 }
7878 if strategy .Fixed != nil {
79- return strategyFixed
79+ return v1alpha1 . StrategyTypeFixed
8080 }
8181 if strategy .Linear != nil {
82- return strategyLinear
82+ return v1alpha1 . StrategyTypeLinear
8383 }
8484 if strategy .Exponential != nil {
85- return strategyExponential
85+ return v1alpha1 . StrategyTypeExponential
8686 }
87- return strategyUnknown
87+ return v1alpha1 . StrategyTypeUnknown
8888}
8989
9090// strategyIsSafer returns true if strategy a is safer than strategy b
9191// Strategy safety order: Fixed > Linear > Exponential
92- func strategyIsSafer (a , b strategyType ) bool {
93- return a < b
92+ func strategyIsSafer (a , b v1alpha1. StrategyType ) bool {
93+ return strategySafetyOrder [ a ] < strategySafetyOrder [ b ]
9494}
9595
9696// computeEffectiveCapacity calculates the effective ceiling for a compartment's budget
@@ -111,7 +111,7 @@ func computeEffectiveCapacity(budget v1alpha1.DeploymentBudget, matchedNodes int
111111// compartmentMatch represents a compartment that matches a node
112112type compartmentMatch struct {
113113 name string
114- strategyType strategyType
114+ strategyType v1alpha1. StrategyType
115115 capacity int
116116}
117117
0 commit comments