github

package
v0.0.0-...-66acf6f Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIStatuses

func CIStatuses(token string, repo string, commit string) error

CIStatuses lists statuses for CI

func CreateRelease

func CreateRelease(token string, repo string, tag string, name string) error

CreateRelease creates a release for a tag

func DoAuthRequest

func DoAuthRequest(method, url, bodyType, token string, headers map[string]string, body io.Reader) (*http.Response, error)

DoAuthRequest does an authenticated request to Github

func Download

func Download(token string, url string, name string) error

Download from Github

func DownloadAsset

func DownloadAsset(token string, repo string, tag string, name string) error

DownloadAsset downloads an asset from Github that matches name

func DownloadSource

func DownloadSource(token string, repo string, tag string) error

DownloadSource dowloads source from repo tag

func Get

func Get(token string, url string, v interface{}) error

Get does a GET request to the Github API

func NewAuthRequest

func NewAuthRequest(method, url, bodyType, token string, headers map[string]string, body io.Reader) (*http.Request, error)

NewAuthRequest creates a new request that sends the auth token

func Upload

func Upload(token string, repo string, tag string, name string, file string) error

Upload uploads a file to a tagged repo

func WaitForCI

func WaitForCI(token string, repo string, commit string, contexts []string, delay time.Duration, timeout time.Duration) error

WaitForCI waits for commit in repo to pass CI contexts

Types

type Asset

type Asset struct {
	URL                string    `json:"url"`
	ID                 int       `json:"id"`
	Name               string    `json:"name"`
	ContentType        string    `json:"content_type"`
	State              string    `json:"state"`
	Size               uint64    `json:"size"`
	Downloads          uint64    `json:"download_count"`
	Created            time.Time `json:"created_at"`
	Published          time.Time `json:"published_at"`
	BrowserDownloadURL string    `json:"browser_download_url"`
}

Asset is a Github API Asset

type Commit

type Commit struct {
	SHA string `json:"sha"`
}

Commit defines a git commit on Github

func Commits

func Commits(user, repo, token string) ([]Commit, error)

Commits lists commits from Github repo

func LatestCommit

func LatestCommit(token string, repo string, contexts []string) (*Commit, error)

LatestCommit returns a latest commit for all statuses matching state and contexts

type ErrNotFound

type ErrNotFound struct {
	Name  string
	Key   string
	Value string
}

ErrNotFound is error type for not found in API

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type Release

type Release struct {
	URL         string     `json:"url"`
	PageURL     string     `json:"html_url"`
	UploadURL   string     `json:"upload_url"`
	ID          int        `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"body"`
	TagName     string     `json:"tag_name"`
	Draft       bool       `json:"draft"`
	Prerelease  bool       `json:"prerelease"`
	Created     *time.Time `json:"created_at"`
	Published   *time.Time `json:"published_at"`
	Assets      []Asset    `json:"assets"`
}

Release is a Github API Release type

func LatestRelease

func LatestRelease(user, repo, token string) (release *Release, err error)

LatestRelease returns latest release for repo

func ReleaseOfTag

func ReleaseOfTag(user, repo, tag, token string) (*Release, error)

ReleaseOfTag returns release for tag

func Releases

func Releases(user, repo, token string) (releases []Release, err error)

Releases returns releases for a repo

func (*Release) CleanUploadURL

func (r *Release) CleanUploadURL() string

CleanUploadURL is URL for uploading a release

type ReleaseCreate

type ReleaseCreate struct {
	TagName         string `json:"tag_name"`
	TargetCommitish string `json:"target_commitish,omitempty"`
	Name            string `json:"name"`
	Body            string `json:"body"`
	Draft           bool   `json:"draft"`
	Prerelease      bool   `json:"prerelease"`
}

ReleaseCreate is a Github API ReleaseCreate type

type Status

type Status struct {
	State   string `json:"state"`
	Context string `json:"context"`
}

Status defines a git commit on Github

type Statuses

type Statuses struct {
	State    string   `json:"state"`
	Statuses []Status `json:"statuses"`
}

Statuses defines the overall status of a git commit on Github

type Tag

type Tag struct {
	Name string `json:"name"`
}

Tag is a Github API Tag type

func LatestTag

func LatestTag(user, repo, token string) (tag *Tag, err error)

LatestTag returns latest tag for a repo

func Tags

func Tags(user, repo, token string) (tags []Tag, err error)

Tags returns tags for a repo

Jump to

Keyboard shortcuts

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