added isEnabledOrDefault

pull/15762/head
Shubh Bapna 2023-02-17 11:00:22 -05:00
parent 2ac143527f
commit f88c6ad3cd
2 changed files with 11 additions and 1 deletions

View File

@ -538,7 +538,7 @@ func ToEnable(cc *config.ClusterConfig, existing map[string]bool, additional []s
// Get the default values of any addons not saved to our config
for name, a := range assets.Addons {
if _, exists := existing[name]; !exists {
enable[name] = a.IsEnabled(cc)
enable[name] = a.IsEnabledOrDefault(cc)
}
}

View File

@ -80,6 +80,16 @@ func (a *Addon) IsEnabled(cc *config.ClusterConfig) bool {
return status
}
return false
}
// IsEnabledOrDefault checks if an Addon is enabled for the given profile. If not found in profile it returns the default state
func (a *Addon) IsEnabledOrDefault(cc *config.ClusterConfig) bool {
status, ok := cc.Addons[a.Name()]
if ok {
return status
}
// Return the default unconfigured state of the addon
return a.enabled
}