transition

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package transition is the single owner of the gadak transition write (CLI, including `gadak close`, and REST). Both surfaces call Apply so identifier resolution, required screen fields, resolution lookup, field-alias remap, category-token idempotency, and the origin write cannot exist on one path and not the other.

Refused errors carry catalogue data only. The CLI formats flag names; REST maps them to HTTP 400. This package does not name CLI flags.

Mirror refresh is not here: it is the write-through tail shared by every write verb (CLI mutate / server mutate), not a property of this verb.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllASCIIDigits

func AllASCIIDigits(s string) bool

AllASCIIDigits reports whether s is one or more ASCII digits — the "the user typed a bare id, not a name" discriminator in catalog resolution.

func FormatNamedIDs

func FormatNamedIDs(list []jira.NamedID) string

FormatNamedIDs joins a catalog's names (ids where the name is empty) with ", " — the "available: …" list in resolution errors. Single owner; the `gadak agent` / `gadak edit` surfaces import it (GDK-619).

func IsRefused

func IsRefused(err error) bool

IsRefused reports whether err is a caller-side refusal (bad identifier, missing required field, unknown resolution). Origin errors are not.

func Preview

func Preview(ctx context.Context, o Origin, key, target string) (id string, changed bool, err error)

Preview answers what Apply would do without writing: the resolved transition id when one would fire (changed=true), or the category no-op (changed=false, empty id). It exists so a dry-run cannot drift from the real write — both run resolveTransition. A pick miss that is not a no-op returns the pick error.

Types

type Origin

type Origin interface {
	Transitions(ctx context.Context, key string) ([]jira.Transition, error)
	Transition(ctx context.Context, key, transitionID string, fields map[string]any, comment json.RawMessage) error
}

Origin is the origin verbs Apply needs. origin.Writer satisfies it.

type Refused

type Refused struct {
	Msg string
}

Refused is a caller-side refusal: the origin was not written. Adapters map this to a 400 / CLI message; origin errors pass through unchanged.

func (*Refused) Error

func (e *Refused) Error() string

type Request

type Request struct {
	Key        string
	Target     string
	Resolution string
	Fields     map[string]any
	Comment    string
}

Request is one transition write. Target is whatever PickTransition accepts: transition id, target status id, transition/status name, or a status category token (new|inprogress|done). Fields are already parsed (CLI --field, REST JSON); aliases are remapped here. Resolution is a name or id; a name is resolved from the transition's allowedValues, else the origin's resolution catalog.

type RequiredFieldsError

type RequiredFieldsError struct {
	Key             string
	TransitionName  string
	FormattedFields []string
}

RequiredFieldsError is a Refused whose screen lists required fields the request did not supply. CLI appends flag names; REST uses Error as-is.

func (*RequiredFieldsError) Error

func (e *RequiredFieldsError) Error() string

type Result

type Result struct {
	Changed bool `json:"changed"`
}

Result is a successful Apply. Changed is false when Target was a category token and the origin already reports that category: no POST (and no comment). A named or id miss is still an error, not a no-op.

func Apply

func Apply(ctx context.Context, o Origin, cfg *config.Config, req Request) (Result, error)

Apply lists the issue's transitions, picks one, assembles fields, and calls the origin. A category-token target (new|inprogress|done) that the origin already reports is a no-op success (Changed=false). It does not refresh the mirror — that tail is mutate.

Jump to

Keyboard shortcuts

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