1package autoconf 2 3import ( 4 "github.com/hashicorp/consul/agent/config" 5) 6 7// LoadConfig will build the configuration including the extraHead source injected 8// after all other defaults but before any user supplied configuration and the overrides 9// source injected as the final source in the configuration parsing chain. 10func LoadConfig(builderOpts config.BuilderOpts, extraHead config.Source, overrides ...config.Source) (*config.RuntimeConfig, []string, error) { 11 b, err := config.NewBuilder(builderOpts) 12 if err != nil { 13 return nil, nil, err 14 } 15 16 if extraHead.Data != "" { 17 b.Head = append(b.Head, extraHead) 18 } 19 20 if len(overrides) != 0 { 21 b.Tail = append(b.Tail, overrides...) 22 } 23 24 cfg, err := b.BuildAndValidate() 25 if err != nil { 26 return nil, nil, err 27 } 28 29 return &cfg, b.Warnings, nil 30} 31