git

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package git provides a Git connector for Braidplane data sources. It executes file read/write operations against a Git repository via shallow clones.

Index

Constants

View Source
const (
	QueryFormatUnknown     = filedata.QueryFormatUnknown
	QueryFormatAuto        = filedata.QueryFormatAuto
	QueryFormatCSV         = filedata.QueryFormatCSV
	QueryFormatJSON        = filedata.QueryFormatJSON
	QueryFormatFile        = filedata.QueryFormatFile
	QueryFormatSpreadsheet = filedata.QueryFormatSpreadsheet
)

Variables

This section is empty.

Functions

func AuthEnv

func AuthEnv(
	creds Credentials,
) (env []string, modifyURL func(string) (string, error), cleanup func(), err error)

AuthEnv returns the git environment variables and a URL modifier needed to perform raw git operations (ls-remote, clone, push) with the given credentials. For HTTPS: Git's credential helper reads credentials from the child environment. For SSH: a temp key file is written and GIT_SSH_COMMAND is set. The returned cleanup func must be called (via defer) to remove temp files.

func AuthTypeStrings

func AuthTypeStrings() []string

AuthTypeStrings returns a slice of all String values of the enum

Types

type AuthType

type AuthType int
const (
	AuthTypeUnknown AuthType = iota // unknown
	AuthTypeHTTPS                   // https
	AuthTypeSSH                     // ssh
)

func AuthTypeString

func AuthTypeString(s string) (AuthType, error)

AuthTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func AuthTypeValues

func AuthTypeValues() []AuthType

AuthTypeValues returns all values of the enum

func (AuthType) IsAAuthType

func (i AuthType) IsAAuthType() bool

IsAAuthType returns "true" if the value is listed in the enum definition. "false" otherwise

func (AuthType) MarshalJSON

func (i AuthType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for AuthType

func (AuthType) MarshalText

func (i AuthType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for AuthType

func (AuthType) String

func (i AuthType) String() string

func (*AuthType) UnmarshalJSON

func (i *AuthType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for AuthType

func (*AuthType) UnmarshalText

func (i *AuthType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for AuthType

type Config

type Config struct {
	RepoURL           string `json:"repo_url"                      validate:"required,min=1"`
	DefaultBranch     string `json:"default_branch,omitempty"`
	BasePath          string `json:"base_path,omitempty"`
	AllowPrivateHosts bool   `json:"allow_private_hosts,omitempty"`
}

Config holds configuration for Git repository connections.

type Connector

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

Connector is a stateless Git connector. Each operation performs a shallow clone.

func New

func New(ctx context.Context, config Config, creds Credentials) (*Connector, error)

New creates a new Git connector after validating config and credentials. It does NOT establish a persistent connection.

func (*Connector) Close

func (c *Connector) Close() error

Close is a no-op for the Git connector since it is stateless.

func (*Connector) Execute

func (c *Connector) Execute(
	ctx context.Context,
	queryData json.RawMessage,
	params map[string]types.TypedParam,
	limits ...types.ExecutionLimits,
) (*result.ExecutionResult, error)

Execute runs a Git file operation (read or write) and returns an execution result.

func (*Connector) IntrospectSchema

func (c *Connector) IntrospectSchema(ctx context.Context) (*filedata.Schema, error)

IntrospectSchema shallow-clones the repository and infers schema from files in BasePath.

func (*Connector) TestConnection

func (c *Connector) TestConnection(ctx context.Context) error

TestConnection verifies the repository is reachable by running git ls-remote.

type Credentials

type Credentials struct {
	AuthType      AuthType `json:"auth_type"                 validate:"required,oneof=1 2"`
	Username      string   `json:"username,omitempty"`
	Token         string   `json:"token,omitempty"`
	SSHPrivateKey string   `json:"ssh_private_key,omitempty"`
	SSHPassphrase string   `json:"ssh_passphrase,omitempty"`
	SSHKnownHosts string   `json:"ssh_known_hosts,omitempty"`
}

Credentials holds Git authentication values.

type ProviderConfig

type ProviderConfig struct {
	Repository ProviderRepository `json:"repository" validate:"required"`
	BasePath   string             `json:"base_path,omitempty"`
}

type ProviderOnboardingConfig

type ProviderOnboardingConfig struct {
	Provider string `json:"provider" validate:"required,eq=gitlab"`
	BasePath string `json:"base_path,omitempty"`
}

type ProviderRepository

type ProviderRepository struct {
	ID            string `json:"id"             validate:"required"`
	Name          string `json:"name"           validate:"required"`
	FullName      string `json:"full_name"      validate:"required"`
	WebURL        string `json:"web_url"        validate:"required,url"`
	DefaultBranch string `json:"default_branch,omitempty"`
}

type QueryFormat

type QueryFormat = filedata.QueryFormat

QueryFormat is an alias for filedata.QueryFormat.

Jump to

Keyboard shortcuts

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