contract

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package contract parses and validates declarative Pitcrew contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAndValidate

func ParseAndValidate(source []byte) (Contract, []ValidationError)

ParseAndValidate decodes a YAML contract and reports all detected violations.

Types

type Constraints

type Constraints struct {
	Min         *int   `yaml:"min,omitempty" json:"min,omitempty"`
	Max         *int   `yaml:"max,omitempty" json:"max,omitempty"`
	MinLength   *int   `yaml:"minLength,omitempty" json:"minLength,omitempty"`
	MaxLength   *int   `yaml:"maxLength,omitempty" json:"maxLength,omitempty"`
	Pattern     string `yaml:"pattern,omitempty" json:"pattern,omitempty"`
	MinItems    *int   `yaml:"minItems,omitempty" json:"minItems,omitempty"`
	MaxItems    *int   `yaml:"maxItems,omitempty" json:"maxItems,omitempty"`
	UniqueItems bool   `yaml:"uniqueItems,omitempty" json:"uniqueItems,omitempty"`
}

Constraints contains type-specific field validation limits.

type Contract

type Contract struct {
	APIVersion  string      `yaml:"apiVersion" json:"apiVersion"`
	ID          string      `yaml:"id" json:"id"`
	Version     int         `yaml:"version" json:"version"`
	Name        string      `yaml:"name" json:"name"`
	Description string      `yaml:"description,omitempty" json:"description,omitempty"`
	Priorities  []Priority  `yaml:"priorities" json:"priorities"`
	Roles       []Role      `yaml:"roles" json:"roles"`
	IssueTypes  []IssueType `yaml:"issueTypes" json:"issueTypes"`
}

Contract is a versioned process definition.

type Field

type Field struct {
	ID          string       `yaml:"id" json:"id"`
	Name        string       `yaml:"name" json:"name"`
	Type        string       `yaml:"type" json:"type"`
	Required    bool         `yaml:"required,omitempty" json:"required,omitempty"`
	Default     any          `yaml:"default,omitempty" json:"default,omitempty"`
	Values      []string     `yaml:"values,omitempty" json:"values,omitempty"`
	TargetTypes []string     `yaml:"targetTypes,omitempty" json:"targetTypes,omitempty"`
	Items       *FieldItem   `yaml:"items,omitempty" json:"items,omitempty"`
	Constraints *Constraints `yaml:"constraints,omitempty" json:"constraints,omitempty"`
}

Field defines typed custom data for an issue type.

type FieldItem

type FieldItem struct {
	Type        string   `yaml:"type" json:"type"`
	Values      []string `yaml:"values,omitempty" json:"values,omitempty"`
	TargetTypes []string `yaml:"targetTypes,omitempty" json:"targetTypes,omitempty"`
}

FieldItem defines the scalar element type of a list field.

type IssueType

type IssueType struct {
	ID           string       `yaml:"id" json:"id"`
	Name         string       `yaml:"name" json:"name"`
	Description  string       `yaml:"description,omitempty" json:"description,omitempty"`
	InitialState string       `yaml:"initialState" json:"initialState"`
	States       []State      `yaml:"states" json:"states"`
	Transitions  []Transition `yaml:"transitions" json:"transitions"`
	Fields       []Field      `yaml:"fields" json:"fields"`
}

IssueType defines custom fields and a workflow for one kind of issue.

type Priority

type Priority struct {
	ID      string `yaml:"id" json:"id"`
	Name    string `yaml:"name" json:"name"`
	Rank    int    `yaml:"rank" json:"rank"`
	Default bool   `yaml:"default,omitempty" json:"default,omitempty"`
}

Priority defines a sortable issue priority.

type Role

type Role struct {
	ID          string `yaml:"id" json:"id"`
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
}

Role describes a responsibility in a process.

type State

type State struct {
	ID       string `yaml:"id" json:"id"`
	Name     string `yaml:"name" json:"name"`
	Terminal bool   `yaml:"terminal,omitempty" json:"terminal,omitempty"`
}

State is one state in an issue workflow.

type Transition

type Transition struct {
	From string `yaml:"from" json:"from"`
	To   string `yaml:"to" json:"to"`
}

Transition permits a workflow state change.

type ValidationError

type ValidationError struct {
	Code    string `json:"code"`
	Path    string `json:"path,omitempty"`
	Message string `json:"message"`
}

ValidationError describes one contract violation.

func (ValidationError) String

func (e ValidationError) String() string

Jump to

Keyboard shortcuts

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