vbezgachev / maxctrl_exporter

MaxScale metrics exporter for Prometheus
Apache License 2.0
12 stars 11 forks source link

Allow exporter configuration via config file #19

Closed dylan-tock closed 8 months ago

dylan-tock commented 8 months ago

Overview

This PR addresses the open issue requesting the ability to configure username/password via config file vs environment variables. This adds that ability, adds tests for the newly introduced functions, and refactors some of the configuration logic to make it more testable. I worked to make this as backward compatible as possible so not changes are needed to continue using Environment variables for configuration.

Changes

maxctrl_exporter.go

maxctrl_exporter_test.go

Added tests for functions newly added to maxctrl_exporter.go. Added a cheeky Copyright line (along with Apache 2.0 license block) as Makefile.common was checking that one existed. I added my name since I wasn't comfortable adding the names of anyone else.

Makefile.common

Added a verbose option to the common-test block to provide more detailed testing output, specifically the names of tests that passed/failed.

maxctrl_exporter.yaml.example

An example file containing configurable parameters. To guard against anyone accidentally copying this to maxctrl_exporter.yaml and checking it into git, I also added maxctrl_exporter.yaml to the .gitignore file.

vbezgachev commented 8 months ago

@dylan-tock Thank you for adding the functionality! One small thing - I noticed the build failed after I merged your changes. I fixed it by committing the go.sum and go.mod files. Could you pay attention to them next time? 🙏

dylan-tock commented 8 months ago

@dylan-tock Thank you for adding the functionality! One small thing - I noticed the build failed after I merged your changes. I fixed it by committing the go.sum and go.mod files. Could you pay attention to them next time? 🙏

So very sorry about this. I thought I'd done so, but will pay more attention to it and do more local testing for future PRs.