mirror of
https://github.com/helm/helm.git
synced 2026-04-28 01:27:23 -04:00
Add config options to NewConfiguration()
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
This commit is contained in:
parent
e63b4d92cb
commit
aed687eaa1
1 changed files with 19 additions and 2 deletions
|
|
@ -117,9 +117,26 @@ type Configuration struct {
|
|||
logging.LogHolder
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
type ConfigurationOption func(c *Configuration)
|
||||
|
||||
// Override the default logging handler
|
||||
// If unspecified, the default logger will be used
|
||||
func ConfigurationSetLogger(h slog.Handler) ConfigurationOption {
|
||||
return func(c *Configuration) {
|
||||
c.SetLogger(h)
|
||||
}
|
||||
}
|
||||
|
||||
func NewConfiguration(options ...ConfigurationOption) *Configuration {
|
||||
c := &Configuration{}
|
||||
c.SetLogger(slog.Default().Handler())
|
||||
for _, o := range options {
|
||||
o(c)
|
||||
}
|
||||
|
||||
if c.Logger() == nil {
|
||||
c.SetLogger(slog.Default().Handler())
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue