@@ -2,6 +2,7 @@ package client
22
33import (
44 "context"
5+ "errors"
56
67 "github.com/cloudquery/cq-provider-sdk/provider/diag"
78 "github.com/cloudquery/cq-provider-sdk/provider/schema"
@@ -38,24 +39,31 @@ func (c Client) WithOrg(org string) schema.ClientMeta {
3839
3940func Configure (logger hclog.Logger , config interface {}) (schema.ClientMeta , diag.Diagnostics ) {
4041 providerConfig := config .(* Config )
41- _ = providerConfig
42+ // validate provider config
43+ if providerConfig .AccessToken == "" {
44+ return nil , diag .FromError (errors .New ("missing personal access token in configuration" ), diag .ACCESS )
45+ }
46+ if len (providerConfig .Orgs ) == 0 {
47+ return nil , diag .FromError (errors .New ("no organizations defined in configuration " ), diag .ACCESS )
48+ }
49+
4250 ts := oauth2 .StaticTokenSource (
4351 & oauth2.Token {AccessToken : providerConfig .AccessToken },
4452 )
4553 tc := oauth2 .NewClient (context .Background (), ts )
4654
47- client := github .NewClient (tc )
55+ c := github .NewClient (tc )
4856
4957 // Init your client and 3rd party clients using the user's configuration
5058 // passed by the SDK providerConfig
5159 return & Client {
5260 logger : logger ,
5361 Github : GithubServices {
54- Teams : client .Teams ,
55- Billing : client .Billing ,
56- Repositories : client .Repositories ,
57- Organizations : client .Organizations ,
58- Issues : client .Issues ,
62+ Teams : c .Teams ,
63+ Billing : c .Billing ,
64+ Repositories : c .Repositories ,
65+ Organizations : c .Organizations ,
66+ Issues : c .Issues ,
5967 },
6068 Orgs : providerConfig .Orgs ,
6169 }, nil
0 commit comments