-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AliasMangler #95
Merged
Merged
AliasMangler #95
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
// Package common provides constants that are used among different dials sources | ||
package common | ||
|
||
// DialsTagName is the name of the dials tag. | ||
const DialsTagName = "dials" | ||
const ( | ||
// DialsTagName is the name of the dials tag. | ||
DialsTagName = "dials" | ||
|
||
// DialsEnvTagName is the name of the dialsenv tag. | ||
DialsEnvTagName = "dialsenv" | ||
|
||
// DialsFlagTagName is the name of the dialsflag tag. | ||
DialsFlagTagName = "dialsflag" | ||
|
||
// DialsPFlagTagName is the name of the dialspflag tag. | ||
DialsPFlagTag = "dialspflag" | ||
|
||
// DialsFlagAliasTag is the name of the dialsflagalias tag. | ||
DialsPFlagShortTag = "dialspflagshort" | ||
|
||
// HelpTextTag is the name of the struct tag for flag descriptions | ||
DialsHelpTextTag = "dialsdesc" | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,16 +171,6 @@ func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ct | |
flagSrc = fset | ||
} | ||
|
||
// If file-watching is not enabled, we should shutdown the monitor | ||
// goroutine when exiting this function. | ||
// Usually `dials.Config` is smart enough not to start a monitor when | ||
// there are no `Watcher` implementations in the source-list, but the | ||
// `Blank` source uses `Watcher` for its core functionality, so we need | ||
// to shutdown the blank source to actually clean up resources. | ||
if !params.WatchConfigFile { | ||
defer blank.Done(ctx) | ||
} | ||
|
||
dp := dials.Params[T]{ | ||
// Set the OnNewConfig callback. It'll be suppressed by the | ||
// CallGlobalCallbacksAfterVerificationEnabled until just before we return. | ||
|
@@ -199,6 +189,16 @@ func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ct | |
return nil, err | ||
} | ||
|
||
// If file-watching is not enabled, we should shutdown the monitor | ||
// goroutine when exiting this function. | ||
// Usually `dials.Config` is smart enough not to start a monitor when | ||
// there are no `Watcher` implementations in the source-list, but the | ||
// `Blank` source uses `Watcher` for its core functionality, so we need | ||
// to shutdown the blank source to actually clean up resources. | ||
if !params.WatchConfigFile { | ||
defer blank.Done(ctx) | ||
} | ||
|
||
Comment on lines
+192
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we split this (unrelated) bug-fix into a different commit? (it can be the same PR, but it's super-confusing to have a move that's fixing a bug in the middle of a commit introducing a new feature) |
||
basecfg := d.View() | ||
cfgPath, filepathSet := (TP)(basecfg).ConfigPath() | ||
if !filepathSet { | ||
|
@@ -219,7 +219,8 @@ func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ct | |
return nil, fmt.Errorf("decoderFactory provided a nil decoder for path: %s", cfgPath) | ||
} | ||
|
||
manglers := make([]transform.Mangler, 0, 2) | ||
manglers := make([]transform.Mangler, 0, 3) | ||
manglers = append(manglers, transform.NewAliasMangler(common.DialsTagName)) | ||
|
||
if params.FileFieldNameEncoder != nil { | ||
tagDecoder := params.DialsTagNameDecoder | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should mention that this functionality is provided by a mangler upfront, so anyone who doesn't use the
ez
package isn't confused when it doesn't work out of the box.(I think there's a section in the README that you can link to that describes manglers -- we should add on if there isn't)