Skip to content

Commit

Permalink
Update Go version to 1.19 (prebid#2428)
Browse files Browse the repository at this point in the history
  • Loading branch information
4lexvav authored Oct 24, 2022
1 parent cac1ff6 commit d162aa9
Show file tree
Hide file tree
Showing 21 changed files with 169 additions and 202 deletions.
13 changes: 9 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a version of Go
"VARIANT": "1.16",
"VARIANT": "1.19",
// Options
"INSTALL_NODE": "false",
"NODE_VERSION": "lts/*"
}
},
"containerEnv": {
"GOPRIVATE": "${localEnv:GOPRIVATE}",
"GOFLAGS": "-buildvcs=false",
"PBS_GDPR_DEFAULT_VALUE": "0"
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.useGoProxyToCheckForToolUpdates": false,
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/usr/bin/bash"
}
},
"terminal.integrated.defaultProfile.linux": "bash",
"go.toolsManagement.checkForUpdates": "off",
"go.gopath": "/go",
//"go.toolsGopath": "/tmp/go",
},

// Add the IDs of extensions you want installed when the container is created.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.4
go-version: 1.19.2

- name: Checkout Merged Branch
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
validate:
strategy:
matrix:
go-version: [1.16.x, 1.17.x]
go-version: [1.18.x, 1.19.x]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y wget
WORKDIR /tmp
RUN wget https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz && \
tar -xf go1.16.4.linux-amd64.tar.gz && \
RUN wget https://dl.google.com/go/go1.19.2.linux-amd64.tar.gz && \
tar -xf go1.19.2.linux-amd64.tar.gz && \
mv go /usr/local
RUN mkdir -p /app/prebid-server/
WORKDIR /app/prebid-server/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Please consider [registering your Prebid Server](https://docs.prebid.org/prebid-

## Installation

First install [Go](https://golang.org/doc/install) version 1.16 or newer.
First install [Go](https://golang.org/doc/install) version 1.18 or newer.

Note that prebid-server is using [Go modules](https://blog.golang.org/using-go-modules).
We officially support the most recent two major versions of the Go runtime. However, if you'd like to use a version <1.13 and are inside GOPATH `GO111MODULE` needs to be set to `GO111MODULE=on`.
Expand Down
4 changes: 2 additions & 2 deletions analytics/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/prebid/prebid-server/config"
)

//Modules that need to be logged to need to be initialized here
// Modules that need to be logged to need to be initialized here
func NewPBSAnalytics(analytics *config.Analytics) analytics.PBSAnalyticsModule {
modules := make(enabledAnalytics, 0)
if len(analytics.File.Filename) > 0 {
Expand Down Expand Up @@ -40,7 +40,7 @@ func NewPBSAnalytics(analytics *config.Analytics) analytics.PBSAnalyticsModule {
return modules
}

//Collection of all the correctly configured analytics modules - implements the PBSAnalyticsModule interface
// Collection of all the correctly configured analytics modules - implements the PBSAnalyticsModule interface
type enabledAnalytics []analytics.PBSAnalyticsModule

func (ea enabledAnalytics) LogAuctionObject(ao *analytics.AuctionObject) {
Expand Down
10 changes: 5 additions & 5 deletions analytics/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type PBSAnalyticsModule interface {
LogNotificationEventObject(*NotificationEvent)
}

//Loggable object of a transaction at /openrtb2/auction endpoint
// Loggable object of a transaction at /openrtb2/auction endpoint
type AuctionObject struct {
Status int
Errors []error
Expand All @@ -35,7 +35,7 @@ type AuctionObject struct {
StartTime time.Time
}

//Loggable object of a transaction at /openrtb2/amp endpoint
// Loggable object of a transaction at /openrtb2/amp endpoint
type AmpObject struct {
Status int
Errors []error
Expand All @@ -46,7 +46,7 @@ type AmpObject struct {
StartTime time.Time
}

//Loggable object of a transaction at /openrtb2/video endpoint
// Loggable object of a transaction at /openrtb2/video endpoint
type VideoObject struct {
Status int
Errors []error
Expand All @@ -57,7 +57,7 @@ type VideoObject struct {
StartTime time.Time
}

//Loggable object of a transaction at /setuid
// Loggable object of a transaction at /setuid
type SetUIDObject struct {
Status int
Bidder string
Expand All @@ -66,7 +66,7 @@ type SetUIDObject struct {
Success bool
}

//Loggable object of a transaction at /cookie_sync
// Loggable object of a transaction at /cookie_sync
type CookieSyncObject struct {
Status int
Errors []error
Expand Down
16 changes: 8 additions & 8 deletions analytics/filesystem/file_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const (
NOTIFICATION_EVENT RequestType = "/event"
)

//Module that can perform transactional logging
// Module that can perform transactional logging
type FileLogger struct {
Logger *glog.Logger
}

//Writes AuctionObject to file
// Writes AuctionObject to file
func (f *FileLogger) LogAuctionObject(ao *analytics.AuctionObject) {
//Code to parse the object and log in a way required
var b bytes.Buffer
Expand All @@ -34,7 +34,7 @@ func (f *FileLogger) LogAuctionObject(ao *analytics.AuctionObject) {
f.Logger.Flush()
}

//Writes VideoObject to file
// Writes VideoObject to file
func (f *FileLogger) LogVideoObject(vo *analytics.VideoObject) {
//Code to parse the object and log in a way required
var b bytes.Buffer
Expand All @@ -43,7 +43,7 @@ func (f *FileLogger) LogVideoObject(vo *analytics.VideoObject) {
f.Logger.Flush()
}

//Logs SetUIDObject to file
// Logs SetUIDObject to file
func (f *FileLogger) LogSetUIDObject(so *analytics.SetUIDObject) {
//Code to parse the object and log in a way required
var b bytes.Buffer
Expand All @@ -52,7 +52,7 @@ func (f *FileLogger) LogSetUIDObject(so *analytics.SetUIDObject) {
f.Logger.Flush()
}

//Logs CookieSyncObject to file
// Logs CookieSyncObject to file
func (f *FileLogger) LogCookieSyncObject(cso *analytics.CookieSyncObject) {
//Code to parse the object and log in a way required
var b bytes.Buffer
Expand All @@ -61,7 +61,7 @@ func (f *FileLogger) LogCookieSyncObject(cso *analytics.CookieSyncObject) {
f.Logger.Flush()
}

//Logs AmpObject to file
// Logs AmpObject to file
func (f *FileLogger) LogAmpObject(ao *analytics.AmpObject) {
if ao == nil {
return
Expand All @@ -73,7 +73,7 @@ func (f *FileLogger) LogAmpObject(ao *analytics.AmpObject) {
f.Logger.Flush()
}

//Logs NotificationEvent to file
// Logs NotificationEvent to file
func (f *FileLogger) LogNotificationEventObject(ne *analytics.NotificationEvent) {
if ne == nil {
return
Expand All @@ -85,7 +85,7 @@ func (f *FileLogger) LogNotificationEventObject(ne *analytics.NotificationEvent)
f.Logger.Flush()
}

//Method to initialize the analytic module
// Method to initialize the analytic module
func NewFileLogger(filename string) (analytics.PBSAnalyticsModule, error) {
options := glog.LogOptions{
File: filename,
Expand Down
8 changes: 4 additions & 4 deletions currency/rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func NewRates(conversions map[string]map[string]float64) *Rates {
}

// GetRate returns the conversion rate between two currencies or:
// - An error if one of the currency strings is not well-formed
// - An error if any of the currency strings is not a recognized currency code.
// - A ConversionNotFoundError in case the conversion rate between the two
// given currencies is not in the currencies rates map
// - An error if one of the currency strings is not well-formed
// - An error if any of the currency strings is not a recognized currency code.
// - A ConversionNotFoundError in case the conversion rate between the two
// given currencies is not in the currencies rates map
func (r *Rates) GetRate(from, to string) (float64, error) {
var err error
fromUnit, err := currency.ParseISO(from)
Expand Down
17 changes: 2 additions & 15 deletions endpoints/cookie_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http/httptest"
"strings"
"testing"
"testing/iotest"
"time"

"github.com/prebid/prebid-server/analytics"
Expand Down Expand Up @@ -684,7 +685,7 @@ func TestCookieSyncParseRequest(t *testing.T) {
},
{
description: "HTTP Read Error",
givenBody: ErrReader(errors.New("anyError")),
givenBody: iotest.ErrReader(errors.New("anyError")),
givenGDPRConfig: config.GDPR{Enabled: true, DefaultValue: "0"},
givenCCPAEnabled: true,
expectedError: "Failed to read request body",
Expand Down Expand Up @@ -1826,20 +1827,6 @@ func (f FakeAccountsFetcher) FetchAccount(ctx context.Context, accountID string)
return nil, []error{errors.New("Account not found")}
}

// ErrReader returns an io.Reader that returns 0, err from all Read calls. This is added in
// Go 1.16. Copied here for now until we switch over.
func ErrReader(err error) io.Reader {
return &errReader{err: err}
}

type errReader struct {
err error
}

func (r *errReader) Read(p []byte) (int, error) {
return 0, r.err
}

type fakePermissions struct {
}

Expand Down
42 changes: 21 additions & 21 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,27 @@ func NewVideoEndpoint(
}

/*
1. Parse "storedrequestid" field from simplified endpoint request body.
2. If config flag to require that field is set (which it will be for us) and this field is not given then error out here.
3. Load the stored request JSON for the given storedrequestid, if the id was invalid then error out here.
4. Use "json-patch" 3rd party library to merge the request body JSON data into the stored request JSON data.
5. Unmarshal the merged JSON data into a Go structure.
6. Add fields from merged JSON data that correspond to an OpenRTB request into the OpenRTB bid request we are building.
a. Unmarshal certain OpenRTB defined structs directly into the OpenRTB bid request.
b. In cases where customized logic is needed just copy/fill the fields in directly.
7. Call setFieldsImplicitly from auction.go to get basic data from the HTTP request into an OpenRTB bid request to start building the OpenRTB bid request.
8. Loop through ad pods to build array of Imps into OpenRTB request, for each pod:
a. Load the stored impression to use as the basis for impressions generated for this pod from the configid field.
b. NumImps = adpoddurationsec / MIN_VALUE(allowedDurations)
c. Build impression array for this pod:
I.Create array of NumImps entries initialized to the base impression loaded from the configid.
1. If requireexactdurations = true, iterate over allowdDurations and for (NumImps / len(allowedDurations)) number of Imps set minduration = maxduration = allowedDurations[i]
2. If requireexactdurations = false, set maxduration = MAX_VALUE(allowedDurations)
II. Set Imp.id field to "podX_Y" where X is the pod index and Y is the impression index within this pod.
d. Append impressions for this pod to the overall list of impressions in the OpenRTB bid request.
9. Call validateRequest() function from auction.go to validate the generated request.
10. Call HoldAuction() function to run the auction for the OpenRTB bid request that was built in the previous step.
11. Build proper response format.
1. Parse "storedrequestid" field from simplified endpoint request body.
2. If config flag to require that field is set (which it will be for us) and this field is not given then error out here.
3. Load the stored request JSON for the given storedrequestid, if the id was invalid then error out here.
4. Use "json-patch" 3rd party library to merge the request body JSON data into the stored request JSON data.
5. Unmarshal the merged JSON data into a Go structure.
6. Add fields from merged JSON data that correspond to an OpenRTB request into the OpenRTB bid request we are building.
a. Unmarshal certain OpenRTB defined structs directly into the OpenRTB bid request.
b. In cases where customized logic is needed just copy/fill the fields in directly.
7. Call setFieldsImplicitly from auction.go to get basic data from the HTTP request into an OpenRTB bid request to start building the OpenRTB bid request.
8. Loop through ad pods to build array of Imps into OpenRTB request, for each pod:
a. Load the stored impression to use as the basis for impressions generated for this pod from the configid field.
b. NumImps = adpoddurationsec / MIN_VALUE(allowedDurations)
c. Build impression array for this pod:
I.Create array of NumImps entries initialized to the base impression loaded from the configid.
1. If requireexactdurations = true, iterate over allowdDurations and for (NumImps / len(allowedDurations)) number of Imps set minduration = maxduration = allowedDurations[i]
2. If requireexactdurations = false, set maxduration = MAX_VALUE(allowedDurations)
II. Set Imp.id field to "podX_Y" where X is the pod index and Y is the impression index within this pod.
d. Append impressions for this pod to the overall list of impressions in the OpenRTB bid request.
9. Call validateRequest() function from auction.go to validate the generated request.
10. Call HoldAuction() function to run the auction for the OpenRTB bid request that was built in the previous step.
11. Build proper response format.
*/
func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
start := time.Now()
Expand Down
8 changes: 4 additions & 4 deletions exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4196,13 +4196,13 @@ func TestCallSignHeader(t *testing.T) {
}

/*
TestOverrideConfigAlternateBidderCodesWithRequestValues makes sure that the correct alternabiddercodes list is forwarded to the adapters and only the approved bids are returned in auction response.
TestOverrideConfigAlternateBidderCodesWithRequestValues makes sure that the correct alternabiddercodes list is forwarded to the adapters and only the approved bids are returned in auction response.
1. request.ext.prebid.alternatebiddercodes has priority over the content of config.Account.Alternatebiddercodes.
1. request.ext.prebid.alternatebiddercodes has priority over the content of config.Account.Alternatebiddercodes.
2. request is updated with config.Account.Alternatebiddercodes values if request.ext.prebid.alternatebiddercodes is empty or not specified.
2. request is updated with config.Account.Alternatebiddercodes values if request.ext.prebid.alternatebiddercodes is empty or not specified.
3. request.ext.prebid.alternatebiddercodes is given priority over config.Account.Alternatebiddercodes if both are specified.
3. request.ext.prebid.alternatebiddercodes is given priority over config.Account.Alternatebiddercodes if both are specified.
*/
func TestOverrideConfigAlternateBidderCodesWithRequestValues(t *testing.T) {
type testIn struct {
Expand Down
10 changes: 5 additions & 5 deletions firstpartydata/first_party_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func ExtractGlobalFPD(req *openrtb_ext.RequestWrapper) (map[string][]byte, error
return fpdReqData, nil
}

//ExtractOpenRtbGlobalFPD extracts and deletes user.data and {app/site}.content.data from request
// ExtractOpenRtbGlobalFPD extracts and deletes user.data and {app/site}.content.data from request
func ExtractOpenRtbGlobalFPD(bidRequest *openrtb2.BidRequest) map[string][]openrtb2.Data {

openRtbGlobalFPD := make(map[string][]openrtb2.Data, 3)
Expand All @@ -121,7 +121,7 @@ func ExtractOpenRtbGlobalFPD(bidRequest *openrtb2.BidRequest) map[string][]openr

}

//ResolveFPD consolidates First Party Data from different sources and returns valid FPD that will be applied to bidders later or returns errors
// ResolveFPD consolidates First Party Data from different sources and returns valid FPD that will be applied to bidders later or returns errors
func ResolveFPD(bidRequest *openrtb2.BidRequest, fpdBidderConfigData map[openrtb_ext.BidderName]*openrtb_ext.ORTB2, globalFPD map[string][]byte, openRtbGlobalFPD map[string][]openrtb2.Data, biddersWithGlobalFPD []string) (map[openrtb_ext.BidderName]*ResolvedFirstPartyData, []error) {
var errL []error

Expand Down Expand Up @@ -248,7 +248,7 @@ func unmarshalJSONToContent(input json.RawMessage) (*openrtb2.Content, error) {
return &result, err
}

//resolveExtension inserts remaining {site/app/user} attributes back to {site/app/user}.ext.data
// resolveExtension inserts remaining {site/app/user} attributes back to {site/app/user}.ext.data
func resolveExtension(fpdConfig map[string]json.RawMessage, originalExt json.RawMessage) ([]byte, error) {
resExt := originalExt
var err error
Expand Down Expand Up @@ -603,7 +603,7 @@ func buildExtData(data []byte) []byte {
return res
}

//ExtractBidderConfigFPD extracts bidder specific configs from req.ext.prebid.bidderconfig
// ExtractBidderConfigFPD extracts bidder specific configs from req.ext.prebid.bidderconfig
func ExtractBidderConfigFPD(reqExt *openrtb_ext.RequestExt) (map[openrtb_ext.BidderName]*openrtb_ext.ORTB2, error) {

fpd := make(map[openrtb_ext.BidderName]*openrtb_ext.ORTB2)
Expand Down Expand Up @@ -642,7 +642,7 @@ func ExtractBidderConfigFPD(reqExt *openrtb_ext.RequestExt) (map[openrtb_ext.Bid

}

//ExtractFPDForBidders extracts FPD data from request if specified
// ExtractFPDForBidders extracts FPD data from request if specified
func ExtractFPDForBidders(req *openrtb_ext.RequestWrapper) (map[openrtb_ext.BidderName]*ResolvedFirstPartyData, []error) {

reqExt, err := req.GetRequestExt()
Expand Down
Loading

0 comments on commit d162aa9

Please sign in to comment.