Repository navigation
fix: support StringMap values from map value sources (#1634) - #2473
Closed
manish-9245 wants to merge 1 commit into
Closed
manish-9245 wants to merge 1 commit into
manish-9245 wants to merge 1 commit into
Conversation
Map value source Lookup stringified map values with Go-syntax
fmt.Sprintf("%+v"), e.g. map[env:prod], which MapBase.Set rejects
with missing separator "=". Serialize map values through the same
NewStringMap(...).Serialize() path used for flag values so they
round-trip, while preserving scalar and slice formatting.
Fixes urfave#1634.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Member
|
Thanks for the PR, but this doesn't fix #1634. #1634 is about altsrc, i.e. loading flags from config files. In v3 that lives in urfave/cli-altsrc, which does not use For example, with this branch and cli-altsrc main, a labels:
env: prod&cli.StringMapFlag{
Name: "labels",
Sources: cli.NewValueSourceChain(yaml.YAML("labels", altsrc.StringSourcer("config.yaml"))),
}Merging this would still close #1634 because of "Fixes #1634". The same fix is already open for cli-altsrc in urfave/cli-altsrc#50, so let's continue there. Closing this one. |
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.
What type of PR is this?
What this PR does / why we need it:
Map value sources stringified map values with Go syntax (
fmt.Sprintf("%+v"), e.g.map[env:prod]), whichStringMap.Setrejects with a "missing separator =" error. TheLookupinvalue_source.gonow serializes map values through the samecli.NewStringMap(...).Serialize()path used for flag values, and keeps the scalar and slice behavior unchanged. A regression test covers a StringMap flag loaded from a map source.Which issue(s) this PR fixes:
Fixes #1634
Special notes for your reviewer:
The commands listed above are the ones that were actually run.
Testing
go build ./...,go test ./...,go test -run 'TestMapValueSource|TestStringMapFlagFromMapSource' -v .,gofmt -l(clean),go vet .(clean).Release Notes