Documentation
¶
Index ¶
- Constants
- Variables
- func ForFileContentFunc(fs billy.Filesystem, base string, ...) error
- func ForFileNameFunc(fs billy.Filesystem, base string, fun func(filename string) error) error
- type Commit
- type CommitFile
- type CommitMessage
- type Commiter
- type ContentUpdateFunc
- type ContentVistitFunc
- type FileDiff
- type GitHandler
- type GiteaRemote
- type LazySimpleLocalProvider
- type Options
- type Provider
- type Repository
- func (r *Repository) CloneURL() string
- func (r *Repository) CommitPush(ctx context.Context, path string, commit *CommitMessage) error
- func (r *Repository) CommitPushWithRetry(ctx context.Context, path string, commit *CommitMessage) error
- func (r *Repository) ContentFunc(ctx context.Context, path string, fun ContentUpdateFunc) error
- func (r *Repository) Diff(ctx context.Context, path string, hash string) ([]FileDiff, error)
- func (r *Repository) Expired() bool
- func (r *Repository) Filesystem(ctx context.Context, path string) (billy.Filesystem, error)
- func (r *Repository) HistoryFiles(ctx context.Context, path string, rev string) (*Commit, error)
- func (r *Repository) HistoryFunc(ctx context.Context, path string, fun ContentVistitFunc) error
- func (r *Repository) Pull(ctx context.Context) error
- type RepositoryRef
- type RevMeta
- type SimpleLocalProvider
- func (p *SimpleLocalProvider) GenerateCloneURL(ctx context.Context, ref RepositoryRef) string
- func (p *SimpleLocalProvider) Get(ctx context.Context, ref RepositoryRef) (*Repository, error)
- func (p *SimpleLocalProvider) GetRemoteRepoRevMeta(ctx context.Context, repourl string, branchOrRev string) (*RevMeta, error)
- func (p *SimpleLocalProvider) Options() *Options
Constants ¶
View Source
const (
CacheTimeout = 2 * time.Minute
DefaultBranch = "_base"
)
View Source
const MaxCommitRetry = 3
Variables ¶
View Source
var DefaultCommiter = &Commiter{
Name: "service",
Email: "service@kubgems.io",
}
Functions ¶
func ForFileContentFunc ¶
func ForFileContentFunc(fs billy.Filesystem, base string, fun func(filename string, content []byte) error) error
func ForFileNameFunc ¶
func ForFileNameFunc(fs billy.Filesystem, base string, fun func(filename string) error) error
ForFileNameFunc filename 为 base 下的全路径
Types ¶
type Commit ¶
type Commit struct {
Author object.Signature `json:"author"`
Message string `json:"message"`
Hash string `json:"hash"`
Committer object.Signature `json:"committer"`
Files []CommitFile `json:"files"`
}
type CommitFile ¶
type CommitFile struct {
Name string `json:"name"`
Content string `json:"content"`
}
type CommitMessage ¶
type CommitMessage struct {
Message string
Committer *object.Signature
}
type Commiter ¶
type Commiter struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
}
type ContentUpdateFunc ¶
type ContentUpdateFunc = func(ctx context.Context, fs billy.Filesystem) error
type ContentVistitFunc ¶
type ContentVistitFunc func(ctx context.Context, commit Commit) error
type FileDiff ¶
type FileDiff struct {
Name string `json:"name"`
From string `json:"from"`
To string `json:"to"`
}
type GitHandler ¶
type GitHandler = SimpleLocalProvider
type GiteaRemote ¶
type GiteaRemote struct {
*gitea.Client
}
func (*GiteaRemote) EnsureRepo ¶
func (h *GiteaRemote) EnsureRepo(ctx context.Context, orgname, reponame string) (*gitea.Repository, error)
type LazySimpleLocalProvider ¶ added in v1.24.0
type LazySimpleLocalProvider struct {
// contains filtered or unexported fields
}
func NewLazyProvider ¶ added in v1.24.0
func NewLazyProvider(options *Options) *LazySimpleLocalProvider
type Options ¶
type Options struct {
Addr string `json:"addr" description:"git addr"`
Username string `json:"username" description:"git username"`
Password string `json:"password" description:"git password"`
}
func NewDefaultOptions ¶
func NewDefaultOptions() *Options
type Provider ¶ added in v1.24.0
type Provider interface {
Options() *Options
Get(context.Context, RepositoryRef) (*Repository, error)
}
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func (*Repository) CommitPush ¶
func (r *Repository) CommitPush(ctx context.Context, path string, commit *CommitMessage) error
func (*Repository) CommitPushWithRetry ¶
func (r *Repository) CommitPushWithRetry(ctx context.Context, path string, commit *CommitMessage) error
func (*Repository) ContentFunc ¶
func (r *Repository) ContentFunc(ctx context.Context, path string, fun ContentUpdateFunc) error
ContentFunc change fs content and do a commit if commit is not nil
func (*Repository) Diff ¶
func (r *Repository) Diff(ctx context.Context, path string, hash string) ([]FileDiff, error)
func (*Repository) Filesystem ¶
func (r *Repository) Filesystem(ctx context.Context, path string) (billy.Filesystem, error)
func (*Repository) HistoryFiles ¶
func (r *Repository) HistoryFiles(ctx context.Context, path string, rev string) (*Commit, error)
func (*Repository) HistoryFunc ¶
func (r *Repository) HistoryFunc(ctx context.Context, path string, fun ContentVistitFunc) error
type RepositoryRef ¶
type RepositoryRef struct {
Org string `json:"org,omitempty"`
Repo string `json:"repo,omitempty"`
Branch string `json:"branch,omitempty"`
Path string `json:"path,omitempty"`
}
type SimpleLocalProvider ¶
type SimpleLocalProvider struct {
// contains filtered or unexported fields
}
func NewProvider ¶
func NewProvider(options *Options) (*SimpleLocalProvider, error)
func (*SimpleLocalProvider) GenerateCloneURL ¶
func (p *SimpleLocalProvider) GenerateCloneURL(ctx context.Context, ref RepositoryRef) string
func (*SimpleLocalProvider) Get ¶
func (p *SimpleLocalProvider) Get(ctx context.Context, ref RepositoryRef) (*Repository, error)
func (*SimpleLocalProvider) GetRemoteRepoRevMeta ¶
func (p *SimpleLocalProvider) GetRemoteRepoRevMeta(ctx context.Context, repourl string, branchOrRev string) (*RevMeta, error)
Click to show internal directories.
Click to hide internal directories.