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:
2525 @classmethod
2626 def from_repo_config (cls , repo_config : RepoConfig ) -> Self :
2727 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 )
3030 return gh_wrapper
3131
3232 @classmethod
@@ -37,8 +37,8 @@ def from_token(cls, token: str | None = None) -> Self:
3737 gh_wrapper ._write_client = Github (token , base_url = cls .base_url )
3838 return gh_wrapper
3939
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 )
4242 return Github (token , base_url = self .base_url )
4343
4444 def _get_client_for_scope (self , github_scope : GithubScope ) -> Github :
Original file line number Diff line number Diff line change 11import logging
22
33from codegen .git .configs .config import config
4- from codegen .git .schemas .github import GithubType
4+ from codegen .git .schemas .github import GithubScope , GithubType
55from codegen .git .schemas .repo_config import RepoConfig
66
77logger = logging .getLogger (__name__ )
88
99
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
1216 if github_type == GithubType .GithubEnterprise :
1317 return config .LOWSIDE_TOKEN
1418 elif github_type == GithubType .Github :
You can’t perform that action at this time.
0 commit comments