ghkeys

package module
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Documentation

Overview

Package ghkeys fetches a GitHub user's SSH public keys and converts the supported ones into age recipients. FetchRecipients GETs https://github.com/<username>.keys through a caller-supplied HTTPClient (so the transport is injectable and testable), parses the authorized-keys body, and skips — with a warning logged to an injectable Logger — any key age cannot represent. Failures carry a sentinel (ErrFetchKeys or ErrNoValidKeys) recoverable with errors.Is.

Index

Constants

View Source
const (
	// ErrFetchKeys is the leading sentinel wrapped when the GitHub keys endpoint
	// cannot be requested, returns a non-200 status, its body cannot be read, or
	// the fetched listing cannot be scanned into lines (a line past bufio's
	// token limit) — the last so a truncated listing can never pass for a
	// complete one.
	ErrFetchKeys errs.Const = "failed to fetch keys"
	// ErrNoValidKeys is returned when the response contains no SSH public key
	// that could be parsed into an age recipient.
	ErrNoValidKeys errs.Const = "no valid keys found"
)

Variables

This section is empty.

Functions

func FetchRecipients

func FetchRecipients(
	ctx context.Context,
	client HTTPClient,
	username Username,
	options ...Option,
) ([]age.Recipient, error)

FetchRecipients fetches SSH public keys for a GitHub user and returns age recipients.

Types

type HTTPClient

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

HTTPClient is the interface for making HTTP requests.

type Logger

type Logger struct{ *slog.Logger }

Logger is an Option that routes the skip warning (emitted for keys age cannot represent) to a specific slog.Logger instead of slog.Default.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a FetchRecipients call. Options are type-based so the compiler verifies each one and the public surface stays additive. The interface is sealed (config is package-private, so only this package can implement it) and apply is a pure value transform — it receives the current config and returns the updated one — so options never mutate shared state through a pointer.

type Username

type Username string

Username is the GitHub login whose .keys endpoint is fetched.

Jump to

Keyboard shortcuts

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