File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ class GithubClient:
25
25
@classmethod
26
26
def from_repo_config (cls , repo_config : RepoConfig ) -> Self :
27
27
gh_wrapper = cls ()
28
- gh_wrapper .read_client = gh_wrapper ._create_client_for_repo (repo_config )
29
- gh_wrapper ._write_client = gh_wrapper ._create_client_for_repo (repo_config )
28
+ gh_wrapper .read_client = gh_wrapper ._create_client_for_repo (repo_config , github_scope = GithubScope . READ )
29
+ gh_wrapper ._write_client = gh_wrapper ._create_client_for_repo (repo_config , github_scope = GithubScope . WRITE )
30
30
return gh_wrapper
31
31
32
32
@classmethod
@@ -37,8 +37,8 @@ def from_token(cls, token: str | None = None) -> Self:
37
37
gh_wrapper ._write_client = Github (token , base_url = cls .base_url )
38
38
return gh_wrapper
39
39
40
- def _create_client_for_repo (self , repo_config : RepoConfig ) -> Github :
41
- token = get_token_for_repo_config (repo_config = repo_config , github_type = self .type )
40
+ def _create_client_for_repo (self , repo_config : RepoConfig , github_scope : GithubScope = GithubScope . READ ) -> Github :
41
+ token = get_token_for_repo_config (repo_config = repo_config , github_type = self .type , github_scope = github_scope )
42
42
return Github (token , base_url = self .base_url )
43
43
44
44
def _get_client_for_scope (self , github_scope : GithubScope ) -> Github :
Original file line number Diff line number Diff line change 1
1
import logging
2
2
3
3
from codegen .git .configs .config import config
4
- from codegen .git .schemas .github import GithubType
4
+ from codegen .git .schemas .github import GithubScope , GithubType
5
5
from codegen .git .schemas .repo_config import RepoConfig
6
6
7
7
logger = logging .getLogger (__name__ )
8
8
9
9
10
- def get_token_for_repo_config (repo_config : RepoConfig , github_type : GithubType = GithubType .GithubEnterprise ) -> str :
11
- # TODO: implement config such that we can retrieve tokens for different repos
10
+ def get_token_for_repo_config (
11
+ repo_config : RepoConfig ,
12
+ github_type : GithubType = GithubType .GithubEnterprise ,
13
+ github_scope : GithubScope = GithubScope .READ ,
14
+ ) -> str :
15
+ # TODO: implement config such that we can retrieve tokens for different repos + read/write scopes
12
16
if github_type == GithubType .GithubEnterprise :
13
17
return config .LOWSIDE_TOKEN
14
18
elif github_type == GithubType .Github :
You can’t perform that action at this time.
0 commit comments