Skip to content

Commit

Permalink
Rebased against master branch
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Wadsworth <brad.wadsworth@mavenwave.com>
  • Loading branch information
Brad Wadsworth committed Sep 23, 2022
1 parent 458f205 commit 884ac1f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/clients/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,19 @@ func UseProviderConfig(ctx context.Context, c client.Client, mg resource.Managed
return "", nil, errors.Wrap(err, "cannot get credentials")
}
if isJSON(data) {
return pc.Spec.ProjectID, option.WithCredentialsJSON(data), nil
opts = append(opts, option.WithCredentialsJSON(data))
} else {
t := oauth2.Token{
AccessToken: string(data),
}
if ok := t.Valid(); !ok {
return pc.Spec.ProjectID, opts, errors.New("Access token invalid")
}
ts := oauth2.StaticTokenSource(&t)
opts = append(opts, option.WithTokenSource(ts))
}
t := oauth2.Token{
AccessToken: string(data),
}
if ok := t.Valid(); !ok {
return pc.Spec.ProjectID, opts, errors.New("Access token invalid")
}
ts := oauth2.StaticTokenSource(&t)
return pc.Spec.ProjectID, option.WithTokenSource(ts), nil
}
return pc.Spec.ProjectID, opts, nil
}

func isJSON(b []byte) bool {
Expand Down

0 comments on commit 884ac1f

Please # to comment.