mirror of
https://github.com/kubesphere/kubesphere.git
synced 2026-10-23 18:39:41 +08:00
1b5681c12b
Signed-off-by: hongming <talonwan@yunify.com>
28 lines
626 B
Go
28 lines
626 B
Go
package multiconfig
|
|
|
|
type multiLoader []Loader
|
|
|
|
// MultiLoader creates a loader that executes the loaders one by one in order
|
|
// and returns on the first error.
|
|
func MultiLoader(loader ...Loader) Loader {
|
|
return multiLoader(loader)
|
|
}
|
|
|
|
// Load loads the source into the config defined by struct s
|
|
func (m multiLoader) Load(s interface{}) error {
|
|
for _, loader := range m {
|
|
if err := loader.Load(s); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MustLoad loads the source into the struct, it panics if gets any error
|
|
func (m multiLoader) MustLoad(s interface{}) {
|
|
if err := m.Load(s); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|