Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var V1Migration = repo.NewMigration( repo.RepoVersion1, repo.RepoVersion2, func(r repo.FsRepo) error { configExist, err := configExists(r) if err != nil { return err } if !configExist { return nil } v, cfg, err := readConfig(r) if err != nil { return err } doWrite := false if haveSameElements(oldSwarmPeers, cfg.Node.IPFS.SwarmAddresses) { v.Set(types.NodeIPFSSwarmAddresses, []string{}) doWrite = true } if haveSameElements(oldBootstrapPeers, cfg.Node.BootstrapAddresses) { v.Set(types.NodeBootstrapAddresses, []string{}) doWrite = true } if doWrite { return v.WriteConfig() } return nil })
View Source
var V2Migration = repo.NewMigration( repo.RepoVersion2, repo.RepoVersion3, func(r repo.FsRepo) error { v, fileCfg, err := readConfig(r) if err != nil { return err } repoPath, err := r.Path() if err != nil { return err } resolvedCfg, err := config.Load(repoPath) if err != nil { return err } libp2pNodeID, err := getLibp2pNodeID() if err != nil { return err } doWrite := false var logMessage strings.Builder set := func(key string, value interface{}) { v.Set(key, value) logMessage.WriteString(fmt.Sprintf("\n%s:\t%v", key, value)) doWrite = true } if fileCfg.Node.Compute.ExecutionStore.Path == "" { executionStore := resolvedCfg.Node.Compute.ExecutionStore if executionStore.Path == "" { executionStore.Path = filepath.Join(repoPath, "compute_store", "executions.db") } legacyStoreName := filepath.Join(repoPath, libp2pNodeID+"-compute") newStorePath := filepath.Dir(executionStore.Path) if _, err := os.Stat(legacyStoreName); err == nil { if err := os.Rename(legacyStoreName, newStorePath); err != nil { return err } } else if err = os.MkdirAll(newStorePath, util.OS_USER_RWX); err != nil { return err } set(types.NodeComputeExecutionStore, executionStore) } if fileCfg.Node.Requester.JobStore.Path == "" { jobStore := resolvedCfg.Node.Requester.JobStore if jobStore.Path == "" { jobStore.Path = filepath.Join(repoPath, "orchestrator_store", "jobs.db") } legacyStoreName := filepath.Join(repoPath, libp2pNodeID+"-requester") newStorePath := filepath.Dir(jobStore.Path) if _, err := os.Stat(legacyStoreName); err == nil { if err := os.Rename(legacyStoreName, newStorePath); err != nil { return err } } else if err = os.MkdirAll(newStorePath, util.OS_USER_RWX); err != nil { return err } set(types.NodeRequesterJobStore, jobStore) } if fileCfg.Node.Name == "" { set(types.NodeName, libp2pNodeID) } if doWrite { return v.WriteConfig() } return nil })
V2Migration updates the repo so that nodeID is no longer part of the execution and job store paths. It does the following: - Generates and persists the nodeID in the config if it is missing, which is the case for v2 repos - Adds the execution and job store paths to the config if they are missing, which is the case for v3 repos - Renames the execution and job store directories to the new name if they exist
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.