Documentation ¶
Overview ¶
Package provider provides an interface for querying git provider APIs
Index ¶
- func IsHosted(u string) bool
- func MigrateWiki(repo *GitRepository, id *auth.ID) error
- func ToGitLabelStringSlice(labels []GitLabel) *[]string
- func UsersToString(users []GitUser) *[]string
- type CachedIssue
- type CachedRepo
- type FakeIssue
- type FakeProvider
- func (f *FakeProvider) CreateIssue(issue *GitIssue) (*GitIssue, error)
- func (f *FakeProvider) CreateIssueComment(issueNum int, comment *GitIssueComment) error
- func (f *FakeProvider) CreateLabel(label *GitLabel) (*GitLabel, error)
- func (f *FakeProvider) CreateRepository(srcRepo *GitRepository) (*GitRepository, error)
- func (f *FakeProvider) GetAuth() *auth.ID
- func (f *FakeProvider) GetComments(pid, issueNum int, repo string) ([]*GitIssueComment, error)
- func (f *FakeProvider) GetImportProgress(repo string) (string, error)
- func (f *FakeProvider) GetIssues(pid int, repo string) ([]*GitIssue, error)
- func (f *FakeProvider) GetLabels(pid int, repo string) ([]*GitLabel, error)
- func (f *FakeProvider) GetRepositories() ([]*GitRepository, error)
- func (f *FakeProvider) MigrateRepo(repo *GitRepository, token string) (string, error)
- type FakeRepository
- type GitIssue
- type GitIssueComment
- type GitLabel
- type GitProvider
- func NewFakeProvider() GitProvider
- func NewGithubProvider(ctx context.Context, id *auth.ID) (GitProvider, error)
- func NewGitlabProvider(id *auth.ID) (GitProvider, error)
- func WithGithubClient(ctx context.Context, client *github.Client, id *auth.ID) GitProvider
- func WithGitlabClient(client *gitlab.Client, id *auth.ID) GitProvider
- type GitRepository
- type GitUser
- type GithubProvider
- func (g *GithubProvider) CreateIssue(issue *GitIssue) (*GitIssue, error)
- func (g *GithubProvider) CreateIssueComment(issueNum int, comment *GitIssueComment) error
- func (g *GithubProvider) CreateLabel(srcLabel *GitLabel) (*GitLabel, error)
- func (g *GithubProvider) CreateRepository(srcRepo *GitRepository) (*GitRepository, error)
- func (g *GithubProvider) GetAuth() *auth.ID
- func (g *GithubProvider) GetComments(pid, issueNum int, repo string) ([]*GitIssueComment, error)
- func (g *GithubProvider) GetImportProgress(repoName string) (string, error)
- func (g *GithubProvider) GetIssues(pid int, repo string) ([]*GitIssue, error)
- func (g *GithubProvider) GetLabels(pid int, repo string) ([]*GitLabel, error)
- func (g *GithubProvider) GetRepositories() ([]*GitRepository, error)
- func (g *GithubProvider) LoadCache() error
- func (g *GithubProvider) MigrateRepo(repo *GitRepository, token string) (string, error)
- func (g *GithubProvider) NewCachedIssue(issue *GitIssue) *CachedIssue
- func (g *GithubProvider) NewCachedRepo(repo *GitRepository)
- func (g *GithubProvider) PrintCache()
- func (g *GithubProvider) RepositoryExists(name string) bool
- type GitlabProvider
- func (g *GitlabProvider) CreateIssue(issue *GitIssue) (*GitIssue, error)
- func (g *GitlabProvider) CreateIssueComment(issueNum int, comment *GitIssueComment) error
- func (g *GitlabProvider) CreateLabel(label *GitLabel) (*GitLabel, error)
- func (g *GitlabProvider) CreateRepository(repo *GitRepository) (*GitRepository, error)
- func (g *GitlabProvider) GetAuth() *auth.ID
- func (g *GitlabProvider) GetComments(pid, issueNum int, repo string) ([]*GitIssueComment, error)
- func (g *GitlabProvider) GetImportProgress(repo string) (string, error)
- func (g *GitlabProvider) GetIssues(pid int, repo string) ([]*GitIssue, error)
- func (g *GitlabProvider) GetLabels(pid int, repo string) ([]*GitLabel, error)
- func (g *GitlabProvider) GetRepositories() ([]*GitRepository, error)
- func (g *GitlabProvider) GetUserByID(uid int) *GitUser
- func (g *GitlabProvider) MigrateRepo(repo *GitRepository, token string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateWiki ¶
func MigrateWiki(repo *GitRepository, id *auth.ID) error
func ToGitLabelStringSlice ¶
ToGitLabelStringSlice converts a list of GitLabels to a list of strings
func UsersToString ¶
UsersToString converts a list of GitUsers to a pointer to a slice of user strings
Types ¶
type CachedIssue ¶
type CachedIssue struct { Issue *GitIssue Comments map[time.Time]*GitIssueComment // contains filtered or unexported fields }
type CachedRepo ¶
type CachedRepo struct { Repo *GitRepository Issues map[string]*CachedIssue Labels map[string]*GitLabel // contains filtered or unexported fields }
type FakeIssue ¶
type FakeIssue struct { Issue *GitIssue Comments []*GitIssueComment }
FakeIssue stores information about git issues and their associated comments
type FakeProvider ¶
FakeProvider stores a thread safe hashmap of repository data
func (*FakeProvider) CreateIssue ¶
func (f *FakeProvider) CreateIssue(issue *GitIssue) (*GitIssue, error)
CreateIssue creates a new fake issue
func (*FakeProvider) CreateIssueComment ¶
func (f *FakeProvider) CreateIssueComment(issueNum int, comment *GitIssueComment) error
CreateIssueComment creates a new fake issue comment
func (*FakeProvider) CreateLabel ¶
func (f *FakeProvider) CreateLabel(label *GitLabel) (*GitLabel, error)
CreateLabel creates a new fake issue label
func (*FakeProvider) CreateRepository ¶
func (f *FakeProvider) CreateRepository(srcRepo *GitRepository) (*GitRepository, error)
CreateRepository creates a new Fake repository
func (*FakeProvider) GetAuth ¶
func (f *FakeProvider) GetAuth() *auth.ID
GetAuthToken returns a string with a user's api authentication token
func (*FakeProvider) GetComments ¶
func (f *FakeProvider) GetComments(pid, issueNum int, repo string) ([]*GitIssueComment, error)
GetComments gets the fake provider's comments
func (*FakeProvider) GetImportProgress ¶
func (f *FakeProvider) GetImportProgress(repo string) (string, error)
func (*FakeProvider) GetIssues ¶
func (f *FakeProvider) GetIssues(pid int, repo string) ([]*GitIssue, error)
GetIssues gets the fake provider's issues
func (*FakeProvider) GetLabels ¶
func (f *FakeProvider) GetLabels(pid int, repo string) ([]*GitLabel, error)
GetLabels gets the fake provider's labels
func (*FakeProvider) GetRepositories ¶
func (f *FakeProvider) GetRepositories() ([]*GitRepository, error)
GetRepositories gets the fake provider's repositories
func (*FakeProvider) MigrateRepo ¶
func (f *FakeProvider) MigrateRepo(repo *GitRepository, token string) (string, error)
MigrateRepo migrates a git repo from an existing provider
type FakeRepository ¶
type FakeRepository struct { GitRepo *GitRepository Issues *sync.Map Labels []*GitLabel Private bool Description string // contains filtered or unexported fields }
FakeRepository stores information about a new git repository
type GitIssue ¶
type GitIssue struct { Repo string PID int Number int Title string Body string State string Labels []GitLabel User *GitUser Assignees []GitUser }
GitIssue stores general git SaaS issue data
type GitIssueComment ¶
type GitIssueComment struct { Repo string IssueNum int User GitUser Body string CreatedAt time.Time UpdatedAt time.Time }
GitIssueComment stores general SaaS git issue comment data
type GitLabel ¶
GitLabel stores general git SaaS label data
func ToGitLabels ¶
ToGitLabels converts a list of strings into a list of GitLabels
type GitProvider ¶
type GitProvider interface { // Create methods CreateRepository(*GitRepository) (*GitRepository, error) CreateIssue(*GitIssue) (*GitIssue, error) CreateIssueComment(int, *GitIssueComment) error CreateLabel(*GitLabel) (*GitLabel, error) MigrateRepo(*GitRepository, string) (string, error) // Read methods GetRepositories() ([]*GitRepository, error) GetIssues(int, string) ([]*GitIssue, error) GetComments(int, int, string) ([]*GitIssueComment, error) GetLabels(int, string) ([]*GitLabel, error) GetAuth() *auth.ID GetImportProgress(string) (string, error) }
GitProvider
func NewFakeProvider ¶
func NewFakeProvider() GitProvider
NewFakeProvider creates a new fake provider
func NewGithubProvider ¶
NewGithubProvider creates a new GitHub clients which implements the provider interface
func NewGitlabProvider ¶
func NewGitlabProvider(id *auth.ID) (GitProvider, error)
NewGitlabProvider creates a new GitLab client which implements the provider interface
func WithGithubClient ¶
WithGithubClient creates a new GitProvider with a GitHub client
func WithGitlabClient ¶
func WithGitlabClient(client *gitlab.Client, id *auth.ID) GitProvider
WithGitlabClient creates a new GitProvider with a Gitlab client This function is exported to create mock clients in tests
type GitRepository ¶
type GitRepository struct { Name string Description string CloneURL string SSHURL string Owner string Archived bool Fork bool Empty bool PID int }
GitRepository stores general git repository data
type GithubProvider ¶
type GithubProvider struct { Client *github.Client Context context.Context ID *auth.ID Repocache map[string]*CachedRepo Members map[string]*github.User // contains filtered or unexported fields }
GitHubProvider implements the provider interface for GitHub
func (*GithubProvider) CreateIssue ¶
func (g *GithubProvider) CreateIssue(issue *GitIssue) (*GitIssue, error)
CreateIssue creates a new GitHub issue
func (*GithubProvider) CreateIssueComment ¶
func (g *GithubProvider) CreateIssueComment(issueNum int, comment *GitIssueComment) error
CreateIssueComment creates a new GitHub issue comment
func (*GithubProvider) CreateLabel ¶
func (g *GithubProvider) CreateLabel(srcLabel *GitLabel) (*GitLabel, error)
CreateLabel creates a new GitHub issue label
func (*GithubProvider) CreateRepository ¶
func (g *GithubProvider) CreateRepository(srcRepo *GitRepository) (*GitRepository, error)
CreateRepository creates a new GitHub repository
func (*GithubProvider) GetAuth ¶
func (g *GithubProvider) GetAuth() *auth.ID
GetAuth returns a string with a user's api authentication token
func (*GithubProvider) GetComments ¶
func (g *GithubProvider) GetComments(pid, issueNum int, repo string) ([]*GitIssueComment, error)
GetComments retrieves a list of issue comments associated with a GitHub issue
func (*GithubProvider) GetImportProgress ¶
func (g *GithubProvider) GetImportProgress(repoName string) (string, error)
GetImportProgress checks the progress of a previously started GitHub import
func (*GithubProvider) GetIssues ¶
func (g *GithubProvider) GetIssues(pid int, repo string) ([]*GitIssue, error)
GetIssues retrieves a list of issues associated with a GitHub repository
func (*GithubProvider) GetLabels ¶
func (g *GithubProvider) GetLabels(pid int, repo string) ([]*GitLabel, error)
GetLabels retrieves a list of labels associated with a GitHub repository
func (*GithubProvider) GetRepositories ¶
func (g *GithubProvider) GetRepositories() ([]*GitRepository, error)
GetRepositories retrieves a list of GitHub repositories for the organization/owner
func (*GithubProvider) LoadCache ¶
func (g *GithubProvider) LoadCache() error
func (*GithubProvider) MigrateRepo ¶
func (g *GithubProvider) MigrateRepo(repo *GitRepository, token string) (string, error)
MigrateRepo migrates a repo from an existing provider into GitHub
func (*GithubProvider) NewCachedIssue ¶
func (g *GithubProvider) NewCachedIssue(issue *GitIssue) *CachedIssue
func (*GithubProvider) NewCachedRepo ¶
func (g *GithubProvider) NewCachedRepo(repo *GitRepository)
func (*GithubProvider) PrintCache ¶
func (g *GithubProvider) PrintCache()
func (*GithubProvider) RepositoryExists ¶
func (g *GithubProvider) RepositoryExists(name string) bool
RepositoryExists checks if a given repostory already exists in GitHub
type GitlabProvider ¶
GitlabProvider implements the provider interface for GitLab
func (*GitlabProvider) CreateIssue ¶
func (g *GitlabProvider) CreateIssue(issue *GitIssue) (*GitIssue, error)
CreateIssue creates a new GitLab issue
func (*GitlabProvider) CreateIssueComment ¶
func (g *GitlabProvider) CreateIssueComment(issueNum int, comment *GitIssueComment) error
CreateIssueComment creates a new GitLab issue note/comment
func (*GitlabProvider) CreateLabel ¶
func (g *GitlabProvider) CreateLabel(label *GitLabel) (*GitLabel, error)
CreateLabel creates a new GitLab issue label
func (*GitlabProvider) CreateRepository ¶
func (g *GitlabProvider) CreateRepository(repo *GitRepository) (*GitRepository, error)
CreateRepository creates a new GitLab repository
func (*GitlabProvider) GetAuth ¶
func (g *GitlabProvider) GetAuth() *auth.ID
GetAuthToken returns a string with a user's api authentication token
func (*GitlabProvider) GetComments ¶
func (g *GitlabProvider) GetComments(pid, issueNum int, repo string) ([]*GitIssueComment, error)
GetComments retrieves a full list of comments for a project issue For >100 comments this _depaginates_ the responses and appends them to one slice
func (*GitlabProvider) GetImportProgress ¶
func (g *GitlabProvider) GetImportProgress(repo string) (string, error)
func (*GitlabProvider) GetIssues ¶
func (g *GitlabProvider) GetIssues(pid int, repo string) ([]*GitIssue, error)
GetIssues retrieves a full list of Issues for a project For >100 issues this _depaginates_ the responses and appends them to one slice
func (*GitlabProvider) GetLabels ¶
func (g *GitlabProvider) GetLabels(pid int, repo string) ([]*GitLabel, error)
GetLabels retrieves a full list of labels associated with a project
func (*GitlabProvider) GetRepositories ¶
func (g *GitlabProvider) GetRepositories() ([]*GitRepository, error)
GetRepositories gets a list of all repositories in the target Gitlab instance For >100 repositories this _depaginates_ the responses and appends them to one slice
func (*GitlabProvider) GetUserByID ¶
func (g *GitlabProvider) GetUserByID(uid int) *GitUser
GetUserByID looks up a user by ID and lifts them to the GitUser type
func (*GitlabProvider) MigrateRepo ¶
func (g *GitlabProvider) MigrateRepo(repo *GitRepository, token string) (string, error)
MigrateRepo migrates a git repo from an existing provider