Documentation ¶
Index ¶
- Constants
- Variables
- func ChangeColor(t dagutils.ChangeType) func(arg interface{}) aurora.Value
- func ChangeType(t dagutils.ChangeType) string
- func DefaultConfConfig() cmd.ConfConfig
- func Diff(ctx context.Context, ds ipld.DAGService, a, b ipld.Node) ([]*du.Change, error)
- func Ignore(pth string) bool
- type AddOption
- type Archive
- type ArchiveDeal
- type ArchiveInfo
- type ArchiveMessageType
- type ArchiveStatusMessage
- type AuthFunc
- type Bucket
- func (b *Bucket) AddRemoteCid(ctx context.Context, c cid.Cid, dest string, opts ...AddOption) error
- func (b *Bucket) ArchiveInfo(ctx context.Context) (info ArchiveInfo, err error)
- func (b *Bucket) ArchiveRemote(ctx context.Context) error
- func (b *Bucket) ArchiveStatus(ctx context.Context, watch bool) (<-chan ArchiveStatusMessage, error)
- func (b *Bucket) CatRemotePath(ctx context.Context, pth string, w io.Writer) error
- func (b *Bucket) DBInfo(ctx context.Context) (info *client.DBInfo, err error)
- func (b *Bucket) DecryptLocalPath(pth, password string, w io.Writer) error
- func (b *Bucket) DecryptRemotePath(ctx context.Context, pth, password string, w io.Writer) error
- func (b *Bucket) Destroy(ctx context.Context) error
- func (b *Bucket) DiffLocal() ([]Change, error)
- func (b *Bucket) EncryptLocalPath(pth, password string, w io.Writer) error
- func (b *Bucket) Info(ctx context.Context) (info BucketInfo, err error)
- func (b *Bucket) Key() string
- func (b *Bucket) ListRemotePath(ctx context.Context, pth string) (items []BucketItem, err error)
- func (b *Bucket) LocalSize() (int64, error)
- func (b *Bucket) Path() (string, error)
- func (b *Bucket) PullRemote(ctx context.Context, opts ...PathOption) (roots Roots, err error)
- func (b *Bucket) PushLocal(ctx context.Context, opts ...PathOption) (roots Roots, err error)
- func (b *Bucket) RemoteLinks(ctx context.Context) (links Links, err error)
- func (b *Bucket) Roots(ctx context.Context) (roots Roots, err error)
- func (b *Bucket) Thread() (id thread.ID, err error)
- func (b *Bucket) Watch(ctx context.Context, opts ...WatchOption) (<-chan cmd.WatchState, error)
- type BucketInfo
- type BucketItem
- type Buckets
- func (b *Buckets) Clients() *cmd.Clients
- func (b *Buckets) Context(ctx context.Context) context.Context
- func (b *Buckets) GetLocalBucket(ctx context.Context, pth string) (*Bucket, error)
- func (b *Buckets) NewBucket(ctx context.Context, conf Config, opts ...NewOption) (buck *Bucket, err error)
- func (b *Buckets) NewConfigFromCmd(c *cobra.Command, pth string) (conf Config, err error)
- func (b *Buckets) RemoteBuckets(ctx context.Context, id thread.ID) (list []BucketInfo, err error)
- type Change
- type Config
- type ConfirmDiffFunc
- type Links
- type MergeStrategy
- type NewOption
- type PathEvent
- type PathEventType
- type PathOption
- type Repo
- func (b *Repo) CidVersion() int
- func (b *Repo) Close() error
- func (b *Repo) Diff(ctx context.Context, pth string) (diff []*du.Change, err error)
- func (b *Repo) GetNode(ctx context.Context, c cid.Cid) (ipld.Node, error)
- func (b *Repo) GetPathMap(pth string) (local, remote cid.Cid, err error)
- func (b *Repo) HashFile(pth string) (cid.Cid, error)
- func (b *Repo) MatchPath(pth string, local, remote cid.Cid) (bool, error)
- func (b *Repo) Path() string
- func (b *Repo) RemovePath(ctx context.Context, pth string) error
- func (b *Repo) Root() (local, remote cid.Cid, err error)
- func (b *Repo) Save(ctx context.Context) error
- func (b *Repo) SaveFile(ctx context.Context, pth string, name string) error
- func (b *Repo) SetCidVersion(v int)
- func (b *Repo) SetRemotePath(pth string, remote cid.Cid) error
- type Roots
- type SelectMergeFunc
- type WatchOption
Constants ¶
const ( // Skip skips the path merge. Skip MergeStrategy = "Skip" // Merge attempts to merge the paths (directories only). Merge = "Merge" // Replace replaces the old path with the new path. Replace = "Replace" )
Variables ¶
var ( // ErrUpToDate indicates there are no locally staged changes. ErrUpToDate = errors.New("everything up-to-date") // ErrAborted indicates the caller aborted the operation via a confirm function. ErrAborted = errors.New("operation aborted by caller") )
var ( // ErrNotABucket indicates the given path is not within a bucket. ErrNotABucket = errors.New("not a bucket (or any of the parent directories): .textile") // ErrBucketExists is used during initialization to indicate the path already contains a bucket. ErrBucketExists = errors.New("bucket is already initialized") // ErrThreadRequired indicates the operation requires a thread ID but none was given. ErrThreadRequired = errors.New("thread ID is required") )
var ArchiveStatusTimeout = time.Second * 5
ArchiveStatusTimeout is the timeout used when requesting a single status message.
Functions ¶
func ChangeColor ¶ added in v1.0.13
func ChangeColor(t dagutils.ChangeType) func(arg interface{}) aurora.Value
ChangeColor returns an appropriate color for the given change type.
func ChangeType ¶ added in v1.0.13
func ChangeType(t dagutils.ChangeType) string
ChangeType returns a string representation of a change type.
func DefaultConfConfig ¶ added in v1.0.13
func DefaultConfConfig() cmd.ConfConfig
DefaultConfConfig returns the default ConfConfig.
func Diff ¶ added in v1.0.11
Diff returns a set of changes that transform node 'a' into node 'b'. Modified from https://github.com/ipfs/go-merkledag/blob/master/dagutils/diff.go#L104 It only traverses links in the following cases: 1. two node's links number are greater than 0. 2. both of two nodes are ProtoNode. 3. neither of the nodes is a file node, which contains only unnamed raw blocks Otherwise, it compares the cid and emits a Mod change object.
Types ¶
type AddOption ¶ added in v1.0.13
type AddOption func(*addOptions)
AddOption is used when staging a remote Unixfs dag cid in a local bucket.
func WithAddEvents ¶ added in v1.0.13
WithAddEvents allows the caller to receive path events when staging files from a remote Unixfs dag.
func WithSelectMerge ¶ added in v1.0.13
func WithSelectMerge(f SelectMergeFunc) AddOption
WithSelectMerge allows the caller to select the path merge strategy.
type Archive ¶ added in v1.0.13
type Archive struct { Cid cid.Cid `json:"cid"` Deals []ArchiveDeal `json:"deals"` }
Archive describes the state of an archive.
type ArchiveDeal ¶ added in v1.0.13
type ArchiveDeal struct { ProposalCid cid.Cid `json:"proposal_cid"` Miner string `json:"miner"` }
ArchiveDeal describes an archive deal.
type ArchiveInfo ¶ added in v1.0.13
ArchiveInfo wraps info about an archive.
type ArchiveMessageType ¶ added in v1.0.13
type ArchiveMessageType int
ArchiveMessageType is the type of status message.
const ( // ArchiveMessage accompanies an informational message. ArchiveMessage ArchiveMessageType = iota // ArchiveWarning accompanies a warning state. ArchiveWarning // ArchiveError accompanies an error state. ArchiveError // ArchiveSuccess accompanies a successful state. ArchiveSuccess )
type ArchiveStatusMessage ¶ added in v1.0.13
type ArchiveStatusMessage struct { Type ArchiveMessageType Message string Error error }
ArchiveStatusMessage is used to wrap an archive status message.
type AuthFunc ¶ added in v1.0.13
AuthFunc is a function that's used to add additional context information to the outgoing API requests.
type Bucket ¶
Bucket is a local-first object storage and synchronization model built on ThreadDB, IPFS, and Filecoin. A bucket represents a dynamic Unixfs directory with auto-updating IPNS resolution, website rendering, and Filecoin archivng.
Private buckets are fully encrypted using AES-CTR + AES-512 HMAC (see https://github.com/textileio/dcrypto for more). Both Unixfs node metadata (size, links, etc.) and node data (files) are obfuscated by encryption. The AES and HMAC keys used for bucket encryption are stored in the ThreadDB collection instance. This setup allows for bucket access to inherit from thread ACL rules.
Additionally, files can be further protected by password-based encryption before they are added to the bucket. See EncryptLocalPath and DecryptLocalPath for more.
func (*Bucket) AddRemoteCid ¶ added in v1.0.13
AddRemoteCid stages the Unixfs dag at cid in the local bucket, optionally allowing the caller to select a merge strategy.
func (*Bucket) ArchiveInfo ¶ added in v1.0.13
func (b *Bucket) ArchiveInfo(ctx context.Context) (info ArchiveInfo, err error)
ArchiveInfo returns information about the current archvie.
func (*Bucket) ArchiveRemote ¶ added in v1.0.13
ArchiveRemote requests an archive of the current remote bucket.
func (*Bucket) ArchiveStatus ¶ added in v1.0.13
func (b *Bucket) ArchiveStatus(ctx context.Context, watch bool) (<-chan ArchiveStatusMessage, error)
ArchiveStatus returns the current archive status. When watch is true, the channel remains open, delivering all messages.
func (*Bucket) CatRemotePath ¶ added in v1.0.13
CatRemotePath writes the content of the remote path to writer.
func (*Bucket) DBInfo ¶ added in v1.0.13
DBInfo returns info about the bucket's ThreadDB. This info can be used to add replicas or additional peers to the bucket.
func (*Bucket) DecryptLocalPath ¶ added in v1.0.13
DecryptLocalPath decrypts the file at path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC. https://godoc.org/golang.org/x/crypto/scrypt is used to derive the keys from the password.
func (*Bucket) DecryptRemotePath ¶ added in v1.0.13
DecryptRemotePath decrypts the file at the remote path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC. https://godoc.org/golang.org/x/crypto/scrypt is used to derive the keys from the password.
func (*Bucket) DiffLocal ¶ added in v1.0.13
DiffLocal returns a list of locally staged bucket file changes.
func (*Bucket) EncryptLocalPath ¶ added in v1.0.13
EncryptLocalPath encrypts the file at path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC. https://godoc.org/golang.org/x/crypto/scrypt is used to derive the keys from the password.
func (*Bucket) Info ¶ added in v1.0.13
func (b *Bucket) Info(ctx context.Context) (info BucketInfo, err error)
Info returns info about a bucket from the remote.
func (*Bucket) Key ¶ added in v1.0.13
Key returns the bucket's unique key identifier, which is also an IPNS public key.
func (*Bucket) ListRemotePath ¶ added in v1.0.13
ListRemotePath returns a list of all bucket items under path.
func (*Bucket) LocalSize ¶ added in v1.0.13
LocalSize returns the cumalative size of the bucket's local files.
func (*Bucket) PullRemote ¶ added in v1.0.13
PullRemote pulls remote files. By default, only missing files are pulled. See PathOption for more info.
func (*Bucket) PushLocal ¶ added in v1.0.13
PushRemote pushes local files. By default, only staged changes are pushed. See PathOption for more info.
func (*Bucket) RemoteLinks ¶ added in v1.0.13
RemoteLinks returns the remote links for the bucket.
func (*Bucket) Roots ¶ added in v1.0.13
Roots returns the bucket's current local and remote root cids.
func (*Bucket) Watch ¶ added in v1.0.13
func (b *Bucket) Watch(ctx context.Context, opts ...WatchOption) (<-chan cmd.WatchState, error)
Watch watches for and auto-pushes local bucket changes at an interval, and listens for and auto-pulls remote changes as they arrive. Use the WithOffline option to keep watching during network interruptions. Returns a channel of watch connectivity states. Cancel context to stop watching.
type BucketInfo ¶ added in v1.0.13
type BucketInfo struct { Key string `json:"key"` Name string `json:"name"` Path path.Resolved `json:"path"` Thread thread.ID `json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
BucketInfo wraps info about a bucket.
type BucketItem ¶ added in v1.0.13
type BucketItem struct { Cid cid.Cid `json:"cid"` Name string `json:"name"` Path string `json:"path"` Size int64 `json:"size"` IsDir bool `json:"is_dir"` Items []BucketItem `json:"items"` ItemsCount int `json:"items_count"` }
BucketItem describes an item (file/directory) in a bucket.
type Buckets ¶ added in v1.0.13
type Buckets struct {
// contains filtered or unexported fields
}
Buckets is used to create new individual buckets based on the provided clients and config.
func NewBuckets ¶ added in v1.0.13
func NewBuckets(clients *cmd.Clients, config cmd.ConfConfig) *Buckets
NewBuckets creates Buckets from clients and config.
func NewBucketsWithAuth ¶ added in v1.0.13
NewBucketsWithAuth creates Buckets from clients and config and auth.
func (*Buckets) GetLocalBucket ¶ added in v1.0.13
GetLocalBucket loads and returns the bucket at path if it exists.
func (*Buckets) NewBucket ¶ added in v1.0.13
func (b *Buckets) NewBucket(ctx context.Context, conf Config, opts ...NewOption) (buck *Bucket, err error)
NewBucket initializes a new bucket from the config. A local blockstore is created that's used to sync local changes with the remote. By default, this will be an unencrypted, unnamed, empty bucket. The remote bucket will also be created if it doesn't already exist. See NewOption for more info.
func (*Buckets) NewConfigFromCmd ¶ added in v1.0.13
NewConfigFromCmd returns a config by inflating values from the given cobra command and path. First, flags for "key" and "thread" are used if they exist. If still unset, the env vars {EnvPrefix}_KEY and {EnvPrefix}_THREAD are used.
func (*Buckets) RemoteBuckets ¶ added in v1.0.13
RemoteBuckets lists all existing remote buckets in the thread. If id is not defined, this will return buckets from all threads. In a hub context, this will only list buckets that the context has access to.
type Change ¶ added in v1.0.13
type Change struct { Type dagutils.ChangeType Name string // Absolute file name Path string // File name relative to the bucket root Rel string // File name relative to the bucket current working directory }
Change describes a local bucket change.
type Config ¶ added in v1.0.13
type Config struct { // Path is the path in which the new bucket should be created (required). Path string // Key is a key of an existing bucket (optional). // It's value may be inflated from a --key flag or {EnvPrefix}_KEY env variable. Key string // Thread is the thread ID of the target thread (required). // It's value may be inflated from a --thread flag or {EnvPrefix}_THREAD env variable. Thread thread.ID }
Config contains details for a new local bucket.
type ConfirmDiffFunc ¶ added in v1.0.13
ConfirmDiffFunc is a caller-provided function which presents a list of bucket changes.
type Links ¶ added in v1.0.13
type Links struct { // URL is the thread URL, which maps to a ThreadDB collection instance. URL string `json:"url"` // WWW is the URL at which the bucket will be rendered as a website (requires remote DNS configuration). WWW string `json:"www"` // IPNS is the bucket IPNS address. IPNS string `json:"ipns"` }
Links wraps remote link info for a bucket.
type MergeStrategy ¶ added in v1.0.13
type MergeStrategy string
MergeStrategy describes the type of path merge strategy.
type NewOption ¶ added in v1.0.13
type NewOption func(*newOptions)
NewOption is used when creating a new bucket.
func WithCid ¶ added in v1.0.13
WithCid indicates that an inited bucket should be boostraped with a particular UnixFS DAG.
func WithExistingPathEvents ¶ added in v1.0.13
WithExistingPathEvents allows the caller to receive path events when pulling files from an existing bucket on initialization.
func WithPrivate ¶ added in v1.0.13
WithPrivate specifies that an encryption key will be used for the bucket.
type PathEvent ¶ added in v1.0.13
type PathEvent struct { // Path relative to the bucket's cwd. Path string // Path cid if known. Cid cid.Cid // Type of event. Type PathEventType // Path total size. Size int64 // Progress of the event if known (useful for upload/download progress). Progress int64 }
PathEvent describes a path event that occurred. These events can be used to display live info during path uploads/downloads.
type PathEventType ¶ added in v1.0.13
type PathEventType int
PathEventType is the type of path event.
const ( // PathStart indicates a path has begun uploading/downloading. PathStart PathEventType = iota // PathComplete indicates a path has completed uploading/downloading. PathComplete // FileStart indicates a file under path has begun uploading/downloading. FileStart // FileProgress indicates a file has made some progress uploading/downloading. FileProgress // File complete indicates a file has completed uploading/downloading. FileComplete // FileRemoved indicates a file has been removed. FileRemoved )
type PathOption ¶ added in v1.0.13
type PathOption func(*pathOptions)
PathOption is used when pushing or pulling bucket paths.
func WithConfirm ¶ added in v1.0.13
func WithConfirm(f ConfirmDiffFunc) PathOption
WithConfirm allows the caller to confirm a list of bucket changes.
func WithForce ¶ added in v1.0.13
func WithForce(b bool) PathOption
WithForce indicates that all remote files should be pulled even if they already exist.
func WithHard ¶ added in v1.0.13
func WithHard(b bool) PathOption
WithHard indicates that locally staged changes should be pruned.
func WithPathEvents ¶ added in v1.0.13
func WithPathEvents(ch chan<- PathEvent) PathOption
WithPathEvents allows the caller to receive path events when pushing or pulling files.
type Repo ¶ added in v1.0.13
type Repo struct {
// contains filtered or unexported fields
}
Repo tracks a local bucket tree structure.
func (*Repo) CidVersion ¶ added in v1.0.13
CidVersion gets the repo cid version (0 or 1).
func (*Repo) Diff ¶ added in v1.0.13
Diff returns a list of changes that are present in path compared to the bucket.
func (*Repo) GetPathMap ¶ added in v1.0.13
GetPathMap returns details about a local path.
func (*Repo) HashFile ¶ added in v1.0.13
HashFile returns the cid of the file at path. This method does not alter the bucket.
func (*Repo) MatchPath ¶ added in v1.0.13
MatchPath returns whether or not the path exists and has matching local and remote cids.
func (*Repo) RemovePath ¶ added in v1.0.13
RemovePath removes a local path map from the store.
func (*Repo) Save ¶ added in v1.0.13
Save saves the bucket as a node describing the file tree at the current path.
func (*Repo) SaveFile ¶ added in v1.0.13
SaveFile saves the bucket as a node describing a directory containing reader.
func (*Repo) SetCidVersion ¶ added in v1.0.13
SetCidVersion set the repo cid version (0 or 1). The default version is 1.
func (*Repo) SetRemotePath ¶ added in v1.0.13
SetRemotePath sets or creates a mapping from a local path to a remote cid.
type Roots ¶ added in v1.0.13
type Roots struct { Local cid.Cid `json:"local"` Remote cid.Cid `json:"remote"` }
Roots wraps local and remote root cids. If the bucket is not private (encrypted), these will be the same.
type SelectMergeFunc ¶ added in v1.0.13
type SelectMergeFunc func(description string, isDir bool) (MergeStrategy, error)
SelectMergeFunc is a caller-provided function which is used to select a merge strategy.
type WatchOption ¶ added in v1.0.13
type WatchOption func(*watchOptions)
WatchOption is used when watching a bucket for changes.
func WithOffline ¶ added in v1.0.14
func WithOffline(offline bool) WatchOption
WithOffline will keep watching for bucket changes while the local network is offline.
func WithWatchEvents ¶ added in v1.0.13
func WithWatchEvents(ch chan<- PathEvent) WatchOption
WithWatchEvents allows the caller to receive path events when watching a bucket for changes.