client

package
v0.0.0-...-6bdf688 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBranch string = "master"
View Source
const LIVENESS_PORT = "32608"
View Source
const RPCTimeout time.Duration = 20 * time.Second
View Source
const SERVER_PORT = "32607"
View Source
const SERVER_PORT_OLD = "6969"

Variables

This section is empty.

Functions

func CheckName

func CheckName(name string) bool

func DeduceUrl

func DeduceUrl(ctx context.Context, hostnames []string, mode, user, apiKey string) (string, error)

func ParseNamespacedVolume

func ParseNamespacedVolume(name string) (string, string, error)

func ParseNamespacedVolumeWithDefault

func ParseNamespacedVolumeWithDefault(name, defaultNamespace string) (string, string, error)

Types

type CommitArgs

type CommitArgs struct {
	Namespace string
	Name      string
	Branch    string
	Message   string
	Metadata  map[string]string
}

type Configuration

type Configuration struct {
	CurrentRemote string
	DMRemotes     map[string]*DMRemote `json:"Remotes"`
	S3Remotes     map[string]*S3Remote
	// contains filtered or unexported fields
}

func NewConfiguration

func NewConfiguration(configPath string) (*Configuration, error)

func (*Configuration) AddRemote

func (c *Configuration) AddRemote(remote, user, hostname string, port int, apiKey string) error

func (*Configuration) AddS3Remote

func (c *Configuration) AddS3Remote(remote, keyID, secretKey, endpoint string) error

func (*Configuration) ClusterFromCurrentRemote

func (c *Configuration) ClusterFromCurrentRemote(verbose bool) (*JsonRpcClient, error)

func (*Configuration) ClusterFromRemote

func (c *Configuration) ClusterFromRemote(remote string, verbose bool) (*JsonRpcClient, error)

func (*Configuration) CredsForRemote

func (c *Configuration) CredsForRemote(remote string) (*DMRemote, error)

func (*Configuration) CurrentBranch

func (c *Configuration) CurrentBranch() (string, error)

func (*Configuration) CurrentBranchFor

func (c *Configuration) CurrentBranchFor(volume string) (string, error)

func (*Configuration) CurrentVolume

func (c *Configuration) CurrentVolume() (string, error)

func (*Configuration) DefaultRemoteVolumeFor

func (c *Configuration) DefaultRemoteVolumeFor(peer, namespace, volume string) (string, string, bool)

func (*Configuration) DeleteStateForVolume

func (c *Configuration) DeleteStateForVolume(volume string) error

func (*Configuration) GetCurrentRemote

func (c *Configuration) GetCurrentRemote() string

func (*Configuration) GetRemote

func (c *Configuration) GetRemote(name string) (Remote, error)

func (*Configuration) GetRemotes

func (c *Configuration) GetRemotes() map[string]*DMRemote

todo this should probably return interfaces and just make a map of all of them

func (*Configuration) GetS3Remotes

func (c *Configuration) GetS3Remotes() map[string]*S3Remote

func (*Configuration) Load

func (c *Configuration) Load() error

func (*Configuration) RemoteExists

func (c *Configuration) RemoteExists(remote string) bool

func (*Configuration) RemoveRemote

func (c *Configuration) RemoveRemote(remote string) error

func (*Configuration) Save

func (c *Configuration) Save() error

func (*Configuration) SetCurrentBranch

func (c *Configuration) SetCurrentBranch(branch string) error

func (*Configuration) SetCurrentBranchForVolume

func (c *Configuration) SetCurrentBranchForVolume(volume, branch string) error

func (*Configuration) SetCurrentRemote

func (c *Configuration) SetCurrentRemote(remote string) error

func (*Configuration) SetCurrentVolume

func (c *Configuration) SetCurrentVolume(volume string) error

func (*Configuration) SetDefaultRemoteVolumeFor

func (c *Configuration) SetDefaultRemoteVolumeFor(peer, namespace, volume, remoteNamespace, remoteVolume string) error

func (*Configuration) SetPrefixesFor

func (c *Configuration) SetPrefixesFor(peer, namespace, volume string, prefixes []string) error

type Container

type Container struct {
	Id   string
	Name string
}

type DMRemote

type DMRemote struct {
	User                 string
	Hostname             string
	Port                 int `json:",omitempty"`
	ApiKey               string
	CurrentVolume        string
	CurrentBranches      map[string]string
	DefaultRemoteVolumes map[string]map[string]types.VolumeName
}

func (DMRemote) DefaultNamespace

func (remote DMRemote) DefaultNamespace() string

func (*DMRemote) DefaultRemoteVolumeFor

func (remote *DMRemote) DefaultRemoteVolumeFor(localNamespace, localVolume string) (string, string, bool)

func (*DMRemote) SetDefaultRemoteVolumeFor

func (remote *DMRemote) SetDefaultRemoteVolumeFor(localNamespace, localVolume, remoteNamespace, remoteVolume string)

TODO is there a less hacky way of doing this? hate the duplication, but otherwise you need to cast all over the place

func (DMRemote) String

func (remote DMRemote) String() string

type Dotmesh

type Dotmesh interface {
	CallRemote(ctx context.Context, method string, args interface{}, response interface{}) error
	ListCommits(activeVolumeName, activeBranch string) ([]types.Snapshot, error)
	CommitsById(dotID string) ([]types.Snapshot, error)
	Diff(namespace, name string) ([]types.ZFSFileDiff, error)
	DiffFromCommit(namespace, name, commitID string) ([]types.ZFSFileDiff, error)
	LastModified(namespace, name string) (*types.LastModified, error)
	GetFsId(namespace, name, branch string) (string, error)
	Get(fsId string) (types.DotmeshVolume, error)
	Procure(data types.ProcureArgs) (string, error)
	CommitWithStruct(args types.CommitArgs) (string, error)
	NewVolumeFromStruct(name types.VolumeName) (bool, error)
	GetMasterBranchId(volume types.VolumeName) (string, error)
	DeleteVolumeFromStruct(name types.VolumeName) (bool, error)
	MountCommit(request types.MountCommitRequest) (string, error)
	Rollback(request types.RollbackRequest) (bool, error)
	Fork(request types.ForkRequest) (string, error)
	List() (map[string]map[string]types.DotmeshVolume, error)
	GetVersion() (VersionInfo, error)
	GetTransfer(transferId string) (TransferPollResult, error)
	Transfer(request types.TransferRequest) (string, error)
	S3Transfer(request types.S3TransferRequest) (string, error)
}

type DotmeshAPI

type DotmeshAPI struct {
	Configuration *Configuration

	Client *JsonRpcClient
	PB     *pb.ProgressBar
	// contains filtered or unexported fields
}

func NewDotmeshAPI

func NewDotmeshAPI(configPath string, verbose bool) (*DotmeshAPI, error)

func NewDotmeshAPIFromClient

func NewDotmeshAPIFromClient(client *JsonRpcClient, verbose bool) *DotmeshAPI

func (*DotmeshAPI) AllBranches

func (dm *DotmeshAPI) AllBranches(volumeName string) ([]string, error)

func (*DotmeshAPI) AllVolumes

func (dm *DotmeshAPI) AllVolumes() ([]types.DotmeshVolume, error)

func (*DotmeshAPI) AllVolumesWithContainers

func (dm *DotmeshAPI) AllVolumesWithContainers() ([]DotmeshVolumeAndContainers, error)

func (*DotmeshAPI) BackupEtcd

func (dm *DotmeshAPI) BackupEtcd() (string, error)

func (*DotmeshAPI) BranchExists

func (dm *DotmeshAPI) BranchExists(volumeName, branchName string) (bool, error)

func (*DotmeshAPI) BranchInfo

func (dm *DotmeshAPI) BranchInfo(namespace, name, branch string) (types.DotmeshVolume, error)

func (*DotmeshAPI) Branches

func (dm *DotmeshAPI) Branches(volumeName string) ([]string, error)

func (*DotmeshAPI) CallRemote

func (dm *DotmeshAPI) CallRemote(
	ctx context.Context, method string, args interface{}, response interface{},
) error

proxy thru

func (*DotmeshAPI) CheckoutBranch

func (dm *DotmeshAPI) CheckoutBranch(volumeName, from, to string, create bool) error

func (*DotmeshAPI) Commit

func (dm *DotmeshAPI) Commit(activeVolumeName, activeBranch, commitMessage string, metadata map[string]string) (string, error)

func (*DotmeshAPI) CommitWithStruct

func (dm *DotmeshAPI) CommitWithStruct(args types.CommitArgs) (string, error)

func (*DotmeshAPI) CommitsById

func (dm *DotmeshAPI) CommitsById(dotID string) ([]types.Snapshot, error)

func (*DotmeshAPI) CreateBranch

func (dm *DotmeshAPI) CreateBranch(volumeName, sourceBranch, newBranch string) error

func (*DotmeshAPI) CurrentBranch

func (dm *DotmeshAPI) CurrentBranch(volumeName string) (string, error)

func (*DotmeshAPI) CurrentVolume

func (dm *DotmeshAPI) CurrentVolume() (string, error)

func (*DotmeshAPI) DeleteVolume

func (dm *DotmeshAPI) DeleteVolume(volumeName string) error

func (*DotmeshAPI) DeleteVolumeFromStruct

func (dm *DotmeshAPI) DeleteVolumeFromStruct(name types.VolumeName) (bool, error)

func (*DotmeshAPI) Diff

func (dm *DotmeshAPI) Diff(namespace, name string) ([]types.ZFSFileDiff, error)

func (*DotmeshAPI) DiffFromCommit

func (dm *DotmeshAPI) DiffFromCommit(namespace, name, commitID string) ([]types.ZFSFileDiff, error)

func (*DotmeshAPI) ForceBranchMaster

func (dm *DotmeshAPI) ForceBranchMaster(namespace, name, branch, newMaster string) error

func (*DotmeshAPI) Fork

func (dm *DotmeshAPI) Fork(request types.ForkRequest) (string, error)

func (*DotmeshAPI) Get

func (dm *DotmeshAPI) Get(FsID string) (types.DotmeshVolume, error)

func (*DotmeshAPI) GetFsId

func (dm *DotmeshAPI) GetFsId(namespace, name, branch string) (string, error)

func (*DotmeshAPI) GetMasterBranchId

func (dm *DotmeshAPI) GetMasterBranchId(volume types.VolumeName) (string, error)

func (*DotmeshAPI) GetReplicationLatencyForBranch

func (dm *DotmeshAPI) GetReplicationLatencyForBranch(volumeName string, branch string) (map[string][]string, error)

func (*DotmeshAPI) GetTransfer

func (dm *DotmeshAPI) GetTransfer(transferId string) (TransferPollResult, error)

func (*DotmeshAPI) GetTransferWithContext

func (dm *DotmeshAPI) GetTransferWithContext(ctx context.Context, transferId string) (TransferPollResult, error)

func (*DotmeshAPI) GetVersion

func (dm *DotmeshAPI) GetVersion() (VersionInfo, error)

func (*DotmeshAPI) IsUserPriveledged

func (dm *DotmeshAPI) IsUserPriveledged() bool

func (*DotmeshAPI) LastModified

func (dm *DotmeshAPI) LastModified(namespace, name string) (*types.LastModified, error)

func (*DotmeshAPI) List

func (dm *DotmeshAPI) List() (map[string]map[string]types.DotmeshVolume, error)

func (*DotmeshAPI) ListCommits

func (dm *DotmeshAPI) ListCommits(activeVolumeName, activeBranch string) ([]types.Snapshot, error)

func (*DotmeshAPI) MountCommit

func (dm *DotmeshAPI) MountCommit(request types.MountCommitRequest) (string, error)

func (*DotmeshAPI) NewVolume

func (dm *DotmeshAPI) NewVolume(volumeName string) error

func (*DotmeshAPI) NewVolumeFromStruct

func (dm *DotmeshAPI) NewVolumeFromStruct(name types.VolumeName) (bool, error)

func (*DotmeshAPI) PingLocal

func (dm *DotmeshAPI) PingLocal() (bool, error)

func (*DotmeshAPI) PollTransfer

func (dm *DotmeshAPI) PollTransfer(transferId string, out io.Writer, callback func(result TransferPollResult, err error, started bool) bool) error

func (*DotmeshAPI) Procure

func (dm *DotmeshAPI) Procure(data types.ProcureArgs) (string, error)

func (*DotmeshAPI) ProcureVolume

func (dm *DotmeshAPI) ProcureVolume(volumeName string) (string, error)

func (*DotmeshAPI) RelatedContainers

func (dm *DotmeshAPI) RelatedContainers(volumeName types.VolumeName, branch string) ([]Container, error)

func (*DotmeshAPI) RequestTransfer

func (dm *DotmeshAPI) RequestTransfer(
	direction, peer,
	localFilesystemName, localBranchName,
	remoteFilesystemName, remoteBranchName string,
	prefixes []string,
	stashDivergence bool,
) (string, error)

attempt to get the latest commits in filesystemId (which may be a branch) from fromRemote to toRemote as a one-off.

the reason for supporting both directions is that the "current" is often behind NAT from its peer, and so it must initiate the connection.

func (*DotmeshAPI) ResetCurrentVolume

func (dm *DotmeshAPI) ResetCurrentVolume(commit string) error

func (*DotmeshAPI) RestoreEtcd

func (dm *DotmeshAPI) RestoreEtcd(dump string) error

func (*DotmeshAPI) Rollback

func (dm *DotmeshAPI) Rollback(request types.RollbackRequest) (bool, error)

func (*DotmeshAPI) S3Transfer

func (dm *DotmeshAPI) S3Transfer(request types.S3TransferRequest) (string, error)

func (*DotmeshAPI) SetVerboseFlag

func (dm *DotmeshAPI) SetVerboseFlag(verbose bool)

func (*DotmeshAPI) StrictCurrentVolume

func (dm *DotmeshAPI) StrictCurrentVolume() (string, error)

func (*DotmeshAPI) SwitchVolume

func (dm *DotmeshAPI) SwitchVolume(volumeName string) error

func (*DotmeshAPI) Transfer

func (dm *DotmeshAPI) Transfer(request types.TransferRequest) (string, error)

func (*DotmeshAPI) UpdateBar

func (dm *DotmeshAPI) UpdateBar(result TransferPollResult, err error, started bool) bool

func (*DotmeshAPI) VolumeExists

func (dm *DotmeshAPI) VolumeExists(volumeName string) (bool, error)

type DotmeshVolumeAndContainers

type DotmeshVolumeAndContainers struct {
	Volume     types.DotmeshVolume
	Containers []Container
}

type JsonRpcClient

type JsonRpcClient struct {
	User     string
	Hostname string
	ApiKey   string
	Port     int
	Verbose  bool
}

func NewJsonRpcClient

func NewJsonRpcClient(user, hostname, apiKey string, port int) *JsonRpcClient

func (*JsonRpcClient) CallRemote

func (j *JsonRpcClient) CallRemote(
	ctx context.Context, method string, args interface{}, result interface{},
) error

TODO remove duplication wrt dm/pkg/api/remotes.go call a method with args, and attempt to decode it into result

func (*JsonRpcClient) Ping

func (client *JsonRpcClient) Ping() (bool, error)

func (JsonRpcClient) String

func (jsonRpcClient JsonRpcClient) String() string

type PollTransferInternalResult

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

type Remote

type Remote interface {
	DefaultNamespace() string
	DefaultRemoteVolumeFor(string, string) (string, string, bool)
	SetDefaultRemoteVolumeFor(string, string, string, string)
}

type S3Remote

type S3Remote struct {
	KeyID                string
	SecretKey            string
	Endpoint             string
	DefaultRemoteVolumes map[string]map[string]S3VolumeName
}

func (S3Remote) DefaultNamespace

func (remote S3Remote) DefaultNamespace() string

func (*S3Remote) DefaultRemoteVolumeFor

func (remote *S3Remote) DefaultRemoteVolumeFor(localNamespace, localVolume string) (string, string, bool)

func (*S3Remote) PrefixesFor

func (remote *S3Remote) PrefixesFor(localNamespace, localVolume string) ([]string, bool)

func (*S3Remote) SetDefaultRemoteVolumeFor

func (remote *S3Remote) SetDefaultRemoteVolumeFor(localNamespace, localVolume, remoteNamespace, remoteVolume string)

func (*S3Remote) SetPrefixesFor

func (remote *S3Remote) SetPrefixesFor(localNamespace, localVolume string, prefixes []string)

type S3VolumeName

type S3VolumeName struct {
	Namespace string
	Name      string
	Prefixes  []string
}

type TransferPollResult

type TransferPollResult = types.TransferPollResult

TransferPollResult - an alias for dotmesh server type

type VersionInfo

type VersionInfo struct {
	InstalledVersion    string `json:"installed_version"`
	CurrentVersion      string `json:"current_version"`
	CurrentReleaseDate  int    `json:"current_release_date"`
	CurrentDownloadURL  string `json:"current_download_url"`
	CurrentChangelogURL string `json:"current_changelog_url"`
	ProjectWebsite      string `json:"project_website"`
	Outdated            bool   `json:"outdated"`
}

Jump to

Keyboard shortcuts

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