Documentation
¶
Index ¶
- Variables
- func CheckRemote(ctx context.Context, repoURL string, env []string) error
- func HTTPSAuthEnv(env []string, username, password string) []string
- func NormalizeRemoteURL(repoURL string) string
- func PrepareRemote(ctx context.Context, repoURL string, env []string, ...) (string, []string, error)
- func PushRemote(ctx context.Context, repoDir, repoURL string, env []string, opts PushOptions) error
- func SanitizeGitErrorDetail(detail string) string
- func SanitizeRemoteURL(repoURL string) string
- func SanitizedGitEnv(base, extra []string) []string
- func WithNativeFileLimits(ctx context.Context, maxBytes int64) (context.Context, error)
- type FileEntry
- type GitMetadata
- type Provider
- type PushOptions
- type RemoteBranch
- type RemoteGit
- type RepoStore
- type StreamingStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileNotFound = xerror.NotFound(xerror.RepoFile) ErrFileExists = xerror.AlreadyExists(xerror.RepoFile) ErrInvalidPath = xerror.InvalidInput(xerror.RepoFile) ErrRepositorySetup = xerror.Unavailable(xerror.RepoFile) ErrRemoteRefNotFound = xerror.New( xerror.KindNotFound, "REPOSITORY_REMOTE_REF_NOT_FOUND", "remote repository ref not found", ) )
Functions ¶
func CheckRemote ¶
CheckRemote verifies a remote repository is reachable.
func HTTPSAuthEnv ¶
HTTPSAuthEnv configures Git HTTPS credentials without executable temporary files or secrets in repository URLs, Git configuration values, or process arguments.
func NormalizeRemoteURL ¶
NormalizeRemoteURL returns a stable repo identifier for provider-backed remotes when possible. For GitHub/GitLab, it normalizes SSH/HTTPS variants to "<host>/<owner>/<repo>" without the .git suffix. Unknown formats are returned unchanged (trimmed).
func PrepareRemote ¶
func PrepareRemote( ctx context.Context, repoURL string, env []string, policy hostguard.DestinationPolicy, ) (string, []string, error)
PrepareRemote resolves a Git remote once and adds native-Git transport settings that force HTTPS or SSH sockets to a vetted IP while preserving the original hostname for TLS and host keys. HTTPS redirects are disabled because native Git cannot expose each redirect target for revalidation.
func PushRemote ¶
func PushRemote( ctx context.Context, repoDir, repoURL string, env []string, opts PushOptions, ) error
PushRemote pushes local commits from repoDir to repoURL.
func SanitizeGitErrorDetail ¶
SanitizeGitErrorDetail removes credential-bearing URLs before Git errors reach operator logs.
func SanitizeRemoteURL ¶
SanitizeRemoteURL removes any embedded userinfo from HTTP(S)/SSH URLs before they are logged, persisted, or surfaced in errors. SCP-style SSH remotes do not encode credentials in the URL and are returned unchanged.
func SanitizedGitEnv ¶
SanitizedGitEnv returns a child-process environment with inherited Git repository context removed and explicit overrides appended.
Types ¶
type GitMetadata ¶
GitMetadata captures source metadata from a checked-out git repository.
func ResolveGitMetadata ¶
func ResolveGitMetadata(ctx context.Context, repoPath string) GitMetadata
ResolveGitMetadata reads best-effort source metadata from repoPath.
type Provider ¶
type Provider string
Provider identifies a git hosting provider inferred from a repository URL.
func DetectProvider ¶
DetectProvider infers the provider from a repository URL. Unknown/self-hosted remotes are treated as generic git.
type PushOptions ¶
PushOptions controls git push behavior for PushRemote.
type RemoteBranch ¶
RemoteBranch describes a branch returned by a remote git repository.
func ListRemoteBranches ¶
ListRemoteBranches returns visible heads from a remote repository.
type RemoteGit ¶
type RemoteGit interface {
CheckRemote(ctx context.Context, repoURL string, env []string) error
ListRemoteBranches(ctx context.Context, repoURL string, env []string) ([]RemoteBranch, error)
CloneRemote(
ctx context.Context,
repoURL, branch string,
env []string,
) (RepoStore, string, func(), error)
PushRemote(ctx context.Context, repoDir, repoURL string, env []string, opts PushOptions) error
}
RemoteGit encapsulates remote git operations.
func NewRemoteGit ¶
func NewRemoteGit() RemoteGit
NewRemoteGit returns the default remote git operation client.
type RepoStore ¶
type RepoStore interface {
// ReadFile returns up to maxBytes of the file at path. A positive maxBytes
// must be enforced before the implementation materializes file contents.
// Returns ErrFileNotFound if the file does not exist.
ReadFile(ctx context.Context, path string, maxBytes int64) ([]byte, error)
// WriteFile creates or overwrites the file at path with data.
// message is an opaque commit description used by git-backed implementations.
WriteFile(ctx context.Context, path string, data []byte, message string) error
// DeleteFile removes the file at path.
// Returns ErrFileNotFound if the file does not exist.
DeleteFile(ctx context.Context, path, message string) error
// ListFiles returns all files under dir recursively.
// Pass "" or "." to list files from the repository root.
ListFiles(ctx context.Context, dir string) ([]FileEntry, error)
// FileExists reports whether the file at path exists.
FileExists(ctx context.Context, path string) (bool, error)
}
RepoStore abstracts a content-addressed file store. Implementations must be safe for sequential use but are not required to be safe for concurrent use.
func CloneNativeFileRemote ¶
func CloneNativeFileRemote(ctx context.Context, repoURL, branch, target string, maxBytes int64, env []string) (RepoStore, string, func(), error)
CloneNativeFileRemote materializes only the selected raw blob, checking its size before checkout when maxBytes is positive. A missing target allows creation.
type StreamingStore ¶
type StreamingStore interface {
ReadFileTo(context.Context, string, int64, io.Writer) (*filestream.Metadata, error)
WriteFileFrom(context.Context, string, io.Reader, filepayload.Reference, bool, string) error
}
StreamingStore extends checkout storage without requiring snapshot stores to materialize large inputs or pretend to support streaming writes.