client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Path string
	Mask []string
	Head *Commit
	Next *Commit

	MovedTo         string
	WasPreviouslyAt string

	IsPinned   bool
	IsExplicit bool
}

Change describes a change of a node between two commits.

type Client

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

Client is a helper API that implements the rpc interface to brig and makes all data easily accessible from Go. Note that this layer is needed, so we could later support other languages.

func Dial

func Dial(ctx context.Context, port int) (*Client, error)

Dial will attempt to connect to brigd under the specified port

func (*Client) Become

func (ctl *Client) Become(who string) error

Become changes the current users to one of the users in the remote list.

func (*Client) Cat

func (cl *Client) Cat(path string) (io.ReadCloser, error)

Cat outputs the contents of the node at `path`. The node must be a file.

func (*Client) ClearExplicitPins

func (cl *Client) ClearExplicitPins(prefix, from, to string) (int, error)

ClearExplicitPins clears all explicit pins in the commit range `from` until `to`. The files have to start with `prefix`.

func (*Client) Close

func (cl *Client) Close() error

Close will close the connection from the client side

func (*Client) CommitInfo added in v0.2.0

func (ctl *Client) CommitInfo(rev string) (bool, *Commit, error)

CommitInfo is like a stat(2) for commits.

func (*Client) ConfigAll

func (ctl *Client) ConfigAll() ([]ConfigEntry, error)

ConfigAll returns all config entries with details.

func (*Client) ConfigDoc

func (ctl *Client) ConfigDoc(key string) (ConfigEntry, error)

ConfigDoc gets the documentation for a single config entry at `key`.

func (*Client) ConfigGet

func (ctl *Client) ConfigGet(key string) (string, error)

ConfigGet returns the value at `key`.

func (*Client) ConfigSet

func (ctl *Client) ConfigSet(key, value string) error

ConfigSet sets the key at `key` to `value`

func (*Client) Copy

func (cl *Client) Copy(srcPath, dstPath string) error

Copy copies the node at `srcPath` to `dstPath`.

func (*Client) Exists

func (cl *Client) Exists(path string) (bool, error)

Exists tells us if a file at `path` exists.

func (*Client) Fetch

func (ctl *Client) Fetch(remote string) error

Fetch updates our internal copy of the data of `remote`.

func (*Client) FsTabList added in v0.2.0

func (ctl *Client) FsTabList() ([]FsTabEntry, error)

FsTabList lists all fs tab entries.

func (*Client) FstabAdd added in v0.2.0

func (ctl *Client) FstabAdd(mountName, mountPath string, opts MountOptions) error

FstabAdd adds a new mount named `mountName` at `mountPath` with `opts`. The mount will only be created after calling FstabApply.

func (*Client) FstabApply added in v0.2.0

func (ctl *Client) FstabApply() error

FstabApply will apply any changes made the filesystem tab. This won't do anything if nothing was changed in the mean time.

func (*Client) FstabRemove added in v0.2.0

func (ctl *Client) FstabRemove(mountName string) error

FstabRemove removes a named mount called `mountName`.

func (*Client) FstabUnmountAll added in v0.2.0

func (ctl *Client) FstabUnmountAll() error

FstabUnmountAll will unmount all currently mounted fstab entries.

func (*Client) GarbageCollect

func (ctl *Client) GarbageCollect(aggressive bool) ([]*GarbageItem, error)

GarbageCollect calls the backend (IPSF) garbage collector and returns the collected items.

func (*Client) History

func (ctl *Client) History(path string) ([]*Change, error)

History returns a detailed set of changes that happened to the node at `path`.

func (*Client) Init

func (ctl *Client) Init(path, owner, password, backend string) error

Init tells the daemon to start creating the repository.

func (*Client) List

func (cl *Client) List(root string, maxDepth int) ([]StatInfo, error)

List will list all nodes beneath and including `root` up to `maxDepth`.

func (*Client) ListExplicitPins

func (cl *Client) ListExplicitPins(prefix, from, to string) ([]PathAtCommit, error)

ListExplicitPins lists all paths at all commits that have an explicit pin in the commit range `from` until `to`. The files have to start with `prefix`.

func (*Client) LocalAddr

func (cl *Client) LocalAddr() net.Addr

LocalAddr return info about the local addr

func (*Client) Log

func (ctl *Client) Log() ([]Commit, error)

Log lists all commits, starting with the newest one.

func (*Client) MakeCommit

func (ctl *Client) MakeCommit(msg string) error

MakeCommit creates a new commit from the current staging area. The commit will have the message `msg`.

func (*Client) MakeDiff

func (ctl *Client) MakeDiff(local, remote, localRev, remoteRev string, needFetch bool) (*Diff, error)

MakeDiff creates a diff between the commits at `remoteRev` and `localRev`. If `needFetch` is true, the data is first updated from the remote.

func (*Client) Mkdir

func (cl *Client) Mkdir(path string, createParents bool) error

Mkdir creates a new empty directory at `path`, possibly creating intermediate directories if `createParents` is set.

func (*Client) Mount

func (ctl *Client) Mount(mountPath string, opts MountOptions) error

Mount creates a new mount at `mountPath` with `opts`.

func (*Client) Move

func (cl *Client) Move(srcPath, dstPath string) error

Move moves the node at `srcPath` to `dstPath`.

func (*Client) NetConnect added in v0.2.0

func (cl *Client) NetConnect() error

NetConnect connects to the ipfs network.

func (*Client) NetDisconnect added in v0.2.0

func (cl *Client) NetDisconnect() error

NetDisconnect disconnects from the ipfs network.

func (*Client) NetLocate

func (cl *Client) NetLocate(who, mask string, timeoutSec float64) (chan *LocateResult, error)

NetLocate tries to find other remotes by searching of `who` described by `mask`. It will at max. take `timeoutSec` to search. This operation might take some time. The return channel will yield a LocateResult once a new result is available.

func (*Client) OnlinePeers

func (cl *Client) OnlinePeers() ([]PeerStatus, error)

OnlinePeers is like RemoteList but also includes IsOnline and Authenticated status.

func (*Client) Pin

func (cl *Client) Pin(path string) error

Pin sets an explicit pin on the node at `path`.

func (*Client) Ping

func (ctl *Client) Ping() error

Ping pings the daemon to see if it is responding.

func (*Client) Quit

func (ctl *Client) Quit() error

Quit sends a quit signal to brigd.

func (*Client) RemoteAdd

func (cl *Client) RemoteAdd(remote Remote) error

RemoteAdd adds a new remote described in `remote`. We thus authenticate this remote.

func (*Client) RemoteAddr

func (cl *Client) RemoteAddr() net.Addr

RemoteAddr return info about the remote addr

func (*Client) RemoteClear

func (cl *Client) RemoteClear() error

RemoteClear clears all of the remote list.

func (*Client) RemoteLs

func (cl *Client) RemoteLs() ([]Remote, error)

RemoteLs lists all remotes in the remote list.

func (*Client) RemotePing

func (cl *Client) RemotePing(who string) (float64, error)

RemotePing pings a remote by the name `who`.

func (*Client) RemoteRm

func (cl *Client) RemoteRm(name string) error

RemoteRm removes a remote by `name` from the remote list.

func (*Client) RemoteSave

func (cl *Client) RemoteSave(remotes []Remote) error

RemoteSave swaps the contents of the remote lists with the contents of `remotes`.

func (*Client) RemoteUpdate added in v0.2.0

func (cl *Client) RemoteUpdate(remote Remote) error

RemoteUpdate Updates the contents of `remote`.

func (*Client) Remove

func (cl *Client) Remove(path string) error

Remove removes the node at `path`. Directories are removed recursively.

func (*Client) Reset

func (ctl *Client) Reset(path, rev string, force bool) error

Reset restores the content of `path` to the state at `rev`. If `force` is true, it will overwrite the staging area if it needs to.

func (*Client) SetExplicitPins

func (cl *Client) SetExplicitPins(prefix, from, to string) (int, error)

SetExplicitPins creates explicit pins for all files starting with `prefix` in the commit range `from` until `to`.

func (*Client) Stage

func (cl *Client) Stage(localPath, repoPath string) error

Stage will add a new node at `repoPath` with the contents of `localPath`.

func (*Client) StageFromReader

func (cl *Client) StageFromReader(repoPath string, r io.Reader) error

StageFromReader will create a new node at `repoPath` from the contents of `r`.

func (*Client) Stat

func (cl *Client) Stat(path string) (*StatInfo, error)

Stat gives detailed information about the node at `path`.

func (*Client) Sync

func (ctl *Client) Sync(remote string, needFetch bool) (*Diff, error)

Sync triggers a sync with the data from `remote`. If `needFetch` is true, the data is first updated from the remote.

func (*Client) Tag

func (ctl *Client) Tag(rev, name string) error

Tag tags a commit (`rev`) with a certain `name`.

func (*Client) Tar added in v0.2.0

func (cl *Client) Tar(path string) (io.ReadCloser, error)

Tar outputs a tar archive with the contents of `path`. `path` can be either a file or directory.

func (*Client) Touch

func (cl *Client) Touch(path string) error

Touch creates a new empty file at `path`.

func (*Client) Unmount

func (ctl *Client) Unmount(mountPath string) error

Unmount kills a previously created mount at `mountPath`.

func (*Client) Unpin

func (cl *Client) Unpin(path string) error

Unpin removes an explicit pin at the node at `path`.

func (*Client) Untag

func (ctl *Client) Untag(name string) error

Untag removes the `name` tag.

func (*Client) Version

func (ctl *Client) Version() (*VersionInfo, error)

Version returns version information about the server.

func (*Client) WaitForInit added in v0.2.0

func (ctl *Client) WaitForInit() error

WaitForInit waits until the server is fully functional.

func (*Client) Whoami

func (cl *Client) Whoami() (*Whoami, error)

Whoami describes our own identity.

type Commit

type Commit struct {
	Hash h.Hash
	Msg  string
	Tags []string
	Date time.Time
}

Commit describes a single commit in more detail.

type ConfigEntry

type ConfigEntry struct {
	Key          string
	Val          string
	Doc          string
	Default      string
	NeedsRestart bool
}

ConfigEntry is a single entry of the config.

type Diff

type Diff struct {
	Added   []StatInfo
	Removed []StatInfo
	Ignored []StatInfo
	Missing []StatInfo

	Moved    []DiffPair
	Merged   []DiffPair
	Conflict []DiffPair
}

Diff gives a detailed overview over the changes between two commits.

func (*Diff) IsEmpty added in v0.2.0

func (df *Diff) IsEmpty() bool

IsEmpty reports if a diff is completely empty (i.e. nothing changed)

type DiffPair

type DiffPair struct {
	Src StatInfo
	Dst StatInfo
}

DiffPair is a pair of nodes that were changed in some way.

type FsTabEntry added in v0.2.0

type FsTabEntry struct {
	Name     string
	Path     string
	Root     string
	Active   bool
	ReadOnly bool
}

FsTabEntry describes a single entry in the filesystem tab

type GarbageItem

type GarbageItem struct {
	Path    string
	Owner   string
	Content h.Hash
}

GarbageItem is a single path that was reaped by the garbage collector.

type LocateResult

type LocateResult struct {
	Name        string
	Addr        string
	Mask        []string
	Fingerprint string
}

LocateResult is a result returned by Locate()

type MountOptions added in v0.2.0

type MountOptions struct {
	ReadOnly bool
	RootPath string
}

MountOptions holds the possible option for a single mount.

type PathAtCommit added in v0.2.0

type PathAtCommit struct {
	Path   string
	Commit string
}

PathAtCommit describes the path to a file at the state of a certain commit.

type PeerStatus

type PeerStatus struct {
	Name          string
	Fingerprint   string
	LastSeen      time.Time
	Roundtrip     time.Duration
	Err           error
	Authenticated bool
}

PeerStatus is a entry in the remote online list. Fingerprint is not necessarily filled.

type Remote

type Remote struct {
	Name        string   `yaml:"Name"`
	Fingerprint string   `yaml:"Fingerprint"`
	Folders     []string `yaml:"Folders,flow"`
}

Remote describes a single remote in the remote list.

type RemoteFolder

type RemoteFolder struct {
	Folder string
}

RemoteFolder describes a folder entry in the remote list. Is is currently only a single folder.

type StatInfo

type StatInfo struct {
	Path        string
	User        string
	Size        uint64
	Inode       uint64
	IsDir       bool
	Depth       int
	ModTime     time.Time
	IsPinned    bool
	IsExplicit  bool
	TreeHash    h.Hash
	ContentHash h.Hash
	BackendHash h.Hash
}

StatInfo gives information about a file or directory similar to the normal stat(2) call on POSIX.

type VersionInfo

type VersionInfo struct {
	ServerSemVer  string
	ServerRev     string
	BackendSemVer string
	BackendRev    string
}

VersionInfo describes the version of the server.

type Whoami

type Whoami struct {
	CurrentUser string
	Owner       string
	Fingerprint string
	IsOnline    bool
}

Whoami describes the current user state

Jump to

Keyboard shortcuts

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