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

Changes User-Agent header generation #54

Closed
wants to merge 2 commits into from

Conversation

austingebauer
Copy link
Member

Overview

This PR changes User-Agent header generation to rely on the result of PluginEnv(). This will allow the plugin to correctly determine version information when running as builtin or external to Vault. Currently, the version information may not be correct if running as an external plugin.

Additionally, this fixes usage attribution to include the missing pid- prefix per Azure documentation.

Testing

I've verified that the result of PluginEnv() is correct using Vault oss and enterprise. If VersionMetadata is not empty, we can assume the build is enterprise.

See the version format from various Vault builds:

# Format
Vault v<Version>-<VersionPrerelease>+<VersionMetadata> (<Revision>)

# OSS
$ vault version
Vault v1.10.0 (7738ec5d0d6f5bf94a809ee0f6ff0142cfa525a6)

# Enterprise
$ vault version
Vault v1.10.0+ent (d71d7710888891761ce43ec4e5f9d9fdeff31d8e)

# OSS Release Candidate
$ vault version
Vault v1.10.0-rc1 (3c389362c05c41a014dac7ad9aed393c8f69b125)

# Enterprise Release Candidate
$ vault version
Vault v1.10.0-rc1+ent (0886b5e08b93d4a5e140e11717934aa4042e7d3f)

# OSS Dev
$ vault version
Vault v1.11.0-dev1 ('aed9514c21481603bd8f04ea14e4717189c7df36')

# Enterprise Dev
$ vault version
Vault v1.11.0-dev1+prem ('410cf4829e685cf8ce9624795bc3fab96692111b')

Additional testing will be done to ensure that the GUIDs work as expected for attribution.

@@ -240,5 +242,11 @@ func getAzureSettings(config *azureConfig) (*azureSettings, error) {
}
}

pluginEnv, err := b.System().PluginEnv(ctx)
if err != nil {
return nil, fmt.Errorf("error loading plugin environment: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we consider logging the error instead of failing here? Or is the plugin env info important enough to warrant a failure?

Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

Looks good! Just one question on an error case

@austingebauer austingebauer deleted the fix-user-agent-attribution branch May 4, 2022 19:03
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.

2 participants