migrations

package
v1.15.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRepoNotCreated returns the error that repository not created
	ErrRepoNotCreated = errors.New("repository is not created yet")
)
View Source
var (

	// GithubLimitRateRemaining limit to wait for new rate to apply
	GithubLimitRateRemaining = 0
)

Functions

func DumpRepository added in v1.14.0

func DumpRepository(ctx context.Context, baseDir, ownerName string, opts base.MigrateOptions) error

DumpRepository dump repository according MigrateOptions to a local directory

func Init added in v1.13.0

func Init() error

Init migrations service

func IsMigrateURLAllowed added in v1.14.0

func IsMigrateURLAllowed(remoteURL string, doer *models.User) error

IsMigrateURLAllowed checks if an URL is allowed to be migrated from

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError returns true if the err is github.RateLimitError

func IsTwoFactorAuthError

func IsTwoFactorAuthError(err error) bool

IsTwoFactorAuthError returns true if the err is github.TwoFactorAuthError

func MigrateRepository

func MigrateRepository(ctx context.Context, doer *models.User, ownerName string, opts base.MigrateOptions, messenger base.Messenger) (*models.Repository, error)

MigrateRepository migrate repository according MigrateOptions

func RegisterDownloaderFactory

func RegisterDownloaderFactory(factory base.DownloaderFactory)

RegisterDownloaderFactory registers a downloader factory

func RestoreRepository added in v1.14.0

func RestoreRepository(ctx context.Context, baseDir string, ownerName, repoName string, units []string) error

RestoreRepository restore a repository from the disk directory

func UpdateMigrationPosterID added in v1.10.0

func UpdateMigrationPosterID(ctx context.Context) error

UpdateMigrationPosterID updates all migrated repositories' issues and comments posterID

Types

type GiteaDownloader added in v1.13.0

type GiteaDownloader struct {
	base.NullDownloader
	// contains filtered or unexported fields
}

GiteaDownloader implements a Downloader interface to get repository information's

func NewGiteaDownloader added in v1.13.0

func NewGiteaDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GiteaDownloader, error)

NewGiteaDownloader creates a gitea Downloader via gitea API

Use either a username/password or personal token. token is preferred
Note: Public access only allows very basic access

func (*GiteaDownloader) GetComments added in v1.13.0

func (g *GiteaDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error)

GetComments returns comments according issueNumber

func (*GiteaDownloader) GetIssues added in v1.13.0

func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

func (*GiteaDownloader) GetLabels added in v1.13.0

func (g *GiteaDownloader) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GiteaDownloader) GetMilestones added in v1.13.0

func (g *GiteaDownloader) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GiteaDownloader) GetPullRequests added in v1.13.0

func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*GiteaDownloader) GetReleases added in v1.13.0

func (g *GiteaDownloader) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*GiteaDownloader) GetRepoInfo added in v1.13.0

func (g *GiteaDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GiteaDownloader) GetReviews added in v1.13.0

func (g *GiteaDownloader) GetReviews(index int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*GiteaDownloader) GetTopics added in v1.13.0

func (g *GiteaDownloader) GetTopics() ([]string, error)

GetTopics return gitea topics

func (*GiteaDownloader) SetContext added in v1.13.0

func (g *GiteaDownloader) SetContext(ctx context.Context)

SetContext set context

type GiteaDownloaderFactory added in v1.13.0

type GiteaDownloaderFactory struct {
}

GiteaDownloaderFactory defines a gitea downloader factory

func (*GiteaDownloaderFactory) GitServiceType added in v1.13.0

func (f *GiteaDownloaderFactory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GiteaDownloaderFactory) New added in v1.13.0

New returns a Downloader related to this factory according MigrateOptions

type GiteaLocalUploader

type GiteaLocalUploader struct {
	// contains filtered or unexported fields
}

GiteaLocalUploader implements an Uploader to gitea sites

func NewGiteaLocalUploader

func NewGiteaLocalUploader(ctx context.Context, doer *models.User, repoOwner, repoName string) *GiteaLocalUploader

NewGiteaLocalUploader creates an gitea Uploader via gitea API v1

func (*GiteaLocalUploader) Close added in v1.9.6

func (g *GiteaLocalUploader) Close()

Close closes this uploader

func (*GiteaLocalUploader) CreateComments

func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error

CreateComments creates comments of issues

func (*GiteaLocalUploader) CreateIssues

func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error

CreateIssues creates issues

func (*GiteaLocalUploader) CreateLabels

func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error

CreateLabels creates labels

func (*GiteaLocalUploader) CreateMilestones

func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) error

CreateMilestones creates milestones

func (*GiteaLocalUploader) CreatePullRequests

func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error

CreatePullRequests creates pull requests

func (*GiteaLocalUploader) CreateReleases

func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error

CreateReleases creates releases

func (*GiteaLocalUploader) CreateRepo

func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error

CreateRepo creates a repository

func (*GiteaLocalUploader) CreateReviews added in v1.12.0

func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error

CreateReviews create pull request reviews

func (*GiteaLocalUploader) CreateTopics added in v1.10.0

func (g *GiteaLocalUploader) CreateTopics(topics ...string) error

CreateTopics creates topics

func (*GiteaLocalUploader) Finish added in v1.14.0

func (g *GiteaLocalUploader) Finish() error

Finish when migrating success, this will do some status update things.

func (*GiteaLocalUploader) MaxBatchInsertSize

func (g *GiteaLocalUploader) MaxBatchInsertSize(tp string) int

MaxBatchInsertSize returns the table's max batch insert size

func (*GiteaLocalUploader) Rollback

func (g *GiteaLocalUploader) Rollback() error

Rollback when migrating failed, this will rollback all the changes.

func (*GiteaLocalUploader) SyncTags added in v1.10.2

func (g *GiteaLocalUploader) SyncTags() error

SyncTags syncs releases with tags in the database

type GithubDownloaderV3

type GithubDownloaderV3 struct {
	base.NullDownloader
	// contains filtered or unexported fields
}

GithubDownloaderV3 implements a Downloader interface to get repository information from github via APIv3

func NewGithubDownloaderV3

func NewGithubDownloaderV3(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GithubDownloaderV3

NewGithubDownloaderV3 creates a github Downloader via github v3 API

func (*GithubDownloaderV3) GetAllComments added in v1.15.0

func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, bool, error)

GetAllComments returns repository comments according page and perPageSize

func (*GithubDownloaderV3) GetComments

func (g *GithubDownloaderV3) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error)

GetComments returns comments according issueNumber

func (*GithubDownloaderV3) GetIssues

func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

func (*GithubDownloaderV3) GetLabels

func (g *GithubDownloaderV3) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GithubDownloaderV3) GetMilestones

func (g *GithubDownloaderV3) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GithubDownloaderV3) GetPullRequests

func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*GithubDownloaderV3) GetReleases

func (g *GithubDownloaderV3) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*GithubDownloaderV3) GetRepoInfo

func (g *GithubDownloaderV3) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GithubDownloaderV3) GetReviews added in v1.12.0

func (g *GithubDownloaderV3) GetReviews(pullRequestNumber int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*GithubDownloaderV3) GetTopics added in v1.10.0

func (g *GithubDownloaderV3) GetTopics() ([]string, error)

GetTopics return github topics

func (*GithubDownloaderV3) RefreshRate added in v1.11.0

func (g *GithubDownloaderV3) RefreshRate() error

RefreshRate update the current rate (doesn't count in rate limit)

func (*GithubDownloaderV3) SetContext added in v1.11.0

func (g *GithubDownloaderV3) SetContext(ctx context.Context)

SetContext set context

func (*GithubDownloaderV3) SupportGetRepoComments added in v1.15.0

func (g *GithubDownloaderV3) SupportGetRepoComments() bool

SupportGetRepoComments return true if it supports get repo comments

type GithubDownloaderV3Factory

type GithubDownloaderV3Factory struct {
}

GithubDownloaderV3Factory defines a github downloader v3 factory

func (*GithubDownloaderV3Factory) GitServiceType added in v1.10.0

func (f *GithubDownloaderV3Factory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GithubDownloaderV3Factory) New

New returns a Downloader related to this factory according MigrateOptions

type GitlabDownloader added in v1.12.0

type GitlabDownloader struct {
	base.NullDownloader
	// contains filtered or unexported fields
}

GitlabDownloader implements a Downloader interface to get repository information from gitlab via go-gitlab - issueCount is incremented in GetIssues() to ensure PR and Issue numbers do not overlap, because Gitlab has individual Issue and Pull Request numbers. - issueSeen, working alongside issueCount, is checked in GetComments() to see whether we need to fetch the Issue or PR comments, as Gitlab stores them separately.

func NewGitlabDownloader added in v1.12.0

func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error)

NewGitlabDownloader creates a gitlab Downloader via gitlab API

Use either a username/password, personal token entered into the username field, or anonymous/public access
Note: Public access only allows very basic access

func (*GitlabDownloader) GetComments added in v1.12.0

func (g *GitlabDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error)

GetComments returns comments according issueNumber TODO: figure out how to transfer comment reactions

func (*GitlabDownloader) GetIssues added in v1.12.0

func (g *GitlabDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

Note: issue label description and colors are not supported by the go-gitlab library at this time

func (*GitlabDownloader) GetLabels added in v1.12.0

func (g *GitlabDownloader) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GitlabDownloader) GetMilestones added in v1.12.0

func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GitlabDownloader) GetPullRequests added in v1.12.0

func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*GitlabDownloader) GetReleases added in v1.12.0

func (g *GitlabDownloader) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*GitlabDownloader) GetRepoInfo added in v1.12.0

func (g *GitlabDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GitlabDownloader) GetReviews added in v1.12.0

func (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*GitlabDownloader) GetTopics added in v1.12.0

func (g *GitlabDownloader) GetTopics() ([]string, error)

GetTopics return gitlab topics

func (*GitlabDownloader) SetContext added in v1.12.0

func (g *GitlabDownloader) SetContext(ctx context.Context)

SetContext set context

type GitlabDownloaderFactory added in v1.12.0

type GitlabDownloaderFactory struct {
}

GitlabDownloaderFactory defines a gitlab downloader factory

func (*GitlabDownloaderFactory) GitServiceType added in v1.12.0

func (f *GitlabDownloaderFactory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GitlabDownloaderFactory) New added in v1.12.0

New returns a Downloader related to this factory according MigrateOptions

type GogsDownloader added in v1.14.0

type GogsDownloader struct {
	base.NullDownloader
	// contains filtered or unexported fields
}

GogsDownloader implements a Downloader interface to get repository information from gogs via API

func NewGogsDownloader added in v1.14.0

func NewGogsDownloader(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GogsDownloader

NewGogsDownloader creates a gogs Downloader via gogs API

func (*GogsDownloader) FormatCloneURL added in v1.14.0

func (g *GogsDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)

FormatCloneURL add authentification into remote URLs

func (*GogsDownloader) GetComments added in v1.14.0

func (g *GogsDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error)

GetComments returns comments according issueNumber

func (*GogsDownloader) GetIssues added in v1.14.0

func (g *GogsDownloader) GetIssues(page, _ int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit, perPage is not supported

func (*GogsDownloader) GetLabels added in v1.14.0

func (g *GogsDownloader) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GogsDownloader) GetMilestones added in v1.14.0

func (g *GogsDownloader) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GogsDownloader) GetRepoInfo added in v1.14.0

func (g *GogsDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GogsDownloader) GetTopics added in v1.14.0

func (g *GogsDownloader) GetTopics() ([]string, error)

GetTopics return repository topics

func (*GogsDownloader) RoundTrip added in v1.14.0

func (g *GogsDownloader) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip wraps the provided request within this downloader's context and passes it to our internal http.Transport. This implements http.RoundTripper and makes the gogs client requests cancellable even though it is not cancellable itself

func (*GogsDownloader) SetContext added in v1.14.0

func (g *GogsDownloader) SetContext(ctx context.Context)

SetContext set context

type GogsDownloaderFactory added in v1.14.0

type GogsDownloaderFactory struct {
}

GogsDownloaderFactory defines a gogs downloader factory

func (*GogsDownloaderFactory) GitServiceType added in v1.14.0

func (f *GogsDownloaderFactory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GogsDownloaderFactory) New added in v1.14.0

New returns a Downloader related to this factory according MigrateOptions

type MigrateOptions

type MigrateOptions = base.MigrateOptions

MigrateOptions is equal to base.MigrateOptions

type PlainGitDownloader

type PlainGitDownloader struct {
	base.NullDownloader
	// contains filtered or unexported fields
}

PlainGitDownloader implements a Downloader interface to clone git from a http/https URL

func NewPlainGitDownloader

func NewPlainGitDownloader(ownerName, repoName, remoteURL string) *PlainGitDownloader

NewPlainGitDownloader creates a git Downloader

func (*PlainGitDownloader) GetRepoInfo

func (g *PlainGitDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (PlainGitDownloader) GetTopics added in v1.10.0

func (g PlainGitDownloader) GetTopics() ([]string, error)

GetTopics return empty string slice

func (*PlainGitDownloader) SetContext added in v1.11.0

func (g *PlainGitDownloader) SetContext(ctx context.Context)

SetContext set context

type RepositoryDumper added in v1.14.0

type RepositoryDumper struct {
	// contains filtered or unexported fields
}

RepositoryDumper implements an Uploader to the local directory

func NewRepositoryDumper added in v1.14.0

func NewRepositoryDumper(ctx context.Context, baseDir, repoOwner, repoName string, opts base.MigrateOptions) (*RepositoryDumper, error)

NewRepositoryDumper creates an gitea Uploader

func (*RepositoryDumper) Close added in v1.14.0

func (g *RepositoryDumper) Close()

Close closes this uploader

func (*RepositoryDumper) CreateComments added in v1.14.0

func (g *RepositoryDumper) CreateComments(comments ...*base.Comment) error

CreateComments creates comments of issues

func (*RepositoryDumper) CreateIssues added in v1.14.0

func (g *RepositoryDumper) CreateIssues(issues ...*base.Issue) error

CreateIssues creates issues

func (*RepositoryDumper) CreateLabels added in v1.14.0

func (g *RepositoryDumper) CreateLabels(labels ...*base.Label) error

CreateLabels creates labels

func (*RepositoryDumper) CreateMilestones added in v1.14.0

func (g *RepositoryDumper) CreateMilestones(milestones ...*base.Milestone) error

CreateMilestones creates milestones

func (*RepositoryDumper) CreatePullRequests added in v1.14.0

func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error

CreatePullRequests creates pull requests

func (*RepositoryDumper) CreateReleases added in v1.14.0

func (g *RepositoryDumper) CreateReleases(releases ...*base.Release) error

CreateReleases creates releases

func (*RepositoryDumper) CreateRepo added in v1.14.0

func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error

CreateRepo creates a repository

func (*RepositoryDumper) CreateReviews added in v1.14.0

func (g *RepositoryDumper) CreateReviews(reviews ...*base.Review) error

CreateReviews create pull request reviews

func (*RepositoryDumper) CreateTopics added in v1.14.0

func (g *RepositoryDumper) CreateTopics(topics ...string) error

CreateTopics creates topics

func (*RepositoryDumper) Finish added in v1.14.0

func (g *RepositoryDumper) Finish() error

Finish when migrating succeed, this will update something.

func (*RepositoryDumper) MaxBatchInsertSize added in v1.14.0

func (g *RepositoryDumper) MaxBatchInsertSize(tp string) int

MaxBatchInsertSize returns the table's max batch insert size

func (*RepositoryDumper) Rollback added in v1.14.0

func (g *RepositoryDumper) Rollback() error

Rollback when migrating failed, this will rollback all the changes.

func (*RepositoryDumper) SyncTags added in v1.14.0

func (g *RepositoryDumper) SyncTags() error

SyncTags syncs releases with tags in the database

type RepositoryRestorer added in v1.14.0

type RepositoryRestorer struct {
	base.NullDownloader
	// contains filtered or unexported fields
}

RepositoryRestorer implements an Downloader from the local directory

func NewRepositoryRestorer added in v1.14.0

func NewRepositoryRestorer(ctx context.Context, baseDir string, owner, repoName string) (*RepositoryRestorer, error)

NewRepositoryRestorer creates a repository restorer which could restore repository from a dumped folder

func (*RepositoryRestorer) GetComments added in v1.14.0

func (r *RepositoryRestorer) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error)

GetComments returns comments according issueNumber

func (*RepositoryRestorer) GetIssues added in v1.14.0

func (r *RepositoryRestorer) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

func (*RepositoryRestorer) GetLabels added in v1.14.0

func (r *RepositoryRestorer) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*RepositoryRestorer) GetMilestones added in v1.14.0

func (r *RepositoryRestorer) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*RepositoryRestorer) GetPullRequests added in v1.14.0

func (r *RepositoryRestorer) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*RepositoryRestorer) GetReleases added in v1.14.0

func (r *RepositoryRestorer) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*RepositoryRestorer) GetRepoInfo added in v1.14.0

func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*RepositoryRestorer) GetReviews added in v1.14.0

func (r *RepositoryRestorer) GetReviews(pullRequestNumber int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*RepositoryRestorer) GetTopics added in v1.14.0

func (r *RepositoryRestorer) GetTopics() ([]string, error)

GetTopics return github topics

func (*RepositoryRestorer) SetContext added in v1.14.0

func (r *RepositoryRestorer) SetContext(ctx context.Context)

SetContext set context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL