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

Allow setting the User Agent Operator suffix #2831

Merged
merged 8 commits into from Oct 13, 2023

Conversation

jacobbednarz
Copy link
Member

@jacobbednarz jacobbednarz commented Oct 11, 2023

Within the Terraform ecosystem, there are multiple ways of using the
providers. Generally, it is through the Terraform CLI however, there are
third party tools like Pulumi that rely on the schemas to build their
own integrations.

One issue with this is that the requests they make are lumped with the
label of terraform/<version> in the HTTP user agent which doesn’t
allow observablility into those specific requests. To enable better
visibility here, we are introducing a new schema field called a User
Agent Operator suffix. It is configurable in the schema
(user_agent_operator_suffix) and via the environment variable
(CLOUDFLARE_USER_AGENT_OPERATOR_SUFFIX) and will provide a way for
these third party integrations to denote the source of their requests.

⚠️This is not a recommended configuration change for most and when not
explicitly configured will default to the existing terraform/<version>
string (as it always has). You should only change this value if you know
what you are doing.

Supersedes and closes #2816

Introduces a `UserAgentBuilder` method that allows us to build contextually conditional user agent strings based on the plugin and operator suffix provided by the user.

Signed-off-by: Jacob Bednarz <jacob.bednarz@gmail.com>
Within the Terraform ecosystem, there are multiple ways of using the
providers. Generally, it is through the Terraform CLI however, there are
third party tools like Pulumi that rely on the schemas to build their
own integrations.

One issue with this is that the requests they make are lumped with the
label of `terraform/<version>` in the HTTP user agent which doesn’t
allow observablility into those specific requests. To enable better
visibility here, we are introducing a new schema field called a User
Agent Operator suffix. It is configurable in the schema
(`user_agent_operator_suffix`) and via the environment variable
(`CLOUDFLARE_USER_AGENT_OPERATOR_SUFFIX `) and will provide a way for
these third party integrations to denote the source of their requests.

⚠️This *is not* a recommended configuration change for most and when not
explicitly configured will default to the existing `terraform/<version>`
string (as it always has). You should only change this value if you know
what you are doing.

Signed-off-by: Jacob Bednarz <jacob.bednarz@gmail.com>
@github-actions
Copy link
Contributor

changelog detected ✅

Before this change, we relied on the plugin libraries to expose their version. Unfortunately, this was incorrectly set in SDKv2[1] and non-existent in the framework[2].

The recommended approach is to instead dig into the build information via`runtime/debug.ReadBuildInfo()`[3] which is what we introduce here in a slightly safer and consistent way.

[1]: hashicorp/terraform-plugin-sdk#1257
[2]: hashicorp/terraform-plugin-framework#855
[3]: https://pkg.go.dev/runtime/debug#ReadBuildInfo

Signed-off-by: Jacob Bednarz <jacob.bednarz@gmail.com>
@jacobbednarz
Copy link
Member Author

fyi @jaxxstorm

@jacobbednarz jacobbednarz merged commit d9e8f42 into master Oct 13, 2023
9 checks passed
@jacobbednarz jacobbednarz deleted the allow-ua-operator-appending branch October 13, 2023 02:18
@github-actions github-actions bot added this to the v4.17.0 milestone Oct 13, 2023
github-actions bot pushed a commit that referenced this pull request Oct 13, 2023
@github-actions
Copy link
Contributor

This functionality has been released in v4.17.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant