forge

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package forge reads a forge instance the way aqua gr reads GitHub.

Both serve the API Gitea wrote and Forgejo inherited, at /api/v1, which GitHub's was the model for: a release says tag_name, published_at, draft and prerelease, and an asset says name and browser_download_url. What differs is how a page is asked for -- page and limit rather than per_page -- and that nothing says how many pages there are.

The answers are translated into go-github's types, because what reads them is aqua's generator, which is written against GitHub. Translating here is what lets the asset naming of a release on an instance be inferred by the same code that infers GitHub's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func For

func For(httpClient *http.Client, typ, host string) genrgst.RepositoriesService

For is the client reading the instance a package is on, and nil for a package that is on none.

Which client is the type's: the Gitea family's API and GitLab's answer the same questions in different words, and a definition says which forge it is on rather than leaving it to be discovered.

Types

type Client

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

Client reads one instance. Which instance is not an argument because a package is on one of them: a client is made for the package's own.

func New

func New(httpClient *http.Client, host string) *Client

New returns a client reading the instance at the given host.

func (*Client) Get

func (c *Client) Get(ctx context.Context, owner, repo string) (*gogithub.Repository, *gogithub.Response, error)

Get returns what the generator reads about a repository, which is its description.

func (*Client) GetLatestRelease

func (c *Client) GetLatestRelease(ctx context.Context, owner, repo string) (*gogithub.RepositoryRelease, *gogithub.Response, error)

GetLatestRelease returns the instance's newest release of the repository.

func (*Client) GetReleaseByTag

func (c *Client) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*gogithub.RepositoryRelease, *gogithub.Response, error)

GetReleaseByTag returns the release the tag names.

func (*Client) Host

func (c *Client) Host() string

Host is the instance the client reads.

func (*Client) ListReleaseAssets

func (c *Client) ListReleaseAssets(ctx context.Context, owner, repo string, id int64, opts *gogithub.ListOptions) ([]*gogithub.ReleaseAsset, *gogithub.Response, error)

ListReleaseAssets returns one page of a release's assets.

func (*Client) ListReleases

func (c *Client) ListReleases(ctx context.Context, owner, repo string, opts *gogithub.ListOptions) ([]*gogithub.RepositoryRelease, *gogithub.Response, error)

ListReleases returns one page of the repository's releases, newest first.

type GitLab

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

GitLab reads a GitLab instance the way aqua gr reads GitHub.

GitLab's API is its own rather than Gitea's with another name on it: it is /api/v4, a project is one escaped path rather than an owner and a name, a page is asked for with page and per_page, and a release says released_at and upcoming_release where the others say published_at, draft and prerelease. The answers are translated into go-github's types for the same reason the Gitea client's are: what reads them is aqua's generator, so the asset naming of a release on an instance is inferred by the code that infers GitHub's.

Two things about an asset are GitLab's alone, and both are in servedAsset.

func NewGitLab

func NewGitLab(httpClient *http.Client, host string) *GitLab

NewGitLab returns a client reading the GitLab instance at the given host.

func (*GitLab) Get

func (c *GitLab) Get(ctx context.Context, owner, repo string) (*gogithub.Repository, *gogithub.Response, error)

Get returns what the generator reads about a project, which is its description.

func (*GitLab) GetLatestRelease

func (c *GitLab) GetLatestRelease(ctx context.Context, owner, repo string) (*gogithub.RepositoryRelease, *gogithub.Response, error)

GetLatestRelease returns the instance's newest release of the project.

GitLab answers with the releases newest first and has no endpoint for the newest one, so it is the first of them that is published: a release dated in the future publishes nothing to install yet.

func (*GitLab) GetReleaseByTag

func (c *GitLab) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*gogithub.RepositoryRelease, *gogithub.Response, error)

GetReleaseByTag returns the release the tag names.

func (*GitLab) Host

func (c *GitLab) Host() string

Host is the instance the client reads.

func (*GitLab) ListReleaseAssets

func (c *GitLab) ListReleaseAssets(_ context.Context, _, _ string, id int64, opts *gogithub.ListOptions) ([]*gogithub.ReleaseAsset, *gogithub.Response, error)

ListReleaseAssets returns one page of a release's assets.

The assets came with the release, so this answers from what reading it kept. An id this client never gave out has no assets, which is what an empty page says.

func (*GitLab) ListReleases

func (c *GitLab) ListReleases(ctx context.Context, owner, repo string, opts *gogithub.ListOptions) ([]*gogithub.RepositoryRelease, *gogithub.Response, error)

ListReleases returns one page of the project's releases, newest first.

Jump to

Keyboard shortcuts

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