diff --git a/connector.go b/connector.go index 55dab73..a6443b3 100644 --- a/connector.go +++ b/connector.go @@ -6,6 +6,8 @@ import ( "errors" "fmt" "os" + "regexp" + "strings" jsoniter "github.com/json-iterator/go" @@ -229,6 +231,15 @@ func newConnectorConfigFromPath(path string) (*config.Connector, error) { if err != nil { return nil, err } + envPattern := regexp.MustCompile(`\${([^}]+)}`) + matches := envPattern.FindAllStringSubmatch(string(file), -1) + for _, match := range matches { + envVar := match[1] + if value, exists := os.LookupEnv(envVar); exists { + updatedFile := strings.ReplaceAll(string(file), "${"+envVar+"}", value) + file = []byte(updatedFile) + } + } var c config.Connector err = yaml.Unmarshal(file, &c) if err != nil {