Documentation
¶
Overview ¶
Package gitlab provides a client for interacting with GitLab repositories as vaults.
Index ¶
- func ParseRepoURL(repoURL string) (any, error)
- type Client
- func (c *Client) CheckConnectivity(ctx context.Context) error
- func (c *Client) DeleteFile(ctx context.Context, path, sha, message string) error
- func (c *Client) DownloadFile(ctx context.Context, path string) ([]byte, error)
- func (c *Client) GetFileSHA(ctx context.Context, path string) (string, error)
- func (c *Client) ListCommits(ctx context.Context, path string) ([]vault.CommitInfo, error)
- func (c *Client) ListFiles(ctx context.Context) ([]vault.FileInfo, error)
- func (c *Client) Owner() string
- func (c *Client) Repo() string
- func (c *Client) RepoURL() string
- func (c *Client) ResetBranchToCommit(_ context.Context, _, _ string) error
- func (c *Client) UploadFile(ctx context.Context, path string, content []byte, message string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRepoURL ¶
ParseRepoURL parses a GitLab repository URL and returns the project ID. GitLab accepts both numeric IDs and string IDs in "namespace/project" format.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitLab client and provides vault operations.
func NewClient ¶
NewClient creates a new GitLab client using the provided token and project ID. ProjectID can be either a numeric ID (int) or namespace/project string.
func NewClientFromURL ¶
NewClientFromURL creates a new GitLab client from a repository URL and token. Supports HTTPS URLs like: https://gitlab.com/namespace/project. Supports short format: namespace/project.
func (*Client) CheckConnectivity ¶
CheckConnectivity verifies that the token has access to the project.
func (*Client) DeleteFile ¶
DeleteFile deletes a file from the vault.
func (*Client) DownloadFile ¶
DownloadFile downloads a file from the vault. GitLab returns content in base64 encoding, which we decode before returning.
func (*Client) GetFileSHA ¶
GetFileSHA returns the SHA (BlobID) of a file for update operations.
func (*Client) ListCommits ¶
ListCommits returns commits that affect the specified path.
func (*Client) ResetBranchToCommit ¶
ResetBranchToCommit resets the branch to point to a specific commit SHA. This effectively wipes all history after that commit for the repository.