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

Add RegisterFlagsWithPrefix to config structs #2414

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Jul 24, 2020

All config structs now have a RegisterFlagsWithPrefix function that allows specifying a prefixed string to append to all flag names. This may be used by clients to namespace support for Promtail in a larger application (e.g., grafana/agent).

One exception to this is the Weaveworks server which doesn't currently have a RegisterFlagsWithPrefix function. This might be a problem down the line, but it's not a problem for my particular use case (I expose a subset of the Promtail config which doesn't include the weaveworks server).

I noticed a few config structs were incorrectly registering to the global FlagSet rather than the FlagSet passed to RegisterFlags. This PR also includes a fix for that.

Related to #2405.

All config structs now have a RegisterFlagsWithPrefix function that
allows specifying a prefixed string to append to all flag names. This
may be used by clients to namespace support for Promtail in a larger
application (e.g., grafana/agent).

When implementing this PR, I noticed a few config structs were
incorrectly registering to the global flagset rather than the flagset
passed to RegisterFlags. This PR also includes a fix for that and
ensures every option is registered to the flagset in the parameter.

Related to grafana#2405.
@codecov-commenter
Copy link

Codecov Report

Merging #2414 into master will increase coverage by 0.07%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2414      +/-   ##
==========================================
+ Coverage   61.58%   61.66%   +0.07%     
==========================================
  Files         160      160              
  Lines       13590    13596       +6     
==========================================
+ Hits         8370     8384      +14     
+ Misses       4597     4586      -11     
- Partials      623      626       +3     
Impacted Files Coverage Δ
pkg/promtail/client/config.go 54.83% <0.00%> (-3.79%) ⬇️
pkg/promtail/positions/positions.go 59.64% <0.00%> (+12.32%) ⬆️
pkg/promtail/targets/file/filetarget.go 69.64% <0.00%> (+0.96%) ⬆️
pkg/promtail/targets/file/tailer.go 76.13% <0.00%> (-2.28%) ⬇️
pkg/logql/evaluator.go 92.47% <0.00%> (-0.41%) ⬇️

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

lgtm

@owen-d owen-d merged commit 3451dd7 into grafana:master Jul 27, 2020
@rfratto rfratto deleted the promtail-flags-prefix branch September 18, 2024 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants