Add built-in key mapping options (SecretKeyMappingOptions)#123
Conversation
Agent-Logs-Url: https://github.com/Kralizek/AWSSecretsManagerConfigurationExtensions/sessions/6c69b9cf-ba50-4e85-8bca-87aa1b77b6b4 Co-authored-by: Kralizek <2458439+Kralizek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Kralizek/AWSSecretsManagerConfigurationExtensions/sessions/6c69b9cf-ba50-4e85-8bca-87aa1b77b6b4 Co-authored-by: Kralizek <2458439+Kralizek@users.noreply.github.com>
Kralizek
left a comment
There was a problem hiding this comment.
This looks very close. The implementation matches the direction of #121: SecretKeyMappingOptions is shared across all provider modes, mapping is centralized in SecretKeyMapper, RawKey stays pre-mapping, and DefaultKey is correctly passed to KeyGenerator after built-in mapping.
A few cleanup items before merging:
-
Please remove the
CHANGELOG.mdchanges from this PR. We decided not to add changelog entries for beta-internal changes until the final2.0.0release notes. The README andMIGRATION.mdupdates are fine. -
Please fix the migration guide wording that says
After (2.0.1+). This is still part of the2.0.0beta/final stabilization path, not a2.0.1change. Prefer wording likeAfter this changeorCurrent 2.0 beta / 2.0.0 final behavior. -
Please adjust the PR body’s mapping-pipeline description. The implementation does not simply “strip or normalize” first. For JSON keys, it extracts the JSON path from
RawKey, then either combines it with the mapped secret name or uses the JSON path directly, then prependsTargetSection.
No need to introduce inheritance between option classes.
Agent-Logs-Url: https://github.com/Kralizek/AWSSecretsManagerConfigurationExtensions/sessions/e7e93852-dea8-42fa-b5f2-41f1f01eaf9b Co-authored-by: Kralizek <2458439+Kralizek@users.noreply.github.com>
Done in f8d4d31:
|
|



Adds
SecretKeyMappingOptions— shared across all three provider modes — to handle common secret-name-to-config-key projection patterns without requiring a customKeyGenerator.Summary
New API
Exposed on all three options types as
options.KeyMapping.Mapping pipeline
Applied in order before
KeyGeneratoris called; the result becomesSecretKeyGeneratorContext.DefaultKey:RawKey, then either combine it with the mapped secret name (whenPrefixJsonKeysWithSecretName = true) or use the JSON path directly (whenfalse)SecretNamePathSeparatornormalization to the secret nameTargetSectionDefaultKeytoKeyGeneratorRawKeyretains the pre-mapping key.JsonPathis always computed fromRawKey.Usage examples
Breaking change
The default
SecretNamePathSeparator = "/"changes key generation for secrets with/-style names:/my-app/production/databasenow producesmy-app:production:database(not/my-app/production/database). SetSecretNamePathSeparator = nullto restore the previous verbatim behavior. SeeMIGRATION.mdfor details.CHANGELOG.mdis unchanged; entries for this feature are deferred to the final 2.0.0 release notes.How it was tested
SecretKeyMapperunit behavior (all option combinations, validation) and provider integration tests forKnownSecret,KnownSecrets, andDiscoverymodes across JSON and scalar secret types/-style secret names updated to assert the new default-mapped keys--warnaserrorChecklist
--warnaserror(zero warnings)