Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/codegen/git/clients/github_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class GithubClient:
@classmethod
def from_repo_config(cls, repo_config: RepoConfig) -> Self:
gh_wrapper = cls()
gh_wrapper.read_client = gh_wrapper._create_client_for_repo(repo_config)
gh_wrapper._write_client = gh_wrapper._create_client_for_repo(repo_config)
gh_wrapper.read_client = gh_wrapper._create_client_for_repo(repo_config, github_scope=GithubScope.READ)
gh_wrapper._write_client = gh_wrapper._create_client_for_repo(repo_config, github_scope=GithubScope.WRITE)
return gh_wrapper

@classmethod
Expand All @@ -37,8 +37,8 @@ def from_token(cls, token: str | None = None) -> Self:
gh_wrapper._write_client = Github(token, base_url=cls.base_url)
return gh_wrapper

def _create_client_for_repo(self, repo_config: RepoConfig) -> Github:
token = get_token_for_repo_config(repo_config=repo_config, github_type=self.type)
def _create_client_for_repo(self, repo_config: RepoConfig, github_scope: GithubScope = GithubScope.READ) -> Github:
token = get_token_for_repo_config(repo_config=repo_config, github_type=self.type, github_scope=github_scope)
return Github(token, base_url=self.base_url)

def _get_client_for_scope(self, github_scope: GithubScope) -> Github:
Expand Down
10 changes: 7 additions & 3 deletions src/codegen/git/configs/token.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import logging

from codegen.git.configs.config import config
from codegen.git.schemas.github import GithubType
from codegen.git.schemas.github import GithubScope, GithubType
from codegen.git.schemas.repo_config import RepoConfig

logger = logging.getLogger(__name__)


def get_token_for_repo_config(repo_config: RepoConfig, github_type: GithubType = GithubType.GithubEnterprise) -> str:
# TODO: implement config such that we can retrieve tokens for different repos
def get_token_for_repo_config(
repo_config: RepoConfig,
github_type: GithubType = GithubType.GithubEnterprise,
github_scope: GithubScope = GithubScope.READ,
) -> str:
# TODO: implement config such that we can retrieve tokens for different repos + read/write scopes
if github_type == GithubType.GithubEnterprise:
return config.LOWSIDE_TOKEN
elif github_type == GithubType.Github:
Expand Down
Loading