Documentation
¶
Index ¶
- func CreateGitHubClient(ctx context.Context, token string) *github.Client
- func CreateOrUpdatePullRequest(ctx context.Context, owner, repo, branch, title, body string, ...) (*github.PullRequest, error)
- func IsEnterpriseURL(url string) bool
- type AuthService
- func (s *AuthService) ExchangeCodeForToken(ctx context.Context, code string) (*oauth2.Token, error)
- func (s *AuthService) GenerateJWT(user *github.User, email, token string) (string, error)
- func (s *AuthService) GetAuthorizationURL(state string) string
- func (s *AuthService) GetUserEmail(ctx context.Context, token *oauth2.Token) (string, error)
- func (s *AuthService) GetUserFromGitHub(ctx context.Context, token *oauth2.Token) (*github.User, error)
- func (s *AuthService) ValidateToken(tokenString string) (*JWTClaims, error)
- type Branch
- type DirectoryContent
- type ErrorResponse
- type FileContent
- type GitHubService
- func (s *GitHubService) GetEnterpriseOrganizations(ctx context.Context, token, enterpriseServer string) ([]*github.Organization, error)
- func (s *GitHubService) GetOrganizationRepositories(ctx context.Context, token, org, visibility string) ([]Repository, error)
- func (s *GitHubService) GetRepositories(ctx context.Context, token, visibility, affiliation string) ([]Repository, error)
- func (s *GitHubService) GetRepositoryBranches(ctx context.Context, token, owner, repo string) ([]Branch, error)
- func (s *GitHubService) GetRepositoryContent(ctx context.Context, token, owner, repo, path string, ref string) (interface{}, error)
- func (s *GitHubService) GetRepositoryPullRequests(ctx context.Context, token, owner, repo string, state, sort, direction string) ([]PullRequest, error)
- func (s *GitHubService) GetUserOrganizations(ctx context.Context, token string) ([]Organization, error)
- func (s *GitHubService) GetUserProfile(ctx context.Context, token string) (UserProfile, error)
- func (s *GitHubService) GetUserRepositories(ctx context.Context, token, username, visibility string) ([]Repository, error)
- func (s *GitHubService) IsRepositoryAccessible(ctx context.Context, token, owner, repo string) (bool, error)
- type JWTClaims
- func (c *JWTClaims) GetAudience() (jwt.ClaimStrings, error)
- func (c *JWTClaims) GetExpirationTime() (*jwt.NumericDate, error)
- func (c *JWTClaims) GetIssuedAt() (*jwt.NumericDate, error)
- func (c *JWTClaims) GetIssuer() (string, error)
- func (c *JWTClaims) GetNotBefore() (*jwt.NumericDate, error)
- func (c *JWTClaims) GetSubject() (string, error)
- func (c *JWTClaims) Valid() error
- type Organization
- type PullRequest
- type PullRequestResponse
- type PullRequestUser
- type Repository
- type UserProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGitHubClient ¶ added in v0.4.0
func CreateOrUpdatePullRequest ¶
func CreateOrUpdatePullRequest(ctx context.Context, owner, repo, branch, title, body string, githubConfig manifest.GitHubConfig, ) (*github.PullRequest, error)
func IsEnterpriseURL ¶ added in v0.4.0
IsEnterpriseURL checks if a URL is for a GitHub Enterprise instance
Types ¶
type AuthService ¶ added in v0.4.0
type AuthService struct {
// contains filtered or unexported fields
}
AuthService handles authentication related operations
func NewAuthService ¶ added in v0.4.0
func NewAuthService(config *config.Config) *AuthService
NewAuthService creates a new AuthService
func (*AuthService) ExchangeCodeForToken ¶ added in v0.4.0
ExchangeCodeForToken exchanges the authorization code for a token
func (*AuthService) GenerateJWT ¶ added in v0.4.0
GenerateJWT generates a JWT token for the user
func (*AuthService) GetAuthorizationURL ¶ added in v0.4.0
func (s *AuthService) GetAuthorizationURL(state string) string
GetAuthorizationURL returns the GitHub authorization URL
func (*AuthService) GetUserEmail ¶ added in v0.4.0
GetUserEmail gets the primary email of the user from GitHub
func (*AuthService) GetUserFromGitHub ¶ added in v0.4.0
func (s *AuthService) GetUserFromGitHub(ctx context.Context, token *oauth2.Token) (*github.User, error)
GetUserFromGitHub gets the user information from GitHub
func (*AuthService) ValidateToken ¶ added in v0.4.0
func (s *AuthService) ValidateToken(tokenString string) (*JWTClaims, error)
ValidateToken validates a JWT token
type Branch ¶ added in v0.4.0
type Branch struct {
Name string `json:"name"`
CommitSHA string `json:"commit_sha"`
Protected bool `json:"protected"`
IsDefault bool `json:"is_default,omitempty"`
}
Branch represents a GitHub repository branch
type DirectoryContent ¶ added in v0.4.0
type DirectoryContent []FileContent
DirectoryContent represents a directory listing from GitHub
type ErrorResponse ¶ added in v0.4.0
ErrorResponse represents an error response
type FileContent ¶ added in v0.4.0
type FileContent struct {
Name string `json:"name"`
Path string `json:"path"`
SHA string `json:"sha"`
Size int `json:"size"`
Type string `json:"type"` // "file" or "dir"
Content string `json:"content,omitempty"`
Encoding string `json:"encoding,omitempty"`
DownloadURL string `json:"download_url,omitempty"`
URL string `json:"url"`
HTMLURL string `json:"html_url,omitempty"`
}
FileContent represents a file content from GitHub
type GitHubService ¶ added in v0.4.0
type GitHubService struct {
// contains filtered or unexported fields
}
func NewGitHubService ¶ added in v0.4.0
func NewGitHubService(authService *AuthService) *GitHubService
NewGitHubService creates a new GitHubService
func (*GitHubService) GetEnterpriseOrganizations ¶ added in v0.4.0
func (s *GitHubService) GetEnterpriseOrganizations(ctx context.Context, token, enterpriseServer string) ([]*github.Organization, error)
GetEnterpriseOrganizations gets organizations for a GitHub Enterprise instance
func (*GitHubService) GetOrganizationRepositories ¶ added in v0.4.0
func (s *GitHubService) GetOrganizationRepositories(ctx context.Context, token, org, visibility string) ([]Repository, error)
GetOrganizationRepositories gets repositories for an organization
func (*GitHubService) GetRepositories ¶ added in v0.4.0
func (s *GitHubService) GetRepositories(ctx context.Context, token, visibility, affiliation string) ([]Repository, error)
GetRepositories gets repositories for the user
func (*GitHubService) GetRepositoryBranches ¶ added in v0.4.0
func (s *GitHubService) GetRepositoryBranches(ctx context.Context, token, owner, repo string) ([]Branch, error)
GetRepositoryBranches gets branches for a repository
func (*GitHubService) GetRepositoryContent ¶ added in v0.4.0
func (s *GitHubService) GetRepositoryContent(ctx context.Context, token, owner, repo, path string, ref string) (interface{}, error)
GetRepositoryContent gets content from a repository
func (*GitHubService) GetRepositoryPullRequests ¶ added in v0.4.0
func (s *GitHubService) GetRepositoryPullRequests(ctx context.Context, token, owner, repo string, state, sort, direction string) ([]PullRequest, error)
GetRepositoryPullRequests fetches pull requests for a repository from GitHub
func (*GitHubService) GetUserOrganizations ¶ added in v0.4.0
func (s *GitHubService) GetUserOrganizations(ctx context.Context, token string) ([]Organization, error)
GetUserOrganizations gets organizations for the authenticated user
func (*GitHubService) GetUserProfile ¶ added in v0.4.0
func (s *GitHubService) GetUserProfile(ctx context.Context, token string) (UserProfile, error)
GetUserProfile gets the user profile from GitHub
func (*GitHubService) GetUserRepositories ¶ added in v0.4.0
func (s *GitHubService) GetUserRepositories(ctx context.Context, token, username, visibility string) ([]Repository, error)
GetUserRepositories gets repositories for a specific user
func (*GitHubService) IsRepositoryAccessible ¶ added in v0.4.0
func (s *GitHubService) IsRepositoryAccessible(ctx context.Context, token, owner, repo string) (bool, error)
IsRepositoryAccessible checks if a repository is accessible
type JWTClaims ¶ added in v0.4.0
type JWTClaims struct {
UserID int64 `json:"user_id"`
Login string `json:"login"`
Email string `json:"email"`
AvatarURL string `json:"avatar_url"`
Name string `json:"name"`
GitHubToken string `json:"github_token"`
// Standard JWT claims
ExpiresAt int64 `json:"exp"`
IssuedAt int64 `json:"iat"`
}
JWTClaims represents the claims in the JWT token
func NewJWTClaims ¶ added in v0.4.0
func NewJWTClaims(userID int64, login, email, avatarURL, name, githubToken string, expiresIn time.Duration) JWTClaims
NewJWTClaims creates a new JWTClaims
func (*JWTClaims) GetAudience ¶ added in v0.4.0
func (c *JWTClaims) GetAudience() (jwt.ClaimStrings, error)
GetAudience implements the jwt.Claims interface
func (*JWTClaims) GetExpirationTime ¶ added in v0.4.0
func (c *JWTClaims) GetExpirationTime() (*jwt.NumericDate, error)
GetExpirationTime implements the jwt.Claims interface
func (*JWTClaims) GetIssuedAt ¶ added in v0.4.0
func (c *JWTClaims) GetIssuedAt() (*jwt.NumericDate, error)
GetIssuedAt implements the jwt.Claims interface
func (*JWTClaims) GetNotBefore ¶ added in v0.4.0
func (c *JWTClaims) GetNotBefore() (*jwt.NumericDate, error)
GetNotBefore implements the jwt.Claims interface
func (*JWTClaims) GetSubject ¶ added in v0.4.0
GetSubject implements the jwt.Claims interface
type Organization ¶ added in v0.4.0
type Organization struct {
ID int64 `json:"id"`
Login string `json:"login"`
Name string `json:"name,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
}
Organization represents a GitHub organization
type PullRequest ¶ added in v0.4.0
type PullRequest struct {
ID int64 `json:"id"`
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"` // "open", "closed"
User PullRequestUser `json:"user"`
Body string `json:"body"`
CreatedAt github.Timestamp `json:"created_at"`
UpdatedAt github.Timestamp `json:"updated_at"`
ClosedAt *github.Timestamp `json:"closed_at"`
MergedAt *github.Timestamp `json:"merged_at"`
HTMLURL string `json:"html_url"`
}
PullRequest represents a GitHub pull request
type PullRequestResponse ¶ added in v0.4.0
type PullRequestResponse struct {
PullRequests []PullRequest `json:"pull_requests"`
}
PullRequestResponse represents the response for a pull requests API request
type PullRequestUser ¶ added in v0.4.0
type PullRequestUser struct {
ID int64 `json:"id"`
Login string `json:"login"`
AvatarURL string `json:"avatar_url"`
HTMLURL string `json:"html_url"`
}
PullRequestUser represents a GitHub user who created or is assigned to a pull request
type Repository ¶ added in v0.4.0
type Repository struct {
ID int64 `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Description string `json:"description,omitempty"`
Private bool `json:"private"`
HTMLURL string `json:"html_url"`
CloneURL string `json:"clone_url,omitempty"`
SSHURL string `json:"ssh_url,omitempty"`
Owner struct {
Login string `json:"login"`
ID int64 `json:"id"`
AvatarURL string `json:"avatar_url"`
} `json:"owner"`
DefaultBranch string `json:"default_branch,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
IsEnterprise bool `json:"is_enterprise"`
Team string `json:"team,omitempty"`
ProdBranch string `json:"prodBranch,omitempty"`
DevBranch string `json:"devBranch,omitempty"`
}
Repository represents a GitHub repository
type UserProfile ¶ added in v0.4.0
type UserProfile struct {
ID int64 `json:"id"`
Login string `json:"login"`
Name string `json:"name"`
Email string `json:"email"`
AvatarURL string `json:"avatar_url"`
HTMLURL string `json:"html_url"`
Bio string `json:"bio,omitempty"`
Company string `json:"company,omitempty"`
Location string `json:"location,omitempty"`
}
UserProfile represents GitHub user information sent to the client