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 ¶
This section is empty.
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 Error ¶
type Error string
Error is ghkeys's sentinel-error type. Every error the package can emit is declared as a const of this type, so each one is matchable with errors.Is rather than by string comparison. It follows the same shape as the rest of the ecosystem's sentinel-error helpers.
const ( // ErrFetchKeys is the leading sentinel wrapped when the GitHub keys endpoint // cannot be requested, returns a non-200 status, or its body cannot be read. ErrFetchKeys Error = "failed to fetch keys" // ErrNoValidKeys is returned when the response contains no SSH public key // that could be parsed into an age recipient. ErrNoValidKeys Error = "no valid keys found" )
type HTTPClient ¶
HTTPClient is the interface for making HTTP requests.
type 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.