env

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 34 Imported by: 8

Documentation

Index

Constants

View Source
const (
	UserEmailKey = "user.email"
	UserNameKey  = "user.name"

	// should be able to have remote specific creds?
	UserCreds = "user.creds"

	DoltEditor = "core.editor"

	InitBranchName = "init.defaultbranch"

	RemotesApiHostKey     = "remotes.default_host"
	RemotesApiHostPortKey = "remotes.default_port"

	AddCredsUrlKey     = "creds.add_url"
	DoltLabInsecureKey = "doltlab.insecure"

	MetricsDisabled = "metrics.disabled"
	MetricsHost     = "metrics.host"
	MetricsPort     = "metrics.port"
	MetricsInsecure = "metrics.insecure"
)
View Source
const (
	DefaultEmail = "doltuser@dolthub.com"
	DefaultName  = "Dolt System Account"
)
View Source
const (
	DefaultInitBranch = "main"

	DefaultLoginUrl = "https://dolthub.com/settings/credentials"

	DefaultMetricsHost = "eventsapi.dolthub.com"
	DefaultMetricsPort = "443"

	DefaultRemotesApiHost = "doltremoteapi.dolthub.com"
	DefaultRemotesApiPort = "443"
)
View Source
const (
	// SqlServerGlobalsPrefix is config namespace accessible by the SQL engine (ex: sqlserver.global.key)
	SqlServerGlobalsPrefix = "sqlserver.global"
)

Variables

View Source
var DefaultFailsafeConfig = map[string]string{
	UserEmailKey: DefaultEmail,
	UserNameKey:  DefaultName,
}
View Source
var ErrBackupAlreadyExists = errors.New("backup already exists")
View Source
var ErrBackupNotFound = errors.New("backup not found")
View Source
var ErrBranchDoesNotMatchUpstream = errors.New("the upstream branch of your current branch does not match the nane if your current branch")
View Source
var ErrCannotPushRef = errors.New("cannot push ref")
View Source
var ErrCannotSetUpstreamForTag = errors.New("cannot set upstream for tag")
View Source
var ErrCantDetermineDefault = errors.New("unable to determine the default remote")
View Source
var ErrFailedToDeleteBackup = errors.New("failed to delete backup")
View Source
var ErrFailedToDeleteRemote = errors.New("failed to delete remote")
View Source
var ErrFailedToReadDb = errors.New("failed to read from the db")
View Source
var ErrFailedToReadFromDb = errors.New("failed to read from db")
View Source
var ErrFailedToWriteRepoState = errors.New("failed to write repo state")
View Source
var ErrInvalidBackupName = errors.New("backup name invalid")
View Source
var ErrInvalidBackupURL = errors.New("backup URL invalid")
View Source
var ErrInvalidCredsFile = errors.New("invalid creds file")
View Source
var ErrInvalidFetchSpec = errors.New("invalid fetch spec")
View Source
var ErrInvalidRefSpecRemote = errors.New("refspec refers to different remote")
View Source
var ErrInvalidRemoteName = errors.New("remote name invalid")
View Source
var ErrInvalidRemoteURL = errors.New("remote URL invalid")
View Source
var ErrInvalidSetUpstreamArgs = errors.New("invalid set-upstream arguments")
View Source
var ErrMarshallingSchema = errors.New("error marshalling schema")
View Source
var ErrNoRefSpecForRemote = errors.New("no refspec for remote")
View Source
var ErrNoRemote = errors.New("no remote")
View Source
var ErrNoUpstreamForBranch = errors.New("the current branch has no upstream branch")
View Source
var ErrNotACred = errors.New("not a valid credential key id or public key")
View Source
var ErrPreexistingDoltDir = errors.New(".dolt dir already exists")
View Source
var ErrRemoteAddressConflict = errors.New("address conflict with a remote")
View Source
var ErrRemoteAlreadyExists = errors.New("remote already exists")
View Source
var ErrRemoteNotFound = errors.New("remote not found")
View Source
var ErrStateUpdate = errors.New("error updating local data repo state")
View Source
var ErrUnknownBranch = errors.New("unknown branch")
View Source
var ErrUnknownRemote = errors.New("unknown remote")
View Source
var ErrUpstreamBranchAlreadySet = errors.New("upstream branch already set")
View Source
var GlobalConfigWhitelist = set.NewStrSet([]string{UserNameKey, UserEmailKey})
View Source
var LocalConfigWhitelist = set.NewStrSet([]string{UserNameKey, UserEmailKey})
View Source
var NoRemote = Remote{}

Functions

func GetAbsRemoteUrl

func GetAbsRemoteUrl(fs filesys2.Filesys, cfg config.ReadableConfig, urlArg string) (string, string, error)

func GetCurrentUserHomeDir

func GetCurrentUserHomeDir() (string, error)

GetCurrentUserHomeDir will return the current user's home directory by default. This directory is where global dolt state will be stored inside of the .dolt directory. The environment variable DOLT_ROOT_PATH can be used to provide a different directory where the root .dolt directory should be located and global state will be stored there.

func GetDefaultBranch

func GetDefaultBranch(dEnv *DoltEnv, branches []ref.DoltRef) string

GetDefaultBranch returns the default branch from among the branches given, returning the configs default config branch first, then init branch main, then the old init branch master, and finally the first lexicographical branch if none of the others are found

func GetDefaultInitBranch

func GetDefaultInitBranch(cfg config.ReadableConfig) string

func GetGCKeepers

func GetGCKeepers(ctx context.Context, env *DoltEnv) ([]hash.Hash, error)

GetGCKeepers returns the hashes of all the objects in the environment provided that should be perserved during GC. TODO: this should be unnecessary since we now store the working set in a noms dataset, remove it

func GetNameAndEmail

func GetNameAndEmail(cfg config.ReadableConfig) (string, string, error)

GetNameAndEmail returns the name and email from the supplied config

func GetRefSpecs

func GetRefSpecs(rsr RepoStateReader, remoteName string) ([]ref.RemoteRefSpec, error)

GetRefSpecs takes an optional remoteName and returns all refspecs associated with that remote. If "" is passed as the remoteName then the default remote is used.

func GetStringOrDefault

func GetStringOrDefault(cfg config.ReadableConfig, key, defStr string) string

func GetTrackingRef

func GetTrackingRef(branchRef ref.DoltRef, remote Remote) (ref.DoltRef, error)

func IsEmptyRemote

func IsEmptyRemote(r Remote) bool

func NewMemoryDoltDB

func NewMemoryDoltDB(ctx context.Context, initBranch string) (*doltdb.DoltDB, error)

func ParseRSFromArgs

func ParseRSFromArgs(remName string, args []string) ([]ref.RemoteRefSpec, error)

func WorkingSet

func WorkingSet(ctx context.Context, ddb *doltdb.DoltDB, rsr RepoStateReader) (*doltdb.WorkingSet, error)

Types

type BranchConfig

type BranchConfig struct {
	Merge  ref.MarshalableRef `json:"head"`
	Remote string             `json:"remote"`
}

type ConfigScope

type ConfigScope int

ConfigScope is an enum representing the elements that make up the ConfigHierarchy

const (
	// LocalConfig is the repository's local config portion of the ConfigHierarchy
	LocalConfig ConfigScope = iota

	// GlobalConfig is the user's global config portion of the ConfigHierarchy
	GlobalConfig
)

func (ConfigScope) String

func (ce ConfigScope) String() string

String gives the string name of an element that was used when it was added to the ConfigHierarchy, which is the same name that is used to retrieve that element of the string hierarchy.

type DbData

type DbData struct {
	Ddb *doltdb.DoltDB
	Rsw RepoStateWriter
	Rsr RepoStateReader
	Drw DocsReadWriter
}

func NewMemoryDbData

func NewMemoryDbData(ctx context.Context, cfg config.ReadableConfig) (DbData, error)

type DocsReadWriter

type DocsReadWriter interface {
	// GetDocsOnDisk returns the docs in the filesytem optionally filtered by docNames.
	GetDocsOnDisk(docNames ...string) (doltdocs.Docs, error)
	// WriteDocsToDisk updates the documents stored in the filesystem with the contents in docs.
	WriteDocsToDisk(docs doltdocs.Docs) error
}

type DoltCliConfig

type DoltCliConfig struct {
	config.ReadableConfig
	// contains filtered or unexported fields
}

DoltCliConfig is the config for the cli

func LoadDoltCliConfig

func LoadDoltCliConfig(hdp HomeDirProvider, fs filesys.ReadWriteFS) (*DoltCliConfig, error)

func (*DoltCliConfig) CreateLocalConfig

func (dcc *DoltCliConfig) CreateLocalConfig(vals map[string]string) error

CreateLocalConfig creates a new repository local config file. The current directory must have already been initialized as a data repository before a local config can be created.

func (*DoltCliConfig) GetConfig

func (dcc *DoltCliConfig) GetConfig(element ConfigScope) (config.ReadWriteConfig, bool)

GetConfig retrieves a specific element of the config hierarchy.

func (*DoltCliConfig) GetStringOrDefault

func (dcc *DoltCliConfig) GetStringOrDefault(key, defStr string) string

GetStringOrDefault retrieves a string from the config hierarchy and returns it if available. Otherwise it returns the default string value

func (*DoltCliConfig) IfEmptyUseConfig

func (dcc *DoltCliConfig) IfEmptyUseConfig(val, key string) string

IfEmptyUseConfig looks at a strings value and if it is an empty string will try to return a value from the config hierarchy. If it is missing in the config a pointer to an empty string will be returned.

func (DoltCliConfig) SetFailsafes

func (dcc DoltCliConfig) SetFailsafes(cfg map[string]string)

SetFailsafes sets the config values given as failsafes, i.e. values that will be returned as a last resort if they are not found elsewhere in the config hierarchy. The "failsafe" config can be written to in order to conform to the interface of ConfigHierarchy, but values will not persist beyond this session. Calling SetFailsafes more than once will overwrite any previous values. Should only be called after primary configuration of the config hierarchy has been completed.

func (*DoltCliConfig) WriteableConfig

func (dcc *DoltCliConfig) WriteableConfig() config.ReadWriteConfig

WriteableConfig returns a ReadWriteConfig reading from this config hierarchy. The config will read from the hierarchy and write to the local config if it's available, or the global config otherwise.

type DoltEnv

type DoltEnv struct {
	Version string

	Config     *DoltCliConfig
	CfgLoadErr error

	RepoState *RepoState
	RSLoadErr error

	Docs        doltdocs.Docs
	DocsLoadErr error

	DoltDB      *doltdb.DoltDB
	DBLoadError error

	FS filesys.Filesys
	// contains filtered or unexported fields
}

DoltEnv holds the state of the current environment used by the cli.

func Load

func Load(ctx context.Context, hdp HomeDirProvider, fs filesys.Filesys, urlStr, version string) *DoltEnv

Load loads the DoltEnv for the current directory of the cli

func (*DoltEnv) AbortMerge

func (dEnv *DoltEnv) AbortMerge(ctx context.Context) error

func (*DoltEnv) AddBackup

func (dEnv *DoltEnv) AddBackup(name string, url string, fetchSpecs []string, params map[string]string) error

func (*DoltEnv) AddRemote

func (dEnv *DoltEnv) AddRemote(name string, url string, fetchSpecs []string, params map[string]string) error

func (*DoltEnv) BulkDbEaFactory

func (dEnv *DoltEnv) BulkDbEaFactory() editor.DbEaFactory

func (*DoltEnv) ClearMerge

func (dEnv *DoltEnv) ClearMerge(ctx context.Context) error

func (*DoltEnv) CredsDir

func (dEnv *DoltEnv) CredsDir() (string, error)

func (*DoltEnv) DbData

func (dEnv *DoltEnv) DbData() DbData

func (*DoltEnv) DbEaFactory

func (dEnv *DoltEnv) DbEaFactory() editor.DbEaFactory

func (*DoltEnv) DocsReadWriter

func (dEnv *DoltEnv) DocsReadWriter() DocsReadWriter

func (*DoltEnv) FindCreds

func (dEnv *DoltEnv) FindCreds(credsDir, pubKeyOrId string) (string, error)

func (*DoltEnv) FindRef

func (dEnv *DoltEnv) FindRef(ctx context.Context, refStr string) (ref.DoltRef, error)

func (*DoltEnv) GetBackups

func (dEnv *DoltEnv) GetBackups() (map[string]Remote, error)

func (*DoltEnv) GetBranches

func (dEnv *DoltEnv) GetBranches() (map[string]BranchConfig, error)

func (*DoltEnv) GetDoltDir

func (dEnv *DoltEnv) GetDoltDir() string

GetDoltDir returns the path to the .dolt directory

func (*DoltEnv) GetGRPCDialParams

func (dEnv *DoltEnv) GetGRPCDialParams(config grpcendpoint.Config) (string, []grpc.DialOption, error)

func (*DoltEnv) GetRemotes

func (dEnv *DoltEnv) GetRemotes() (map[string]Remote, error)

func (*DoltEnv) GetTablesWithConflicts

func (dEnv *DoltEnv) GetTablesWithConflicts(ctx context.Context) ([]string, error)

func (*DoltEnv) GetUserHomeDir

func (dEnv *DoltEnv) GetUserHomeDir() (string, error)

GetUserHomeDir returns the user's home dir based on current filesys

func (*DoltEnv) HasDoltDataDir

func (dEnv *DoltEnv) HasDoltDataDir() bool

func (*DoltEnv) HasDoltDir

func (dEnv *DoltEnv) HasDoltDir() bool

HasDoltDir returns true if the .dolt directory exists and is a valid directory

func (*DoltEnv) HasDoltTempTableDir

func (dEnv *DoltEnv) HasDoltTempTableDir() bool

func (*DoltEnv) HasLocalConfig

func (dEnv *DoltEnv) HasLocalConfig() bool

HasLocalConfig returns true if a repository local config file

func (*DoltEnv) HeadRoot

func (dEnv *DoltEnv) HeadRoot(ctx context.Context) (*doltdb.RootValue, error)

func (*DoltEnv) InitDBAndRepoState

func (dEnv *DoltEnv) InitDBAndRepoState(ctx context.Context, nbf *types.NomsBinFormat, name, email, branchName string, t time.Time) error

Inits the dolt DB of this environment with an empty commit at the time given and writes default docs to disk. Writes new repo state with a main branch and current root hash.

func (*DoltEnv) InitDBWithTime

func (dEnv *DoltEnv) InitDBWithTime(ctx context.Context, nbf *types.NomsBinFormat, name, email, branchName string, t time.Time) error

Inits the dolt DB of this environment with an empty commit at the time given and writes default docs to disk. Does not update repo state.

func (*DoltEnv) InitRepo

func (dEnv *DoltEnv) InitRepo(ctx context.Context, nbf *types.NomsBinFormat, name, email, branchName string) error

InitRepo takes an empty directory and initializes it with a .dolt directory containing repo state, uncommitted license and readme, and creates a noms database with dolt structure.

func (*DoltEnv) InitRepoWithNoData

func (dEnv *DoltEnv) InitRepoWithNoData(ctx context.Context, nbf *types.NomsBinFormat) error

func (*DoltEnv) InitRepoWithTime

func (dEnv *DoltEnv) InitRepoWithTime(ctx context.Context, nbf *types.NomsBinFormat, name, email, branchName string, t time.Time) error

func (*DoltEnv) InitializeRepoState

func (dEnv *DoltEnv) InitializeRepoState(ctx context.Context, branchName string) error

InitializeRepoState writes a default repo state to disk, consisting of a main branch and current root hash value.

func (*DoltEnv) IsMergeActive

func (dEnv *DoltEnv) IsMergeActive(ctx context.Context) (bool, error)

func (*DoltEnv) NewWorkingSetMeta

func (dEnv *DoltEnv) NewWorkingSetMeta(message string) *datas.WorkingSetMeta

func (*DoltEnv) RecoveryRoots

func (dEnv *DoltEnv) RecoveryRoots(ctx context.Context) (doltdb.Roots, error)

RecoveryRoots returns the roots for this environment in the case that the currently checked out branch has been deleted or HEAD has been updated in a non-principled way to point to a branch that does not exist. This is used by `dolt checkout`, in particular, to go forward with a `dolt checkout` of an existing branch in the degraded state where the current branch was deleted.

func (*DoltEnv) RemoveBackup

func (dEnv *DoltEnv) RemoveBackup(ctx context.Context, name string) error

func (*DoltEnv) RemoveRemote

func (dEnv *DoltEnv) RemoveRemote(ctx context.Context, name string) error

func (*DoltEnv) RepoStateReader

func (dEnv *DoltEnv) RepoStateReader() RepoStateReader

func (*DoltEnv) RepoStateWriter

func (dEnv *DoltEnv) RepoStateWriter() RepoStateWriter

func (*DoltEnv) Roots

func (dEnv *DoltEnv) Roots(ctx context.Context) (doltdb.Roots, error)

Roots returns the roots for this environment

func (*DoltEnv) StagedRoot

func (dEnv *DoltEnv) StagedRoot(ctx context.Context) (*doltdb.RootValue, error)

StagedRoot returns the staged root value in the current working set

func (*DoltEnv) StartMerge

func (dEnv *DoltEnv) StartMerge(ctx context.Context, commit *doltdb.Commit) error

func (*DoltEnv) TempTableFilesDir

func (dEnv *DoltEnv) TempTableFilesDir() string

func (*DoltEnv) UpdateBranch

func (dEnv *DoltEnv) UpdateBranch(name string, new BranchConfig) error

func (*DoltEnv) UpdateRoots

func (dEnv *DoltEnv) UpdateRoots(ctx context.Context, roots doltdb.Roots) error

UpdateRoots updates the working and staged roots for this environment

func (*DoltEnv) UpdateStagedRoot

func (dEnv *DoltEnv) UpdateStagedRoot(ctx context.Context, newRoot *doltdb.RootValue) error

UpdateStagedRoot updates the staged root for the current working branch. This can fail if multiple clients attempt to update at the same time.

func (*DoltEnv) UpdateWorkingRoot

func (dEnv *DoltEnv) UpdateWorkingRoot(ctx context.Context, newRoot *doltdb.RootValue) error

UpdateWorkingRoot updates the working root for the current working branch to the root value given. This method can fail if another client updates the working root at the same time.

func (*DoltEnv) UpdateWorkingSet

func (dEnv *DoltEnv) UpdateWorkingSet(ctx context.Context, ws *doltdb.WorkingSet) error

UpdateWorkingSet updates the working set for the current working branch to the value given. This method can fail if another client updates the working set at the same time.

func (*DoltEnv) UserRPCCreds

func (dEnv *DoltEnv) UserRPCCreds() (creds.DoltCreds, bool, error)

func (*DoltEnv) Valid

func (dEnv *DoltEnv) Valid() bool

Valid returns whether this environment has been properly initialized. This is useful because although every command gets a DoltEnv, not all of them require it, and we allow invalid dolt envs to be passed around for this reason.

func (*DoltEnv) WorkingRoot

func (dEnv *DoltEnv) WorkingRoot(ctx context.Context) (*doltdb.RootValue, error)

WorkingRoot returns the working root for the current working branch

func (*DoltEnv) WorkingSet

func (dEnv *DoltEnv) WorkingSet(ctx context.Context) (*doltdb.WorkingSet, error)

type EnvNameAndPath

type EnvNameAndPath struct {
	// Name is the name of the environment and is used as the identifier when accessing a given environment
	Name string
	// Path is the path on disk to where the environment lives
	Path string
}

EnvNameAndPath is a simple tuple of the name of an environment and the path to where it is on disk

func DBNamesAndPathsFromDir

func DBNamesAndPathsFromDir(fs filesys.Filesys, path string) ([]EnvNameAndPath, error)

type HomeDirProvider

type HomeDirProvider func() (string, error)

HomeDirProvider is a function that returns the users home directory. This is where global dolt state is stored for the current user

type MemoryRepoState

type MemoryRepoState struct {
	DoltDB *doltdb.DoltDB
	Head   ref.DoltRef
}

func NewMemoryRepoState

func NewMemoryRepoState(ctx context.Context, ddb *doltdb.DoltDB, initBranch string) (MemoryRepoState, error)

func (MemoryRepoState) AddBackup

func (m MemoryRepoState) AddBackup(name string, url string, fetchSpecs []string, params map[string]string) error

func (MemoryRepoState) AddRemote

func (m MemoryRepoState) AddRemote(name string, url string, fetchSpecs []string, params map[string]string) error

func (MemoryRepoState) CWBHeadRef

func (m MemoryRepoState) CWBHeadRef() ref.DoltRef

func (MemoryRepoState) CWBHeadSpec

func (m MemoryRepoState) CWBHeadSpec() *doltdb.CommitSpec

func (MemoryRepoState) GetBackups

func (m MemoryRepoState) GetBackups() (map[string]Remote, error)

func (MemoryRepoState) GetBranches

func (m MemoryRepoState) GetBranches() (map[string]BranchConfig, error)

func (MemoryRepoState) GetDocsOnDisk

func (m MemoryRepoState) GetDocsOnDisk(docNames ...string) (doltdocs.Docs, error)

func (MemoryRepoState) GetRemotes

func (m MemoryRepoState) GetRemotes() (map[string]Remote, error)

func (MemoryRepoState) RemoveBackup

func (m MemoryRepoState) RemoveBackup(ctx context.Context, name string) error

func (MemoryRepoState) RemoveRemote

func (m MemoryRepoState) RemoveRemote(ctx context.Context, name string) error

func (MemoryRepoState) SetCWBHeadRef

func (m MemoryRepoState) SetCWBHeadRef(_ context.Context, r ref.MarshalableRef) (err error)

func (MemoryRepoState) TempTableFilesDir

func (m MemoryRepoState) TempTableFilesDir() string

func (MemoryRepoState) UpdateBranch

func (m MemoryRepoState) UpdateBranch(name string, new BranchConfig) error

func (MemoryRepoState) UpdateStagedRoot

func (m MemoryRepoState) UpdateStagedRoot(ctx context.Context, newRoot *doltdb.RootValue) error

func (MemoryRepoState) UpdateWorkingRoot

func (m MemoryRepoState) UpdateWorkingRoot(ctx context.Context, newRoot *doltdb.RootValue) error

func (MemoryRepoState) WorkingSet

func (m MemoryRepoState) WorkingSet(ctx context.Context) (*doltdb.WorkingSet, error)

func (MemoryRepoState) WriteDocsToDisk

func (m MemoryRepoState) WriteDocsToDisk(docs doltdocs.Docs) error

type MultiRepoEnv

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

MultiRepoEnv is a type used to store multiple environments which can be retrieved by name

func DoltEnvAsMultiEnv

func DoltEnvAsMultiEnv(ctx context.Context, dEnv *DoltEnv) (*MultiRepoEnv, error)

DoltEnvAsMultiEnv returns a MultiRepoEnv which wraps the DoltEnv and names it based on the directory DoltEnv refers to. If the env given doesn't contain a valid dolt database, creates a MultiEnvRepo from any databases found in the directory at the root of the filesystem and returns that.

func LoadMultiEnv

func LoadMultiEnv(
	ctx context.Context,
	hdp HomeDirProvider,
	cfg config.ReadWriteConfig,
	fs filesys.Filesys,
	version string,
	envNamesAndPaths ...EnvNameAndPath,
) (*MultiRepoEnv, error)

LoadMultiEnv takes a variable list of EnvNameAndPath objects loads each of the environments, and returns a new MultiRepoEnv

func LoadMultiEnvFromDir

func LoadMultiEnvFromDir(
	ctx context.Context,
	hdp HomeDirProvider,
	cfg config.ReadWriteConfig,
	fs filesys.Filesys,
	path, version string,
) (*MultiRepoEnv, error)

LoadMultiEnvFromDir looks at each subfolder of the given path as a Dolt repository and attempts to return a MultiRepoEnv with initialized environments for each of those subfolder data repositories. subfolders whose name starts with '.' are skipped.

func MultiEnvForDirectory

func MultiEnvForDirectory(
	ctx context.Context,
	config config.ReadWriteConfig,
	fs filesys.Filesys,
	version string,
) (*MultiRepoEnv, error)

MultiEnvForDirectory returns a MultiRepoEnv for the directory rooted at the file system given

func (*MultiRepoEnv) AddEnv

func (mrEnv *MultiRepoEnv) AddEnv(name string, dEnv *DoltEnv)

TODO: un export AddEnv adds an environment to the MultiRepoEnv by name

func (*MultiRepoEnv) Config

func (mrEnv *MultiRepoEnv) Config() config.ReadWriteConfig

func (*MultiRepoEnv) FileSystem

func (mrEnv *MultiRepoEnv) FileSystem() filesys.Filesys

func (*MultiRepoEnv) GetEnv

func (mrEnv *MultiRepoEnv) GetEnv(name string) *DoltEnv

GetEnv returns the env with the name given, or nil if no such env exists

func (*MultiRepoEnv) GetWorkingRoots

func (mrEnv *MultiRepoEnv) GetWorkingRoots(ctx context.Context) (map[string]*doltdb.RootValue, error)

GetWorkingRoots returns a map with entries for each environment name with a value equal to the working root for that environment

func (*MultiRepoEnv) Iter

func (mrEnv *MultiRepoEnv) Iter(cb func(name string, dEnv *DoltEnv) (stop bool, err error)) error

Iter iterates over all environments in the MultiRepoEnv

type NamedEnv

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

type PullSpec

type PullSpec struct {
	Msg        string
	Squash     bool
	Noff       bool
	Force      bool
	RemoteName string
	Remote     Remote
	RefSpecs   []ref.RemoteRefSpec
	Branch     ref.DoltRef
}

func NewPullSpec

func NewPullSpec(ctx context.Context, rsr RepoStateReader, remoteName string, squash, noff, force bool) (*PullSpec, error)

type PushOpts

type PushOpts struct {
	SrcRef      ref.DoltRef
	DestRef     ref.DoltRef
	RemoteRef   ref.DoltRef
	Remote      Remote
	Mode        ref.UpdateMode
	SetUpstream bool
}

func NewPushOpts

func NewPushOpts(ctx context.Context, apr *argparser.ArgParseResults, rsr RepoStateReader, ddb *doltdb.DoltDB, force bool, setUpstream bool) (*PushOpts, error)

type Remote

type Remote struct {
	Name       string            `json:"name"`
	Url        string            `json:"url"`
	FetchSpecs []string          `json:"fetch_specs"`
	Params     map[string]string `json:"params"`
	// contains filtered or unexported fields
}

func GetDefaultRemote

func GetDefaultRemote(rsr RepoStateReader) (Remote, error)

GetDefaultRemote gets the default remote for the environment. Not fully implemented yet. Needs to support multiple repos and a configurable default.

func NewFetchOpts

func NewFetchOpts(args []string, rsr RepoStateReader) (Remote, []ref.RemoteRefSpec, error)

func NewRemote

func NewRemote(name, url string, params map[string]string, dialer dbfactory.GRPCDialProvider) Remote

func (*Remote) GetParam

func (r *Remote) GetParam(pName string) (string, bool)

func (*Remote) GetParamOrDefault

func (r *Remote) GetParamOrDefault(pName, defVal string) string

func (*Remote) GetRemoteDB

func (r *Remote) GetRemoteDB(ctx context.Context, nbf *types.NomsBinFormat) (*doltdb.DoltDB, error)

func (*Remote) GetRemoteDBWithoutCaching

func (r *Remote) GetRemoteDBWithoutCaching(ctx context.Context, nbf *types.NomsBinFormat) (*doltdb.DoltDB, error)

type RepoState

type RepoState struct {
	Head     ref.MarshalableRef      `json:"head"`
	Remotes  map[string]Remote       `json:"remotes"`
	Backups  map[string]Remote       `json:"backups"`
	Branches map[string]BranchConfig `json:"branches"`
	// contains filtered or unexported fields
}

func CloneRepoState

func CloneRepoState(fs filesys.ReadWriteFS, r Remote) (*RepoState, error)

func CreateRepoState

func CreateRepoState(fs filesys.ReadWriteFS, br string) (*RepoState, error)

func LoadRepoState

func LoadRepoState(fs filesys.ReadWriteFS) (*RepoState, error)

LoadRepoState parses the repo state file from the file system given

func (*RepoState) AddBackup

func (rs *RepoState) AddBackup(r Remote)

func (*RepoState) AddRemote

func (rs *RepoState) AddRemote(r Remote)

func (*RepoState) CWBHeadRef

func (rs *RepoState) CWBHeadRef() ref.DoltRef

func (*RepoState) CWBHeadSpec

func (rs *RepoState) CWBHeadSpec() *doltdb.CommitSpec

func (*RepoState) RemoveBackup

func (rs *RepoState) RemoveBackup(r Remote)

func (*RepoState) RemoveRemote

func (rs *RepoState) RemoveRemote(r Remote)

func (RepoState) Save

func (rs RepoState) Save(fs filesys.ReadWriteFS) error

Save writes this repo state file to disk on the filesystem given

type RepoStateReader

type RepoStateReader interface {
	CWBHeadRef() ref.DoltRef
	CWBHeadSpec() *doltdb.CommitSpec
	GetRemotes() (map[string]Remote, error)
	GetBackups() (map[string]Remote, error)
	GetBranches() (map[string]BranchConfig, error)
}

type RepoStateWriter

type RepoStateWriter interface {
	// TODO: get rid of this
	UpdateStagedRoot(ctx context.Context, newRoot *doltdb.RootValue) error
	// TODO: get rid of this
	UpdateWorkingRoot(ctx context.Context, newRoot *doltdb.RootValue) error
	SetCWBHeadRef(context.Context, ref.MarshalableRef) error
	AddRemote(name string, url string, fetchSpecs []string, params map[string]string) error
	AddBackup(name string, url string, fetchSpecs []string, params map[string]string) error
	RemoveRemote(ctx context.Context, name string) error
	RemoveBackup(ctx context.Context, name string) error
	TempTableFilesDir() string
	UpdateBranch(name string, new BranchConfig) error
}

type RootsProvider

type RootsProvider interface {
	GetRoots(ctx context.Context) (doltdb.Roots, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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