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

protectedenvdata

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: 4 Imported by: 0

Documentation

Overview

Package protectedenvdata contains the protected environment shapes the project and the group protected environment tools share: the four entry shapes a protect and an update send, the deploy access levels and approval rules GitLab answers with, and the Markdown both packages render them in.

GitLab declares the project and the group routes with the same param blocks (ee/lib/api/protected_environments.rb) and answers both with API::Entities::ProtectedEnvironment, and client-go models each side with structs that carry the same fields, so the shapes are declared once here and each package names them under its own name. Each package keeps its handlers, its converters to and from its own client-go structs, and its formatters, which differ in their headings and hints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListHeader

func ListHeader() string

ListHeader is the header of the table a page of protected environments is listed in, a project's or a group's.

func ListRow

func ListRow(name string, requiredApprovalCount int64, deployAccessLevels []AccessLevel, approvalRules []ApprovalRule) string

ListRow is one protected environment's row of the table ListHeader opens: its name, the approvals GitLab sent for it, and how many deploy access levels and approval rules it carries.

func WriteRules

func WriteRules(c *toolutil.Card, requiredApprovalCount int64, deployAccessLevels []AccessLevel, approvalRules []ApprovalRule)

WriteRules writes what a protected environment's card carries between its heading and its hints: the approvals it needs, then the deploy access levels and the approval rules as nested collections, each table left out when GitLab sent no entry for it. The project and the group cards differ in nothing else.

An environment with approval rules of its own counts its approvals per rule, so the single number GitLab sends beside them is not what gates a deployment, and printing it alone said a deployment needed two approvals when it needed one from each of three rules.

Types

type AccessLevel

type AccessLevel 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"`
}

AccessLevel represents a deploy access level on a protected environment, as gl.EnvironmentAccessDescription and gl.GroupEnvironmentAccessDescription both decode it.

It and ApprovalRule are named without the Output suffix because neither is a response on its own: each is a row of the protected environment a project or a group route answers with, and is published there under the name its package gives it, AccessLevelOutput and ApprovalRuleOutput. The request-path audit reads a type named for an output as a response.

type ApprovalRule

type ApprovalRule 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"`
}

ApprovalRule represents an approval rule on a protected environment, as gl.EnvironmentApprovalRule and gl.GroupEnvironmentApprovalRule both decode it.

type ApprovalRuleInput

type ApprovalRuleInput struct {
	UserID                *int64 `` /* 140-byte string literal not displayed */
	GroupID               *int64 `` /* 151-byte string literal not displayed */
	AccessLevel           *int   `` /* 204-byte string literal not displayed */
	RequiredApprovalCount *int64 `json:"required_approvals,omitempty"       jsonschema:"Approvals this rule requires, 1 to 5 (GitLab's default is 1)"`
	GroupInheritanceType  *int64 `` /* 146-byte string literal not displayed */
}

ApprovalRuleInput represents an approval rule for an environment. It mirrors gl.EnvironmentApprovalRuleOptions and gl.GroupEnvironmentApprovalRuleOptions, which carry the same fields, field for field but for access_level_description, which neither the protect nor the update route declares, so GitLab drops it (upstream register row 139).

func (ApprovalRuleInput) EnvironmentAccess

func (r ApprovalRuleInput) EnvironmentAccess() toolutil.EnvironmentAccess

EnvironmentAccess answers the rule as the checks of GitLab's rules read it.

type DeployAccessLevelInput

type DeployAccessLevelInput struct {
	AccessLevel          *int   `` /* 193-byte string literal not displayed */
	UserID               *int64 `` /* 139-byte string literal not displayed */
	GroupID              *int64 `` /* 147-byte string literal not displayed */
	GroupInheritanceType *int64 `` /* 145-byte string literal not displayed */
}

DeployAccessLevelInput represents an access level for deployment. It mirrors gl.EnvironmentAccessOptions and gl.GroupEnvironmentAccessOptions, which carry the same fields.

func (DeployAccessLevelInput) EnvironmentAccess

func (d DeployAccessLevelInput) EnvironmentAccess() toolutil.EnvironmentAccess

EnvironmentAccess answers the entry as the checks of GitLab's rules read it.

type UpdateApprovalRuleInput

type UpdateApprovalRuleInput struct {
	ID                    *int64 `` /* 140-byte string literal not displayed */
	UserID                *int64 `` /* 193-byte string literal not displayed */
	GroupID               *int64 `` /* 204-byte string literal not displayed */
	AccessLevel           *int   `` /* 257-byte string literal not displayed */
	RequiredApprovalCount *int64 `json:"required_approvals,omitempty"       jsonschema:"Approvals this rule requires, 1 to 5 unless _destroy is true"`
	GroupInheritanceType  *int64 `` /* 146-byte string literal not displayed */
	Destroy               *bool  `json:"_destroy,omitempty"                 jsonschema:"Set true, with the rule's id, to remove this rule"`
}

UpdateApprovalRuleInput represents an updated approval rule for an environment. It mirrors gl.UpdateEnvironmentApprovalRuleOptions and gl.UpdateGroupEnvironmentApprovalRuleOptions, which carry the same fields, field for field but for access_level_description, which the update route does not declare, so GitLab drops it (upstream register row 139).

func (UpdateApprovalRuleInput) EnvironmentAccess

func (r UpdateApprovalRuleInput) EnvironmentAccess() toolutil.EnvironmentAccess

EnvironmentAccess answers the rule as the checks of GitLab's rules read it.

type UpdateDeployAccessLevelInput

type UpdateDeployAccessLevelInput struct {
	ID                   *int64 `` /* 148-byte string literal not displayed */
	AccessLevel          *int   `` /* 224-byte string literal not displayed */
	UserID               *int64 `` /* 170-byte string literal not displayed */
	GroupID              *int64 `` /* 178-byte string literal not displayed */
	GroupInheritanceType *int64 `` /* 145-byte string literal not displayed */
	Destroy              *bool  `json:"_destroy,omitempty"               jsonschema:"Set true, with the entry's id, to remove this access level"`
}

UpdateDeployAccessLevelInput represents an updated access level for deployment. It mirrors gl.UpdateEnvironmentAccessOptions and gl.UpdateGroupEnvironmentAccessOptions, which carry the same fields.

func (UpdateDeployAccessLevelInput) EnvironmentAccess

EnvironmentAccess answers the entry as the checks of GitLab's rules read it.

Jump to

Keyboard shortcuts

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