Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the use of the $ character in the config file #88

Open
clinmanc opened this issue Sep 21, 2022 · 0 comments
Open

Support the use of the $ character in the config file #88

clinmanc opened this issue Sep 21, 2022 · 0 comments

Comments

@clinmanc
Copy link

As shown below, if the password contains the $ character, the read password is uhQhu4watyTgn$, resulting in failure to connect to the redis

[[resource]]
name = "alertmanager"

  [resource.backend]
    [resource.backend.redis]
      nodes    = ["127.0.0.1:6379"]
      password = "uhQhu4watyTgn$Q$"
      prefix   = "/alert"
      interval = 5
      keys     = ["/*"]

The code that causes this problem

func readFileAndExpandEnv(path string) ([]byte, error) {
	buf, err := ioutil.ReadFile(path)
	if err != nil {
		return buf, errors.Wrap(err, "read file failed")
	}
	// expand the environment variables
	buf = []byte(os.ExpandEnv(string(buf)))
	return buf, nil
}

It can be fixed in the following way

https://play.golang.org/p/JOJ7WLIUY3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant