Documentation ¶
Overview ¶
Git Repository Adapter
This component implements integration of git into package orchestration. A local clone of a registered git repository is created in a cache, and periodically refreshed. All package operations happen on the local copy; on completion of an operation (create, update, delete package revision or its resources) any new changes (in one or more commits) are pushed to the remote repository.
Branching Strategy ¶
Porch doesn't create tracking branches for remotes. This indirection would add a layer of complexity where branches can become out of sync and in need of reconciliation and conflict resolution. Instead, Porch analyzes the remote references (refs/remotes/origin/branch...) to discover packges. These refs are never directly updated by Porch other than by push or fetch to/from remote. Any intermediate commits Porch makes are either in 'detached HEAD' mode, or using temporary branches (these will become relevant if/when Porch implements repository garbage collection).
Porch uses the default convention for naming remote branches (refs/remotes/origin/branch...) in order to make direct introspection of the repositories aligned with traditional git repositories.
Index ¶
- Constants
- func AnnotateCommitMessage(message string, annotation *gitAnnotation) (string, error)
- func CreateEmptyCommit(repo *gogit.Repository) error
- func ExtractGitAnnotations(commit *object.Commit) ([]*gitAnnotation, error)
- func InitEmptyRepositoryWithWorktree(t *testing.T, path string) *gogit.Repository
- func InitializeBranch(t *testing.T, git *gogit.Repository, branch string)
- func OpenGitRepositoryFromArchive(t *testing.T, tarfile, tempdir string) *gogit.Repository
- func OpenGitRepositoryFromArchiveWithWorktree(t *testing.T, tarfile, path string) *gogit.Repository
- func ServeExistingRepository(t *testing.T, git *gogit.Repository) string
- func ServeGitRepository(t *testing.T, tarfile, tempdir string) (*gogit.Repository, string)
- func ServeGitRepositoryWithBranch(t *testing.T, tarfile, tempdir, branch string) (*gogit.Repository, string)
- type BranchName
- type DiscoverPackagesOptions
- type DynamicRepos
- type GitHash
- type GitRepoOption
- type GitRepository
- type GitRepositoryOptions
- type GitServer
- type GitServerOption
- type MainBranchStrategy
- type PacketLineWriter
- type RefUpdate
- type Repo
- type Repos
- type StaticRepos
Constants ¶
const ( DefaultMainReferenceName plumbing.ReferenceName = "refs/heads/main" OriginName string = "origin" )
Variables ¶
This section is empty.
Functions ¶
func AnnotateCommitMessage ¶
AnnotateCommitMessage adds the gitAnnotation to the commit message.
func CreateEmptyCommit ¶ added in v0.0.10
func CreateEmptyCommit(repo *gogit.Repository) error
func ExtractGitAnnotations ¶
ExtractGitAnnotations reads the gitAnnotations from the given commit. If no annotation are found, it returns [], nil If an invalid annotation is found, it returns an error.
func InitEmptyRepositoryWithWorktree ¶
func InitEmptyRepositoryWithWorktree(t *testing.T, path string) *gogit.Repository
func InitializeBranch ¶
func InitializeBranch(t *testing.T, git *gogit.Repository, branch string)
func OpenGitRepositoryFromArchive ¶
func OpenGitRepositoryFromArchive(t *testing.T, tarfile, tempdir string) *gogit.Repository
func OpenGitRepositoryFromArchiveWithWorktree ¶
func OpenGitRepositoryFromArchiveWithWorktree(t *testing.T, tarfile, path string) *gogit.Repository
func ServeExistingRepository ¶
func ServeExistingRepository(t *testing.T, git *gogit.Repository) string
func ServeGitRepository ¶
Types ¶
type BranchName ¶
type BranchName string
BranchName represents a relative branch name (i.e. 'main', 'drafts/bucket/v1') and supports transformation to the ReferenceName in local (cached) repository (those references are in the form 'refs/remotes/origin/...') or in the remote repository (those references are in the form 'refs/heads/...').
const (
MainBranch BranchName = "main"
)
func (BranchName) ForceFetchSpec ¶
func (b BranchName) ForceFetchSpec() config.RefSpec
func (BranchName) RefInLocal ¶
func (b BranchName) RefInLocal() plumbing.ReferenceName
func (BranchName) RefInRemote ¶
func (b BranchName) RefInRemote() plumbing.ReferenceName
type DiscoverPackagesOptions ¶
type DiscoverPackagesOptions struct { // FilterPrefix restricts package discovery to a particular subdirectory. // The subdirectory is not required to exist (we will return an empty list of packages). FilterPrefix string // Recurse enables recursive traversal of the git tree. Recurse bool }
DiscoveryPackagesOptions holds the configuration for walking a git tree
type DynamicRepos ¶ added in v0.0.10
type DynamicRepos struct {
// contains filtered or unexported fields
}
func NewDynamicRepos ¶ added in v0.0.10
func NewDynamicRepos(baseDir string, gitRepoOptions []GitRepoOption) *DynamicRepos
type GitRepoOption ¶ added in v0.0.10
type GitRepoOption interface {
// contains filtered or unexported methods
}
GitRepoOption is implemented by configuration settings for git repository.
func WithBasicAuth ¶
func WithBasicAuth(username, password string) GitRepoOption
type GitRepository ¶
type GitRepository interface { repository.Repository GetPackageRevision(ctx context.Context, ref, path string) (repository.PackageRevision, kptfilev1.GitLock, error) }
func OpenRepository ¶
func OpenRepository(ctx context.Context, name, namespace string, spec *configapi.GitRepository, root string, opts GitRepositoryOptions) (GitRepository, error)
type GitRepositoryOptions ¶
type GitRepositoryOptions struct { CredentialResolver repository.CredentialResolver UserInfoProvider repository.UserInfoProvider MainBranchStrategy MainBranchStrategy }
type GitServer ¶
type GitServer struct {
// contains filtered or unexported fields
}
GitServer is a mock git server implementing "just enough" of the git protocol
func NewGitServer ¶
func NewGitServer(repos Repos, opts ...GitServerOption) (*GitServer, error)
NewGitServer constructs a GitServer backed by the specified repo.
type GitServerOption ¶
type GitServerOption interface {
// contains filtered or unexported methods
}
type MainBranchStrategy ¶ added in v0.0.9
type MainBranchStrategy int
const ( ErrorIfMissing MainBranchStrategy = iota // ErrorIsMissing CreateIfMissing // CreateIfMissing SkipVerification // SkipVerification )
func (MainBranchStrategy) String ¶ added in v0.0.9
func (i MainBranchStrategy) String() string
type PacketLineWriter ¶
type PacketLineWriter struct {
// contains filtered or unexported fields
}
PacketLineWriter implements the git protocol line framing, with deferred error handling.
func NewPacketLineWriter ¶
func NewPacketLineWriter(w io.Writer) *PacketLineWriter
NewPackageLineWriter constructs a PacketLineWriter
func (*PacketLineWriter) Flush ¶
func (w *PacketLineWriter) Flush() error
Flush writes any buffered data, and returns an error if one has accumulated.
func (*PacketLineWriter) WriteLine ¶
func (w *PacketLineWriter) WriteLine(s string)
WriteLine frames and writes a line, accumulating errors until Flush is called.
func (*PacketLineWriter) WriteZeroPacketLine ¶
func (w *PacketLineWriter) WriteZeroPacketLine()
WriteZeroPacketLine writes a special "0000" line - often used to indicate the end of a block in the git protocol
type Repo ¶ added in v0.0.10
type Repo struct {
// contains filtered or unexported fields
}
Repo manages a single git repository
func NewRepo ¶ added in v0.0.10
func NewRepo(gogit *gogit.Repository, options ...GitRepoOption) (*Repo, error)
NewRepo constructs an instance of Repo
type StaticRepos ¶ added in v0.0.10
type StaticRepos struct {
// contains filtered or unexported fields
}
StaticRepos holds multiple registered git repositories
func NewStaticRepos ¶ added in v0.0.10
func NewStaticRepos() *StaticRepos
NewRepos constructs an instance of Repos