githosts

package module
v0.0.0-...-30e71ae Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 25 Imported by: ? modules, 0 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.

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
	HttpClient       *retryablehttp.Client
	Provider         string
	PAT              string
	Orgs             []string
	UserName         string
	DiffRemoteMethod string
	BackupDir        string
	BackupsToRetain  int
	LogLevel         int
}

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
	HttpClient       *retryablehttp.Client
	Provider         string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	BackupsToRetain  int
	User             string
	Key              string
	Secret           string
	LogLevel         int
}

func NewBitBucketHost

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

func (BitbucketHost) Backup

func (bb BitbucketHost) Backup() ProviderBackupResult

type GitHubHost

type GitHubHost struct {
	Caller           string
	HttpClient       *retryablehttp.Client
	Provider         string
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	SkipUserRepos    bool
	LimitUserOwned   bool
	BackupsToRetain  int
	Token            string
	Orgs             []string
	LogLevel         int
}

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 {
	HTTPClient       *retryablehttp.Client
	Caller           string
	BackupDir        string
	DiffRemoteMethod string
	UserName         string
	PAT              string
	Orgs             []string
	BackupsToRetain  int
	LogLevel         int
}

type NewBitBucketHostInput

type NewBitBucketHostInput struct {
	Caller           string
	HTTPClient       *retryablehttp.Client
	APIURL           string
	DiffRemoteMethod string
	BackupDir        string
	User             string
	Key              string
	Secret           string
	BackupsToRetain  int
	LogLevel         int
}

type NewGitHubHostInput

type NewGitHubHostInput struct {
	HTTPClient       *retryablehttp.Client
	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
	HTTPClient            *retryablehttp.Client
	APIURL                string
	DiffRemoteMethod      string
	BackupDir             string
	Token                 string
	ProjectMinAccessLevel int
	BackupsToRetain       int
	LogLevel              int
}

type NewGiteaHostInput

type NewGiteaHostInput struct {
	Caller           string
	HTTPClient       *retryablehttp.Client
	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
⌂ 换网址