"""Configuration for GitHub client.""" import os from pydantic import model_validator from pydantic_settings import BaseSettings class GitHubConfig(BaseSettings): """Configuration for GitHub client. Locally, set GITHUB_TOKEN to the token value directly. In AWS Lambda, set GITHUB_TOKEN to the Secrets Manager secret name; the token will be fetched from Secrets Manager at runtime. """ github_token: str @model_validator(mode='after') def _resolve_secrets(self) -> 'GitHubConfig': """Fetch token from Secrets Manager when running in Lambda.""" if os.environ.get('AWS_LAMBDA_FUNCTION_NAME'): from github_client.secrets_manager import SecretsManagerClient if not self.github_token: raise ValueError('GITHUB_TOKEN must be set') self.github_token = SecretsManagerClient().get_github_token( self.github_token ) if not self.github_token: raise ValueError('GITHUB_TOKEN must be set') return self