Help us shape the future of Go! Take the 2026 Go Developer Survey

projectimportexport

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package projectimportexport implements MCP tools for GitLab project import and export operations.

The package wraps the GitLab Project import/export API:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionSpecs

func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec

ActionSpecs returns canonical specs for project import and export actions.

func FormatExportDownloadMarkdown

func FormatExportDownloadMarkdown(out ExportDownloadOutput) *mcp.CallToolResult

FormatExportDownloadMarkdown renders the one line a downloaded archive answers with: the size, and where the bytes are.

func FormatExportStatusMarkdown

func FormatExportStatusMarkdown(out ExportStatusOutput) *mcp.CallToolResult

FormatExportStatusMarkdown renders an export's status as a card: the project's identity, the status GitLab reports and the two addresses the archive is reachable at when the export has finished.

func FormatImportStatusMarkdown

func FormatImportStatusMarkdown(out ImportStatusOutput) *mcp.CallToolResult

FormatImportStatusMarkdown renders an import's status as a card, with GitLab's own failure text when the import failed.

func FormatScheduleExportMarkdown

func FormatScheduleExportMarkdown(out ScheduleExportOutput) *mcp.CallToolResult

FormatScheduleExportMarkdown renders the one sentence a scheduled export answers with. The sentence is this package's own literal; the cell escaper is idempotent over it and is what keeps the line one line whatever a later GitLab-authored message holds.

Types

type ExportDownloadInput

type ExportDownloadInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
}

ExportDownloadInput is the input for downloading a project export.

type ExportDownloadOutput

type ExportDownloadOutput struct {
	toolutil.HintableOutput
	ContentBase64 string `json:"content_base64"`
	SizeBytes     int    `json:"size_bytes"`
}

ExportDownloadOutput is the output for downloading a project export.

func ExportDownload

func ExportDownload(ctx context.Context, client *gitlabclient.Client, input ExportDownloadInput) (ExportDownloadOutput, error)

ExportDownload downloads the finished export archive of a project as base64.

client-go reads the whole body before it returns it, so the shared download ceiling is applied where the body is read, as a response limit on this one request: an archive over it stops the read there instead of being buffered up to the client's own ceiling and then refused, and is answered with the way out rather than returned or truncated.

type ExportStatusInput

type ExportStatusInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
}

ExportStatusInput is the input for getting export status.

type ExportStatusOutput

type ExportStatusOutput struct {
	toolutil.HintableOutput
	ID                int64  `json:"id"`
	Description       string `json:"description"`
	Name              string `json:"name"`
	NameWithNamespace string `json:"name_with_namespace"`
	Path              string `json:"path"`
	PathWithNamespace string `json:"path_with_namespace"`
	CreatedAt         string `json:"created_at,omitempty"`
	ExportStatus      string `json:"export_status"`
	APIURL            string `json:"api_url,omitempty"`
	WebURL            string `json:"web_url,omitempty"`
}

ExportStatusOutput is the output for getting export status.

func GetExportStatus

func GetExportStatus(ctx context.Context, client *gitlabclient.Client, input ExportStatusInput) (ExportStatusOutput, error)

GetExportStatus returns the export status of a project.

type FailedRelationOutput added in v3.1.0

type FailedRelationOutput struct {
	ID             int64  `json:"id"`
	CreatedAt      string `json:"created_at,omitempty"`
	ExceptionClass string `json:"exception_class"`
	Source         string `json:"source"`
	RelationName   string `json:"relation_name"`
	LineNumber     int64  `json:"line_number"`
}

FailedRelationOutput is one relation an import could not bring over, as lib/api/entities/project_import_failed_relation.rb renders it: when and where it failed, the exception's class, and the relation and line it was reading. The entity also exposes exception_message through a block that returns nil whatever the relation, so it is never filled and is not published.

type GetImportStatusInput

type GetImportStatusInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
}

GetImportStatusInput is the input for getting import status.

type ImportFromFileInput

type ImportFromFileInput struct {
	FilePath       string                     `` /* 289-byte string literal not displayed */
	ContentBase64  string                     `` /* 143-byte string literal not displayed */
	Namespace      string                     `json:"namespace,omitempty" jsonschema:"Namespace to import the project into (user or group path)"`
	Name           string                     `json:"name,omitempty" jsonschema:"Name for the imported project"`
	Path           string                     `json:"path,omitempty" jsonschema:"URL path for the imported project,required"`
	Overwrite      *bool                      `json:"overwrite,omitempty" jsonschema:"If true, overwrite an existing project with the same path"`
	OverrideParams *ImportOverrideParamsInput `` /* 179-byte string literal not displayed */
}

ImportFromFileInput is the input for importing a project from an archive file. Fields mirror gl.ImportFileOptions 1:1, override_params as the nested struct over gl.CreateProjectOptions that ImportOverrideParamsInput mirrors.

type ImportOverrideParamsInput

type ImportOverrideParamsInput struct {
	Description                  string `json:"description,omitempty" jsonschema:"Override the imported project's description"`
	Visibility                   string `json:"visibility,omitempty" jsonschema:"Override visibility level (private, internal, public)"`
	MergeMethod                  string `json:"merge_method,omitempty" jsonschema:"Override merge method (merge, rebase_merge, ff)"`
	RequestAccessEnabled         *bool  `json:"request_access_enabled,omitempty" jsonschema:"Override whether users can request access"`
	SharedRunnersEnabled         *bool  `json:"shared_runners_enabled,omitempty" jsonschema:"Override whether shared (instance) CI runners are enabled"`
	IssuesAccessLevel            string `json:"issues_access_level,omitempty" jsonschema:"Override issues access level (disabled, private, enabled)"`
	MergeRequestsAccessLevel     string `json:"merge_requests_access_level,omitempty" jsonschema:"Override merge requests access level (disabled, private, enabled)"`
	WikiAccessLevel              string `json:"wiki_access_level,omitempty" jsonschema:"Override wiki access level (disabled, private, enabled)"`
	BuildsAccessLevel            string `json:"builds_access_level,omitempty" jsonschema:"Override CI/CD builds access level (disabled, private, enabled)"`
	SnippetsAccessLevel          string `json:"snippets_access_level,omitempty" jsonschema:"Override snippets access level (disabled, private, enabled)"`
	ContainerRegistryAccessLevel string `` /* 131-byte string literal not displayed */

	RepositoryAccessLevel            string `json:"repository_access_level,omitempty" jsonschema:"Override repository access level (disabled, private, enabled)"`
	ForkingAccessLevel               string `json:"forking_access_level,omitempty" jsonschema:"Override forking access level (disabled, private, enabled)"`
	AnalyticsAccessLevel             string `json:"analytics_access_level,omitempty" jsonschema:"Override analytics access level (disabled, private, enabled)"`
	PagesAccessLevel                 string `json:"pages_access_level,omitempty" jsonschema:"Override Pages access level (disabled, private, enabled, public)"`
	PackageRegistryAccessLevel       string `` /* 127-byte string literal not displayed */
	ReleasesAccessLevel              string `json:"releases_access_level,omitempty" jsonschema:"Override releases access level (disabled, private, enabled)"`
	EnvironmentsAccessLevel          string `json:"environments_access_level,omitempty" jsonschema:"Override environments access level (disabled, private, enabled)"`
	FeatureFlagsAccessLevel          string `json:"feature_flags_access_level,omitempty" jsonschema:"Override feature flags access level (disabled, private, enabled)"`
	InfrastructureAccessLevel        string `json:"infrastructure_access_level,omitempty" jsonschema:"Override infrastructure access level (disabled, private, enabled)"`
	MonitorAccessLevel               string `json:"monitor_access_level,omitempty" jsonschema:"Override monitor access level (disabled, private, enabled)"`
	RequirementsAccessLevel          string `json:"requirements_access_level,omitempty" jsonschema:"Override requirements access level (disabled, private, enabled)"`
	SecurityAndComplianceAccessLevel string `` /* 141-byte string literal not displayed */
	ModelExperimentsAccessLevel      string `` /* 129-byte string literal not displayed */
	ModelRegistryAccessLevel         string `json:"model_registry_access_level,omitempty" jsonschema:"Override model registry access level (disabled, private, enabled)"`

	SquashOption                              string `json:"squash_option,omitempty" jsonschema:"Override the squash option (never, always, default_on, default_off)"`
	OnlyAllowMergeIfPipelineSucceeds          *bool  `json:"only_allow_merge_if_pipeline_succeeds,omitempty" jsonschema:"Override whether a merge waits for a successful pipeline"`
	OnlyAllowMergeIfAllDiscussionsAreResolved *bool  `` /* 145-byte string literal not displayed */
	AllowMergeOnSkippedPipeline               *bool  `` /* 126-byte string literal not displayed */
	RemoveSourceBranchAfterMerge              *bool  `` /* 133-byte string literal not displayed */
	AutocloseReferencedIssues                 *bool  `json:"autoclose_referenced_issues,omitempty" jsonschema:"Override whether a merge closes the issues it references"`
	ResolveOutdatedDiffDiscussions            *bool  `` /* 127-byte string literal not displayed */
	PrintingMergeRequestLinkEnabled           *bool  `` /* 126-byte string literal not displayed */
	MergeCommitTemplate                       string `json:"merge_commit_template,omitempty" jsonschema:"Override the merge commit message template"`
	SquashCommitTemplate                      string `json:"squash_commit_template,omitempty" jsonschema:"Override the squash commit message template"`
	SuggestionCommitMessage                   string `json:"suggestion_commit_message,omitempty" jsonschema:"Override the default commit message for applied suggestions"`
	ApprovalsBeforeMerge                      *int64 `` /* 167-byte string literal not displayed */

	ServiceDeskEnabled *bool `json:"service_desk_enabled,omitempty" jsonschema:"Override whether Service Desk is enabled"`
	AutoDevopsEnabled  *bool `json:"auto_devops_enabled,omitempty" jsonschema:"Override whether Auto DevOps is enabled"`

	AutoDevopsDeployStrategy                 string `` /* 138-byte string literal not displayed */
	AutoCancelPendingPipelines               string `` /* 132-byte string literal not displayed */
	BuildGitStrategy                         string `json:"build_git_strategy,omitempty" jsonschema:"Override the Git strategy of jobs (fetch, clone)"`
	BuildTimeout                             *int64 `json:"build_timeout,omitempty" jsonschema:"Override the job timeout in seconds"`
	ExternalAuthorizationClassificationLabel string `` /* 130-byte string literal not displayed */

	// The deprecated toggles GitLab still declares under override_params
	// and the import applies, each sent as the caller gives it.
	IssuesEnabled            *bool `json:"issues_enabled,omitempty" jsonschema:"Override whether issues are enabled (deprecated: use issues_access_level)"`
	MergeRequestsEnabled     *bool `` /* 142-byte string literal not displayed */
	WikiEnabled              *bool `json:"wiki_enabled,omitempty" jsonschema:"Override whether the wiki is enabled (deprecated: use wiki_access_level)"`
	SnippetsEnabled          *bool `json:"snippets_enabled,omitempty" jsonschema:"Override whether snippets are enabled (deprecated: use snippets_access_level)"`
	ContainerRegistryEnabled *bool `` /* 157-byte string literal not displayed */
	PublicBuilds             *bool `` /* 142-byte string literal not displayed */
}

ImportOverrideParamsInput mirrors the project attributes an import from file applies from its `override_params` field: every one that gl.CreateProjectOptions (the type of gl.ImportFileOptions.OverrideParams) models and the import keeps. Only set fields are forwarded, so a boolean or a number is a pointer: overriding a setting the export carries as true with false is the point of the field.

The project's name, path and namespace are not among them: GitLab declares them as the import's own params and not under override_params, whose declared params (optional_project_params) Grape keeps alone, so an override_params name, path, namespace_id or default_branch was dropped. The name, path and namespace of ImportFromFileInput place the project.

Nor is any key GitLab declares under override_params and the import never applies. The tree restorer merges the overrides into the archive's project attributes and keeps only those import_export.yml permits for a project (Gitlab::ImportExport::AttributesPermitter, through Group::RelationTreeRestorer#filter_attributes), which leaves out the CI/CD configuration path, the cleanup policy, the email, mirroring, runner and template settings among others, and excludes lfs_enabled, mirror, repository_storage and tag_list by name. Two keys it permits are left out too, because the restorer cannot assign them: topics is the project's association with Projects::Topic, which a list of names does not fill, and the project has no jobs_enabled (lib/api/projects.rb renames it to builds_enabled for the create and the edit alone), so either one fails the restore and the import with it. builds_access_level sets what jobs_enabled would.

type ImportStatusOutput

type ImportStatusOutput struct {
	toolutil.HintableOutput
	ID                int64                       `json:"id"`
	Description       string                      `json:"description"`
	Name              string                      `json:"name"`
	NameWithNamespace string                      `json:"name_with_namespace"`
	Path              string                      `json:"path"`
	PathWithNamespace string                      `json:"path_with_namespace"`
	CreatedAt         string                      `json:"created_at,omitempty"`
	ImportStatus      string                      `json:"import_status"`
	ImportType        string                      `json:"import_type,omitempty"`
	CorrelationID     string                      `json:"correlation_id,omitempty"`
	ImportError       string                      `json:"import_error,omitempty"`
	FailedRelations   []FailedRelationOutput      `json:"failed_relations"`
	Stats             map[string]map[string]int64 `json:"stats,omitempty"`
}

ImportStatusOutput is the output for import operations: every key lib/api/entities/project_import_status.rb sends. FailedRelations are the relations the import could not bring over, at most a hundred, and Stats is what a GitHub import has fetched and imported so far, per object type, which GitLab sends as null for any other import. client-go's ImportStatus models neither, and both are read by the raw decode this package already makes.

func GetImportStatus

func GetImportStatus(ctx context.Context, client *gitlabclient.Client, input GetImportStatusInput) (ImportStatusOutput, error)

GetImportStatus returns the import status of a project.

func ImportFromFile

func ImportFromFile(ctx context.Context, client *gitlabclient.Client, input ImportFromFileInput) (ImportStatusOutput, error)

ImportFromFile imports a project from an export archive.

type ScheduleExportInput

type ScheduleExportInput struct {
	ProjectID   toolutil.StringOrInt       `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Description string                     `json:"description,omitempty" jsonschema:"Override the project description in the export"`
	Upload      *ScheduleExportUploadInput `` /* 135-byte string literal not displayed */

	// Deprecated: use Upload.URL. Retained as a flat alias for backward
	// compatibility; ignored when Upload is set.
	UploadURL string `` /* 129-byte string literal not displayed */
	// Deprecated: use Upload.HTTPMethod. Retained as a flat alias for backward
	// compatibility; ignored when Upload is set.
	UploadHTTP string `` /* 132-byte string literal not displayed */
}

ScheduleExportInput is the input for scheduling a project export. Fields mirror gl.ScheduleExportOptions 1:1.

type ScheduleExportOutput

type ScheduleExportOutput struct {
	toolutil.HintableOutput
	Message string `json:"message"`
}

ScheduleExportOutput is the output for scheduling a project export.

func ScheduleExport

func ScheduleExport(ctx context.Context, client *gitlabclient.Client, input ScheduleExportInput) (ScheduleExportOutput, error)

ScheduleExport schedules an asynchronous project export.

type ScheduleExportUploadInput

type ScheduleExportUploadInput struct {
	URL        string `json:"url,omitempty" jsonschema:"URL to upload the exported project archive to after export completes"`
	HTTPMethod string `json:"http_method,omitempty" jsonschema:"HTTP method to use for the upload (PUT or POST. Default PUT)"`
}

ScheduleExportUploadInput mirrors gl.ScheduleExportUploadOptions: the nested upload destination for a scheduled export. When set, GitLab uploads the generated archive to the given URL instead of (or in addition to) keeping it for download.

Jump to

Keyboard shortcuts

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