Skip to content

Commit

Permalink
GODRIVER-2911: Fix receiver names and remove authenticator field from…
Browse files Browse the repository at this point in the history
… structs that were automatically updated when not needed
  • Loading branch information
pmeredit committed Jun 14, 2024
1 parent 651af66 commit 6b16e91
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 237 deletions.
4 changes: 2 additions & 2 deletions x/mongo/driver/auth/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (oa *OIDCAuthenticator) getAccessToken(
}

oa.accessToken = cred.AccessToken
oa.tokenGenID += 1
oa.tokenGenID++
oa.cfg.Connection.SetOIDCTokenGenID(oa.tokenGenID)
if cred.RefreshToken != nil {
oa.refreshToken = cred.RefreshToken
Expand All @@ -154,7 +154,7 @@ func (oa *OIDCAuthenticator) getAccessTokenWithRefresh(
}

oa.accessToken = cred.AccessToken
oa.tokenGenID += 1
oa.tokenGenID++
oa.cfg.Connection.SetOIDCTokenGenID(oa.tokenGenID)
return cred.AccessToken, nil
}
Expand Down
10 changes: 5 additions & 5 deletions x/mongo/driver/operation/abort_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ func (at *AbortTransaction) ServerAPI(serverAPI *driver.ServerAPIOptions) *Abort
}

// Authenticator sets the authenticator to use for this operation.
func (a *AbortTransaction) Authenticator(authenticator driver.Authenticator) *AbortTransaction {
if a == nil {
a = new(AbortTransaction)
func (at *AbortTransaction) Authenticator(authenticator driver.Authenticator) *AbortTransaction {
if at == nil {
at = new(AbortTransaction)
}

a.authenticator = authenticator
return a
at.authenticator = authenticator
return at
}
10 changes: 5 additions & 5 deletions x/mongo/driver/operation/commit_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ func (ct *CommitTransaction) ServerAPI(serverAPI *driver.ServerAPIOptions) *Comm
}

// Authenticator sets the authenticator to use for this operation.
func (c *CommitTransaction) Authenticator(authenticator driver.Authenticator) *CommitTransaction {
if c == nil {
c = new(CommitTransaction)
func (ct *CommitTransaction) Authenticator(authenticator driver.Authenticator) *CommitTransaction {
if ct == nil {
ct = new(CommitTransaction)
}

c.authenticator = authenticator
return c
ct.authenticator = authenticator
return ct
}
11 changes: 0 additions & 11 deletions x/mongo/driver/operation/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type Count struct {

// CountResult represents a count result returned by the server.
type CountResult struct {
authenticator driver.Authenticator
// The number of documents found
N int64
}
Expand Down Expand Up @@ -324,13 +323,3 @@ func (c *Count) Authenticator(authenticator driver.Authenticator) *Count {
c.authenticator = authenticator
return c
}

// Authenticator sets the authenticator to use for this operation.
func (c *CountResult) Authenticator(authenticator driver.Authenticator) *CountResult {
if c == nil {
c = new(CountResult)
}

c.authenticator = authenticator
return c
}
21 changes: 5 additions & 16 deletions x/mongo/driver/operation/create_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type CreateIndexes struct {

// CreateIndexesResult represents a createIndexes result returned by the server.
type CreateIndexesResult struct {
authenticator driver.Authenticator
// If the collection was created automatically.
CreatedCollectionAutomatically bool
// The number of indexes existing after this command.
Expand Down Expand Up @@ -283,21 +282,11 @@ func (ci *CreateIndexes) Timeout(timeout *time.Duration) *CreateIndexes {
}

// Authenticator sets the authenticator to use for this operation.
func (c *CreateIndexes) Authenticator(authenticator driver.Authenticator) *CreateIndexes {
if c == nil {
c = new(CreateIndexes)
}

c.authenticator = authenticator
return c
}

// Authenticator sets the authenticator to use for this operation.
func (c *CreateIndexesResult) Authenticator(authenticator driver.Authenticator) *CreateIndexesResult {
if c == nil {
c = new(CreateIndexesResult)
func (ci *CreateIndexes) Authenticator(authenticator driver.Authenticator) *CreateIndexes {
if ci == nil {
ci = new(CreateIndexes)
}

c.authenticator = authenticator
return c
ci.authenticator = authenticator
return ci
}
34 changes: 6 additions & 28 deletions x/mongo/driver/operation/create_search_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ type CreateSearchIndexes struct {

// CreateSearchIndexResult represents a single search index result in CreateSearchIndexesResult.
type CreateSearchIndexResult struct {
authenticator driver.Authenticator
Name string
Name string
}

// CreateSearchIndexesResult represents a createSearchIndexes result returned by the server.
type CreateSearchIndexesResult struct {
authenticator driver.Authenticator
IndexesCreated []CreateSearchIndexResult
}

Expand Down Expand Up @@ -243,31 +241,11 @@ func (csi *CreateSearchIndexes) Timeout(timeout *time.Duration) *CreateSearchInd
}

// Authenticator sets the authenticator to use for this operation.
func (c *CreateSearchIndexes) Authenticator(authenticator driver.Authenticator) *CreateSearchIndexes {
if c == nil {
c = new(CreateSearchIndexes)
}

c.authenticator = authenticator
return c
}

// Authenticator sets the authenticator to use for this operation.
func (c *CreateSearchIndexResult) Authenticator(authenticator driver.Authenticator) *CreateSearchIndexResult {
if c == nil {
c = new(CreateSearchIndexResult)
}

c.authenticator = authenticator
return c
}

// Authenticator sets the authenticator to use for this operation.
func (c *CreateSearchIndexesResult) Authenticator(authenticator driver.Authenticator) *CreateSearchIndexesResult {
if c == nil {
c = new(CreateSearchIndexesResult)
func (csi *CreateSearchIndexes) Authenticator(authenticator driver.Authenticator) *CreateSearchIndexes {
if csi == nil {
csi = new(CreateSearchIndexes)
}

c.authenticator = authenticator
return c
csi.authenticator = authenticator
return csi
}
11 changes: 0 additions & 11 deletions x/mongo/driver/operation/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type Delete struct {

// DeleteResult represents a delete result returned by the server.
type DeleteResult struct {
authenticator driver.Authenticator
// Number of documents successfully deleted.
N int64
}
Expand Down Expand Up @@ -341,13 +340,3 @@ func (d *Delete) Authenticator(authenticator driver.Authenticator) *Delete {
d.authenticator = authenticator
return d
}

// Authenticator sets the authenticator to use for this operation.
func (d *DeleteResult) Authenticator(authenticator driver.Authenticator) *DeleteResult {
if d == nil {
d = new(DeleteResult)
}

d.authenticator = authenticator
return d
}
21 changes: 5 additions & 16 deletions x/mongo/driver/operation/drop_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type DropCollection struct {

// DropCollectionResult represents a dropCollection result returned by the server.
type DropCollectionResult struct {
authenticator driver.Authenticator
// The number of indexes in the dropped collection.
NIndexesWas int32
// The namespace of the dropped collection.
Expand Down Expand Up @@ -227,21 +226,11 @@ func (dc *DropCollection) Timeout(timeout *time.Duration) *DropCollection {
}

// Authenticator sets the authenticator to use for this operation.
func (d *DropCollection) Authenticator(authenticator driver.Authenticator) *DropCollection {
if d == nil {
d = new(DropCollection)
}

d.authenticator = authenticator
return d
}

// Authenticator sets the authenticator to use for this operation.
func (d *DropCollectionResult) Authenticator(authenticator driver.Authenticator) *DropCollectionResult {
if d == nil {
d = new(DropCollectionResult)
func (dc *DropCollection) Authenticator(authenticator driver.Authenticator) *DropCollection {
if dc == nil {
dc = new(DropCollection)
}

d.authenticator = authenticator
return d
dc.authenticator = authenticator
return dc
}
10 changes: 5 additions & 5 deletions x/mongo/driver/operation/drop_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ func (dd *DropDatabase) ServerAPI(serverAPI *driver.ServerAPIOptions) *DropDatab
}

// Authenticator sets the authenticator to use for this operation.
func (d *DropDatabase) Authenticator(authenticator driver.Authenticator) *DropDatabase {
if d == nil {
d = new(DropDatabase)
func (dd *DropDatabase) Authenticator(authenticator driver.Authenticator) *DropDatabase {
if dd == nil {
dd = new(DropDatabase)
}

d.authenticator = authenticator
return d
dd.authenticator = authenticator
return dd
}
11 changes: 0 additions & 11 deletions x/mongo/driver/operation/drop_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type DropIndexes struct {

// DropIndexesResult represents a dropIndexes result returned by the server.
type DropIndexesResult struct {
authenticator driver.Authenticator
// Number of indexes that existed before the drop was executed.
NIndexesWas int32
}
Expand Down Expand Up @@ -255,13 +254,3 @@ func (d *DropIndexes) Authenticator(authenticator driver.Authenticator) *DropInd
d.authenticator = authenticator
return d
}

// Authenticator sets the authenticator to use for this operation.
func (d *DropIndexesResult) Authenticator(authenticator driver.Authenticator) *DropIndexesResult {
if d == nil {
d = new(DropIndexesResult)
}

d.authenticator = authenticator
return d
}
23 changes: 6 additions & 17 deletions x/mongo/driver/operation/drop_search_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ type DropSearchIndex struct {

// DropSearchIndexResult represents a dropSearchIndex result returned by the server.
type DropSearchIndexResult struct {
authenticator driver.Authenticator
Ok int32
Ok int32
}

func buildDropSearchIndexResult(response bsoncore.Document) (DropSearchIndexResult, error) {
Expand Down Expand Up @@ -217,21 +216,11 @@ func (dsi *DropSearchIndex) Timeout(timeout *time.Duration) *DropSearchIndex {
}

// Authenticator sets the authenticator to use for this operation.
func (d *DropSearchIndex) Authenticator(authenticator driver.Authenticator) *DropSearchIndex {
if d == nil {
d = new(DropSearchIndex)
}

d.authenticator = authenticator
return d
}

// Authenticator sets the authenticator to use for this operation.
func (d *DropSearchIndexResult) Authenticator(authenticator driver.Authenticator) *DropSearchIndexResult {
if d == nil {
d = new(DropSearchIndexResult)
func (dsi *DropSearchIndex) Authenticator(authenticator driver.Authenticator) *DropSearchIndex {
if dsi == nil {
dsi = new(DropSearchIndex)
}

d.authenticator = authenticator
return d
dsi.authenticator = authenticator
return dsi
}
10 changes: 5 additions & 5 deletions x/mongo/driver/operation/end_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ func (es *EndSessions) ServerAPI(serverAPI *driver.ServerAPIOptions) *EndSession
}

// Authenticator sets the authenticator to use for this operation.
func (e *EndSessions) Authenticator(authenticator driver.Authenticator) *EndSessions {
if e == nil {
e = new(EndSessions)
func (es *EndSessions) Authenticator(authenticator driver.Authenticator) *EndSessions {
if es == nil {
es = new(EndSessions)
}

e.authenticator = authenticator
return e
es.authenticator = authenticator
return es
}
32 changes: 5 additions & 27 deletions x/mongo/driver/operation/find_and_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type FindAndModify struct {

// LastErrorObject represents information about updates and upserts returned by the server.
type LastErrorObject struct {
authenticator driver.Authenticator
// True if an update modified an existing document
UpdatedExisting bool
// Object ID of the upserted document.
Expand All @@ -67,7 +66,6 @@ type LastErrorObject struct {

// FindAndModifyResult represents a findAndModify result returned by the server.
type FindAndModifyResult struct {
authenticator driver.Authenticator
// Either the old or modified document, depending on the value of the new parameter.
Value bsoncore.Document
// Contains information about updates and upserts.
Expand Down Expand Up @@ -483,31 +481,11 @@ func (fam *FindAndModify) Timeout(timeout *time.Duration) *FindAndModify {
}

// Authenticator sets the authenticator to use for this operation.
func (f *FindAndModify) Authenticator(authenticator driver.Authenticator) *FindAndModify {
if f == nil {
f = new(FindAndModify)
}

f.authenticator = authenticator
return f
}

// Authenticator sets the authenticator to use for this operation.
func (l *LastErrorObject) Authenticator(authenticator driver.Authenticator) *LastErrorObject {
if l == nil {
l = new(LastErrorObject)
}

l.authenticator = authenticator
return l
}

// Authenticator sets the authenticator to use for this operation.
func (f *FindAndModifyResult) Authenticator(authenticator driver.Authenticator) *FindAndModifyResult {
if f == nil {
f = new(FindAndModifyResult)
func (fam *FindAndModify) Authenticator(authenticator driver.Authenticator) *FindAndModify {
if fam == nil {
fam = new(FindAndModify)
}

f.authenticator = authenticator
return f
fam.authenticator = authenticator
return fam
}
15 changes: 2 additions & 13 deletions x/mongo/driver/operation/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ func getFaasEnvName() string {
}

type containerInfo struct {
authenticator driver.Authenticator
runtime string
orchestrator string
runtime string
orchestrator string
}

// getContainerEnvInfo returns runtime and orchestrator of a container.
Expand Down Expand Up @@ -661,13 +660,3 @@ func (h *Hello) Authenticator(authenticator driver.Authenticator) *Hello {
h.authenticator = authenticator
return h
}

// Authenticator sets the authenticator to use for this operation.
func (c *containerInfo) Authenticator(authenticator driver.Authenticator) *containerInfo {
if c == nil {
c = new(containerInfo)
}

c.authenticator = authenticator
return c
}
Loading

0 comments on commit 6b16e91

Please sign in to comment.