Documentation
¶
Index ¶
- func DeleteByID(client newclient.Client, spaceID string, ID string) error
- func Get(client newclient.Client, spaceID string, query ApprovalRulesQuery) (*resources.Resources[*ApprovalRule], error)
- type ApprovalRule
- func Add(client newclient.Client, spaceID string, rule *ApprovalRule) (*ApprovalRule, error)
- func GetAll(client newclient.Client, spaceID string) ([]*ApprovalRule, error)
- func GetByID(client newclient.Client, spaceID string, ID string) (*ApprovalRule, error)
- func NewApprovalRule(name string) *ApprovalRule
- func Update(client newclient.Client, spaceID string, rule *ApprovalRule) (*ApprovalRule, error)
- type ApprovalRuleIdScope
- type ApprovalRuleScopingStrategy
- type ApprovalRuleTagScope
- type ApprovalRulesQuery
- type TenantApprovalStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteByID ¶
DeleteByID deletes the approval rule that matches the input ID.
func Get ¶
func Get(client newclient.Client, spaceID string, query ApprovalRulesQuery) (*resources.Resources[*ApprovalRule], error)
Get returns a paginated collection of approval rules matching the query.
Types ¶
type ApprovalRule ¶
type ApprovalRule struct {
SpaceID string `json:"SpaceId,omitempty"`
Name string `json:"Name" validate:"required"`
Description string `json:"Description,omitempty"`
ScopingStrategy ApprovalRuleScopingStrategy `json:"ScopingStrategy"`
// TenantApprovalStrategy determines how tenanted deployments are gated. When
// several rules match a deployment the most restrictive wins, so any matching
// rule set to "PerTenant" results in per-tenant change requests.
TenantApprovalStrategy TenantApprovalStrategy `json:"TenantApprovalStrategy"`
TagScopes []ApprovalRuleTagScope `json:"TagScopes"`
IdScopes []ApprovalRuleIdScope `json:"IdScopes"`
// MinimumApproversRequired is accepted in the range 1-99. It is omitted when
// zero, which is never a valid value, so that the server applies its default
// of 2 rather than rejecting the request.
MinimumApproversRequired int `json:"MinimumApproversRequired,omitempty"`
// AllowSelfApproval controls whether the deployment creator may approve their own
// deployment. There is no separate "block by creator" field — this is it, inverted.
AllowSelfApproval bool `json:"AllowSelfApproval"`
// IsDisabled disables the rule. There is no "Enabled" field — this is it, inverted.
// An enabled rule must have at least one scope.
IsDisabled bool `json:"IsDisabled"`
// ApprovingUserIds and ApprovingTeamIds must not both be empty.
ApprovingUserIds []string `json:"ApprovingUserIds"`
ApprovingTeamIds []string `json:"ApprovingTeamIds"`
resources.Resource
}
ApprovalRule is the reusable approval configuration applied to a set of projects/environments (by tag or by id).
Update replaces the whole resource: Name, Description, MinimumApproversRequired and the approver lists are always taken from the request, so omitting Description clears it and omitting MinimumApproversRequired resets it to 2. Always send a fully populated rule, ideally one returned by GetByID.
The stored ScopingStrategy follows whichever scope list is sent: supplying TagScopes forces "Tag" and clears IdScopes, and supplying IdScopes forces "Id" and clears TagScopes.
func Add ¶
func Add(client newclient.Client, spaceID string, rule *ApprovalRule) (*ApprovalRule, error)
Add creates a new approval rule.
func GetAll ¶
func GetAll(client newclient.Client, spaceID string) ([]*ApprovalRule, error)
GetAll returns all approval rules in the space. The list endpoint requires the skip and take query parameters, so this issues a single request with the maximum take rather than relying on the generic paginated helper (which omits them and would be rejected by the server).
func NewApprovalRule ¶
func NewApprovalRule(name string) *ApprovalRule
NewApprovalRule creates an ApprovalRule with server-friendly defaults (Tag scoping, per-release tenant approvals, 2 minimum approvers, and empty scope/approver slices).
func Update ¶
func Update(client newclient.Client, spaceID string, rule *ApprovalRule) (*ApprovalRule, error)
Update modifies an existing approval rule. The whole resource is replaced, so send a fully populated rule — see the ApprovalRule documentation.
func (*ApprovalRule) GetName ¶
func (r *ApprovalRule) GetName() string
func (*ApprovalRule) SetName ¶
func (r *ApprovalRule) SetName(name string)
type ApprovalRuleIdScope ¶
type ApprovalRuleIdScope struct {
Id string `json:"Id,omitempty"`
ProjectId string `json:"ProjectId"`
EnvironmentIds []string `json:"EnvironmentIds"`
}
ApprovalRuleIdScope scopes a rule by a project + specific environments (ScopingStrategy = "Id"). Each scope requires at least one environment id, and every environment must be reachable from the project's lifecycles.
type ApprovalRuleScopingStrategy ¶
type ApprovalRuleScopingStrategy string
ApprovalRuleScopingStrategy selects whether a rule is scoped by tags or by ids.
const ( ApprovalRuleScopingStrategyTag ApprovalRuleScopingStrategy = "Tag" ApprovalRuleScopingStrategyId ApprovalRuleScopingStrategy = "Id" )
type ApprovalRuleTagScope ¶
type ApprovalRuleTagScope struct {
Id string `json:"Id,omitempty"`
ProjectTags []string `json:"ProjectTags"`
EnvironmentTags []string `json:"EnvironmentTags"`
}
ApprovalRuleTagScope scopes a rule by project/environment tags (ScopingStrategy = "Tag"). Each scope requires at least one project tag and at least one environment tag.
type ApprovalRulesQuery ¶
type ApprovalRulesQuery struct {
PartialName string `uri:"partialName,omitempty" url:"partialName,omitempty"`
Skip int `uri:"skip" url:"skip"`
Take int `uri:"take,omitempty" url:"take,omitempty"`
}
ApprovalRulesQuery is the query for the paginated approval-rules list endpoint.
type TenantApprovalStrategy ¶
type TenantApprovalStrategy string
TenantApprovalStrategy determines how tenanted deployments are gated.
const ( // TenantApprovalStrategyPerRelease creates a single change request that covers // every tenant of a release and environment. TenantApprovalStrategyPerRelease TenantApprovalStrategy = "PerRelease" // TenantApprovalStrategyPerTenant creates a separate change request, requiring // its own approvals, for each tenant. TenantApprovalStrategyPerTenant TenantApprovalStrategy = "PerTenant" )