Documentation
¶
Index ¶
- Constants
- Variables
- func ChangedFields(stamp Stamp, operation Operation, names ...string) []string
- func CheckWrite(operation Operation, stamp Stamp, live string, names []string, label string) (bool, error)
- func Description(item domain.WorkItem, synopsis string) string
- func Digest(values ...any) string
- func Edited(stamp Stamp, live string) bool
- func FieldDigests(operation Operation, names ...string) map[string]string
- func OrphanWarnings(labels map[string]string, planned []Operation) []string
- func ResolveReferences(value string, resolved map[domain.ItemID]RemoteRef) (string, error)
- func UniqueSorted(values []string) []string
- type AccessChecker
- type Adapter
- type ConcurrencyLimiter
- type Confirmer
- type FieldChange
- type IssueTypeChecker
- type Operation
- type OperationResult
- type Plan
- type PlanInput
- type Preflighter
- type PublishedIssue
- type Receipt
- type RemoteRef
- type Stamp
- type SyncRequest
- type Syncer
- type Synopsis
Constants ¶
const ( ActionCreateIssue = "create_issue" ActionReuseIssue = "reuse_issue" ActionUpdateIssue = "update_issue" ActionLinkIssues = "link_issues" ActionUnlinkIssues = "unlink_issues" )
Operation actions shared by adapters and apply.
const SchemaVersion = "v1"
Variables ¶
var Rewritten = FieldChange{Note: "rewritten from the bundle"}
Rewritten notes a field too long to show, such as a description.
Functions ¶
func ChangedFields ¶ added in v0.21.6
ChangedFields lists the named fields whose digest differs from a stamp. A stamp without source digests predates sync, so every field counts as changed and the first sync rewrites the issue.
func CheckWrite ¶ added in v0.21.6
func CheckWrite(operation Operation, stamp Stamp, live string, names []string, label string) (bool, error)
CheckWrite decides whether an update still needs to write. It reports written when the stamp already records this operation's write, as on a retry of an update that landed before apply recorded it. Otherwise it refuses an issue that changed after the plan read it: --force covers only the edits the plan saw.
func Description ¶ added in v0.26.0
Description opens an item's description with the repository it changes, when it names one, and an initiative's with synopsis above that, when there is one. Each opener stands in a paragraph of its own. The repository sits in a code span, so a tracker renders no part of it as a link.
func Digest ¶ added in v0.21.6
Digest hashes values into a stable hex string. Maps hash identically whatever their key order, because encoding/json sorts map keys.
func Edited ¶ added in v0.21.6
Edited reports whether a remote issue may have changed since devex last wrote it. An issue stamped before sync existed carries no source digests and counts as unedited. A stamp without a live digest records a write devex could not read back, or a stamp damaged by hand, so it counts as edited.
func FieldDigests ¶ added in v0.21.6
FieldDigests digests each named field of an operation.
func OrphanWarnings ¶ added in v0.21.6
OrphanWarnings names published issues whose markers the bundle no longer plans. labels maps each published marker to its issue label.
func ResolveReferences ¶
func UniqueSorted ¶ added in v0.16.4
UniqueSorted returns the distinct non-empty values in sorted order, so label sets stay stable across plans and therefore keep the plan digest stable.
Types ¶
type AccessChecker ¶ added in v0.24.0
AccessChecker confirms a target's credentials work and can reach its project, for doctor --online.
type Adapter ¶
type Adapter interface {
ID() string
Plan(context.Context, PlanInput, config.Target) ([]Operation, []string, error)
// Resolve reports which of the given operations already exist remotely, keyed by
// idempotency key. Apply calls it once with the operations a receipt has not already
// accounted for, so an adapter can search for exactly the work that remains. Only apply
// calls it, so it may write, such as to label issues for a cheaper next lookup.
Resolve(context.Context, config.Target, *Plan, []Operation) (map[string]RemoteRef, error)
Execute(context.Context, config.Target, Operation, map[domain.ItemID]RemoteRef) (RemoteRef, error)
}
type ConcurrencyLimiter ¶ added in v0.24.0
type ConcurrencyLimiter interface {
MaxConcurrent() int
}
ConcurrencyLimiter declares how many operations an adapter can execute at once; apply runs one at a time for an adapter without it.
type Confirmer ¶ added in v0.24.0
type Confirmer interface {
// Confirm returns the candidates, keyed by idempotency key, whose issue still exists in the
// target and still carries that key, with each issue's current reference. It leaves out a
// missing issue and returns an error for a failed read.
Confirm(ctx context.Context, target config.Target, candidates map[string]RemoteRef) (map[string]RemoteRef, error)
}
Confirmer reads published issues by key, which a remote answers consistently where its search can lag behind a recent write. Apply uses it to recognize issues an earlier plan published that Resolve could not find. Like Resolve, it runs only during apply, so it may repair what its lookups rely on, such as a label.
type FieldChange ¶ added in v0.24.0
type FieldChange struct {
Before string `yaml:"before,omitempty" json:"before,omitempty"`
After string `yaml:"after,omitempty" json:"after,omitempty"`
Note string `yaml:"note,omitempty" json:"note,omitempty"`
}
FieldChange is one field an update rewrites, as plan output shows it: the remote's value and the plan's, or a note where a value is too long to show.
func LabelChange ¶ added in v0.24.0
func LabelChange(existing []string, desired []string) FieldChange
LabelChange shows the labels an update leaves on an issue: it adds the desired ones and removes none.
type IssueTypeChecker ¶ added in v0.24.0
type IssueTypeChecker interface {
MissingIssueTypes(context.Context, config.Target) ([]string, error)
}
IssueTypeChecker reports which issue types the target's configuration names that its project lacks.
type Operation ¶
type Operation struct {
ID string `yaml:"id" json:"id"`
Action string `yaml:"action" json:"action"`
ItemID domain.ItemID `yaml:"item_id" json:"item_id"`
DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty"`
IdempotencyKey string `yaml:"idempotency_key" json:"idempotency_key"`
Summary string `yaml:"summary" json:"summary"`
Fields map[string]any `yaml:"fields" json:"fields"`
// Diff shows, for plan output, each field an update rewrites. Apply ignores it.
Diff map[string]FieldChange `yaml:"diff,omitempty" json:"diff,omitempty"`
}
func SyncIssue ¶ added in v0.21.6
func SyncIssue(operation Operation, issue PublishedIssue, changed []string, force bool, liveFields []string) (Operation, string)
SyncIssue turns a planned create for a published item into a reuse or an update. changed names the remote fields the update rewrites, and liveFields those whose content the live digest covers. On an edited issue, the update drops its live fields with a warning; the rest leave edits intact, so they proceed. With force, it rewrites every live field instead, so the new live digest records only what devex wrote. With nothing left to write, the item keeps its issue.
type OperationResult ¶
type Plan ¶
type Plan struct {
SchemaVersion string `yaml:"schema_version" json:"schema_version"`
ID string `yaml:"id" json:"id"`
Provider string `yaml:"provider" json:"provider"`
TargetName string `yaml:"target" json:"target"`
Target config.Target `yaml:"target_config" json:"target_config"`
DiscoveryID string `yaml:"discovery_id" json:"discovery_id"`
BundlePath string `yaml:"bundle_path" json:"bundle_path"`
SourceDigest string `yaml:"source_digest" json:"source_digest"`
PlanDigest string `yaml:"plan_digest" json:"plan_digest"`
GeneratedAt time.Time `yaml:"generated_at" json:"generated_at"`
Warnings []string `yaml:"warnings,omitempty" json:"warnings,omitempty"`
Operations []Operation `yaml:"operations" json:"operations"`
}
type PlanInput ¶ added in v0.16.5
type PlanInput struct {
WorkBreakdown *domain.WorkBreakdown
// DocumentURL resolves the discovery document for a reader, empty when no URL can be built.
DocumentURL string
// TrackingURL is the issue the discovery document links from its title, empty when absent.
TrackingURL string
// Synopsis opens every initiative's description. Its fields are empty when the bundle has none.
Synopsis Synopsis
}
PlanInput carries the bundle and everything derived from its surroundings that planning needs. The derived fields are best-effort: a bundle outside a GitHub checkout has no document URL, and a discovery document that links no tracking issue has no tracking URL.
type Preflighter ¶ added in v0.24.0
Preflighter checks the creates apply has left to make against the remote before it writes anything.
type PublishedIssue ¶ added in v0.21.6
PublishedIssue is a remote issue a sync matched to a planned item. Label names it for people, such as "Jira DEVEX-2".
type Receipt ¶
type Receipt struct {
SchemaVersion string `yaml:"schema_version" json:"schema_version"`
PlanID string `yaml:"plan_id" json:"plan_id"`
Provider string `yaml:"provider" json:"provider"`
TargetName string `yaml:"target" json:"target"`
PlanDigest string `yaml:"plan_digest" json:"plan_digest"`
Status string `yaml:"status" json:"status"`
UpdatedAt time.Time `yaml:"updated_at" json:"updated_at"`
Operations map[string]OperationResult `yaml:"operations" json:"operations"`
}
type Stamp ¶ added in v0.21.6
type Stamp struct {
ID string `json:"id"`
Source map[string]string `json:"source,omitempty"`
Live string `json:"live,omitempty"`
}
Stamp records what devex last wrote to a remote issue: one digest per bundle field it wrote from, and one of the title and description as the remote stored them.
func DamagedStamp ¶ added in v0.21.6
DamagedStamp stands in for a stamp changed by hand. It records a write with no live digest, which counts as edited.
type SyncRequest ¶ added in v0.21.6
SyncRequest carries the planned operations and warnings to reconcile. Force overwrites issues edited since devex last wrote them.
type Syncer ¶ added in v0.21.6
type Syncer interface {
Sync(context.Context, config.Target, SyncRequest) ([]Operation, []string, error)
}
Syncer reconciles already-published work with a bundle. It reads the remote and returns the operations that bring it in line, with the plan's warnings revised to match them.
type Synopsis ¶ added in v0.26.0
type Synopsis struct {
// WithDiagram keeps the Mermaid diagram.
WithDiagram string
// DiagramLinked replaces the diagram with a link to the synopsis document, or drops it when
// no URL can be built.
DiagramLinked string
}
Synopsis is the bundle's synopsis, rendered for trackers that draw Mermaid and for those that cannot.