New static configuration loading system.
Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
This commit is contained in:
parent
d18edd6f77
commit
8d7eccad5d
165 changed files with 10894 additions and 6076 deletions
21
pkg/cli/loader.go
Normal file
21
pkg/cli/loader.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package cli
|
||||
|
||||
// ResourceLoader is a configuration resource loader.
|
||||
type ResourceLoader interface {
|
||||
// Load populates cmd.Configuration, optionally using args to do so.
|
||||
Load(args []string, cmd *Command) (bool, error)
|
||||
}
|
||||
|
||||
type filenameGetter interface {
|
||||
GetFilename() string
|
||||
}
|
||||
|
||||
// GetConfigFile returns the configuration file corresponding to the first configuration file loader found in ResourceLoader, if any.
|
||||
func GetConfigFile(loaders []ResourceLoader) string {
|
||||
for _, loader := range loaders {
|
||||
if v, ok := loader.(filenameGetter); ok {
|
||||
return v.GetFilename()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue