config

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConditionalLabel labelType = "conditional"
	GenerateLabels   labelType = "generate"
)

Variables

This section is empty.

Functions

func WithConfig added in v0.10.1

func WithConfig(ctx context.Context, config *Config) context.Context

Types

type Action added in v0.3.0

type Action struct {
	// The name of the action, this is purely for debugging and your convenience.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.name
	Name string `json:"name" yaml:"name"`

	// (Optional) Only one action per group (in order) will be executed per evaluation cycle.
	// Use this to 'stop' other actions from running with the same group name
	Group string `json:"group,omitempty" yaml:"group,omitempty"`

	// A key controlling if the action should executed or not.
	//
	// This script is in Expr-lang: https://expr-lang.org/docs/language-definition
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if
	If string `json:"if" yaml:"if"`

	// The list of operations to take if the action.if returned true.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if.then
	Then []ActionStep `json:"then" yaml:"then"`
}

func (*Action) Evaluate added in v0.3.0

func (p *Action) Evaluate(ctx context.Context, evalContext scm.EvalContext) (bool, error)

func (*Action) Setup added in v0.18.0

func (p *Action) Setup(evalContext scm.EvalContext) (*vm.Program, error)

type ActionStep added in v0.3.0

type ActionStep map[string]any

This key controls what kind of action that should be taken.

See: https://jippi.github.io/scm-engine/configuration/#actions.if.then

func (ActionStep) Get added in v0.18.0

func (step ActionStep) Get(name string) (any, error)

func (ActionStep) JSONSchema added in v0.18.0

func (step ActionStep) JSONSchema() *jsonschema.Schema

func (ActionStep) OptionalString added in v0.18.0

func (step ActionStep) OptionalString(name, defaultValue string) (string, error)

func (ActionStep) RequiredString added in v0.18.0

func (step ActionStep) RequiredString(name string) (string, error)

type Actions added in v0.3.0

type Actions []Action

func (Actions) Evaluate added in v0.3.0

func (actions Actions) Evaluate(ctx context.Context, evalContext scm.EvalContext) ([]Action, error)

type AddLabelAction added in v0.18.0

type AddLabelAction struct {
	BaseAction

	// The label name to add.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if.then.action
	Label string `json:"label" yaml:"label"`
}

type ApproveAction added in v0.18.0

type ApproveAction struct {
	BaseAction
}

Hello World?

type BaseAction added in v0.18.0

type BaseAction struct {
	// The action to take
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if.then.action
	Action string `json:"action" yaml:"action"`
}

type CloseAction added in v0.18.0

type CloseAction struct {
	BaseAction
}

type CommentAction added in v0.18.0

type CommentAction struct {
	BaseAction

	// The message that will be commented on the Merge Request
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if.then.action
	Message string `json:"message" yaml:"message"`
}

type Config

type Config struct {
	// (Optional) When on, no actions will be taken, but instead logged for review
	DryRun *bool `json:"dry_run,omitempty" yaml:"dry_run" jsonschema:"default=false"`

	// (Optional) Import configuration from other git repositories
	//
	// See: https://jippi.github.io/scm-engine/configuration/#include
	Includes []Include `json:"include,omitempty" yaml:"include"`

	// (Optional) Configure what users that should be ignored when considering activity on a Merge Request
	//
	// SCM-Engine defines activity as comments, reviews, commits, adding/removing labels and similar actions made on a change request.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#ignore_activity_from
	IgnoreActivityFrom IgnoreActivityFrom `json:"ignore_activity_from,omitempty" yaml:"ignore_activity_from"`

	// (Optional) Actions can modify a Merge Request in various ways, for example, adding a comment or closing the Merge Request.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions
	Actions Actions `json:"actions,omitempty" yaml:"actions"`

	// (Optional) Labels are a way to categorize and filter issues, merge requests, and epics in GitLab. -- GitLab documentation
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label
	Labels Labels `json:"label,omitempty" yaml:"label"`
}

func FromContext added in v0.10.1

func FromContext(ctx context.Context) *Config

func LoadFile

func LoadFile(path string) (*Config, error)

LoadFile loads and parses a GITLAB_LABELS file at the path specified.

func ParseFile

func ParseFile(f io.Reader) (*Config, error)

ParseFile parses a Gitlabber file, returning a Config.

func ParseFileString added in v0.16.0

func ParseFileString(in string) (*Config, error)

ParseFile parses a Gitlabber file, returning a Config.

func (Config) Evaluate

func (c Config) Evaluate(ctx context.Context, evalContext scm.EvalContext) ([]scm.EvaluationResult, []Action, error)

func (Config) Lint added in v0.18.0

func (c Config) Lint(_ context.Context, evalContext scm.EvalContext) error

func (*Config) LoadIncludes added in v0.16.0

func (c *Config) LoadIncludes(ctx context.Context, client scm.Client) error

type IgnoreActivityFrom added in v0.10.1

type IgnoreActivityFrom struct {
	// (Optional) Should bot users be ignored when considering activity? Default: false
	//
	// See: https://jippi.github.io/scm-engine/configuration/#ignore_activity_from.bots
	IsBot bool `json:"bots,omitempty" yaml:"bots" jsonschema:"default=false"`

	// (Optional) A list of usernames that should be ignored when considering user activity. Default: []
	//
	// See: https://jippi.github.io/scm-engine/configuration/#ignore_activity_from.usernames
	Usernames []string `json:"usernames,omitempty" yaml:"usernames"`

	// (Optional) A list of emails that should be ignored when considering user activity. Default: []
	// NOTE: If a user do not have a public email configured on their profile, that users activity will never match this rule.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#ignore_activity_from.emails
	Emails []string `json:"emails,omitempty" yaml:"emails"`
}

func (IgnoreActivityFrom) Matches added in v0.10.1

func (i IgnoreActivityFrom) Matches(actor scm.Actor) bool

type Include added in v0.16.0

type Include struct {
	// The project to include files from
	//
	// See: https://jippi.github.io/scm-engine/configuration/#include.project
	Project string `json:"project" yaml:"project"`

	// The list of files to include from the project. The paths must be relative to the repository root, e.x. label/some-config-file.yml; NOT /label/some-config-file.yml
	//
	// See: https://jippi.github.io/scm-engine/configuration/#include.files
	Files []string `json:"files" yaml:"files"`

	// (Optional) Git reference to read the configuration from; it can be a tag, branch, or commit SHA.
	//
	// If omitted, HEAD is used; meaning your default branch.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#include.ref
	Ref *string `json:"ref,omitempty" yaml:"ref"`
}

type Label

type Label struct {
	// (Optional) Strategy used for the label
	//
	// - "conditional" will, based on the boolean output of [script], control if the label [name] should be added/removed on the MR
	// - "computed" will, based on the list of strings output of [script], add/remove labels on the MR
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.strategy
	Strategy labelType `json:"strategy,omitempty" yaml:"strategy,omitempty" jsonschema:"default=conditional,enum=conditional,enum=generate"`

	// Name of the label being generated.
	//
	// May only be used with [conditional] labelling type
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.name
	Name string `json:"name,omitempty" yaml:"name,omitempty" jsonschema:"dependentRequired"`

	// (Optional) Description for the label being generated.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.description
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// (Optional) The HEX color code to use for the label.
	//
	// May use the color variables (e.g., $purple-300) defined in Twitter Bootstrap
	// https://getbootstrap.com/docs/5.3/customize/color/#all-colors
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.color
	Color string `json:"color,omitempty" yaml:"color,omitempty"`

	// (Optional) Priority controls wether the label should be a priority label or regular one.
	//
	// This controls if the label is prioritized (sorted first) in the list.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.priority
	Priority types.Value[int] `json:"priority,omitempty" yaml:"priority,omitempty"`

	// Script contains the (https://expr-lang.org/) script used to emit labels for the MR.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.script
	Script string `json:"script" yaml:"script,omitempty"`

	// SkipIf is an optional (https://expr-lang.org/) script, returning a boolean, wether to
	// skip (true) or process (false) this label step.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#label.skip_if
	SkipIf string `json:"skip_if,omitempty" yaml:"skip_if,omitempty"`
	// contains filtered or unexported fields
}

func (*Label) Evaluate

func (p *Label) Evaluate(ctx context.Context, evalContext scm.EvalContext) ([]scm.EvaluationResult, error)

func (*Label) Setup added in v0.18.0

func (p *Label) Setup(evalContext scm.EvalContext) error

func (*Label) ShouldSkip

func (p *Label) ShouldSkip(ctx context.Context, evalContext scm.EvalContext) (bool, error)

type Labels

type Labels []*Label

func (Labels) Evaluate

func (labels Labels) Evaluate(ctx context.Context, evalContext scm.EvalContext) ([]scm.EvaluationResult, error)

type LockDiscussionAction added in v0.18.0

type LockDiscussionAction struct {
	BaseAction
}

type RemoveLabelAction added in v0.18.0

type RemoveLabelAction struct {
	BaseAction

	// The label name to remove.
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if.then.action
	Label string `json:"label" yaml:"label"`
}

type ReopenAction added in v0.18.0

type ReopenAction struct {
	BaseAction
}

type UnapproveAction added in v0.18.0

type UnapproveAction struct {
	BaseAction
}

type UnlockDiscussionAction added in v0.18.0

type UnlockDiscussionAction struct {
	BaseAction
}

type UpdateDescriptionAction added in v0.18.0

type UpdateDescriptionAction struct {
	BaseAction

	// A list of key/value pairs to replace in the description.
	// The key is the raw string to replace in the Merge Request description.
	// The value is an Expr Lang expression returning a string that key will be replaced with
	//
	// See: https://jippi.github.io/scm-engine/configuration/#actions.if.then.action
	Replace map[string]string `json:"replace" yaml:"replace"`
}

Updates the Merge Request Description

Jump to

Keyboard shortcuts

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