Skip to content

Commit

Permalink
apf: refactor bootstrap ensure strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
tkashem committed Jun 9, 2023
1 parent af99df6 commit 672614b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/registry/flowcontrol/ensurer/strategy.go
Expand Up @@ -116,23 +116,27 @@ type configurationObject interface {
// NewSuggestedEnsureStrategy returns an EnsureStrategy for suggested config objects
func NewSuggestedEnsureStrategy() EnsureStrategy {
return &strategy{
alwaysAutoUpdateSpec: false,
name: "suggested",
alwaysAutoUpdateSpecFn: func(_ wantAndHave) bool {
return false
},
name: "suggested",
}
}

// NewMandatoryEnsureStrategy returns an EnsureStrategy for mandatory config objects
func NewMandatoryEnsureStrategy() EnsureStrategy {
return &strategy{
alwaysAutoUpdateSpec: true,
name: "mandatory",
alwaysAutoUpdateSpecFn: func(_ wantAndHave) bool {
return true
},
name: "mandatory",
}
}

// auto-update strategy for the configuration objects
type strategy struct {
alwaysAutoUpdateSpec bool
name string
alwaysAutoUpdateSpecFn func(wantAndHave) bool
name string
}

func (s *strategy) Name() string {
Expand All @@ -146,7 +150,7 @@ func (s *strategy) ShouldUpdate(wah wantAndHave) (updatable, bool, error) {
return nil, false, nil
}

autoUpdateSpec := s.alwaysAutoUpdateSpec
autoUpdateSpec := s.alwaysAutoUpdateSpecFn(wah)
if !autoUpdateSpec {
autoUpdateSpec = shouldUpdateSpec(current)
}
Expand Down

0 comments on commit 672614b

Please sign in to comment.