Documentation ¶
Index ¶
- Variables
- func InjectGitalyServers(ctx context.Context, name, address, token string) (context.Context, error)
- func InjectGitalyServersEnv(ctx context.Context) (context.Context, error)
- func IsGitDirectory(dir string) bool
- func QuarantineDirectoryPrefix(repo repository.GitRepo) string
- func ValidateRelativePath(rootDir, relativePath string) (string, error)
- func WriteMetadataFile(storagePath string) (returnedErr error)
- type GetRepoPathConfig
- type GetRepoPathOption
- type GitalyServers
- type Locator
- type Metadata
- type ServerInfo
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyMetadata = errors.New("empty metadata")
ErrEmptyMetadata indicates that the gRPC metadata was not found in the context
var ErrRelativePathEscapesRoot = errors.New("relative path escapes root directory")
Functions ¶
func InjectGitalyServers ¶
InjectGitalyServers injects gitaly-servers metadata into an outgoing context
func InjectGitalyServersEnv ¶
InjectGitalyServersEnv injects the GITALY_SERVERS env var into an incoming context.
func IsGitDirectory ¶
IsGitDirectory checks if the directory passed as first argument looks like a valid git directory.
func QuarantineDirectoryPrefix ¶
func QuarantineDirectoryPrefix(repo repository.GitRepo) string
QuarantineDirectoryPrefix returns a prefix for use in the temporary directory. The prefix is based on the relative repository path and will stay stable for any given repository. This allows us to verify that a given quarantine object directory indeed belongs to the repository at hand. Ideally, this function would directly be located in the quarantine module, but this is not possible due to cyclic dependencies.
func ValidateRelativePath ¶
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 ¶
WriteMetadataFile marshals and writes a metadata file
Types ¶
type GetRepoPathConfig ¶
type GetRepoPathConfig struct { // SkipRepositoryVerification will cause GetRepoPath to skip verification the verification whether the // computed path is an actual Git repository or not. SkipRepositoryVerification bool }
GetRepoPathConfig is used to configure GetRepoPath.
type GetRepoPathOption ¶
type GetRepoPathOption func(*GetRepoPathConfig)
GetRepoPathOption can be passed to GetRepoPath to change its default behavior.
func WithRepositoryVerificationSkipped ¶
func WithRepositoryVerificationSkipped() GetRepoPathOption
WithRepositoryVerificationSkipped skips the repository path validation that ensures the Git directory is valid.
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.
func ExtractGitalyServers ¶
func ExtractGitalyServers(ctx context.Context) (gitalyServersInfo GitalyServers, err error)
ExtractGitalyServers extracts `storage.GitalyServers` from an incoming context.
type Locator ¶
type Locator interface { // GetRepoPath returns the full path of the repository referenced by an RPC Repository message. // By default, it verifies that the path is an existing git directory. However, if invoked with // the `GetRepoPathOption` produced by `WithRepositoryVerificationSkipped()`, this validation // will be skipped. The errors returned are gRPC errors with relevant error codes and should be // passed back to gRPC without further decoration. GetRepoPath(repo repository.GitRepo, opts ...GetRepoPathOption) (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) // CacheDir returns the path to the cache dir for a storage. CacheDir(storageName string) (string, error) // TempDir returns the path to the temp dir for a storage. TempDir(storageName string) (string, error) // StateDir returns the path to the state dir for a storage. StateDir(storageName string) (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 ¶
ReadMetadataFile reads and decodes the json metadata file
type ServerInfo ¶
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.
func ExtractGitalyServer ¶
func ExtractGitalyServer(ctx context.Context, storageName string) (ServerInfo, error)
ExtractGitalyServer extracts server information for a specific storage
func (ServerInfo) Zero ¶
func (si ServerInfo) Zero() bool
Zero returns true when no attributes have been set.