[chore][confma] minor refactor of `enableMergeAppendOption` feature gate (#12976)
@mx-psi @dmitryax While working on my RFC, I realized that we can simplify the logic by moving the merge behavior into `conf.Merge`. Currently, the feature gate check happens externally, and we choose the merge option based on that. This PR moves the check inside `conf.Merge`. By doing this [converters](https://github.com/open-telemetry/opentelemetry-collector/blob/main/confmap/README.md) can also make use of this feature. There are no changes to any API signatures, so this doesn’t introduce any breaking changes. Let me know what you think about this.
This commit is contained in:
parent
4aaf5ee3ae
commit
5a9dbb5b02
|
|
@ -173,6 +173,10 @@ func (l *Conf) IsSet(key string) bool {
|
|||
// Merge merges the input given configuration into the existing config.
|
||||
// Note that the given map may be modified.
|
||||
func (l *Conf) Merge(in *Conf) error {
|
||||
if enableMergeAppendOption.IsEnabled() {
|
||||
// only use MergeAppend when enableMergeAppendOption featuregate is enabled.
|
||||
return l.mergeAppend(in)
|
||||
}
|
||||
return l.k.Merge(in.k)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,13 +183,8 @@ func (mr *Resolver) Resolve(ctx context.Context) (*Conf, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if enableMergeAppendOption.IsEnabled() {
|
||||
// only use MergeAppend when enableMergeAppendOption featuregate is enabled.
|
||||
err = retMap.mergeAppend(retCfgMap)
|
||||
} else {
|
||||
err = retMap.Merge(retCfgMap)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
if err := retMap.Merge(retCfgMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue