migrate

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package migrate resolves a migration plan into concrete repository migrations and executes them against the target Forgejo instance with a bounded worker pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Source      SourceSpec
	TargetOwner string
	Options     forgejo.Options
}

Job pairs a source with resolved options and an optional target-owner override.

type Plan

type Plan struct {
	Target   Target
	Settings Settings
	Jobs     []Job
}

Plan is the fully-resolved unit of work handed to the runner.

type Result

type Result struct {
	Migrated int
	Skipped  int
	Adopted  int
	Failed   int
}

Result summarizes a run.

type Runner

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

Runner executes migration plans.

func NewRunner

func NewRunner(log zerolog.Logger) *Runner

NewRunner builds a Runner.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, plan Plan) (Result, error)

Run resolves every job's repositories and migrates them. It returns a summary; per-repository failures are logged and counted rather than aborting the whole run.

type Settings

type Settings struct {
	Concurrency  int
	RateLimit    int
	SkipExisting bool
	DryRun       bool
	// MigrateTimeout bounds one migration call, and the reconciliation that
	// follows when the call times out.
	MigrateTimeout time.Duration
	// ReconcileInterval is how often the target is polled while reconciling.
	ReconcileInterval time.Duration
	// ProgressInterval is how often a running migration's target repository is
	// polled to report what it has imported so far. Zero switches reporting off.
	ProgressInterval time.Duration
	// MigrateRetries is how many extra attempts a migration gets after one
	// that was cut short and left nothing usable on the target. Zero, the
	// default, migrates each repository at most once.
	MigrateRetries int
	// ReplaceIncomplete allows deleting a leftover from an interrupted
	// migration on the target and migrating again in its place.
	ReplaceIncomplete bool
	// AdoptExistingFiles allows adopting repository files left on the target's
	// disk. Requires a site admin token.
	AdoptExistingFiles bool
	// ReplaceExisting widens ReplaceIncomplete to a repository that already
	// holds content, which is what a migration that failed partway through
	// leaves behind. The target cannot tell such a repository apart from one
	// an earlier run migrated successfully, so this is the caller's call.
	ReplaceExisting bool
}

Settings are resolved run-level controls.

type SourceSpec

type SourceSpec struct {
	Kind  source.Kind
	URL   string
	Token string
	Org   string
	User  string
	Repos []string
}

SourceSpec is a resolved source description for a single job.

type Target

type Target struct {
	URL       string
	Owner     string
	Token     string
	CreateOrg bool
}

Target is the resolved destination instance and default owner.

Jump to

Keyboard shortcuts

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