config

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 18 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

func (*Action) Evaluate added in v0.3.0

func (p *Action) Evaluate(ctx context.Context, evalContext scm.EvalContext) (bool, 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 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) 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" 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" 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"`

	// (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"`

	// (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"`

	// 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"`

	// 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"`
	// contains filtered or unexported fields
}

func (*Label) Evaluate

func (p *Label) Evaluate(ctx context.Context, evalContext scm.EvalContext) ([]scm.EvaluationResult, 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)

Jump to

Keyboard shortcuts

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