protectedenvs

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package protectedenvs implements GitLab protected environment operations including list, get, protect, update, and unprotect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) string

FormatListMarkdown renders a paginated list of protected environments as a Markdown table.

func FormatOutputMarkdown

func FormatOutputMarkdown(pe Output) string

FormatOutputMarkdown renders a single protected environment as Markdown.

func RegisterMeta

func RegisterMeta(server *mcp.Server, client *gitlab.Client)

RegisterMeta registers the gitlab_protected_environment meta-tool.

func RegisterTools

func RegisterTools(server *mcp.Server, client *gitlab.Client)

RegisterTools registers the five protected environment management tools with the MCP server.

func Unprotect

func Unprotect(ctx context.Context, client *gitlabclient.Client, input UnprotectInput) error

Unprotect removes protection from an environment.

Types

type AccessLevelOutput

type AccessLevelOutput struct {
	ID                     int64  `json:"id"`
	AccessLevel            int    `json:"access_level"`
	AccessLevelDescription string `json:"access_level_description"`
	UserID                 int64  `json:"user_id,omitempty"`
	GroupID                int64  `json:"group_id,omitempty"`
	GroupInheritanceType   int64  `json:"group_inheritance_type,omitempty"`
}

AccessLevelOutput represents an access level on a protected environment.

type ApprovalRuleInput

type ApprovalRuleInput struct {
	UserID                *int64 `json:"user_id,omitempty"                jsonschema:"User ID"`
	GroupID               *int64 `json:"group_id,omitempty"               jsonschema:"Group ID"`
	AccessLevel           *int   `json:"access_level,omitempty"           jsonschema:"Access level"`
	RequiredApprovalCount *int64 `json:"required_approvals,omitempty"     jsonschema:"Required number of approvals"`
	GroupInheritanceType  *int64 `json:"group_inheritance_type,omitempty" jsonschema:"Group inheritance type (0=direct, 1=inherited)"`
}

ApprovalRuleInput represents an approval rule for an environment.

type ApprovalRuleOutput

type ApprovalRuleOutput struct {
	ID                     int64  `json:"id"`
	UserID                 int64  `json:"user_id,omitempty"`
	GroupID                int64  `json:"group_id,omitempty"`
	AccessLevel            int    `json:"access_level"`
	AccessLevelDescription string `json:"access_level_description"`
	RequiredApprovalCount  int64  `json:"required_approvals"`
	GroupInheritanceType   int64  `json:"group_inheritance_type,omitempty"`
}

ApprovalRuleOutput represents an approval rule on a protected environment.

type DeployAccessLevelInput

type DeployAccessLevelInput struct {
	AccessLevel          *int   `json:"access_level,omitempty"           jsonschema:"Access level (0=No access, 30=Developer, 40=Maintainer, 60=Admin)"`
	UserID               *int64 `json:"user_id,omitempty"                jsonschema:"User ID"`
	GroupID              *int64 `json:"group_id,omitempty"               jsonschema:"Group ID"`
	GroupInheritanceType *int64 `json:"group_inheritance_type,omitempty" jsonschema:"Group inheritance type (0=direct, 1=inherited)"`
}

DeployAccessLevelInput represents an access level for deployment.

type GetInput

type GetInput struct {
	ProjectID   toolutil.StringOrInt `json:"project_id"   jsonschema:"Project ID or URL-encoded path,required"`
	Environment string               `json:"environment"  jsonschema:"Environment name,required"`
}

GetInput holds parameters for retrieving a single protected environment.

type ListInput

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

ListInput holds parameters for listing protected environments.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Environments []Output                  `json:"environments"`
	Pagination   toolutil.PaginationOutput `json:"pagination"`
}

ListOutput represents a paginated list of protected environments.

func List

func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)

List retrieves a paginated list of protected environments for a project.

type Output

type Output struct {
	toolutil.HintableOutput
	Name                  string               `json:"name"`
	DeployAccessLevels    []AccessLevelOutput  `json:"deploy_access_levels"`
	RequiredApprovalCount int64                `json:"required_approval_count"`
	ApprovalRules         []ApprovalRuleOutput `json:"approval_rules"`
}

Output represents a single protected environment.

func Get

func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Get retrieves a single protected environment by name.

func Protect

func Protect(ctx context.Context, client *gitlabclient.Client, input ProtectInput) (Output, error)

Protect creates a new protected environment.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)

Update modifies an existing protected environment.

type ProtectInput

type ProtectInput struct {
	ProjectID             toolutil.StringOrInt     `json:"project_id"                        jsonschema:"Project ID or URL-encoded path,required"`
	Name                  string                   `json:"name"                              jsonschema:"Environment name to protect,required"`
	DeployAccessLevels    []DeployAccessLevelInput `json:"deploy_access_levels,omitempty"    jsonschema:"Deploy access levels"`
	RequiredApprovalCount *int64                   `json:"required_approval_count,omitempty" jsonschema:"Required number of approvals"`
	ApprovalRules         []ApprovalRuleInput      `json:"approval_rules,omitempty"          jsonschema:"Approval rules"`
}

ProtectInput holds parameters for protecting a repository environment.

type UnprotectInput

type UnprotectInput struct {
	ProjectID   toolutil.StringOrInt `json:"project_id"   jsonschema:"Project ID or URL-encoded path,required"`
	Environment string               `json:"environment"  jsonschema:"Environment name to unprotect,required"`
}

UnprotectInput holds parameters for unprotecting an environment.

type UpdateApprovalRuleInput

type UpdateApprovalRuleInput struct {
	ID                    *int64 `json:"id,omitempty"                     jsonschema:"Existing approval rule ID to update"`
	UserID                *int64 `json:"user_id,omitempty"                jsonschema:"User ID"`
	GroupID               *int64 `json:"group_id,omitempty"               jsonschema:"Group ID"`
	AccessLevel           *int   `json:"access_level,omitempty"           jsonschema:"Access level"`
	RequiredApprovalCount *int64 `json:"required_approvals,omitempty"     jsonschema:"Required number of approvals"`
	GroupInheritanceType  *int64 `json:"group_inheritance_type,omitempty" jsonschema:"Group inheritance type"`
	Destroy               *bool  `json:"_destroy,omitempty"               jsonschema:"Set true to remove this rule"`
}

UpdateApprovalRuleInput represents an updated approval rule for an environment.

type UpdateDeployAccessLevelInput

type UpdateDeployAccessLevelInput struct {
	ID                   *int64 `json:"id,omitempty"                     jsonschema:"Existing access level ID to update"`
	AccessLevel          *int   `json:"access_level,omitempty"           jsonschema:"Access level"`
	UserID               *int64 `json:"user_id,omitempty"                jsonschema:"User ID"`
	GroupID              *int64 `json:"group_id,omitempty"               jsonschema:"Group ID"`
	GroupInheritanceType *int64 `json:"group_inheritance_type,omitempty" jsonschema:"Group inheritance type"`
	Destroy              *bool  `json:"_destroy,omitempty"               jsonschema:"Set true to remove this access level"`
}

UpdateDeployAccessLevelInput represents an updated access level for deployment.

type UpdateInput

type UpdateInput struct {
	ProjectID             toolutil.StringOrInt           `json:"project_id"                        jsonschema:"Project ID or URL-encoded path,required"`
	Environment           string                         `json:"environment"                       jsonschema:"Environment name,required"`
	Name                  string                         `json:"name,omitempty"                    jsonschema:"New environment name"`
	DeployAccessLevels    []UpdateDeployAccessLevelInput `json:"deploy_access_levels,omitempty"    jsonschema:"Updated deploy access levels"`
	RequiredApprovalCount *int64                         `json:"required_approval_count,omitempty" jsonschema:"Required number of approvals"`
	ApprovalRules         []UpdateApprovalRuleInput      `json:"approval_rules,omitempty"          jsonschema:"Updated approval rules"`
}

UpdateInput holds parameters for updating a protected environment.

Jump to

Keyboard shortcuts

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