git

package
v1.17.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSHHostKeyVerificationStrict    = "strict"     // Require host key in known_hosts
	SSHHostKeyVerificationAcceptNew = "accept_new" // Auto-add unknown host keys
	SSHHostKeyVerificationSkip      = "skip"       // Skip host key verification (insecure)

)

SSH host key verification modes

Variables

This section is empty.

Functions

func ValidatePath

func ValidatePath(repoPath, requestedPath string) error

ValidatePath ensures the path is safe and doesn't escape the repo

Types

type AuthConfig

type AuthConfig struct {
	AuthType               string
	Username               string
	Token                  string
	SSHKey                 string
	SSHHostKeyVerification string // strict, accept_new, skip
}

AuthConfig holds authentication configuration

type BranchInfo

type BranchInfo struct {
	Name      string
	IsDefault bool
}

BranchInfo holds information about a git branch

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles git operations

func NewClient

func NewClient(workDir string) *Client

NewClient creates a new git client

func (*Client) BrowseTree

func (c *Client) BrowseTree(ctx context.Context, repoPath, targetPath string) ([]gitops.FileTreeNode, error)

BrowseTree returns the file tree at the specified path

func (*Client) Cleanup

func (c *Client) Cleanup(repoPath string) error

Cleanup removes a temporary repository directory

func (*Client) Clone

func (c *Client) Clone(ctx context.Context, url, branch string, auth AuthConfig) (string, error)

Clone clones a repository to a temporary directory

func (*Client) FileExists

func (c *Client) FileExists(ctx context.Context, repoPath, filePath string) bool

FileExists checks if a file exists in the repository

func (*Client) GetCurrentCommit

func (c *Client) GetCurrentCommit(ctx context.Context, repoPath string) (string, error)

GetCurrentCommit returns the HEAD commit hash of a cloned repository

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context, url string, auth AuthConfig) ([]BranchInfo, error)

ListBranches lists all branches in a remote repository

func (*Client) ProbeRemote added in v1.17.1

func (c *Client) ProbeRemote(ctx context.Context, url string, auth AuthConfig) error

ProbeRemote verifies that a remote repository is reachable without cloning it.

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, repoPath, filePath string) (string, error)

ReadFile reads a file from the repository

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context, url, branch string, auth AuthConfig) error

TestConnection tests if the repository can be accessed with the given credentials

func (*Client) WalkDirectory

func (c *Client) WalkDirectory(ctx context.Context, repoPath, composePath string,
	maxFiles int, maxTotalSize, maxBinarySize int64) (*DirectoryWalkResult, error)

WalkDirectory walks the directory containing the compose file and returns all files. It enforces limits on file count, total size, and skips large binary files. The composePath is the path to the compose file within the repo - the directory containing this file will be walked.

type CommitInfo

type CommitInfo struct {
	Hash    string
	Author  string
	Message string
	Date    time.Time
}

CommitInfo holds information about a git commit

type DirectoryWalkResult

type DirectoryWalkResult struct {
	Files           []SyncFileInfo
	TotalFiles      int
	TotalSize       int64
	SkippedBinaries int
}

DirectoryWalkResult holds the result of walking a directory for sync

type SyncFileInfo

type SyncFileInfo struct {
	RelativePath string // Path relative to the sync directory
	Content      []byte
	Size         int64
	IsBinary     bool
}

SyncFileInfo holds information about a file to be synced

Jump to

Keyboard shortcuts

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