Files
core/config/resolve.go
T

25 lines
770 B
Go
Raw Normal View History

package config
// Resolve returns the highest-priority existing configuration file
// (spec section 25). found is false if no layer's file exists -- this is
// not an error; callers decide whether "no configuration file" is fine.
func (r *Resolver) Resolve() (layer Layer, found bool, err error) {
all, err := r.layers()
if err != nil {
return Layer{}, false, err
}
for _, l := range all {
if l.Exists {
return l, true, nil
}
}
return Layer{}, false, nil
}
// ResolveAll returns every layer in the priority hierarchy, highest
// priority first, whether or not the file exists there (spec section
// 26) -- e.g. for a `doctor`-style report of every location that was
// considered.
func (r *Resolver) ResolveAll() ([]Layer, error) {
return r.layers()
}