writer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package writer carries out an issue plan on GitHub.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingLabel = errors.New("missing label")

ErrMissingLabel is returned when a repo lacks the baton label.

View Source
var ErrNoRedirect = errors.New("apply needs --redirect-owner: the preview doesn't write to real repos")

ErrNoRedirect is returned when writing without a sandbox owner. The preview never writes to the real component repos.

View Source
var ErrUnknownOp = errors.New("unknown plan op")

ErrUnknownOp is returned for a plan item the writer can't carry out.

Functions

This section is empty.

Types

type Issue

type Issue struct {
	ID     int64
	Number int
	State  string // "open" or "closed"
	Title  string
	Body   string
}

Issue is the part of a GitHub issue the writer uses.

type Issues

type Issues interface {
	LabelExists(repo, label string) (bool, error)
	CreateLabel(repo, label, color, description string) error
	// ListIssues returns open and closed issues with label, without PRs.
	ListIssues(repo, label string) ([]Issue, error)
	CreateIssue(repo, title, body string, labels, assignees []string) (Issue, error)
	UpdateIssue(repo string, number int, u Update) (Issue, error)
	Comment(repo string, number int, body string) error
	SubIssueIDs(repo string, number int) ([]int64, error)
	AddSubIssue(repo string, number int, childID int64) error
}

Issues is the issue API the writer needs. Repos are "owner/name".

type Options

type Options struct {
	// RedirectOwner sends every issue for owner/name to
	// RedirectOwner/name, prefixes titles with the intended repo, and
	// drops assignees so no real maintainer is notified.
	RedirectOwner string
	// CreateLabel creates the baton label when a repo lacks it.
	// Otherwise a missing label is an error.
	CreateLabel bool
}

Options control where and how issues are written.

func (*Options) Validate

func (o *Options) Validate() error

Validate checks the options.

type Update

type Update struct {
	State       string
	StateReason string
	Title       string
	Body        string
}

Update changes an issue. Empty fields are left alone.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer applies plans.

func New

func New(opts *Options, api Issues) *Writer

New returns a Writer for opts over api.

func (*Writer) Run

func (w *Writer) Run(rep *reconcile.Report, items []plan.Item) ([]string, error)

Run carries out items. Issues whose key the report doesn't know (an older release, a removed rule) are closed as superseded. Issues for blocked, unknown, or errored obligations are left open. It stops at the first API error and returns what it did so far.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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