mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
apf: refactor bootstrap ensure strategy
This commit is contained in:
parent
af99df6a6b
commit
672614b57e
@ -116,7 +116,9 @@ type configurationObject interface {
|
|||||||
// NewSuggestedEnsureStrategy returns an EnsureStrategy for suggested config objects
|
// NewSuggestedEnsureStrategy returns an EnsureStrategy for suggested config objects
|
||||||
func NewSuggestedEnsureStrategy() EnsureStrategy {
|
func NewSuggestedEnsureStrategy() EnsureStrategy {
|
||||||
return &strategy{
|
return &strategy{
|
||||||
alwaysAutoUpdateSpec: false,
|
alwaysAutoUpdateSpecFn: func(_ wantAndHave) bool {
|
||||||
|
return false
|
||||||
|
},
|
||||||
name: "suggested",
|
name: "suggested",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,14 +126,16 @@ func NewSuggestedEnsureStrategy() EnsureStrategy {
|
|||||||
// NewMandatoryEnsureStrategy returns an EnsureStrategy for mandatory config objects
|
// NewMandatoryEnsureStrategy returns an EnsureStrategy for mandatory config objects
|
||||||
func NewMandatoryEnsureStrategy() EnsureStrategy {
|
func NewMandatoryEnsureStrategy() EnsureStrategy {
|
||||||
return &strategy{
|
return &strategy{
|
||||||
alwaysAutoUpdateSpec: true,
|
alwaysAutoUpdateSpecFn: func(_ wantAndHave) bool {
|
||||||
|
return true
|
||||||
|
},
|
||||||
name: "mandatory",
|
name: "mandatory",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto-update strategy for the configuration objects
|
// auto-update strategy for the configuration objects
|
||||||
type strategy struct {
|
type strategy struct {
|
||||||
alwaysAutoUpdateSpec bool
|
alwaysAutoUpdateSpecFn func(wantAndHave) bool
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +150,7 @@ func (s *strategy) ShouldUpdate(wah wantAndHave) (updatable, bool, error) {
|
|||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
autoUpdateSpec := s.alwaysAutoUpdateSpec
|
autoUpdateSpec := s.alwaysAutoUpdateSpecFn(wah)
|
||||||
if !autoUpdateSpec {
|
if !autoUpdateSpec {
|
||||||
autoUpdateSpec = shouldUpdateSpec(current)
|
autoUpdateSpec = shouldUpdateSpec(current)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user