-
Notifications
You must be signed in to change notification settings - Fork 769
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
Adapter aliases: moved adapter related configs to bidder.yaml files #2353
Conversation
# Conflicts: # config/config.go
config/bidderinfo.go
Outdated
func (s *SyncerEndpoint) Override(original *SyncerEndpoint) *SyncerEndpoint { | ||
if s == nil && original == nil { | ||
return nil | ||
func ProcessBidderInfos(path string, confBidderInfos BidderInfos) (BidderInfos, []error) { |
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.
Nitpick: Could you re-name confBidderInfos
to configBidderInfos
config/bidderinfo.go
Outdated
|
||
for _, bidderConfig := range bidderConfigs { | ||
if bidderConfig.IsDir() { | ||
continue //or throw an error? |
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.
Have you decided if you are going to not throw an error here? If so, could you remove the comment?
config/bidderinfo.go
Outdated
// ToGVLVendorIDMap transforms a BidderInfos object to a map of bidder names to GVL id. Disabled | ||
// bidders are omitted from the result. | ||
func (infos BidderInfos) ToGVLVendorIDMap() map[openrtb_ext.BidderName]uint16 { | ||
m := make(map[openrtb_ext.BidderName]uint16, len(infos)) |
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.
Nitpick: Is there a more descriptive name we can use for this variable other than m
. I understand if you'd prefer to keep it this way.
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.
This is moved from another place, I didn't change content. Renamed for future convenience.
config/bidderinfo.go
Outdated
|
||
if s.RedirectURL != "" { | ||
copy.RedirectURL = s.RedirectURL | ||
// vlidateBidderInfos validates bidder endpoint, info and syncer data |
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.
Nitpick: Spelling error in comment (vlidate)
Also just wanted to comment highlighting the merge conflicts with bidderinfo., bidderinfo_test.go, adapter_util_test.go |
# Conflicts: # config/bidderinfo.go # config/bidderinfo_test.go # exchange/adapter_util_test.go
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.
Very minor comments
config/bidderinfo.go
Outdated
} | ||
|
||
bidderName := strings.Split(fileName, ".yaml") | ||
infos[(bidderName[0])] = info |
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.
Is it guaranteed that there will be data present at index 0 here? Just want to check
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.
good point. Added check if file is a yaml file and array len.
config/bidderinfo.go
Outdated
for _, v := range bidderInfo.Syncer.Supports { | ||
if !strings.EqualFold(v, "iframe") && !strings.EqualFold(v, "redirect") { | ||
return fmt.Errorf("syncer could not be created, invalid supported endpoint: %s", v) |
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.
Could this variable v
be more descriptive? I understand if you want to leave it the way it is, but I tend to like a little more from variable names
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.
Renamed
# Conflicts: # config/config.go # static/bidder-info/yssp.yaml
This looks good! I want to confirm that exchange about bidderInfos and viper is resolved before approving! |
# Conflicts: # static/bidder-info/adkernel.yaml # static/bidder-info/invibes.yaml # static/bidder-info/triplelift.yaml
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.
LGTM
config/bidderinfo.go
Outdated
infos[bidder] = info | ||
func validatePlatformInfo(info *PlatformInfo) error { | ||
if len(info.MediaTypes) == 0 { | ||
return errors.New("mediaTypes should be an array with at least one string element") |
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.
Nitpick: There is no need to include the wording "should be an array". Of course it's an array. Consider changing to an error along the line of "at least one meda type needs to be specified".
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.
Modified
} | ||
|
||
type infoReaderFromDisk struct { | ||
path string | ||
func applyBidderInfoConfigOverrides(configBidderInfos BidderInfos, fsBidderInfos BidderInfos) (BidderInfos, error) { |
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.
This is no longer necessary. We can let Viper take care of this work. You need to only give Viper the bidder infos before calling unmarshal and it will take care of the overrides:
func New(v *viper.Viper, bidderInfos BidderInfos) (*Configuration, error) {
var c Configuration
c.BidderInfos = bidderInfos
if err := v.Unmarshal(&c); err != nil {
return nil, fmt.Errorf("viper failed to unmarshal app config: %v", err)
}
...
This breaks is the legacy user sync url, which we can either choose to remove as part of this work or we alert applyBidderInfoConfigOverrides
to only apply the legacy user sync url override.
This also removes our ability to disallow certain parts of the config to be changed, like the maintainer or media types. The later can cause a problem if it's less restrictive.
I think we can either:
- Let Viper handle everything and remove the override code. This allows hosts to "shoot themselves in the foot", but there's nothing stop them from editing the bidder info files directly?
- Keep control of overrides and create a new BidderInfoOverride with less fields and leave the override code.
Thoughts?
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.
This is what you showed me on our very first discussion about the approach to support env variables.
We also had a discussion about it with Hans: #2353 (comment)
If I set c.BidderInfos = bidderInfos
and have env variable for at least one field for a bidder (for example endpoint) - it overrides the entire object for this bidder and sets "endpoint" only. Other data from yaml file is not present for this bidder after config umnarshalling.
I think we need to control overrides. I removed capabilities
from overrides, we can discuss what other fields should be removed. But I also think this is not obvious why some of the fields can be overridden and some not. Please advice.
v.BindEnv(adapterCfgPrefix+".xapi.username", "") | ||
v.BindEnv(adapterCfgPrefix+".xapi.password", "") | ||
v.BindEnv(adapterCfgPrefix+".xapi.tracker", "") | ||
v.BindEnv(adapterCfgPrefix+".endpointCompression", "") |
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.
There be in danger in allowing unrestricted overrides of capabilities.app.mediaTypes
and capabilities.site.mediaTypes
.
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.
removed support of the capabilities override
|
||
assert.Equal(t, "platform_id_override", cfg.BidderInfos["bidder1"].PlatformID) | ||
assert.Equal(t, "app_secret_override", cfg.BidderInfos["bidder1"].AppSecret) | ||
assert.Equal(t, "GZIP", cfg.BidderInfos["bidder1"].EndpointCompression) | ||
} |
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.
IMHO we don't need to test all of the env variables, just a few is fine to provide viper binding works ok. This seems a little too verbose IMHO.
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.
Removed some of checks
@@ -0,0 +1,3 @@ | |||
maintainer: | |||
email: 123 | |||
gvlVendorID: "42" |
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.
Why do we need do add this? Unit tests should cover this already.
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.
removed. Just wanted to test it with actual yaml file.
endpoints/events/vtrack.go
Outdated
@@ -267,7 +267,7 @@ func isAllowVastForBidder(bidder string, bidderInfos *config.BidderInfos, allowU | |||
// check if bidder is configured | |||
if b, ok := (*bidderInfos)[bidder]; bidderInfos != nil && ok { | |||
// check if bidder is enabled | |||
return b.Enabled && b.ModifyingVastXmlAllowed | |||
return !b.Disabled && b.ModifyingVastXmlAllowed |
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 recommend adding a helper method to bidder info so we can call .IsEnabled() instead of negating the disabled field. The later is harder to read and easier to miss.
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.
Agree, modified
13c2142
# Conflicts: # endpoints/openrtb2/test_utils.go
config/bidderinfo.go
Outdated
@@ -315,7 +319,7 @@ func validateCapabilities(info *CapabilitiesInfo, bidderName string) error { | |||
|
|||
func validatePlatformInfo(info *PlatformInfo) error { | |||
if len(info.MediaTypes) == 0 { | |||
return errors.New("mediaTypes should be an array with at least one string element") | |||
return errors.New("at least one meda type needs to be specified") |
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.
media has a typo 'meda'
# Conflicts: # config/config_test.go
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.
LGTM
* origin/master: (316 commits) Fix alt bidder code test broken by imp wrapper commit (prebid#2405) ImpWrapper (prebid#2375) Update sspBC adapter to v5.7 (prebid#2394) Change errors to warnings (prebid#2385) TheMediaGrid: support native mediaType (prebid#2377) Huaweiadsadapter gdpr (prebid#2345) Add alternatebiddercodes in Prebid request ext (prebid#2339) Changed FS bidder names to mixed case (prebid#2390) Load bidders names from file system in lowercase (prebid#2388) consumable adapter: add schain and coppa support (prebid#2361) Adapter aliases: moved adapter related configs to bidder.yaml files (prebid#2353) pubmatic adapter: add param prebiddealpriority (prebid#2281) Yieldlab Adapter: Add support for ad unit sizes (prebid#2364) GDPR: add enforce_algo config flag and convert enforce_purpose to bool (prebid#2330) Resolves CVE-2022-27664 (prebid#2376) AMP Endpoint: support parameters consentType and gdprApplies (prebid#2338) Dianomi - added usync for redirect (prebid#2368) Create issue_prioritization.yml (prebid#2372) Update yaml files for gzip supported bidders (prebid#2365) Adnuntius Adapter: Set no cookies as a parameter (prebid#2352) ...
…rebid#2353) * Adapter aliases: moved adapter related configs to bidder.yaml files * Moved adapter configs from config.go to bidder.yaml files * Removed ymal mappers * Clean up * Initial unit tests fix * Merge with latest master * Unit tests clean up * Added pbs.json or pbs.yaml config support * Fixes and unit tests, added ssyncer merge functions back * Merge fixes * Returned back adapter config set up using env variables * Unit tests fixes * Added test for adapter config overrides from environment variables * Minor improvements * Added more tests fro env variables, fixed mapstructures from bidder info * Code review refactoring * Code review refactoring and merge conflicts fixes * Typo fix Co-authored-by: vsolovei <[email protected]>
Docs update PR: prebid/prebid.github.io#4008