hashpath

package
v0.1.23-oss Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(ctx context.Context, hp *HashPath, store entities.CASStore, callback NewResolution)

Watch does not notify if the resolved hash goes from non-zero to zero.

Types

type BaseDirRef

type BaseDirRef struct {
	Base entities.Hash
	Dir  entities.Hash
	Ref  string
}

func ResolveBase

func ResolveBase(ctx context.Context, store entities.CASStore, hp *HashPath, defaultServer, defaultProject string) (BaseDirRef, error)

type HashPath

type HashPath struct {
	Hash    entities.Hash
	Ref     string
	Project string
	Server  string
	Path    string
}

HashPath is a string that represents a file-system object (file or directory). In its simplest form a HashPath is a hash. It can also have a relative path to a given hash or reference. A HashPath can be resolved to a single hash of a dir or blob using a specific resolution process.

func Parse

func Parse(a string) (*HashPath, error)

Parse a HashPath, which is a string in one of these forms:

<blob-hash>
<dir-hash>
<dir-hash>:<relative-path>
<commit-hash>:<relative-path>
<ref>:<relative-path> # with inferred project and server
<ref@project>:<relative-path> # with inferred server
<ref@project@server>:<relative-path>

func (*HashPath) IsSimpleHash

func (hp *HashPath) IsSimpleHash() bool

func (*HashPath) String

func (hp *HashPath) String() string

func (*HashPath) UsesRef

func (hp *HashPath) UsesRef() bool

type NewResolution

type NewResolution func(entities.Hash, error)

type Resolution

type Resolution struct {
	// FS is a CAS in-memory file-system rooted at the base object. It will be nil if the base is pointing to a blob or the hash-path was simply a path.
	FS bindcas.MemFS
	// Ref is a fully-qualified reference if a ref is used, otherwise is an empty string.
	Ref string
	// Base is the hash of resolved object either specified explicitly or resolved from the ref.
	Base entities.Hash
	// DirHash is the hash of a tree (directory) object resolved from Base (like if Base is a commit, DirHash is its tree-hash).
	DirHash entities.Hash
	// Resolved is the hash of the target object, found by resolving the base and starting from the directory specified by DirHash.
	Resolved entities.Hash
}

func Resolve

func Resolve(ctx context.Context, store entities.CASStore, hp *HashPath, defaultServer, defaultProject string) (*Resolution, error)

Resolve is split into two methods: ResolveBase -> Uses remote Ref APIs to lookup base and dir hashes. ResolvePath -> Can navigate from the dir hash to the path of interest. They are split here to allow independent caching.

func ResolvePath

func ResolvePath(ctx context.Context, store entities.CASStore, baseDirRef BaseDirRef, hp *HashPath) (*Resolution, error)

Jump to

Keyboard shortcuts

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