release

package
v0.0.0-...-a9f5107 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GithubOwnerBufbuild GithubOwner = "bufbuild"
	GithubRepoPlugins   GithubRepo  = "plugins"
)
View Source
const (
	PluginReleasesFile          = "plugin-releases.json"
	PluginReleasesSignatureFile = PluginReleasesFile + ".minisig"
)

Variables

View Source
var ErrNotFound = errors.New("release not found")

Functions

func CalculateDigest

func CalculateDigest(path string) (string, error)

CalculateDigest will calculate the sha256 digest of the given file. It returns a string in the format: '<digest-type>:<digest>'.

func DefaultPublicKey

func DefaultPublicKey() (minisign.PublicKey, error)

Types

type Client

type Client struct {
	GitHub *github.Client
}

func NewClient

func NewClient(ctx context.Context) *Client

NewClient returns a new HTTP client which can be used to perform actions on GitHub releases.

func (*Client) CreateRelease

func (c *Client) CreateRelease(ctx context.Context, owner GithubOwner, repo GithubRepo, release *github.RepositoryRelease) (*github.RepositoryRelease, error)

CreateRelease creates a new GitHub release under the owner and repo.

func (*Client) DownloadAsset

func (c *Client) DownloadAsset(ctx context.Context, release *github.RepositoryRelease, assetName string) ([]byte, time.Time, error)

DownloadAsset uses the GitHub API to download the asset with the given name from the release. If the asset isn't found, returns ErrNotFound.

func (*Client) DownloadPluginReleasesToDir

func (c *Client) DownloadPluginReleasesToDir(
	ctx context.Context,
	release *github.RepositoryRelease,
	publicKey minisign.PublicKey,
	dir string,
) (*PluginReleases, error)

DownloadPluginReleasesToDir loads the plugin-releases.json file from the specified GitHub release. It will additionally verify the minisign signature of the release if passed a valid minisign.PublicKey. It will download both the plugin-releases.json and plugin-releases.json.minisig to the specified dir.

func (*Client) EditRelease

func (c *Client) EditRelease(ctx context.Context, owner GithubOwner, repo GithubRepo, releaseID int64, releaseChanges *github.RepositoryRelease) (*github.RepositoryRelease, error)

EditRelease performs an update of editable properties of a release (i.e. marking it not as a draft).

func (*Client) GetLatestRelease

func (c *Client) GetLatestRelease(ctx context.Context, owner GithubOwner, repo GithubRepo) (*github.RepositoryRelease, error)

GetLatestRelease returns information about the latest GitHub release for the given org and repo (i.e. 'bufbuild', 'plugins'). If no release is found, returns ErrReleaseNotFound.

func (*Client) GetReleaseByTag

func (c *Client) GetReleaseByTag(ctx context.Context, owner GithubOwner, repo GithubRepo, tag string) (*github.RepositoryRelease, error)

GetReleaseByTag returns information about a given release (by tag name).

func (*Client) UploadReleaseAsset

func (c *Client) UploadReleaseAsset(ctx context.Context, owner GithubOwner, repo GithubRepo, releaseID int64, filename string) error

UploadReleaseAsset uploads the specified file to the release.

type GithubOwner

type GithubOwner string

type GithubRepo

type GithubRepo string

type PluginRelease

type PluginRelease struct {
	PluginName       string    `json:"name"`           // org/name for the plugin (without remote)
	PluginVersion    string    `json:"version"`        // version of the plugin (including 'v' prefix)
	PluginZipDigest  string    `json:"zip_digest"`     // <digest-type>:<digest> for plugin .zip download
	PluginYAMLDigest string    `json:"yaml_digest"`    // <digest-type>:<digest> for buf.plugin.yaml
	ImageID          string    `json:"image_id"`       // <digest-type>:<digest> - https://github.com/opencontainers/image-spec/blob/main/config.md#imageid
	RegistryImage    string    `json:"registry_image"` // ghcr.io/bufbuild/plugins-<org>-<name>@<digest-type>:<digest>
	ReleaseTag       string    `json:"release_tag"`    // GitHub release tag - i.e. 20221121.1
	URL              string    `json:"url"`            // URL to GitHub release zip file for the plugin - i.e. https://github.com/bufbuild/plugins/releases/download/20221121.1/bufbuild-connect-go-v1.1.0.zip
	LastUpdated      time.Time `json:"last_updated"`
	Status           Status    `json:"-"`
	Dependencies     []string  `json:"dependencies,omitempty"` // direct dependencies on other plugins
}

func SortReleasesInDependencyOrder

func SortReleasesInDependencyOrder(original []PluginRelease) ([]PluginRelease, error)

SortReleasesInDependencyOrder sorts the list of plugin releases so that a plugin's dependencies come before each plugin. The original slice is unmodified - it returns a copy in sorted order, or an error if there is a cycle or unmet dependency.

type PluginReleases

type PluginReleases struct {
	Releases []PluginRelease `json:"releases"`
}

type Status

type Status int
const (
	StatusExisting Status = iota
	StatusNew
	StatusUpdated
)

Jump to

Keyboard shortcuts

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