githosts

package module
v0.0.0-...-ba90c70 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 25 Imported by: 1

README

githost-utils: a go library for working with hosted git providers

Go Report Card Go Reference

About

This is the Go library used by soba, a tool for backing up repositories from popular hosted and self-hosted providers. With a focus on simplicity, dependencies are kept to a minimum and no external libraries are used for interacting with the git providers.

Supported OSes

Tested on Windows 10 and 11, MacOS, and Linux, but should work on all OSes/architectures.

Supported Providers
  • Azure DevOps
  • BitBucket
  • Gitea
  • GitHub
  • GitLab

Documentation

Index

Constants

View Source
const (
	AzureDevOpsProviderName = "AzureDevOps"
)
View Source
const (
	BitbucketProviderName = "BitBucket"
)
View Source
const (
	// GitLabDefaultMinimumProjectAccessLevel https://docs.gitlab.com/ee/user/permissions.html#roles
	GitLabDefaultMinimumProjectAccessLevel = 20
)

Variables

This section is empty.

Functions

func AddBasicAuthToURL

func AddBasicAuthToURL(originalURL, username, password string) (string, error)

func ToPtr

func ToPtr[T any](v T) *T

Types

type AzureDevOpsHost

type AzureDevOpsHost struct {
	Caller string

	Provider         string
	PAT              string
	Orgs             []string
	UserName         string
	DiffRemoteMethod string
	BackupDir        string
	BackupsToRetain  int
	LogLevel         int
	// contains filtered or unexported fields
}

func NewAzureDevOpsHost

func NewAzureDevOpsHost(input NewAzureDevOpsHostInput) (*AzureDevOpsHost, error)

func (*AzureDevOpsHost) Backup

type AzureDevOpsRepo

type AzureDevOpsRepo struct {
	Id            string  `json:"id"`
	Url           string  `json:"url"`
	Name          string  `json:"name"`
	Size          int64   `json:"size"`
	SshUrl        string  `json:"sshUrl"`
	WebUrl        string  `json:"webUrl"`
	Project       Project `json:"project"`
	RemoteUrl     string  `json:"remoteUrl"`
	DefaultBranch string  `json:"defaultBranch"`
}

func ListAllRepositories

func ListAllRepositories(httpClient *retryablehttp.Client, basicAuth, projectName, orgName string) ([]AzureDevOpsRepo, error)

type BitbucketHost

type BitbucketHost struct {
	Caller string

	Provider         string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	BackupsToRetain  int
	User             string
	Key              string
	Secret           string
	LogLevel         int
	// contains filtered or unexported fields
}

func NewBitBucketHost

func NewBitBucketHost(input NewBitBucketHostInput) (*BitbucketHost, error)

func (BitbucketHost) Backup

func (bb BitbucketHost) Backup() ProviderBackupResult

type GitHubHost

type GitHubHost struct {
	Caller string

	Provider         string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	SkipUserRepos    bool
	LimitUserOwned   bool
	BackupsToRetain  int
	Token            string
	Orgs             []string
	LogLevel         int
	// contains filtered or unexported fields
}

func NewGitHubHost

func NewGitHubHost(input NewGitHubHostInput) (*GitHubHost, error)

func (*GitHubHost) Backup

func (gh *GitHubHost) Backup() ProviderBackupResult

type GitLabHost

type GitLabHost struct {
	Caller string

	APIURL                string
	DiffRemoteMethod      string
	BackupDir             string
	BackupsToRetain       int
	ProjectMinAccessLevel int
	Token                 string
	User                  gitlabUser
	LogLevel              int
	// contains filtered or unexported fields
}

func NewGitLabHost

func NewGitLabHost(input NewGitLabHostInput) (*GitLabHost, error)

func (*GitLabHost) Backup

func (gl *GitLabHost) Backup() ProviderBackupResult

type GiteaHost

type GiteaHost struct {
	Caller string

	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	BackupsToRetain  int
	Token            string
	Orgs             []string
	LogLevel         int
	// contains filtered or unexported fields
}

func NewGiteaHost

func NewGiteaHost(input NewGiteaHostInput) (*GiteaHost, error)

func (*GiteaHost) Backup

func (g *GiteaHost) Backup() ProviderBackupResult

type NewAzureDevOpsHostInput

type NewAzureDevOpsHostInput struct {
	Caller           string
	BackupDir        string
	DiffRemoteMethod string
	UserName         string
	PAT              string
	Orgs             []string
	BackupsToRetain  int
	LogLevel         int
}

type NewBitBucketHostInput

type NewBitBucketHostInput struct {
	Caller           string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	User             string
	Key              string
	Secret           string
	BackupsToRetain  int
	LogLevel         int
}

type NewGitHubHostInput

type NewGitHubHostInput struct {
	Caller           string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	Token            string
	LimitUserOwned   bool
	SkipUserRepos    bool
	Orgs             []string
	BackupsToRetain  int
	LogLevel         int
}

type NewGitLabHostInput

type NewGitLabHostInput struct {
	Caller                string
	APIURL                string
	DiffRemoteMethod      string
	BackupDir             string
	Token                 string
	ProjectMinAccessLevel int
	BackupsToRetain       int
	LogLevel              int
}

type NewGiteaHostInput

type NewGiteaHostInput struct {
	Caller           string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	Token            string
	Orgs             []string
	BackupsToRetain  int
	LogLevel         int
}

type Project

type Project struct {
	Id             string    `json:"id"`
	Url            string    `json:"url"`
	Name           string    `json:"name"`
	State          string    `json:"state"`
	Revision       int       `json:"revision"`
	Visibility     string    `json:"visibility"`
	Description    string    `json:"description"`
	LastUpdateTime time.Time `json:"lastUpdateTime"`
}

type ProviderBackupResult

type ProviderBackupResult struct {
	BackupResults []RepoBackupResults
	Error         errors.E
}

type ProviderBackupResult []RepoBackupResults

type RepoBackupResults

type RepoBackupResults struct {
	Repo   string   `json:"repo,omitempty"`
	Status string   `json:"status,omitempty"` // ok, failed
	Error  errors.E `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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