Backport of VAULT-32657 deprecate duplicate attributes in HCL configs and policies into release/1.19.x #30745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #30386 to be assessed for backporting due to the inclusion of the label backport/1.19.x.
🚨
The person who merged in the original PR is:
@bosouza
This person should resolve the merge-conflict(s) by either:
The below text is copied from the body of the original PR.
Description
This PR deprecates the usage of duplicate attributes in HCL configuration files and policy definitions. An example of a duplicate attribute is the following, which until support is fully removed will continue parsing to the last occurence of the attribute:
Following our deprecation process, these changes correspond to the deprecation phase to be announced in v1.20 (and cherry picked to v1.19, likely out in v1.19.4), implementing the following:
WARNING: Duplicate keys found
. A comprehensive list of those commands is:vault server
,vault operator migrate
,vault agent
,vault proxy
andvault operator diagnose
;$HOME/.vault
) with duplicate attributes will print a similarWARNING: Duplicate keys found
message;policy contains duplicate attributes
. These include initial caching of policies after unseal, reading policies via the API, using a token that references such a policy among others;Warnings
field in the server response.This was accomplished by upgrading the
hcl
dependency to reject duplicate attributes, and using the new functions exposed in hashicorp/hcl#707 to create a helper functionParseAndCheckForDuplicateHclAttributes
that parses the hcl and reports if there are duplicates.Unfortunately, the library also had a behavior change that I traced back to hashicorp/hcl@e80118a not being included in the
v1.0.1-vault-5
of the library we're using (as it was already included inv1.0.1-vault-4
). This means that an approach we've been using of double-parsing some config fields now doesn't work the same anymore, which I'm trying to fix by removing the automatic parsing from the fields that are manually parsed. More details on the specific commit message.Throughout the code I've left these
TODO (HCL_DUP_KEYS_DEPRECATION)
comments to more easily find all the places that will need to be changed/deleted after each of the following steps on the deprecation process.For 1.20 we will only have these warnings, but on v1.21 all the operations described above involving HCL definitions with duplicate attributes will simply fail. We will add an environment variable though to allow the behavior to be rolled back to a log-only mode, at least until the final removal is completed on a future version.
Jira: VAULT-32657
ADR: VLT-006: Deprecate and remove duplicate attributes in HCL files in Vault
TODO only if you're a HashiCorp employee
backport/
label that matches the desired release branch. Note that in the CE repo, the latest release branch will look likebackport/x.x.x
, but older release branches will bebackport/ent/x.x.x+ent
.of a public function, even if that change is in a CE file, double check that
applying the patch for this PR to the ENT repo and running tests doesn't
break any tests. Sometimes ENT only tests rely on public functions in CE
files.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.
Overview of commits