Closed Gearbox007 closed 2 years ago
On Fri Jan 28, 2022 at 12:00 PM -0800, Gearbox007 wrote:
//setup influxdb client //TODO: get username and password for influx from environment variables c, err := client.NewHTTPClient(client.HTTPConfig{ Addr: conf.Influx.Addr, //Username: conf.Influx.Username, //Password: conf.Influx.Password,
Other than disabling auth on the database, how can I go about hard coding the username and password into go, at least until this part of the project gets finished.
If you want to hardcode the username and password into the code, you can simply uncomment the username and password lines above and and replace conf.Influx.* with strings, i.e.
c, err := client.NewHTTPClient(client.HTTPConfig{
Addr: conf.Influx.Addr,
Username: "user",
Password: "password",
}
Alternatively, you could get the username and password from environment
variables and pass those to the client.NewHttpClient struct. In Go, you
would use os.Getenv("USERNAME")
, for example, to get the value of the
enviorment variable "USERNAME".
Thank you for your response, I hard coded it. It works great!
Hello, this is my first time doing this so bear with me.
Following your guide, I'm trying to write to a test database, except I have authentication enabled on influxdb. I get this error:
Writing to test a http://192.168.x.x:8086 <"error":"unable to parse authentication credentials">
So I looked into the main.go file in the opcflux folder, and found
//setup influxdb client //TODO: get username and password for influx from environment variables c, err := client.NewHTTPClient(client.HTTPConfig{ Addr: conf.Influx.Addr, //Username: conf.Influx.Username, //Password: conf.Influx.Password,
Other than disabling auth on the database, how can I go about hard coding the username and password into go, at least until this part of the project gets finished.