Documentation
¶
Index ¶
Constants ¶
View Source
const LogAttrProtocol = "protocol"
Variables ¶
View Source
var DefaultWorktreeBranch = plumbing.NewBranchReferenceName("ocm")
View Source
var ErrNoValidGitCredentials = errors.New("no valid credentials found for git authentication")
View Source
var REALM = logging.DefineSubRealm("git repository", "git")
Functions ¶
func GetStorage ¶
func VFSBillyFS ¶
func VFSBillyFS(fsToWrap vfs.FileSystem) (billy.Filesystem, error)
Types ¶
type AuthMethod ¶
type AuthMethod = transport.AuthMethod
func AuthFromCredentials ¶
func AuthFromCredentials(creds credentials.Credentials) (AuthMethod, error)
AuthFromCredentials creates a git authentication method from the given credentials. If no valid credentials are found, ErrNoValidGitCredentials is returned. However, one can still perform anonymous operations with the git client if the repo allows it.
type Client ¶
type Client interface { // Repository returns the git repository for the client initialized in the Filesystem given to Setup. // If Setup is not called before Repository, it will an in-memory filesystem. // Repository will attempt to initially clone the repository if it does not exist. // If the repository is already open or cloned in the filesystem, it will attempt to open & return the existing repository. // If the remote repository does not exist, a new repository will be created with a dummy commit and the remote // configured to the given URL. At that point it is up to the remote to accept an initial push to the repository or not with the // given AuthMethod. Repository(ctx context.Context) (*git.Repository, error) // Setup will override the current filesystem with the given filesystem. This will be the filesystem where the repository will be stored. // There can be only one filesystem per client. // If the filesystem contains a repository already, it can be consumed by a subsequent call to Repository. Setup(context.Context, vfs.FileSystem) error }
Client is a heavy abstraction over the go git Client that opinionates the remote as git.DefaultRemoteName as well as access to it via high level functions that are usually required for operation within OCM CTFs that are stored within Git. It is not general-purpose.
func NewClient ¶
func NewClient(opts ClientOptions) (Client, error)
type ClientOptions ¶
type ClientOptions struct { // URL is the URL of the git repository to clone or open. URL string // Ref is the reference to the repository to clone or open. // If empty, it will default to plumbing.HEAD of the remote repository. // If the remote does not exist, it will attempt to push to the remote with DefaultWorktreeBranch on Client.Update. // To point to a remote branch, use refs/heads/<branch>. // To point to a tag, use refs/tags/<tag>. Ref string // Commit is the commit hash to checkout after cloning the repository. // If empty, it will default to the plumbing.HEAD of the Ref. Commit string // AuthMethod is the authentication method to use for the repository. AuthMethod AuthMethod }
Click to show internal directories.
Click to hide internal directories.