Exporter: fix generation of names for databricks_library
resources
#2832
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.
Changes
Internally, the exporter uses the following resource ID for
databricks_library
:<cluster_id>/<type>:coordinate
(i.e.,0426-122546-8xi8q5o3/pypi:chispa
).When generating the final name of the resource, this name is normalized and checked if it's starting with a number, as Terraform doesn't allow identifiers to start with a number. If the final name starts with a number, then the artificial final name is generated consisting in the form of
r<first 12 digits of MD5 of the original name>
. This leads to the generation of duplicate resources in case if cluster ID starts with a number, and the same library was attached to the cluster multiple times, having only differences in the character case, like,Chispa
andchispa
(our clusters UI allows that).This PR fixes this issue with the following changes:
lib_
prefix to the library name together with the first 8 numbers of the MD5 of the library IDr<first 12 digits of MD5 of the original name>
, calculate MD5 of the original string, not the lower-cased formPlease note that you will need to perform a full export because resource names has changed
Tests
make test
run locallydocs/
folderinternal/acceptance