Skip to content

Commit

Permalink
Set context early on in LoadAndValidate to prevent NPE (#3800) (#6903)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 31, 2020
1 parent e6350b4 commit 230c2af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/3800.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Fixed crash due to nil context when loading credentials
```
3 changes: 2 additions & 1 deletion google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
c.Scopes = DefaultClientScopes
}

c.context = ctx

tokenSource, err := c.getTokenSource(c.Scopes)
if err != nil {
return err
Expand Down Expand Up @@ -318,7 +320,6 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
userAgent := fmt.Sprintf("%s %s", tfUserAgent, providerVersion)

c.client = client
c.context = ctx
c.userAgent = userAgent

// This base path and some others below need the version and possibly more of the path
Expand Down

0 comments on commit 230c2af

Please sign in to comment.