ghsource

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ghsource is the read-only GitHub Projects v2 client behind `aeman migrate`: it loads one project board over the GraphQL API and maps it onto the domain board.Board the migration consumes. It deliberately carries no write path — the git layout is the only store aeman writes to.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBoardNotFound is returned when a project cannot be located.
	ErrBoardNotFound = errors.New("project board not found")

	// ErrBadCredentials is GitHub rejecting the caller's token (401/403). It
	// is a distinct condition from a board being missing: the token is dead —
	// expired, revoked, or superseded — and no retry with it will ever work.
	ErrBadCredentials = errors.New("github rejected the token")
)

Sentinel errors returned by the client; callers tell them apart with errors.Is.

Functions

This section is empty.

Types

type Client

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

Client reads GitHub Projects v2 boards over the GraphQL API with a fixed bearer token.

func New

func New(token string, opts ...Option) *Client

New builds a Client authenticating with the given token.

func (*Client) LoadBoard

func (c *Client) LoadBoard(ctx context.Context, owner string, project int) (Export, error)

LoadBoard loads a project board and maps it into the domain board.Board the migration consumes (with the hidden sprint-state cards split out by board.NewBoard), alongside the per-item GitHub data.

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer is the subset of *http.Client used by the client, so tests can inject a stub transport.

type Export

type Export struct {
	Board board.Board
	// Items is keyed by item id and covers every card NewBoard sorted into
	// Board.Cards, Board.Tasks or the roster.
	Items map[string]Item
}

Export is what the reader hands the migration: the domain board, plus what Projects v2 carried per item that the domain card no longer does.

type Field

type Field struct {
	ID       string
	Name     string
	DataType string
	Options  []FieldOption
}

Field is a Projects v2 field definition — what the roles are resolved from.

type FieldOption

type FieldOption struct {
	ID    string
	Name  string
	Color string
}

FieldOption is one single-select choice; a zone is read by its colour.

type Item

type Item struct {
	// IsDraft marks a draft-issue card — the kind the boards were made of.
	IsDraft bool
	// URL is the underlying issue or PR (empty on a draft); it becomes the
	// card's link.
	URL string
	// Events is the action log parsed out of the draft body (or the log
	// comment on an issue card), in source order.
	Events []board.Event
}

Item is the GitHub side of one project item.

type Option

type Option func(*Client)

Option customises a Client.

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint overrides the GraphQL endpoint (used in tests).

func WithHTTPClient

func WithHTTPClient(d Doer) Option

WithHTTPClient sets the HTTP client used for requests.

Jump to

Keyboard shortcuts

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