featureflags

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package featureflags implements MCP tools for GitLab feature flag operations.

The package wraps the GitLab Feature flags 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 feature flag actions exposed as MCP tools. The list, get, create, update, and delete routes are projected into the dynamic, meta, individual, and audit surfaces by the action catalog (ADR-0004). Each spec carries non-generic discovery metadata (Usage, natural-language Aliases, RelatedActions, and a "Returns: … See also: …" individual-tool description) per the 1:1 audit R-META requirement.

func DeleteFeatureFlag

func DeleteFeatureFlag(ctx context.Context, client *gitlabclient.Client, input DeleteInput) error

DeleteFeatureFlag deletes a feature flag.

func FormatFeatureFlagMarkdown

func FormatFeatureFlagMarkdown(out Output) string

FormatFeatureFlagMarkdown formats a single feature flag as markdown.

func FormatListFeatureFlagsMarkdown

func FormatListFeatureFlagsMarkdown(out ListOutput) string

FormatListFeatureFlagsMarkdown formats a list of feature flags as markdown.

Types

type CreateInput

type CreateInput struct {
	ProjectID   toolutil.StringOrInt  `json:"project_id" jsonschema:"Project ID or path,required"`
	Name        string                `json:"name" jsonschema:"Feature flag name,required"`
	Description string                `json:"description,omitempty" jsonschema:"Feature flag description"`
	Version     string                `json:"version,omitempty" jsonschema:"Version of the feature flag (new_version_flag)"`
	Active      *bool                 `json:"active,omitempty" jsonschema:"Whether the flag is active"`
	Strategies  []CreateStrategyInput `` /* 146-byte string literal not displayed */
}

CreateInput contains parameters for creating a feature flag.

type CreateScopeInput

type CreateScopeInput struct {
	EnvironmentScope string `` /* 137-byte string literal not displayed */
}

CreateScopeInput represents a scope of a strategy being created. Creation carries no scope identity: GitLab documents environment_scope alone for POST, and id and _destroy only for PUT.

type CreateStrategyInput

type CreateStrategyInput struct {
	Name       string                  `json:"name" jsonschema:"Strategy name (e.g. default, gradualRolloutUserId, userWithId, flexibleRollout),required"`
	Parameters *StrategyParameterInput `json:"parameters,omitempty" jsonschema:"Strategy-specific parameters (group_id, user_ids, percentage, rollout, stickiness)"`
	UserListID *int64                  `` /* 170-byte string literal not displayed */
	Scopes     []CreateScopeInput      `json:"scopes,omitempty" jsonschema:"Environment scopes to which this strategy applies"`
}

CreateStrategyInput represents a strategy of a flag being created. A strategy that does not exist yet has no id to address and nothing to remove, which is why GitLab documents neither for POST.

type DeleteInput

type DeleteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	Name      string               `json:"name" jsonschema:"Feature flag name,required"`
}

DeleteInput contains parameters for deleting a feature flag.

type GetInput

type GetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	Name      string               `json:"name" jsonschema:"Feature flag name,required"`
}

GetInput contains parameters for getting a feature flag.

type ListInput

type ListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
	Scope     string               `json:"scope,omitempty" jsonschema:"Filter by scope (enabled or disabled)"`
	OrderBy   string               `json:"order_by,omitempty" jsonschema:"Column to order results by (e.g. name, created_at, updated_at)"`
	Sort      string               `json:"sort,omitempty" jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListInput contains parameters for listing feature flags.

type ListOutput

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

ListOutput represents a paginated list of feature flags.

func ListFeatureFlags

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

ListFeatureFlags lists feature flags for a project.

type Output

type Output struct {
	toolutil.HintableOutput
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Active      bool             `json:"active"`
	Version     string           `json:"version"`
	CreatedAt   string           `json:"created_at,omitempty"`
	UpdatedAt   string           `json:"updated_at,omitempty"`
	Scopes      []ScopeOutput    `json:"scopes,omitempty"`
	Strategies  []StrategyOutput `json:"strategies,omitempty"`
}

Output represents a single project feature flag.

func CreateFeatureFlag

func CreateFeatureFlag(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)

CreateFeatureFlag creates a new feature flag.

func GetFeatureFlag

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

GetFeatureFlag gets a single feature flag by name.

func UpdateFeatureFlag

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

UpdateFeatureFlag updates an existing feature flag.

type ScopeOutput

type ScopeOutput struct {
	ID               int64  `json:"id"`
	EnvironmentScope string `json:"environment_scope"`
}

ScopeOutput represents a feature flag scope.

type StrategyOutput

type StrategyOutput struct {
	ID         int64                    `json:"id"`
	Name       string                   `json:"name"`
	Parameters *StrategyParameterOutput `json:"parameters,omitempty"`
	UserList   *StrategyUserListOutput  `json:"user_list,omitempty"`
	Scopes     []ScopeOutput            `json:"scopes,omitempty"`
}

StrategyOutput represents a feature flag strategy.

type StrategyParameterInput

type StrategyParameterInput struct {
	GroupID    string `json:"group_id,omitempty" jsonschema:"Group ID for the gradualRolloutUserId strategy"`
	UserIDs    string `json:"user_ids,omitempty" jsonschema:"Comma-separated user IDs for the userWithId strategy"`
	Percentage string `json:"percentage,omitempty" jsonschema:"Percentage of users to include for the gradualRolloutUserId strategy (e.g. 25)"`
	Rollout    string `json:"rollout,omitempty" jsonschema:"Rollout duration (0-100) for the gradualRolloutUserId strategy"`
	Stickiness string `` /* 154-byte string literal not displayed */
}

StrategyParameterInput represents strategy parameters for create/update.

type StrategyParameterOutput

type StrategyParameterOutput struct {
	GroupID    string `json:"group_id,omitempty"`
	UserIDs    string `json:"user_ids,omitempty"`
	Percentage string `json:"percentage,omitempty"`
	Rollout    string `json:"rollout,omitempty"`
	Stickiness string `json:"stickiness,omitempty"`
}

StrategyParameterOutput represents strategy parameters.

type StrategyUserListOutput

type StrategyUserListOutput struct {
	ID        int64  `json:"id"`
	IID       int64  `json:"iid"`
	ProjectID int64  `json:"project_id"`
	Name      string `json:"name"`
	UserXIDs  string `json:"user_xids"`
	CreatedAt string `json:"created_at,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

StrategyUserListOutput represents the user list a strategy targets, returned for strategies of the gitlabUserList type.

type UpdateInput

type UpdateInput struct {
	ProjectID   toolutil.StringOrInt  `json:"project_id" jsonschema:"Project ID or path,required"`
	Name        string                `json:"name" jsonschema:"Current feature flag name,required"`
	NewName     string                `json:"new_name,omitempty" jsonschema:"New feature flag name"`
	Description string                `json:"description,omitempty" jsonschema:"Feature flag description"`
	Active      *bool                 `json:"active,omitempty" jsonschema:"Whether the flag is active"`
	Strategies  []UpdateStrategyInput `` /* 230-byte string literal not displayed */
}

UpdateInput contains parameters for updating a feature flag.

type UpdateScopeInput

type UpdateScopeInput struct {
	ID               *int64 `` /* 167-byte string literal not displayed */
	EnvironmentScope string `` /* 147-byte string literal not displayed */
	Destroy          *bool  `json:"_destroy,omitempty" jsonschema:"Set true together with id to delete this scope from the strategy"`
}

UpdateScopeInput represents a scope of a strategy being updated, where a scope already on the flag can be addressed by id and removed with _destroy.

type UpdateStrategyInput

type UpdateStrategyInput struct {
	ID         int64                   `` /* 161-byte string literal not displayed */
	Name       string                  `` /* 170-byte string literal not displayed */
	Parameters *StrategyParameterInput `json:"parameters,omitempty" jsonschema:"Strategy-specific parameters (group_id, user_ids, percentage, rollout, stickiness)"`
	UserListID *int64                  `` /* 170-byte string literal not displayed */
	Destroy    *bool                   `json:"_destroy,omitempty" jsonschema:"Set true together with id (and no name) to delete this strategy from the flag"`
	Scopes     []UpdateScopeInput      `json:"scopes,omitempty" jsonschema:"Environment scopes to which this strategy applies"`
}

UpdateStrategyInput represents a strategy of a flag being updated, where a strategy already on the flag can be addressed by id and removed with _destroy.

Jump to

Keyboard shortcuts

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