containerregistry

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package containerregistry implements MCP tools for GitLab container registry operations.

It wraps the GitLab ContainerRegistry service to list project and group repositories, list and delete tags, inspect tag details, and manage container registry protection rules. The package also registers MCP tools and provides Markdown rendering for container registry responses.

Safety Model

Tag and protection-rule deletions are destructive catalog actions. Their ActionSpecs mark that behavior so read-only mode, safe mode previews, and dynamic confirmation handling all see the same metadata.

GitLab API References

The package wraps the GitLab Container Registry 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 container registry actions.

func DeleteProtectionRule

func DeleteProtectionRule(ctx context.Context, client *gitlabclient.Client, input DeleteProtectionRuleInput) error

DeleteProtectionRule deletes a container registry protection rule.

func DeleteProtectionRuleOutput

func DeleteProtectionRuleOutput(ctx context.Context, client *gitlabclient.Client, input DeleteProtectionRuleInput) (toolutil.DeleteOutput, error)

DeleteProtectionRuleOutput deletes a registry protection rule and returns the canonical success message shape.

func DeleteRepository

func DeleteRepository(ctx context.Context, client *gitlabclient.Client, input DeleteRepositoryInput) error

DeleteRepository deletes a container registry repository.

func DeleteRepositoryOutput

func DeleteRepositoryOutput(ctx context.Context, client *gitlabclient.Client, input DeleteRepositoryInput) (toolutil.DeleteOutput, error)

DeleteRepositoryOutput deletes a registry repository and returns the canonical success message shape.

func DeleteTag

func DeleteTag(ctx context.Context, client *gitlabclient.Client, input DeleteTagInput) error

DeleteTag deletes a single registry repository tag.

func DeleteTagOutput

func DeleteTagOutput(ctx context.Context, client *gitlabclient.Client, input DeleteTagInput) (toolutil.DeleteOutput, error)

DeleteTagOutput deletes a registry tag and returns the canonical success message shape.

func DeleteTagProtectionRule added in v2.3.0

func DeleteTagProtectionRule(ctx context.Context, client *gitlabclient.Client, input DeleteTagProtectionRuleInput) error

DeleteTagProtectionRule deletes a container registry tag protection rule.

func DeleteTagProtectionRuleOutput added in v2.3.0

func DeleteTagProtectionRuleOutput(ctx context.Context, client *gitlabclient.Client, input DeleteTagProtectionRuleInput) (toolutil.DeleteOutput, error)

DeleteTagProtectionRuleOutput deletes a registry tag protection rule and returns the canonical success message shape.

func DeleteTagsBulk

func DeleteTagsBulk(ctx context.Context, client *gitlabclient.Client, input DeleteTagsBulkInput) error

DeleteTagsBulk deletes registry repository tags in bulk using regex patterns.

func DeleteTagsBulkOutput

func DeleteTagsBulkOutput(ctx context.Context, client *gitlabclient.Client, input DeleteTagsBulkInput) (toolutil.DeleteOutput, error)

DeleteTagsBulkOutput deletes registry tags in bulk and returns the canonical success message shape.

func FormatProtectionRuleListMarkdown

func FormatProtectionRuleListMarkdown(out ProtectionRuleListOutput) string

FormatProtectionRuleListMarkdown formats a list of protection rules.

func FormatProtectionRuleMarkdown

func FormatProtectionRuleMarkdown(out ProtectionRuleOutput) string

FormatProtectionRuleMarkdown formats a single protection rule as markdown.

func FormatRepositoryListMarkdown

func FormatRepositoryListMarkdown(out RepositoryListOutput) string

FormatRepositoryListMarkdown formats a list of registry repositories.

func FormatRepositoryMarkdown

func FormatRepositoryMarkdown(out RepositoryOutput) string

FormatRepositoryMarkdown formats a single registry repository as markdown.

func FormatTagListMarkdown

func FormatTagListMarkdown(out TagListOutput) string

FormatTagListMarkdown formats a list of registry tags.

func FormatTagMarkdown

func FormatTagMarkdown(out TagOutput) string

FormatTagMarkdown formats a single registry tag as markdown.

func FormatTagProtectionRuleListMarkdown added in v2.3.0

func FormatTagProtectionRuleListMarkdown(out TagProtectionRuleListOutput) string

FormatTagProtectionRuleListMarkdown formats a list of tag protection rules.

func FormatTagProtectionRuleMarkdown added in v2.3.0

func FormatTagProtectionRuleMarkdown(out TagProtectionRuleOutput) string

FormatTagProtectionRuleMarkdown formats a single tag protection rule as markdown.

Types

type CreateProtectionRuleInput

type CreateProtectionRuleInput struct {
	ProjectID                   toolutil.StringOrInt         `json:"project_id" jsonschema:"Project ID or path,required"`
	RepositoryPathPattern       string                       `json:"repository_path_pattern" jsonschema:"Repository path pattern (e.g. my-project/my-image*),required"`
	MinimumAccessLevelForPush   gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_push,omitempty" jsonschema:"Minimum access level for push (maintainer, owner, admin)"`
	MinimumAccessLevelForDelete gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_delete,omitempty" jsonschema:"Minimum access level for delete (maintainer, owner, admin)"`
}

CreateProtectionRuleInput defines the repository path pattern and access thresholds for a new rule.

type CreateTagProtectionRuleInput added in v2.3.0

type CreateTagProtectionRuleInput struct {
	ProjectID                   toolutil.StringOrInt         `json:"project_id" jsonschema:"Project ID or path,required"`
	TagNamePattern              string                       `json:"tag_name_pattern" jsonschema:"Tag name pattern as a RE2 regular expression (e.g. v.+),required"`
	MinimumAccessLevelForPush   gl.ProtectionRuleAccessLevel `` /* 195-byte string literal not displayed */
	MinimumAccessLevelForDelete gl.ProtectionRuleAccessLevel `` /* 199-byte string literal not displayed */
}

CreateTagProtectionRuleInput defines the tag name pattern and access thresholds for a new rule.

type DeleteProtectionRuleInput

type DeleteProtectionRuleInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RuleID    int64                `json:"rule_id" jsonschema:"Protection rule ID,required"`
}

DeleteProtectionRuleInput identifies the registry protection rule to delete.

type DeleteRepositoryInput

type DeleteRepositoryInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RepositoryID int64                `json:"repository_id" jsonschema:"Registry repository ID,required"`
}

DeleteRepositoryInput identifies the project-owned registry repository to delete.

type DeleteTagInput

type DeleteTagInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RepositoryID int64                `json:"repository_id" jsonschema:"Registry repository ID,required"`
	TagName      string               `json:"tag_name" jsonschema:"Tag name to delete,required"`
}

DeleteTagInput identifies the registry tag to delete.

type DeleteTagProtectionRuleInput added in v2.3.0

type DeleteTagProtectionRuleInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RuleID    int64                `json:"rule_id" jsonschema:"Tag protection rule ID,required"`
}

DeleteTagProtectionRuleInput identifies the registry tag protection rule to delete.

type DeleteTagsBulkInput

type DeleteTagsBulkInput struct {
	ProjectID       toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RepositoryID    int64                `json:"repository_id" jsonschema:"Registry repository ID,required"`
	NameRegexDelete string               `json:"name_regex_delete,omitempty" jsonschema:"Regex pattern of tag names to delete"`
	NameRegexKeep   string               `json:"name_regex_keep,omitempty" jsonschema:"Regex pattern of tag names to keep"`
	KeepN           int64                `json:"keep_n,omitempty" jsonschema:"Number of latest tags to keep"`
	OlderThan       string               `json:"older_than,omitempty" jsonschema:"Delete tags older than this (e.g. 1h, 2d, 1month)"`
	NameRegex       string               `json:"name_regex,omitempty" jsonschema:"Deprecated: regex pattern of tag names to delete. Use name_regex_delete instead"`
}

DeleteTagsBulkInput defines the tag cleanup rule for a registry repository.

type GetRepositoryInput

type GetRepositoryInput struct {
	RepositoryID int64 `json:"repository_id" jsonschema:"Registry repository ID,required"`
	Tags         bool  `json:"tags,omitempty" jsonschema:"Include tags in response"`
	TagsCount    bool  `json:"tags_count,omitempty" jsonschema:"Include tags count in response"`
}

GetRepositoryInput identifies a registry repository by ID and optional tag metadata flags.

type GetTagInput

type GetTagInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RepositoryID int64                `json:"repository_id" jsonschema:"Registry repository ID,required"`
	TagName      string               `json:"tag_name" jsonschema:"Tag name,required"`
}

GetTagInput identifies a single registry tag within a project repository.

type ListGroupInput

type ListGroupInput struct {
	GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or path,required"`
	OrderBy string               `json:"order_by,omitempty" jsonschema:"Column to order results by (keyset pagination)"`
	Sort    string               `json:"sort,omitempty"     jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListGroupInput selects a group registry repository page.

type ListProjectInput

type ListProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	Tags      bool                 `json:"tags,omitempty" jsonschema:"Include tags in response"`
	TagsCount bool                 `json:"tags_count,omitempty" jsonschema:"Include tags count in response"`
	OrderBy   string               `json:"order_by,omitempty" jsonschema:"Column to order results by (keyset pagination)"`
	Sort      string               `json:"sort,omitempty"     jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListProjectInput selects a project registry repository page and optional tag metadata.

type ListProtectionRulesInput

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

ListProtectionRulesInput selects the project whose registry protection rules are listed.

type ListTagProtectionRulesInput added in v2.3.0

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

ListTagProtectionRulesInput selects the project whose registry tag protection rules are listed.

type ListTagsInput

type ListTagsInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	RepositoryID int64                `json:"repository_id" jsonschema:"Registry repository ID,required"`
	OrderBy      string               `json:"order_by,omitempty" jsonschema:"Column to order results by (keyset pagination)"`
	Sort         string               `json:"sort,omitempty"     jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListTagsInput selects a registry repository tag page.

type ProtectionRuleListOutput

type ProtectionRuleListOutput struct {
	toolutil.HintableOutput
	Rules      []ProtectionRuleOutput    `json:"rules"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ProtectionRuleListOutput represents a list of protection rules.

func ListProtectionRules

func ListProtectionRules(ctx context.Context, client *gitlabclient.Client, input ListProtectionRulesInput) (ProtectionRuleListOutput, error)

ListProtectionRules lists container registry protection rules for a project.

type ProtectionRuleOutput

type ProtectionRuleOutput struct {
	toolutil.HintableOutput
	ID                          int64                        `json:"id"`
	ProjectID                   int64                        `json:"project_id"`
	RepositoryPathPattern       string                       `json:"repository_path_pattern"`
	MinimumAccessLevelForPush   gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_push"`
	MinimumAccessLevelForDelete gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_delete"`
}

ProtectionRuleOutput represents a container registry protection rule.

func CreateProtectionRule

func CreateProtectionRule(ctx context.Context, client *gitlabclient.Client, input CreateProtectionRuleInput) (ProtectionRuleOutput, error)

CreateProtectionRule creates a container registry protection rule.

func UpdateProtectionRule

func UpdateProtectionRule(ctx context.Context, client *gitlabclient.Client, input UpdateProtectionRuleInput) (ProtectionRuleOutput, error)

UpdateProtectionRule updates a container registry protection rule.

type RepositoryListOutput

type RepositoryListOutput struct {
	toolutil.HintableOutput
	Repositories []RepositoryOutput        `json:"repositories"`
	Pagination   toolutil.PaginationOutput `json:"pagination"`
}

RepositoryListOutput represents a paginated list of registry repositories.

func ListGroup

ListGroup lists container registry repositories for a group.

func ListProject

func ListProject(ctx context.Context, client *gitlabclient.Client, input ListProjectInput) (RepositoryListOutput, error)

ListProject lists container registry repositories for a project.

type RepositoryOutput

type RepositoryOutput struct {
	toolutil.HintableOutput
	ID                     int64                      `json:"id"`
	Name                   string                     `json:"name"`
	Path                   string                     `json:"path"`
	ProjectID              int64                      `json:"project_id"`
	Location               string                     `json:"location"`
	CreatedAt              string                     `json:"created_at,omitempty"`
	CleanupPolicyStartedAt string                     `json:"cleanup_policy_started_at,omitempty"`
	Status                 gl.ContainerRegistryStatus `json:"status,omitempty"`
	TagsCount              int64                      `json:"tags_count"`
	Tags                   []TagOutput                `json:"tags,omitempty"`
}

RepositoryOutput represents a container registry repository.

func GetRepository

func GetRepository(ctx context.Context, client *gitlabclient.Client, input GetRepositoryInput) (RepositoryOutput, error)

GetRepository gets details of a single registry repository by its ID.

type TagListOutput

type TagListOutput struct {
	toolutil.HintableOutput
	Tags       []TagOutput               `json:"tags"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

TagListOutput represents a paginated list of registry tags.

func ListTags

func ListTags(ctx context.Context, client *gitlabclient.Client, input ListTagsInput) (TagListOutput, error)

ListTags lists tags for a registry repository.

type TagOutput

type TagOutput struct {
	toolutil.HintableOutput
	Name          string `json:"name"`
	Path          string `json:"path"`
	Location      string `json:"location"`
	Revision      string `json:"revision,omitempty"`
	ShortRevision string `json:"short_revision,omitempty"`
	Digest        string `json:"digest,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
	TotalSize     int64  `json:"total_size"`
}

TagOutput represents a container registry image tag.

func GetTag

func GetTag(ctx context.Context, client *gitlabclient.Client, input GetTagInput) (TagOutput, error)

GetTag gets details of a specific registry repository tag.

type TagProtectionRuleListOutput added in v2.3.0

type TagProtectionRuleListOutput struct {
	toolutil.HintableOutput
	Rules      []TagProtectionRuleOutput `json:"rules"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

TagProtectionRuleListOutput represents a list of tag protection rules.

func ListTagProtectionRules added in v2.3.0

ListTagProtectionRules lists container registry tag protection rules for a project.

type TagProtectionRuleOutput added in v2.3.0

type TagProtectionRuleOutput struct {
	toolutil.HintableOutput
	ID                          int64                        `json:"id"`
	ProjectID                   int64                        `json:"project_id"`
	TagNamePattern              string                       `json:"tag_name_pattern"`
	MinimumAccessLevelForPush   gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_push"`
	MinimumAccessLevelForDelete gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_delete"`
}

TagProtectionRuleOutput represents a container registry tag protection rule.

func CreateTagProtectionRule added in v2.3.0

func CreateTagProtectionRule(ctx context.Context, client *gitlabclient.Client, input CreateTagProtectionRuleInput) (TagProtectionRuleOutput, error)

CreateTagProtectionRule creates a container registry tag protection rule.

func UpdateTagProtectionRule added in v2.3.0

func UpdateTagProtectionRule(ctx context.Context, client *gitlabclient.Client, input UpdateTagProtectionRuleInput) (TagProtectionRuleOutput, error)

UpdateTagProtectionRule updates a container registry tag protection rule.

type UpdateProtectionRuleInput

type UpdateProtectionRuleInput struct {
	ProjectID                   toolutil.StringOrInt         `json:"project_id" jsonschema:"Project ID or path,required"`
	RuleID                      int64                        `json:"rule_id" jsonschema:"Protection rule ID,required"`
	RepositoryPathPattern       string                       `json:"repository_path_pattern,omitempty" jsonschema:"Repository path pattern"`
	MinimumAccessLevelForPush   gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_push,omitempty" jsonschema:"Minimum access level for push (maintainer, owner, admin)"`
	MinimumAccessLevelForDelete gl.ProtectionRuleAccessLevel `json:"minimum_access_level_for_delete,omitempty" jsonschema:"Minimum access level for delete (maintainer, owner, admin)"`
}

UpdateProtectionRuleInput identifies a registry protection rule and the fields to change.

type UpdateTagProtectionRuleInput added in v2.3.0

type UpdateTagProtectionRuleInput struct {
	ProjectID                   toolutil.StringOrInt         `json:"project_id" jsonschema:"Project ID or path,required"`
	RuleID                      int64                        `json:"rule_id" jsonschema:"Tag protection rule ID,required"`
	TagNamePattern              string                       `json:"tag_name_pattern,omitempty" jsonschema:"Tag name pattern as a RE2 regular expression"`
	MinimumAccessLevelForPush   gl.ProtectionRuleAccessLevel `` /* 129-byte string literal not displayed */
	MinimumAccessLevelForDelete gl.ProtectionRuleAccessLevel `` /* 133-byte string literal not displayed */
}

UpdateTagProtectionRuleInput identifies a registry tag protection rule and the fields to change.

Jump to

Keyboard shortcuts

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