gitea

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gitea contains high level helper routines for interacting with the Gitea releases using the API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRelease

func CreateRelease(clt *gitea.Client, opts CreateReleaseOpts) (*gitea.Release, error)

CreateRelease will create a new release with the given parameters.

func DownloadReleaseAssets

func DownloadReleaseAssets(clt *gitea.Client, release *gitea.Release, destDir string, globs []string) error

DownloadReleaseAssets downloads the associated assets from the given release to the provided destination directory. The release assets to download can be filtered using glob syntax.

func GetReleaseByID

func GetReleaseByID(clt *gitea.Client, owner, repo, releaseIDStr string) (*gitea.Release, error)

GetReleaseByID returns the corresponding release for the given ID string.

func GetReleaseByTag

func GetReleaseByTag(clt *gitea.Client, owner, repo, tagName string) (*gitea.Release, error)

GetReleaseByTag returns the corresponding release for the given tag name.

func GetReleases

func GetReleases(clt *gitea.Client, opts ListReleaseOpts) ([]*gitea.Release, error)

GetReleases returns all the releases that match the provided filter options. This will handle pagination, going through all release pages.

func NewGiteaClient

func NewGiteaClient(serverURL, accessToken string) (*gitea.Client, error)

NewGiteaClient returns an authenticated gitea API client for the given server URL.

func UpdateRelease

func UpdateRelease(clt *gitea.Client, id int64, opts CreateReleaseOpts) (*gitea.Release, error)

UpdateRelease will update an existing release with the given parameters.

func UploadReleaseAssetFromPath

func UploadReleaseAssetFromPath(clt *gitea.Client, path, owner, repo string, releaseID int64) error

UploadReleaseAssetFromPath will upload the file at the given path to the provided release as an asset, using the file basename as the asset name.

Types

type CreateReleaseOpts

type CreateReleaseOpts struct {
	// Owner is the owner of the repository in the target Gitea instance.
	Owner string
	// Repo is the name of the repository in the target Gitea instance.
	Repo string
	// Tag represents the tag to create for the release.
	Tag string
	// Target is the git ref (SHA, tag, branch) where the release tag should be applied.
	Target string
	// Title is the title to apply to the release.
	Title string
	// Body is the body to apply to the release.
	Body string
	// IsPreRelease indicates whether the new release should be marked as a prerelease.
	IsPreRelease bool
}

CreateReleaseOpts is a struct representing the metadata for creating a new release.

type ListReleaseOpts

type ListReleaseOpts struct {
	// Owner is the owner of the repository in the target Gitea instance.
	Owner string
	// Repo is the name of the repository in the target Gitea instance.
	Repo string
	// SemverConstraint is a semantic versioning constraint in the same syntax as Terraform. Refer to
	// https://www.terraform.io/language/expressions/version-constraints for supported syntax.
	SemverConstraint version.Constraints
	// IncludePreRelease indicates if pre releases should be included in the query.
	IncludePreRelease bool
}

ListReleaseOpts is a struct representing the filters to apply when querying for releases.

func NewListReleaseOpts

func NewListReleaseOpts(owner, repo, semverConstraintStr string, includePreRelease bool) (*ListReleaseOpts, error)

NewListReleaseOpts constructs a new ListReleaseOpts filter based on the provided raw values.

Jump to

Keyboard shortcuts

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