gitproviders

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MPL-2.0 Imports: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRepositoryNoPermissionsOrDoesNotExist = errors.New("no permissions to access this repository or repository doesn't exists")

Functions

func NewOrgRepositoryRef

func NewOrgRepositoryRef(domain, org, repoName string) gitprovider.OrgRepositoryRef

func ViperGetStringMapString added in v0.6.0

func ViperGetStringMapString(key string) map[string]string

ViperGetStringMapString looks up a command line flag or env var in the format "foo=1,bar=2" GetStringMapString tries to JSON decode the env var If that fails (silently), try and decode the classic "foo=1,bar=2" form. https://github.com/spf13/viper/issues/911

Types

type AccountTypeGetter added in v0.3.1

type AccountTypeGetter func(provider gitprovider.Client, domain string, owner string) (ProviderAccountType, error)

type Client added in v0.5.0

type Client interface {
	GetProvider(repoURL RepoURL, getAccountType AccountTypeGetter) (GitProvider, error)
}

type Config added in v0.2.2

type Config struct {
	// Provider defines the GitProvider.
	Provider GitProviderName

	// Hostname is the HTTP/S hostname of the Provider,
	// e.g. github.example.com.
	Hostname string

	// Token contains the token used to authenticate with the
	// Provider.
	Token string
}

Config defines the configuration for connecting to a GitProvider.

type GitProvider added in v0.2.2

type GitProvider interface {
	RepositoryExists(ctx context.Context, repoURL RepoURL) (bool, error)
	DeployKeyExists(ctx context.Context, repoURL RepoURL) (bool, error)
	GetDefaultBranch(ctx context.Context, repoURL RepoURL) (string, error)
	GetRepoVisibility(ctx context.Context, repoURL RepoURL) (*gitprovider.RepositoryVisibility, error)
	UploadDeployKey(ctx context.Context, repoURL RepoURL, deployKey []byte) error
	CreatePullRequest(ctx context.Context, repoURL RepoURL, prInfo PullRequestInfo) (gitprovider.PullRequest, error)
	GetCommits(ctx context.Context, repoURL RepoURL, targetBranch string, pageSize int, pageToken int) ([]gitprovider.Commit, error)
	GetProviderDomain() string
	GetRepoDirFiles(ctx context.Context, repoURL RepoURL, dirPath, targetBranch string) ([]*gitprovider.CommitFile, error)
	MergePullRequest(ctx context.Context, repoURL RepoURL, pullRequestNumber int, commitMesage string) error
}

GitProvider Handler

func New added in v0.1.0

func New(config Config, owner string, getAccountType AccountTypeGetter) (GitProvider, error)

func NewDryRun added in v0.3.1

func NewDryRun() (GitProvider, error)

type GitProviderName added in v0.2.2

type GitProviderName string

GitProviderName holds a Git provider definition.

const (
	GitProviderGitHub GitProviderName = "github"
	GitProviderGitLab GitProviderName = "gitlab"
)

type ProviderAccountType added in v0.0.4

type ProviderAccountType string
const (
	AccountTypeUser ProviderAccountType = "user"
	AccountTypeOrg  ProviderAccountType = "organization"
	DeployKeyName                       = "wego-deploy-key"
)

func GetAccountType added in v0.0.4

func GetAccountType(provider gitprovider.Client, domain string, owner string) (ProviderAccountType, error)

type PullRequestInfo added in v0.3.1

type PullRequestInfo struct {
	Title                     string
	Description               string
	CommitMessage             string
	TargetBranch              string
	NewBranch                 string
	SkipAddingFilesOnCreation bool
	Files                     []gitprovider.CommitFile
}

type RepoURL added in v0.3.2

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

func NewRepoURL added in v0.3.2

func NewRepoURL(uri string) (RepoURL, error)

func (RepoURL) Owner added in v0.3.2

func (n RepoURL) Owner() string

func (RepoURL) Protocol added in v0.3.2

func (n RepoURL) Protocol() RepositoryURLProtocol

func (RepoURL) Provider added in v0.3.2

func (n RepoURL) Provider() GitProviderName

func (RepoURL) RepositoryName added in v0.3.2

func (n RepoURL) RepositoryName() string

func (RepoURL) String added in v0.3.2

func (n RepoURL) String() string

func (RepoURL) URL added in v0.3.2

func (n RepoURL) URL() *url.URL

type RepositoryURLProtocol added in v0.2.5

type RepositoryURLProtocol string
const RepositoryURLProtocolHTTPS RepositoryURLProtocol = "https"
const RepositoryURLProtocolSSH RepositoryURLProtocol = "ssh"

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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