storage

package
v14.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRelativePathEscapesRoot = errors.New("relative path escapes root directory")

Functions

func IsGitDirectory

func IsGitDirectory(dir string) bool

IsGitDirectory checks if the directory passed as first argument looks like a valid git directory.

func ValidateRelativePath

func ValidateRelativePath(rootDir, relativePath string) (string, error)

ValidateRelativePath validates a relative path by joining it with rootDir and verifying the result is either rootDir or a path within rootDir. Returns clean relative path from rootDir to relativePath or an ErrRelativePathEscapesRoot if the resulting path is not contained within rootDir.

func WriteMetadataFile

func WriteMetadataFile(storagePath string) error

WriteMetadataFile marshals and writes a metadata file

Types

type GitalyServers

type GitalyServers map[string]ServerInfo

GitalyServers hold Gitaly servers info like {"default":{"token":"x","address":"y"}}, to be passed in `gitaly-servers` metadata.

type Locator

type Locator interface {
	// GetRepoPath returns the full path of the repository referenced by an
	// RPC Repository message. It verifies the path is an existing git directory.
	// The errors returned are gRPC errors with relevant error codes and should
	// be passed back to gRPC without further decoration.
	GetRepoPath(repo repository.GitRepo) (string, error)
	// GetPath returns the path of the repo passed as first argument. An error is
	// returned when either the storage can't be found or the path includes
	// constructs trying to perform directory traversal.
	GetPath(repo repository.GitRepo) (string, error)
	// GetStorageByName will return the path for the storage, which is fetched by
	// its key. An error is return if it cannot be found.
	GetStorageByName(storageName string) (string, error)
	// GetObjectDirectoryPath returns the full path of the object directory in a
	// repository referenced by an RPC Repository message. The errors returned are
	// gRPC errors with relevant error codes and should be passed back to gRPC
	// without further decoration.
	GetObjectDirectoryPath(repo repository.GitRepo) (string, error)
	// InfoAlternatesPath finds the fully qualified path for the alternates file.
	InfoAlternatesPath(repo repository.GitRepo) (string, error)
}

Locator allows to get info about location of the repository or storage at the local file system.

type Metadata

type Metadata struct {
	GitalyFilesystemID string `json:"gitaly_filesystem_id"`
}

Metadata contains metadata about the filesystem

func ReadMetadataFile

func ReadMetadataFile(storagePath string) (Metadata, error)

ReadMetadataFile reads and decodes the json metadata file

type ServerInfo

type ServerInfo struct {
	Address string `json:"address"`
	Token   string `json:"token"`
}

ServerInfo contains information about how to reach a Gitaly server or a Praefect virtual storage. This is necessary for Gitaly RPC's involving more than one Gitaly. Without this information, Gitaly would not know how to reach the remote peer.

Jump to

Keyboard shortcuts

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