Skip to content

Commit

Permalink
Compact call GetConfigProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-aguilar committed Jan 27, 2022
1 parent 1a1202d commit 8d94c23
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/config/config_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
package config

import (
"fmt"
"log"
"os"

"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configmapprovider"
"go.opentelemetry.io/collector/config/configunmarshaler"
"go.opentelemetry.io/collector/service"
)

Expand All @@ -33,14 +29,11 @@ const (
func GetConfigProvider() service.ConfigProvider {
// aws-otel-collector supports loading yaml config from Env Var
// including SSM parameter store for ECS use case
loc := getConfigFlag()
if configContent, ok := os.LookupEnv(envKey); ok {
log.Printf("Reading AOT config from environment: %v\n", configContent)
return service.NewConfigProvider(
[]string{fmt.Sprintf("env:%s", envKey)},
map[string]configmapprovider.Provider{"env": configmapprovider.NewEnv()},
[]config.MapConverterFunc{configmapprovider.NewExpandConverter()},
configunmarshaler.NewDefault())
loc = "env:" + envKey
}

return service.NewDefaultConfigProvider([]string{getConfigFlag()}, getSetFlag())
return service.NewDefaultConfigProvider([]string{loc}, getSetFlag())
}

0 comments on commit 8d94c23

Please sign in to comment.