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 ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func DeleteProtectionRule(ctx context.Context, client *gitlabclient.Client, ...) error
- func DeleteProtectionRuleOutput(ctx context.Context, client *gitlabclient.Client, ...) (toolutil.DeleteOutput, error)
- func DeleteRepository(ctx context.Context, client *gitlabclient.Client, input DeleteRepositoryInput) error
- func DeleteRepositoryOutput(ctx context.Context, client *gitlabclient.Client, input DeleteRepositoryInput) (toolutil.DeleteOutput, error)
- func DeleteTag(ctx context.Context, client *gitlabclient.Client, input DeleteTagInput) error
- func DeleteTagOutput(ctx context.Context, client *gitlabclient.Client, input DeleteTagInput) (toolutil.DeleteOutput, error)
- func DeleteTagsBulk(ctx context.Context, client *gitlabclient.Client, input DeleteTagsBulkInput) error
- func DeleteTagsBulkOutput(ctx context.Context, client *gitlabclient.Client, input DeleteTagsBulkInput) (toolutil.DeleteOutput, error)
- func FormatProtectionRuleListMarkdown(out ProtectionRuleListOutput) string
- func FormatProtectionRuleMarkdown(out ProtectionRuleOutput) string
- func FormatRepositoryListMarkdown(out RepositoryListOutput) string
- func FormatRepositoryMarkdown(out RepositoryOutput) string
- func FormatTagListMarkdown(out TagListOutput) string
- func FormatTagMarkdown(out TagOutput) string
- type CreateProtectionRuleInput
- type DeleteProtectionRuleInput
- type DeleteRepositoryInput
- type DeleteTagInput
- type DeleteTagsBulkInput
- type GetRepositoryInput
- type GetTagInput
- type ListGroupInput
- type ListProjectInput
- type ListProtectionRulesInput
- type ListTagsInput
- type ProtectionRuleListOutput
- type ProtectionRuleOutput
- type RepositoryListOutput
- type RepositoryOutput
- type TagListOutput
- type TagOutput
- type UpdateProtectionRuleInput
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 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 ¶
FormatTagMarkdown formats a single registry tag 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 string `json:"minimum_access_level_for_push,omitempty" jsonschema:"Minimum access level for push (maintainer, owner, admin)"`
MinimumAccessLevelForDelete string `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 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 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)"`
}
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"`
Page int `json:"page,omitempty" jsonschema:"Page number for pagination"`
PerPage int `json:"per_page,omitempty" jsonschema:"Number of items per page"`
}
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"`
Page int `json:"page,omitempty" jsonschema:"Page number for pagination"`
PerPage int `json:"per_page,omitempty" jsonschema:"Number of items per page"`
}
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 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"`
Page int `json:"page,omitempty" jsonschema:"Page number for pagination"`
PerPage int `json:"per_page,omitempty" jsonschema:"Number of items per page"`
}
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 string `json:"minimum_access_level_for_push"`
MinimumAccessLevelForDelete string `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 ¶
func ListGroup(ctx context.Context, client *gitlabclient.Client, input ListGroupInput) (RepositoryListOutput, error)
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 string `json:"status,omitempty"`
TagsCount int64 `json:"tags_count"`
}
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 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 string `json:"minimum_access_level_for_push,omitempty" jsonschema:"Minimum access level for push (maintainer, owner, admin)"`
MinimumAccessLevelForDelete string `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.