Documentation
¶
Overview ¶
Package github provides a GitHub API client for fetching version information.
Index ¶
Constants ¶
const (
// APIVersion is the GitHub REST API version header value.
APIVersion = "2022-11-28"
)
API configuration constants.
Variables ¶
var ( // ErrInvalidURL indicates the provided URL is not a valid GitHub repository URL. ErrInvalidURL = errors.New("invalid GitHub repository URL") // ErrHTTPRequest indicates an HTTP request to the GitHub API failed. ErrHTTPRequest = errors.New("HTTP request failed") )
Sentinel errors for GitHub API operations.
Functions ¶
func GetOwnerRepo ¶
GetOwnerRepo extracts owner and repository name from a GitHub URL.
func ParseGitTagsOutput ¶
ParseGitTagsOutput parses git ls-remote style output into tag names. This is useful for parsing cached or pre-fetched tag data.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides methods to interact with the GitHub REST API.
func NewClient ¶
func NewClient() *Client
NewClient creates a new GitHub API client with default settings. It automatically uses GITHUB_TOKEN or GITHUB_API_TOKEN environment variable if set.
func NewClientWithHTTP ¶
func NewClientWithHTTP(httpClient HTTPClient, apiURL string) *Client
NewClientWithHTTP creates a new GitHub client with a custom HTTP client.
func NewClientWithToken ¶
NewClientWithToken creates a new GitHub client with explicit token.
func (*Client) GetReleases ¶
GetReleases fetches all releases from a GitHub repository.
type HTTPClient ¶
type HTTPClient interface {
// Do sends an HTTP request and returns an HTTP response.
Do(req *http.Request) (*http.Response, error)
}
HTTPClient interface for HTTP operations (allows mocking).
type ReleaseResponse ¶
type ReleaseResponse struct {
TagName string `json:"tag_name"`
}
ReleaseResponse represents a release from the GitHub API.
type TagResponse ¶
type TagResponse struct {
Ref string `json:"ref"`
}
TagResponse represents a tag from the GitHub API.