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

VAULT-12940 Add ability to configure Vault client user agent #1725

Merged
merged 2 commits into from
Mar 22, 2023

Conversation

VioletHynes
Copy link
Contributor

This adds a new configuration item for Vault, ClientUserAgent. When set, Consul Template will use the set User-Agent when making requests to Vault.

This change is being made as part of a broader effort for Vault Agent to send its version as part of a User-Agent string in requests to Vault. Agent will then consume the latest version of consul-template, then use this new config to set the correct User-Agent.

Tests were of course added to validate that this works as expected, but let me know if there's anything else I should be testing as part of this change.

@VioletHynes VioletHynes requested a review from a team as a code owner March 21, 2023 19:30
@VioletHynes VioletHynes requested review from eikenb and removed request for a team March 21, 2023 19:30
@steshageo steshageo requested a review from a team March 21, 2023 20:00
Copy link
Contributor

@roncodingenthusiast roncodingenthusiast left a comment

Choose a reason for hiding this comment

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

Reviewed this with @eikenb. This looks great so far and should be good to go once some docs are added here. Thank you for adding tests

SSLCACert string
SSLCAPath string
ServerName string
ClientUserAgent string

Choose a reason for hiding this comment

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

❓Do we call this ClientUserAgent within CreateVaultClientInput (as opposed to just UserAgent) because Vault (server) is the client here? Like the client (agent) of the client (server)? :)

Copy link
Contributor Author

@VioletHynes VioletHynes Mar 22, 2023

Choose a reason for hiding this comment

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

CreateVaultClientInput builds a Vault Client, essentially, so ClientUserAgent determines the User-Agent of that client. As far as why I didn't call it UserAgent, it's mostly just because I found ClientUserAgent clearer about what it was doing (setting the client's user agent), personally anyway.

Choose a reason for hiding this comment

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

Ah OK, thanks. 👍🏼

Does that mean for example, that Address is a client address? I was wondering if there's some fields that are server specific and some that are client specific (ServerName looks suspicious in that regard).

Sorry it now sounds like a nitpick, I was just trying to understand it... why wouldn't we follow the same format of non-client prefixed fields and just use UserAgent? It feels a bit redundant.

Copy link
Contributor Author

@VioletHynes VioletHynes Mar 22, 2023

Choose a reason for hiding this comment

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

The Address is the server address. Ultimately, this goes into configuring the client, but the inner workings might not be obvious to the user, as we can't assume they're looking at the code.

The configuration is done via HCL, e.g. this:

vault {
  address = "https://vault.service.consul:8200"
  namespace = ""
  client_user_agent = "Consul Template"
#...

Especially in this context, I feel like the 'client' part of the config tells the user something, i.e. that this configuration is for Consul Template's Vault Client. I definitely err on the side of making things as unambiguous as possible. At least to me, user_agent tells me a lot less than client_user_agent in that HCL block.

Copy link

@peteski22 peteski22 Mar 22, 2023

Choose a reason for hiding this comment

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

Cool, so there are fields here that are related to the server properties which are configured within the client, that makes sense. 😄

What I was alluding to was being able to easily distinguish between the types of setting, so like ServerAddress and now ClientUserAgent, so the client specific settings for client and server settings for client were clear in code.

I agree with what you're saying about the clarity for the end-user, I think the HCL config example makes sense. 👍🏼

Maybe worth pointing out that the HCL name isn't the same as the name of the field we use in code though, it's just mapped via:

ClientUserAgent *string `mapstructure:"client_user_agent""`

No more questions from me, thanks!

@VioletHynes
Copy link
Contributor Author

Added some docs! Let me know if there's anything else you need. Thanks in advance!

@VioletHynes VioletHynes merged commit 821bc07 into main Mar 22, 2023
@VioletHynes VioletHynes deleted the violethynes/VAULT-12940 branch March 22, 2023 15:32
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.

3 participants