feat(agent): Print loaded configs (#12827)

This commit is contained in:
Joshua Powers 2023-03-10 05:44:56 -07:00 committed by GitHub
parent 0f5ced7aab
commit 1b36d73a7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -392,11 +392,9 @@ func getDefaultConfigPath() ([]string, error) {
for _, path := range []string{envfile, homefile} { for _, path := range []string{envfile, homefile} {
if isURL(path) { if isURL(path) {
log.Printf("I! Using config url: %s", path)
return []string{path}, nil return []string{path}, nil
} }
if _, err := os.Stat(path); err == nil { if _, err := os.Stat(path); err == nil {
log.Printf("I! Using config file: %s", path)
return []string{path}, nil return []string{path}, nil
} }
} }
@ -405,7 +403,6 @@ func getDefaultConfigPath() ([]string, error) {
// populated and return them all. // populated and return them all.
confFiles := []string{} confFiles := []string{}
if _, err := os.Stat(etcfile); err == nil { if _, err := os.Stat(etcfile); err == nil {
log.Printf("I! Using config file: %s", etcfile)
confFiles = append(confFiles, etcfile) confFiles = append(confFiles, etcfile)
} }
if _, err := os.Stat(etcfolder); err == nil { if _, err := os.Stat(etcfolder); err == nil {
@ -413,9 +410,6 @@ func getDefaultConfigPath() ([]string, error) {
if err != nil { if err != nil {
log.Printf("W! unable walk %q: %s", etcfolder, err) log.Printf("W! unable walk %q: %s", etcfolder, err)
} }
for _, file := range files {
log.Printf("I! Using config file: %s", file)
}
confFiles = append(confFiles, files...) confFiles = append(confFiles, files...)
} }
if len(confFiles) > 0 { if len(confFiles) > 0 {
@ -701,6 +695,7 @@ func escapeEnv(value string) string {
func LoadConfigFile(config string) ([]byte, error) { func LoadConfigFile(config string) ([]byte, error) {
if fetchURLRe.MatchString(config) { if fetchURLRe.MatchString(config) {
log.Printf("I! Loading config url: %s", config)
u, err := url.Parse(config) u, err := url.Parse(config)
if err != nil { if err != nil {
return nil, err return nil, err
@ -715,6 +710,7 @@ func LoadConfigFile(config string) ([]byte, error) {
} }
// If it isn't a https scheme, try it as a file // If it isn't a https scheme, try it as a file
log.Printf("I! Loading config file: %s", config)
buffer, err := os.ReadFile(config) buffer, err := os.ReadFile(config)
if err != nil { if err != nil {
return nil, err return nil, err