Repository navigation
Conversation
ValueMapper is now func(k *Key, value string) string, and Key.Section and Section.File reach the rest of the file, so a mapper can expand references to other sections or keys of its own (#357).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe the pull request
ValueMapperonly got the raw value, so a mapper couldn't tell which key it was mapping or read other keys, which is what #357 needs for${ENV||default}or%{section.key}style expansion.ValueMapperis nowfunc(k *Key, value string) string, and two accessors reach the rest of the file:Key.Section()andSection.File(). During a%(name)ssubstitution the referenced value is mapped with its own key, not the referencing one. The mapper runs without the file's lock held, so it can read other keys.This is a breaking change to the v2 API, so it should land before v2.0.0. A
func(string) stringsuch asos.ExpandEnvis wrapped asfunc(_ *ini.Key, v string) string { return os.ExpandEnv(v) }; the migration guide says so.Link to the issue: closes #357
Checklist
AI usage
Written by Amp (an AI coding agent) at the maintainer's request. Validation:
go test ./...andgo vet. The new test resolves${section.key}throughk.Section().File()and fails if a referenced value is mapped with the referencing key.