client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 4 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error represents a NotFound response from an upstream service.

Types

type GitClient

type GitClient interface {
	GetFile(ctx context.Context, repo, ref, path string) (*scm.Content, error)
	UpdateFile(ctx context.Context, repo, branch, path, message, previousSHA string, signature scm.Signature, content []byte) error
	DeleteFile(ctx context.Context, repo, branch, path, message, previousSHA string, signature scm.Signature, content []byte) error
	CreatePullRequest(ctx context.Context, repo string, inp *scm.PullRequestInput) (*scm.PullRequest, error)
	CreateBranch(ctx context.Context, repo, branch, sha string) error
	GetBranchHead(ctx context.Context, repo, branch string) (string, error)
}

GitClient wraps go-scm's Client with a simplified API.

type SCMClient

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

SCMClient is a wrapper for the go-scm scm.Client with a simplified API.

func New

func New(c *scm.Client) *SCMClient

New creates and returns a new SCMClient.

func (*SCMClient) CreateBranch

func (c *SCMClient) CreateBranch(ctx context.Context, repo, branch, sha string) error

CreateBranch will create a new branch in the repo from the SHA.

func (*SCMClient) CreatePullRequest

func (c *SCMClient) CreatePullRequest(ctx context.Context, repo string, inp *scm.PullRequestInput) (*scm.PullRequest, error)

CreatePullRequest creates a PullRequest with the provided input.

If an HTTP error is returned by the upstream service, an error with the response status code is returned.

func (*SCMClient) DeleteFile

func (c *SCMClient) DeleteFile(ctx context.Context, repo, branch, path, message, previousSHA string, signature scm.Signature, content []byte) error

DeleteFile deletes a file in a repository

If an HTTP error is returned by the upstream service, an error with the response status code is returned.

func (*SCMClient) GetBranchHead

func (c *SCMClient) GetBranchHead(ctx context.Context, repo, branch string) (string, error)

GetBranchHead gets the head SHA for a specific branch.

If an HTTP error is returned by the upstream service, an error with the response status code is returned.

func (*SCMClient) GetFile

func (c *SCMClient) GetFile(ctx context.Context, repo, ref, path string) (*scm.Content, error)

GetFile reads the specific revision of a file from a repository.

If an HTTP error is returned by the upstream service, an error with the response status code is returned.

func (*SCMClient) UpdateFile

func (c *SCMClient) UpdateFile(ctx context.Context, repo, branch, path, message, previousSHA string, signature scm.Signature, content []byte) error

UpdateFile updates an existing file in a repository.

If an HTTP error is returned by the upstream service, an error with the response status code is returned.

type SCMError

type SCMError struct {
	Msg    string
	Status int
}

func (SCMError) Error

func (s SCMError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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