Skip to content

feat: do not load config file when path is empty#1263

Open
litetex wants to merge 1 commit intoprometheus-community:masterfrom
litetex:do-not-load-config-file-if-path-empty
Open

feat: do not load config file when path is empty#1263
litetex wants to merge 1 commit intoprometheus-community:masterfrom
litetex:do-not-load-config-file-if-path-empty

Conversation

@litetex
Copy link

@litetex litetex commented Feb 18, 2026

Fixes #794

Signed-off-by: litetex <40789489+litetex@users.noreply.github.com>
@litetex litetex force-pushed the do-not-load-config-file-if-path-empty branch from 366a183 to 70a4c2d Compare February 18, 2026 20:30
Copy link
Contributor

@sysadmind sysadmind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This input is almost guaranteed to never be empty. It has a default in the flag. What are you trying to achieve with this change because I don't think this achieves it?

@litetex
Copy link
Author

litetex commented Feb 20, 2026

This input is almost guaranteed to never be empty. It has a default in the flag. What are you trying to achieve with this change because I don't think this achieves it?

Hi, thank you for taking the time and asking.

I'm basically running the quickstart setup without any config file.

However this results in the warning: Error opening config file... because it does not exist in my setup.

I want to get rid of the warning because - you know - it's a warning and warning's require attention/a fix in some way.

I thought the simplest way was by setting --config.file=''. However the warning then still happens because there is no empty string check (therefore this PR) or any other way to disable using a config file.

Hope that this helps :)

decoder := yaml.NewDecoder(yamlReader)
decoder.KnownFields(true)
if f != "" {
yamlReader, err := os.Open(f)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use filepath.Clean(f) instead of a plain "f"

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

Successfully merging this pull request may close these issues.

Error opening config file postgres_exporter.yml in logs

3 participants