Documentation
¶
Overview ¶
Package plugsupport provides implementations for loading migrator plugins.
Users of the `migrator` tool should not import or use this package (just the base "go.chromium.org/infra/tools/migrator" package).
Index ¶
- func DumpReports(ctx context.Context) *migrator.ReportDump
- func ExecuteCommit(ctx context.Context, projectDir ProjectDir) (*migrator.ReportDump, error)
- func ExecuteRebase(ctx context.Context, projectDir ProjectDir) (*migrator.ReportDump, error)
- func ExecuteStatusCheck(ctx context.Context, projectDir ProjectDir) (*migrator.ReportDump, error)
- func ExecuteUpload(ctx context.Context, projectDir ProjectDir, force bool) (*migrator.ReportDump, error)
- func Handle(factory migrator.InstantiateAPI, cmd Command) int
- func HasActionableReports(ctx context.Context) (actionable bool)
- func InitReportSink(ctx context.Context) context.Context
- func Invoke(ctx context.Context, projectDir ProjectDir, pluginBin string, command Command) error
- func RemoteProject(ctx context.Context, projID string) migrator.Project
- func RootContext(ctx context.Context) context.Context
- type Command
- type ContextConfig
- type Filter
- type ProjectDir
- func (p ProjectDir) CheckoutDir(checkoutID string) string
- func (p ProjectDir) CheckoutTemp(checkoutID string) string
- func (p ProjectDir) CleanTrash() error
- func (p ProjectDir) CommitMessageFile() string
- func (p ProjectDir) CommitReportPath() string
- func (p ProjectDir) ConfigDir() string
- func (p ProjectDir) ConfigFile() string
- func (p ProjectDir) LoadConfigFile() (*migratorpb.Config, error)
- func (p ProjectDir) LoadProjectFilter() (Filter, error)
- func (p ProjectDir) MkTempDir() (string, error)
- func (p ProjectDir) PluginDir() string
- func (p ProjectDir) ProjectLog(projectID string) string
- func (p ProjectDir) RebaseReportPath() string
- func (p ProjectDir) ScanReportPath() string
- func (p ProjectDir) StatusReportPath() string
- func (p ProjectDir) TrashDir() string
- func (p ProjectDir) UploadReportPath() string
- type ProjectTweaks
- type ScanConfig
- type Tweaks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpReports ¶
func DumpReports(ctx context.Context) *migrator.ReportDump
DumpReports returns all collected Report information within `ctx`.
func ExecuteCommit ¶
func ExecuteCommit(ctx context.Context, projectDir ProjectDir) (*migrator.ReportDump, error)
ExecuteCommit implements "commit" subcommand.
func ExecuteRebase ¶
func ExecuteRebase(ctx context.Context, projectDir ProjectDir) (*migrator.ReportDump, error)
ExecuteRebase implements "rebase" subcommand.
func ExecuteStatusCheck ¶
func ExecuteStatusCheck(ctx context.Context, projectDir ProjectDir) (*migrator.ReportDump, error)
ExecuteStatusCheck implements "status" subcommand.
func ExecuteUpload ¶
func ExecuteUpload(ctx context.Context, projectDir ProjectDir, force bool) (*migrator.ReportDump, error)
ExecuteUpload implements "upload" subcommand.
func Handle ¶
func Handle(factory migrator.InstantiateAPI, cmd Command) int
Handle is called from within the plugin process to execute the command.
The return value becomes the process exit code.
func HasActionableReports ¶
HasActionableReports returns `true` if `ctx` contains any Reports where Actionable is true.
func InitReportSink ¶
InitReportSink adds a new empty ReportSink to context and returns the new context.
If there's an existing ReportSink, it will be hidden by this.
func Invoke ¶
Invoke launches the plugin subprocess passing it the given command.
This eventually results in Handle call from within the plugin binary.
Blocks until the plugin subprocess exits and returns its error (if any).
func RemoteProject ¶
RemoteProject returns a new migrator.Project object for `projID`.
Types ¶
type Command ¶
type Command struct { Action string // what action to perform, e.g. "scan" ProjectDir ProjectDir // an absolute path to the project directory ContextConfig ContextConfig // "instructions" how to setup the root context ScanConfig ScanConfig // parameters specific to the "scan" action }
Command is passed to the plugin subprocess in a JSON-serialized form.
type ContextConfig ¶
ContextConfig contains serializable parameters for setting up a base context.
They are passed across processes to (presumably) get similar contexts across them.
We assume auth.Options are JSON-serializable. This is not guaranteed and stuff may break in the future. If this happens, a more advanced approach would be to use the `authctx` package to setup an authentication context in the `migrator` binary, and use it in the plugin subprocess.
type Filter ¶
Filter reports true if we should visit the given project.
type ProjectDir ¶
type ProjectDir string
ProjectDir is an absolute path to a migrator project directory.
func FindProjectRoot ¶
func FindProjectRoot(abspath string) (ProjectDir, error)
FindProjectRoot finds a migrator ProjectDir starting from `abspath` and working up towards the filesystem root.
func (ProjectDir) CheckoutDir ¶
func (p ProjectDir) CheckoutDir(checkoutID string) string
CheckoutDir returns the path for a git checkout.
func (ProjectDir) CheckoutTemp ¶
func (p ProjectDir) CheckoutTemp(checkoutID string) string
CheckoutTemp returns a temporary checkout directory.
During repo creation, the initial git repo is cloned here and then moved to its CheckoutDir() path on success.
func (ProjectDir) CleanTrash ¶
func (p ProjectDir) CleanTrash() error
CleanTrash removes TrashDir().
func (ProjectDir) CommitMessageFile ¶
func (p ProjectDir) CommitMessageFile() string
CommitMessageFile is the absolute path to the file with the commit message to use in `upload` subcommand.
func (ProjectDir) CommitReportPath ¶
func (p ProjectDir) CommitReportPath() string
CommitReportPath returns the absolute path of the migrator project's CSV commit report file.
func (ProjectDir) ConfigDir ¶
func (p ProjectDir) ConfigDir() string
ConfigDir returns the absolute path of the migrator project's config directory.
func (ProjectDir) ConfigFile ¶
func (p ProjectDir) ConfigFile() string
ConfigFile returns the absolute path of the migrator project's main config file.
The existence of this file is used to determine if a folder is a migrator project.
func (ProjectDir) LoadConfigFile ¶
func (p ProjectDir) LoadConfigFile() (*migratorpb.Config, error)
LoadConfigFile loads the migration project config.
func (ProjectDir) LoadProjectFilter ¶
func (p ProjectDir) LoadProjectFilter() (Filter, error)
LoadProjectFilter loads the config and parses `projects_re` field there.
func (ProjectDir) MkTempDir ¶
func (p ProjectDir) MkTempDir() (string, error)
MkTempDir generates a new temporary directory within TrashDir().
func (ProjectDir) PluginDir ¶
func (p ProjectDir) PluginDir() string
PluginDir returns the absolute path of the migrator project's plugin code directory.
func (ProjectDir) ProjectLog ¶
func (p ProjectDir) ProjectLog(projectID string) string
ProjectLog returns the absolute path of the scan log for a given LUCI project within this migrator project.
func (ProjectDir) RebaseReportPath ¶
func (p ProjectDir) RebaseReportPath() string
RebaseReportPath returns the absolute path of the migrator project's CSV rebase report file.
func (ProjectDir) ScanReportPath ¶
func (p ProjectDir) ScanReportPath() string
ScanReportPath returns the absolute path of the migrator project's CSV scan report file.
func (ProjectDir) StatusReportPath ¶
func (p ProjectDir) StatusReportPath() string
StatusReportPath returns the absolute path of the migrator project's CSV status report file.
func (ProjectDir) TrashDir ¶
func (p ProjectDir) TrashDir() string
TrashDir returns the absolute path of the migrator project's trash directory.
The trash directory is used to compile the plugin; New runs of migrator will make best-effort attempts to clean up this directory using CleanTrash().
func (ProjectDir) UploadReportPath ¶
func (p ProjectDir) UploadReportPath() string
UploadReportPath returns the absolute path of the migrator project's CSV upload report file.
type ProjectTweaks ¶
type ProjectTweaks struct { Reviewers []string // reviewer emails to send CLs to CC []string // emails to CC CLs to }
ProjectTweaks is config tweaks to apply to a particular LUCI project.
type ScanConfig ¶
ScanConfig is passed from the main migrator binary to the plugin process.
type Tweaks ¶
type Tweaks struct {
// contains filtered or unexported fields
}
Tweaks represents loaded `tweaks` section of the migrator config file.
func LoadTweaks ¶
func LoadTweaks(projectDir ProjectDir) (*Tweaks, error)
LoadTweaks parses `tweaks` section of the migrator config file.
func (*Tweaks) ProjectTweaks ¶
func (t *Tweaks) ProjectTweaks(projectID string) *ProjectTweaks
ProjectTweaks returns config tweaks to apply to a particular LUCI project.