github

package
v0.0.0-...-6709811 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitSshProtocolType   = "ssh"
	GitHttpsProtocolType = "https"
)

Variables

View Source
var (
	ErrGitHubCliNotLoggedIn = errors.New("gh cli is not logged in")
	ErrUserNotAuthorized    = errors.New("user is not authorized. " +
		"Try running gh auth refresh with the required scopes to request additional authorization")
	ErrRepositoryNameInUse = errors.New("repository name already in use")

	// The hostname of the public GitHub service.
	GitHubHostName = "github.com"

	// Environment variable that gh cli uses for auth token overrides
	TokenEnvVars = []string{"GITHUB_TOKEN", "GH_TOKEN"}
)
View Source
var Version semver.Version = semver.MustParse("2.55.0")

Version is the minimum version of GitHub cli that we require (and the one we fetch when we fetch gh on behalf of a user).

Functions

func RunningOnCodespaces

func RunningOnCodespaces() bool

RunningOnCodespaces check if the application is running on codespaces.

Types

type ApiCallOptions

type ApiCallOptions struct {
	Headers []string
}

ApiCallOptions represent the options for the ApiCall method.

type AuthStatus

type AuthStatus struct {
	LoggedIn bool
}

The result from calling GetAuthStatus

type Cli

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

func NewGitHubCli

func NewGitHubCli(ctx context.Context, console input.Console, commandRunner exec.CommandRunner) (*Cli, error)

func (*Cli) ApiCall

func (cli *Cli) ApiCall(ctx context.Context, hostname, path string, options ApiCallOptions) (string, error)

ApiCall uses gh cli to call https://api.<hostname>/<path>.

func (*Cli) BinaryPath

func (cli *Cli) BinaryPath() string

func (*Cli) CheckInstalled

func (cli *Cli) CheckInstalled(ctx context.Context) error

func (*Cli) CreatePrivateRepository

func (cli *Cli) CreatePrivateRepository(ctx context.Context, name string) error

func (*Cli) DeleteSecret

func (cli *Cli) DeleteSecret(ctx context.Context, repoSlug string, name string) error

func (*Cli) DeleteVariable

func (cli *Cli) DeleteVariable(ctx context.Context, repoSlug string, name string) error

func (*Cli) GetAuthStatus

func (cli *Cli) GetAuthStatus(ctx context.Context, hostname string) (AuthStatus, error)

func (*Cli) GetGitProtocolType

func (cli *Cli) GetGitProtocolType(ctx context.Context) (string, error)

func (*Cli) GitHubActionsExists

func (cli *Cli) GitHubActionsExists(ctx context.Context, repoSlug string) (bool, error)

GitHubActionsExists gets the information from upstream about the workflows and return true if there is at least one workflow in the repo.

func (*Cli) InstallUrl

func (cli *Cli) InstallUrl() string

func (*Cli) ListRepositories

func (cli *Cli) ListRepositories(ctx context.Context) ([]GhCliRepository, error)

func (*Cli) ListSecrets

func (cli *Cli) ListSecrets(ctx context.Context, repoSlug string) ([]string, error)

func (*Cli) ListVariables

func (cli *Cli) ListVariables(ctx context.Context, repoSlug string) ([]string, error)

func (*Cli) Login

func (cli *Cli) Login(ctx context.Context, hostname string) error

func (*Cli) Name

func (cli *Cli) Name() string

func (*Cli) SetSecret

func (cli *Cli) SetSecret(ctx context.Context, repoSlug string, name string, value string) error

func (*Cli) SetVariable

func (cli *Cli) SetVariable(ctx context.Context, repoSlug string, name string, value string) error

func (*Cli) ViewRepository

func (cli *Cli) ViewRepository(ctx context.Context, name string) (GhCliRepository, error)

type GhCliRepository

type GhCliRepository struct {
	// The slug for a repository (formatted as "<owner>/<name>")
	NameWithOwner string
	// The Url for the HTTPS endpoint for the repository
	HttpsUrl string `json:"url"`
	// The Url for the SSH endpoint for the repository
	SshUrl string
}

type GitHubActionsResponse

type GitHubActionsResponse struct {
	TotalCount int `json:"total_count"`
}

Jump to

Keyboard shortcuts

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