INNER CODE UNIT · Go

applyEnvs

ozontech/file.d · cfg/config.go:168

func applyEnvs(object *simplejson.Json) error {
	for _, env := range os.Environ() {
		kv := strings.SplitN(env, "=", 2)
		if len(kv) != 2 {
			return fmt.Errorf("can't parse env %s", env)
		}

		k, v := kv[0], kv[1]
		if strings.HasPrefix(k, "FILED_") {
			lower := strings.ToLower(k)
			path := strings.Split(lower, "_")[1:]
			object.SetPath(path, v)
		}
	}

	applyConfigFunc(&envs{}, object)

	return nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…