gitlab

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gitlab provides a client for interacting with GitLab repositories as vaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRepoURL

func ParseRepoURL(repoURL string) (any, error)

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

func NewClient(token string, projectID any) (*Client, error)

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

func NewClientFromURL(repoURL, token string) (*Client, error)

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

func (c *Client) CheckConnectivity(ctx context.Context) error

CheckConnectivity verifies that the token has access to the project.

func (*Client) DeleteFile

func (c *Client) DeleteFile(ctx context.Context, path, sha, message string) error

DeleteFile deletes a file from the vault.

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, path string) ([]byte, error)

DownloadFile downloads a file from the vault. GitLab returns content in base64 encoding, which we decode before returning.

func (*Client) GetFileSHA

func (c *Client) GetFileSHA(ctx context.Context, path string) (string, error)

GetFileSHA returns the SHA (BlobID) of a file for update operations.

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context) ([]vault.FileInfo, error)

ListFiles lists all files in the vault.

func (*Client) Owner

func (c *Client) Owner() string

Owner returns the project path with namespace (e.g., "namespace/project").

func (*Client) Repo

func (c *Client) Repo() string

Repo returns the project identifier.

func (*Client) RepoURL

func (c *Client) RepoURL() string

RepoURL returns the full project URL.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, path string, content []byte, message string) error

UploadFile uploads or updates a file in the vault.

Jump to

Keyboard shortcuts

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