importer

package
v1.0.1-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned if no import data was found.
	ErrNotFound = errors.New("import not found")
)

Functions

func JobIDFromRepoID

func JobIDFromRepoID(repoID int64) string

func LoadRepositoriesFromProviderSpace

func LoadRepositoriesFromProviderSpace(
	ctx context.Context,
	provider Provider,
	spaceSlug string,
) ([]RepositoryInfo, Provider, error)

func LoadRepositoryFromProvider

func LoadRepositoryFromProvider(
	ctx context.Context,
	provider Provider,
	repoSlug string,
) (RepositoryInfo, Provider, error)

func RepoIDFromJobID

func RepoIDFromJobID(jobID string) int64

Types

type ExternalComment

type ExternalComment = migratetypes.Comment

type ExternalPullRequest

type ExternalPullRequest = migratetypes.PullRequestData

type Input

type Input struct {
	RepoID    int64          `json:"repo_id"`
	Public    bool           `json:"public"`
	GitUser   string         `json:"git_user"`
	GitPass   string         `json:"git_pass"`
	CloneURL  string         `json:"clone_url"`
	Pipelines PipelineOption `json:"pipelines"`
}

type PipelineOption

type PipelineOption string

PipelineOption defines the supported pipeline import options for repository import.

const (
	PipelineOptionConvert PipelineOption = "convert"
	PipelineOptionIgnore  PipelineOption = "ignore"
)

func (PipelineOption) Enum

func (PipelineOption) Enum() []any

type Provider

type Provider struct {
	Type     ProviderType `json:"type"`
	Host     string       `json:"host"`
	Username string       `json:"username"`
	Password string       `json:"password"`
}

type ProviderType

type ProviderType string
const (
	ProviderTypeGitHub    ProviderType = "github"
	ProviderTypeGitLab    ProviderType = "gitlab"
	ProviderTypeBitbucket ProviderType = "bitbucket"
	ProviderTypeStash     ProviderType = "stash"
	ProviderTypeGitea     ProviderType = "gitea"
	ProviderTypeGogs      ProviderType = "gogs"
	ProviderTypeAzure     ProviderType = "azure"
)

func (ProviderType) Enum

func (p ProviderType) Enum() []any

type PullReq

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

PullReq is pull request importer.

func ProvidePullReqImporter

func ProvidePullReqImporter(
	urlProvider url.Provider,
	git git.Interface,
	principalStore store.PrincipalStore,
	repoStore store.RepoStore,
	pullReqStore store.PullReqStore,
	pullReqActStore store.PullReqActivityStore,
	tx dbtx.Transactor,
) *PullReq

func (PullReq) Import

func (importer PullReq) Import(
	ctx context.Context,
	repo *types.Repository,
	extPullReqs []*ExternalPullRequest,
) ([]*types.PullReq, error)

Import load provided pull requests in go-scm format and imports them.

type Repository

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

func ProvideRepoImporter

func ProvideRepoImporter(
	config *types.Config,
	urlProvider url.Provider,
	git git.Interface,
	tx dbtx.Transactor,
	repoStore store.RepoStore,
	pipelineStore store.PipelineStore,
	triggerStore store.TriggerStore,
	encrypter encrypt.Encrypter,
	scheduler *job.Scheduler,
	executor *job.Executor,
	sseStreamer sse.Streamer,
	indexer keywordsearch.Indexer,
	publicAccess publicaccess.Service,
	auditService audit.Service,
) (*Repository, error)

func (*Repository) Cancel

func (r *Repository) Cancel(ctx context.Context, repo *types.Repository) error

func (*Repository) GetProgress

func (r *Repository) GetProgress(ctx context.Context, repo *types.Repository) (job.Progress, error)

func (*Repository) Handle

func (r *Repository) Handle(ctx context.Context, data string, _ job.ProgressReporter) (string, error)

Handle is repository import background job handler.

func (*Repository) Register

func (r *Repository) Register(executor *job.Executor) error

func (*Repository) Run

func (r *Repository) Run(
	ctx context.Context,
	provider Provider,
	repo *types.Repository,
	public bool,
	cloneURL string,
	pipelines PipelineOption,
) error

Run starts a background job that imports the provided repository from the provided clone URL.

func (*Repository) RunMany

func (r *Repository) RunMany(ctx context.Context,
	groupID string,
	provider Provider,
	repoIDs []int64,
	publics []bool,
	cloneURLs []string,
	pipelines PipelineOption,
) error

RunMany starts background jobs that import the provided repositories from the provided clone URLs.

type RepositoryInfo

type RepositoryInfo struct {
	Space         string
	Identifier    string
	CloneURL      string
	IsPublic      bool
	DefaultBranch string
}

func (*RepositoryInfo) ToRepo

func (r *RepositoryInfo) ToRepo(
	spaceID int64,
	spacePath string,
	identifier string,
	description string,
	principal *types.Principal,
) (*types.Repository, bool)

ToRepo converts the RepositoryInfo into the types.Repository object marked as being imported and is-public flag.

Jump to

Keyboard shortcuts

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