Skip to content

Commit

Permalink
Merge pull request #3674 from Azure/anshulvermapatel/cosmosdb-authori…
Browse files Browse the repository at this point in the history
…zer-context

Fixed context issue
  • Loading branch information
mociarain authored Jul 23, 2024
2 parents 5cddf25 + cb9a49b commit 4b35728
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/gorilla/sessions v1.2.2
github.com/hashicorp/go-multierror v1.1.1
github.com/itchyny/gojq v0.12.13
github.com/jewzaam/go-cosmosdb v0.0.0-20240603205015-e096456eff37
github.com/jewzaam/go-cosmosdb v0.0.0-20240723075448-058185e3c66d
github.com/jongio/azidext/go/azidext v0.5.0
github.com/microsoft/kiota-abstractions-go v1.2.0
github.com/microsoft/kiota-http-go v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ github.com/itchyny/gojq v0.12.13/go.mod h1:JzwzAqenfhrPUuwbmEz3nu3JQmFLlQTQMUcOd
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jewzaam/go-cosmosdb v0.0.0-20240603205015-e096456eff37 h1:69P76EErLYvPuva+ITbDvOIaA+KH9153kU8QeGhJijk=
github.com/jewzaam/go-cosmosdb v0.0.0-20240603205015-e096456eff37/go.mod h1:hEk8/SoE/NBT9ofV69Gzs98vbGyF155SaYl1p9bxKb8=
github.com/jewzaam/go-cosmosdb v0.0.0-20240723075448-058185e3c66d h1:2Xp2eP830w13cWq6sombl3EsBM46xYkdkLog8BgFWyQ=
github.com/jewzaam/go-cosmosdb v0.0.0-20240723075448-058185e3c66d/go.mod h1:hEk8/SoE/NBT9ofV69Gzs98vbGyF155SaYl1p9bxKb8=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
Expand Down
17 changes: 9 additions & 8 deletions pkg/database/cosmosdb/zz_generated_authorizer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/database/cosmosdb/zz_generated_cosmosdb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ func NewMasterKeyAuthorizer(ctx context.Context, log *logrus.Entry, token azcore
}

func NewTokenAuthorizer(ctx context.Context, log *logrus.Entry, cred azcore.TokenCredential, databaseAccountName string, scopes []string) (cosmosdb.Authorizer, error) {
acquireToken := func() (token string, newExpiration time.Time, err error) {
tk, err := cred.GetToken(ctx, azcorepolicy.TokenRequestOptions{Scopes: scopes})
acquireToken := func(contxt context.Context) (token string, newExpiration time.Time, err error) {
tk, err := cred.GetToken(contxt, azcorepolicy.TokenRequestOptions{Scopes: scopes})
if err != nil {
return "", time.Time{}, err
}
return tk.Token, tk.ExpiresOn, nil
}
tk, expiration, err := acquireToken()
tk, expiration, err := acquireToken(ctx)
if err != nil {
return nil, err
}
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ github.com/itchyny/gojq/cli
# github.com/itchyny/timefmt-go v0.1.5
## explicit; go 1.17
github.com/itchyny/timefmt-go
# github.com/jewzaam/go-cosmosdb v0.0.0-20240603205015-e096456eff37
# github.com/jewzaam/go-cosmosdb v0.0.0-20240723075448-058185e3c66d
## explicit; go 1.18
github.com/jewzaam/go-cosmosdb/cmd/gencosmosdb
github.com/jewzaam/go-cosmosdb/pkg/gencosmosdb
Expand Down

0 comments on commit 4b35728

Please sign in to comment.