e071084ebe
govulncheck / govulncheck (push) Waiting to run
Harness (E2E) / Harnesses (mock LLM) (push) Waiting to run
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Run Tests / Unit Tests (push) Waiting to run
Run Tests / Etcd Integration Tests (push) Waiting to run
24 lines
416 B
Go
24 lines
416 B
Go
package reader
|
|
|
|
import (
|
|
"os"
|
|
"regexp"
|
|
)
|
|
|
|
func ReplaceEnvVars(raw []byte) ([]byte, error) {
|
|
re := regexp.MustCompile(`\$\{([A-Za-z0-9_]+)\}`)
|
|
if re.Match(raw) {
|
|
dataS := string(raw)
|
|
res := re.ReplaceAllStringFunc(dataS, replaceEnvVars)
|
|
return []byte(res), nil
|
|
} else {
|
|
return raw, nil
|
|
}
|
|
}
|
|
|
|
func replaceEnvVars(element string) string {
|
|
v := element[2 : len(element)-1]
|
|
el := os.Getenv(v)
|
|
return el
|
|
}
|