ghissue

package
v0.20.8 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ghissue is a minimal GitHub Issues client: obtaining a bearer token and filing one issue. It knows nothing about muster sessions, the daemon store, or Claude Code — CreateIssue takes two strings (title, body) and posts them; the caller (internal/server) owns everything about what goes into those strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTPClient  *http.Client
	BaseURL     string
	TokenReader TokenReader
}

Client is a minimal GitHub Issues client. TokenReader is re-read on every CreateIssue call — never stored, re-read on every use (kb:adr/issue-auth-gh-token-at-time-of-use).

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, repo, title, body string) (number int, htmlURL string, err error)

CreateIssue obtains a fresh bearer token via c.TokenReader, then POSTs {c.BaseURL}/repos/{repo}/issues with title/body (kb:anchor/issue.create's measured headers), returning the created issue's number and html_url. The token travels only in the Authorization header — never logged, never echoed into a returned error (kb:adr/issue-auth-gh-token-at-time-of-use); this holds whether the failure happened obtaining the token (*ErrAuthFailed, returned unwrapped) or posting to GitHub (*ErrPostFailed).

type ErrAuthFailed

type ErrAuthFailed struct {
	Message string
}

ErrAuthFailed is returned by a TokenReader (and by CreateIssue, which returns it unwrapped when the failure happened at the token step) when a bearer token could not be obtained: gh missing, gh auth token exiting non-zero, or an empty token. Message never carries gh's stdout — that's where the token lives (kb:adr/issue-auth-gh-token-at-time-of-use).

func (*ErrAuthFailed) Error

func (e *ErrAuthFailed) Error() string

type ErrPostFailed

type ErrPostFailed struct {
	Message      string
	MaybeCreated bool
}

ErrPostFailed is returned by CreateIssue when the request to GitHub itself failed: non-2xx, a transport error, or a 2xx body that would not parse. MaybeCreated is true whenever the request reached GitHub and may have created the issue — an unreadable or unusable 2xx body counts too, since GitHub may have created the issue before the response became unreadable.

func (*ErrPostFailed) Error

func (e *ErrPostFailed) Error() string

type TokenReader

type TokenReader func(ctx context.Context) (string, error)

TokenReader returns a GitHub bearer token. It is re-read on every call — mirrors internal/claudecode.TokenReader (credentials.go); callers must never cache a value.

func FileTokenReader

func FileTokenReader(path string) TokenReader

FileTokenReader reads the trimmed contents of path as the token — the -issue-token-file test seam, plain text (deliberately not the JSON shape of claudecode.FileTokenReader) that makes it structurally impossible for a test using it to fall through to a real `gh` invocation (docs/conventions.md §Testing: every subprocess call gets an injectable seam, never a real fork in a test).

func GhCLITokenReader

func GhCLITokenReader() TokenReader

GhCLITokenReader runs `gh auth token`, returning its trimmed stdout as the bearer token. A missing gh, a non-zero exit, or an empty token all report *ErrAuthFailed carrying gh's trimmed stderr and naming `gh auth login`; gh's stdout is never included in an error.

Jump to

Keyboard shortcuts

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