githubclient

package
v0.6.0 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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAndExtractZip added in v0.5.0

func DownloadAndExtractZip(url string, runID int64) ([]*client.WorkflowArtifactContent, error)

DownloadAndExtractZip downloads a zip file from the given URL, extracts its contents, and returns only those files that are valid JSON.

func NewGithubClient

func NewGithubClient(ctx context.Context, token string) (*githubClient, error)

Types

type GithubClient

type GithubClient interface {
	// GetLatestRelease fetches the latest release for a repo
	GetLatestRelease(ctx context.Context, owner string, repo string) (*client.Release, error)

	// GetCommitSHA1 fetches the commit SHA in a repo based on a tag, branch head, or other ref.
	// NOTE: Github release 2022-11-28 and similar server returns a commitish for a release.
	// The release commitish can be a commit, branch name, or a tag.
	// We need to resolve it to a commit.
	GetCommitSHA1(ctx context.Context, owner string, repo string, ref string) (string, error)

	// GetReleaseByTagSlices fetches metadata regarding releases for a given tag. If the tag is the empty string,
	// it should just return the latest.
	GetReleaseByTag(ctx context.Context, owner string, repo string, tag string) (*client.Release, error)

	// GetReleaseAsset fetches the content of a release asset, e.g. artifacts, metadata documents, etc.
	GetReleaseAsset(asset client.ReleaseAsset) (*client.ReleaseAssetContent, error)

	// GetWorkflow fetches the workflow for a given workflow name or all workflows if the workflow name is empty
	GetWorkflow(ctx context.Context, owner string, repo string, githubWorkflowName string) ([]*client.Workflow, error)

	// GetLatestWorkflowRun fetches all the workflow run for a given workflow id
	GetLatestWorkflowRun(ctx context.Context, owner, repo string, workflowId int64) (*client.WorkflowRun, error)

	// GetWorkflowRunArtifacts fetches all the workflow run artifacts for a given workflow run id
	GetWorkflowRunArtifacts(ctx context.Context, owner, repo, githubSBOMName string, runID int64) ([]*client.WorkflowArtifactContent, error)
}

TODO (mlieberman85): This interface will probably be pulled out into an interface that can support other services with artifact releases like Gitlab Wrapper interface for Github

Jump to

Keyboard shortcuts

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