types

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventNameResetRegistry         = "reset-registry"
	EventNameResetRegistryComplete = "reset-registry-complete"
)
View Source
const (
	StorageBackendEtcd   = "etcd"
	StorageBackendBoltdb = "boltdb"
)
View Source
const (
	EventNameSaveFailed    = "save-failed"
	EventNameSaveSuccess   = "save-success"
	EventNameReadFailed    = "read-failed"
	EventNameReadSuccess   = "read-success"
	EventNameFileNotFound  = "file-not-found"
	EventNameDeleteFailed  = "delete-failed"
	EventNameDeleteSuccess = "delete-success"
)
View Source
const ADMIN_USER_UUID = "00000000-0000-0000-0000-000000000000"

special admin user with global privs

View Source
const ANONYMOUS_USER_UUID = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
View Source
const BackupVersion string = "v1"
View Source
const BufLength = 131072

BufLength - every 128kb of data transferred through a replication, etcd is updated with the amount of data and ETA and suchlike, this is used in status reporting in `dm` for example

View Source
const (
	DefaultBoltdbPath = "/data"
)
View Source
const DefaultEtcdClientPort = "42379"
View Source
const DefaultEtcdURL = "https://dotmesh-etcd:42379"
View Source
const EnvDotmeshBoltdbPath = "DOTMESH_BOLTDB_PATH"
View Source
const EnvEtcdEndpoint = "DOTMESH_ETCD_ENDPOINT"
View Source
const EnvStorageBackend = "DOTMESH_STORAGE"
View Source
const EtcdPrefix = "dotmesh.io/"
View Source
const MetaKeyPrefix = "io.dotmesh:meta-"
View Source
const NATSPublishCommitsSubject = "dotmesh.commits"

NATSPublishCommitsSubject - default NATS subject when sending commit notifications

View Source
const RootFS = "dmfs"

Variables

View Source
var BackupSupportedVersions = []string{"v1"}
View Source
var EndDotmeshPrelude []byte = []byte("!!END_PRELUDE!!")

NB: It's important that the following includes characters _not_ included in the base64 alphabet. https://en.wikipedia.org/wiki/Base64

Functions

func EncodeZFSFileDiff

func EncodeZFSFileDiff(files []ZFSFileDiff) (string, error)

Types

type BackupV1

type BackupV1 struct {
	Version             string                `json:"version"`
	Created             time.Time             `json:"created"`
	Users               []*User               `json:"users"`
	FilesystemMasters   []*FilesystemMaster   `json:"filesystem_masters"`
	RegistryFilesystems []*RegistryFilesystem `json:"registry_filesystems"`
	RegistryClones      []*Clone              `json:"registry_clones"`
}

type ByAddress

type ByAddress []Server

type Clone

type Clone struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	TopLevelFilesystemId string
	FilesystemId         string
	Name                 string
	Origin               Origin
}

type CloneWithName

type CloneWithName struct {
	Name  string
	Clone Clone
}

type ClonesList

type ClonesList []CloneWithName

type CommitArgs

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

type CommitNotification

type CommitNotification struct {
	FilesystemId string
	Namespace    string
	Name         string
	Branch       string
	CommitId     string
	Metadata     map[string]string

	OwnerID         string
	CollaboratorIDs []string
}

CommitNotification - is used by dotmesh server to send notifications about new commits

type DockerContainer

type DockerContainer struct {
	Name string
	Id   string
}

type DotmeshVolume

type DotmeshVolume struct {
	Id                   string
	Name                 VolumeName
	Branch               string
	Master               string
	SizeBytes            int64
	DirtyBytes           int64
	CommitCount          int64
	ServerStates         map[string]string // serverId => state
	ServerStatuses       map[string]string // serverId => status
	ForkParentId         string
	ForkParentSnapshotId string
}

type DotmeshVolumeAndContainers

type DotmeshVolumeAndContainers struct {
	Volume     DotmeshVolume
	Containers []DockerContainer
}

type Event

type Event struct {
	ID           string
	Name         string
	FilesystemID string
	Type         EventType
	Args         *EventArgs
}

func NewErrorEvent

func NewErrorEvent(name string, err error) *Event

func NewEvent

func NewEvent(name string) *Event

func (Event) Error

func (e Event) Error() error

func (Event) String

func (e Event) String() string

type EventArgs

type EventArgs map[string]interface{}

EventArgs is used to pass any dynamic structs through the event system. Please not that if you send any events, they have to be registered with encoding/gob Existing registration can be found in this file at the top

func (EventArgs) GetString

func (ea EventArgs) GetString(key string) string

func (EventArgs) String

func (ea EventArgs) String() string

type EventType

type EventType int
const (
	EventTypeRequest EventType = iota
	EventTypeResponse
	EventTypeClusterRequest
	EventTypeClusterResponse
)

type FileChange

type FileChange uint
const (
	FileChangeUnknown FileChange = iota
	FileChangeAdded
	FileChangeModified
	FileChangeRemoved
	FileChangeRenamed
)

func (FileChange) MarshalJSON

func (r FileChange) MarshalJSON() ([]byte, error)

MarshalJSON is generated so FileChange satisfies json.Marshaler.

func (FileChange) String

func (c FileChange) String() string

func (*FileChange) UnmarshalJSON

func (r *FileChange) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so FileChange satisfies json.Unmarshaler.

type Filesystem

type Filesystem struct {
	Id        string
	Exists    bool
	Mounted   bool
	Snapshots []*Snapshot
	// support filesystem which is clone of another filesystem, for branching
	// purposes, with origin e.g. "<fs-uuid-of-actual-origin-snapshot>@<snap-id>"
	Origin Origin
}

type FilesystemContainers

type FilesystemContainers struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	FilesystemID string                      `json:"filesystem_id"`
	NodeID       string                      `json:"node_id"`
	Containers   []container.DockerContainer `json:"containers"`
}

type FilesystemDeletionAudit

type FilesystemDeletionAudit struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	FilesystemID string    `json:"filesystem_id"`
	Server       string    `json:"server"`
	Username     string    `json:"username"`
	DeletedAt    time.Time `json:"deleted_at"`

	// These fields are mandatory
	Name                 VolumeName `json:"name"`
	TopLevelFilesystemId string     `json:"top_level_filesystem_id"`
	Clone                string     `json:"clone"`
}

type FilesystemDirty

type FilesystemDirty struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	FilesystemID string `json:"filesystem_id"`
	NodeID       string `json:"node_id"`
	DirtyBytes   int64  `json:"dirty_bytes"`
	SizeBytes    int64  `json:"size_bytes"`
}

type FilesystemLive

type FilesystemLive struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	FilesystemID string `json:"filesystem_id"`
	NodeID       string `json:"node_id"`
}

type FilesystemMaster

type FilesystemMaster struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	FilesystemID string `json:"filesystem_id"`
	NodeID       string `json:"node_id"`
}

type ForkRequest

type ForkRequest struct {
	MasterBranchId string
	ForkNamespace  string
	ForkName       string
}

type InputFile

type InputFile struct {
	Filename string
	// If this is nil, this will delete the file:
	Contents io.Reader
	User     string
	Response chan *Event
	Extract  bool
}

InputFile is used to write files to the disk on the local node, or to delete files if Contents are nil.

type ItemData

type ItemData struct {
	Name      string
	Size      int64
	VersionId string
	Err       error
}

used by pkg/fsm/s3.go to communicate completed file info

type KVAction

type KVAction int

KVAction specifies the action on a KV pair. This is useful to make decisions from the results of a Watch.

const (
	// KVSet signifies the KV was modified.
	KVSet KVAction = 1 << iota
	// KVCreate set if the KV pair was created.
	KVCreate
	// KVGet set when the key is fetched from the KV store
	KVGet
	// KVDelete set when the key is deleted from the KV store
	KVDelete
	// KVExpire set when the key expires
	KVExpire
	// KVUnknown operation on KV pair
	KVUnknown
)

func (KVAction) String

func (kv KVAction) String() string

type KVMeta

type KVMeta struct {
	// KVDBIndex A Monotonically index updated at each modification operation.
	KVDBIndex uint64
	// CreatedIndex for this kv pair
	CreatedIndex uint64
	// ModifiedIndex for this kv pair. It's getting increased
	// for all KV pairs when any modifications are made
	ModifiedIndex uint64

	// Action the last action on this KVPair.
	Action KVAction
}

type LastModified

type LastModified struct {
	Time time.Time
}

type ListFileItem

type ListFileItem struct {
	Key          string    `json:"key"` // the full path to the item (including folders)
	LastModified time.Time `json:"last_modified"`
	Size         int64     `json:"size"`
	Directory    bool      `json:"directory"` // is this item a directory or a file
}

a single item in the results from s3.GetKeysForDirLimit

type ListFileRequest

type ListFileRequest struct {
	Base               string // the root of the dot we are listing
	Prefix             string // the sub path we are listing
	MaxKeys            int64  // limit the number of files we get in the response
	Page               int64  // what page we are viewing - we start listing at Page * Limit
	Recursive          bool   // do we want to recurse into folders or just look at the given path
	IncludeDirectories bool   // do we want directories to be included in the result or just files?
}

request when calling s3.GetKeysForDirLimit

type ListFileResponse

type ListFileResponse struct {
	Items      []ListFileItem
	TotalCount int64
}

type MountCommitRequest

type MountCommitRequest struct {
	FilesystemId string
	CommitId     string
}

type Origin

type Origin struct {
	FilesystemId string
	SnapshotId   string
}

type OutputFile

type OutputFile struct {
	Filename          string
	SnapshotMountPath string
	Contents          io.Writer
	User              string
	Response          chan *Event
}

OutputFile is used to read files from the disk on the local node this is always done against a specific, already mounted snapshotId the mount path of the snapshot is passed through via SnapshotMountPath. Can also be used for stating a file, in which case Contents will be nil.

func (OutputFile) GetFilePath

func (o OutputFile) GetFilePath() (string, error)

Return the path of the file on the host in a secure way.

type PathToTopLevelFilesystem

type PathToTopLevelFilesystem struct {
	TopLevelFilesystemId   string
	TopLevelFilesystemName VolumeName
	Clones                 ClonesList
}

type PermissionDenied

type PermissionDenied struct {
}

func (PermissionDenied) Error

func (e PermissionDenied) Error() string

type Prelude

type Prelude struct {
	SnapshotProperties []*Snapshot
}

func (Prelude) String

func (p Prelude) String() string

type ProcureArgs

type ProcureArgs struct {
	Namespace string
	Name      string
	Subdot    string
}

type Query

type Query struct {
	Ref      string // ID, name, email
	Selector string // K8s style selector to filter based on user metadata fields
}

type RPCDiffRequest

type RPCDiffRequest struct {
	FilesystemID string
}

type RPCDiffResponse

type RPCDiffResponse struct {
	Files []ZFSFileDiff
}

type RPCForkRequest

type RPCForkRequest struct {
	MasterBranchID string
	ForkNamespace  string
	ForkName       string
}

type RegistryFilesystem

type RegistryFilesystem struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	Id                   string
	OwnerId              string // also know as 'namespace'
	Name                 string // volume name
	ForkParentId         string `json:",omitempty"`
	ForkParentSnapshotId string `json:",omitempty"`
	CollaboratorIds      []string
}

the type as stored in the json in etcd (intermediate representation wrt DotmeshVolume)

type RollbackRequest

type RollbackRequest struct {
	Namespace  string
	Name       string
	Branch     string
	SnapshotId string
}

type S3TransferRequest

type S3TransferRequest struct {
	KeyID           string
	SecretKey       string
	Prefixes        []string
	Endpoint        string
	Direction       string
	LocalNamespace  string
	LocalName       string
	LocalBranchName string
	RemoteName      string
}

func (S3TransferRequest) String

func (transferRequest S3TransferRequest) String() string

type SafeConfig

type SafeConfig struct {
}

type SafeUser

type SafeUser struct {
	Id        string
	Name      string
	Email     string
	EmailHash string
	Metadata  map[string]string
}

type Server

type Server struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	Id        string
	Addresses []string
}

type ServerSnapshots

type ServerSnapshots struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	ID           string      `json:"id"` // NodeID
	FilesystemID string      `json:"filesystem_id"`
	Snapshots    []*Snapshot `json:"snapshots"`
}

type ServerState

type ServerState struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	ID           string            `json:"id"` // NodeID
	FilesystemID string            `json:"filesystem_id"`
	State        map[string]string `json:"state"`
}

type Snapshot

type Snapshot struct {
	// exported for json serialization
	Id       string
	Metadata map[string]string
}

func (*Snapshot) DeepCopy

func (s *Snapshot) DeepCopy() *Snapshot

type StashRequest

type StashRequest struct {
	FilesystemId string
	SnapshotId   string
}

type SubscribeQuery

type SubscribeQuery struct {
	RequestID    string
	FilesystemID string
	Type         EventType
}

func (*SubscribeQuery) GetFilesystemID

func (q *SubscribeQuery) GetFilesystemID() string

func (*SubscribeQuery) GetRequestID

func (q *SubscribeQuery) GetRequestID() string

type TopLevelFilesystem

type TopLevelFilesystem struct {
	MasterBranch         DotmeshVolume
	OtherBranches        []DotmeshVolume
	Owner                SafeUser
	Collaborators        []SafeUser
	ForkParentId         string
	ForkParentSnapshotId string
}

type TransferPollResult

type TransferPollResult struct {
	// Meta is populated by the KV store implementer
	Meta *KVMeta `json:"-"`

	TransferRequestId string
	Peer              string // hostname
	User              string
	ApiKey            string
	Direction         string // "push" or "pull"

	// Hold onto this information, it might become useful for e.g. recursive
	// receives of clone filesystems.
	LocalNamespace   string
	LocalName        string
	LocalBranchName  string
	RemoteNamespace  string
	RemoteName       string
	RemoteBranchName string

	// Same across both clusters
	FilesystemId string

	// TODO add clusterIds? probably comes from etcd. in fact, could be the
	// discovery id (although that is only for bootstrap... hmmm).
	InitiatorNodeId string
	PeerNodeId      string

	// XXX a Transfer that spans multiple filesystem ids won't have a unique
	// starting/target snapshot, so this is in the wrong place right now.
	// although maybe it makes sense to talk about a target *final* snapshot,
	// with interim snapshots being an implementation detail.
	StartingCommit string
	TargetCommit   string

	Index              int    // i.e. transfer 1/4 (Index=1)
	Total              int    //                   (Total=4)
	Status             string // one of "starting", "running", "finished", "error"
	NanosecondsElapsed int64
	Size               int64 // size of current segment in bytes
	Sent               int64 // number of bytes of current segment sent so far
	Message            string
}

func (TransferPollResult) String

func (t TransferPollResult) String() string

type TransferRequest

type TransferRequest struct {
	Peer             string // hostname
	User             string
	Port             int
	ApiKey           string //protected value in toString
	Direction        string // "push" or "pull"
	LocalNamespace   string
	LocalName        string
	LocalBranchName  string
	RemoteNamespace  string
	RemoteName       string
	RemoteBranchName string
	// TODO could also include SourceSnapshot here
	TargetCommit    string // optional, "" means "latest"
	StashDivergence bool
}

func (TransferRequest) String

func (transferRequest TransferRequest) String() string

type TransferUpdate

type TransferUpdate struct {
	Kind TransferUpdateKind

	Changes TransferPollResult

	GetResult chan TransferPollResult
}

type TransferUpdateKind

type TransferUpdateKind int
const (
	TransferStart TransferUpdateKind = iota
	TransferGotIds
	TransferCalculatedSize
	TransferTotalAndSize
	TransferProgress
	TransferS3Progress
	TransferIncrementIndex
	TransferStartS3Bucket
	TransferNextS3File
	TransferFinishedS3File
	TransferS3Stuck
	TransferS3Failed
	TransferSent
	TransferFinished
	TransferStatus

	TransferGetCurrentPollResult
)

type User

type User struct {
	Id       string
	Name     string
	Email    string
	Salt     []byte
	Password []byte
	ApiKey   string
	Metadata map[string]string
}

func (User) SafeUser

func (u User) SafeUser() SafeUser

SafeUser - returns safe user by hashing email, removing password and APIKey fields

func (User) String

func (user User) String() string

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"`
}

type VolumeName

type VolumeName struct {
	Namespace string
	Name      string
}

func (VolumeName) String

func (v VolumeName) String() string

func (VolumeName) StringWithoutAdmin

func (v VolumeName) StringWithoutAdmin() string

type VolumesAndBranches

type VolumesAndBranches struct {
	Dots    []TopLevelFilesystem
	Servers []Server
}

type ZFSFileDiff

type ZFSFileDiff struct {
	Change   FileChange `json:"change"`
	Filename string     `json:"filename"`
}

func DecodeZFSFileDiff

func DecodeZFSFileDiff(data string) ([]ZFSFileDiff, error)

Jump to

Keyboard shortcuts

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