mirror of
https://github.com/luxfi/lpm.git
synced 2026-10-30 16:20:57 +00:00
Lux Partners Limited is the Isle of Man company. Lux Industries Inc, a Delaware C corporation, is the company these sites belong to, so it is the one they name — in metadata, copyright, and the press items that record who signed. The fund site names Lux Assets Management LLC, which is its own company. Two sentences were rewritten rather than renamed, because a name was doing work a name cannot do. One claimed an Isle of Man domicile the naming entity does not have. The other said a company acts on behalf of another; with one entity left it said a company acts on behalf of itself. The Isle of Man stays everywhere it is a JURISDICTION the product supports — the regulatory package, the jurisdiction guides, the compliance tables. Only this company's own identity changed.
123 lines
2.7 KiB
Go
123 lines
2.7 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package workflow
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/afero"
|
|
|
|
"github.com/luxfi/lpm/git"
|
|
"github.com/luxfi/lpm/state"
|
|
"github.com/luxfi/lpm/util"
|
|
)
|
|
|
|
var ErrAlreadyUpdated = errors.New("already up-to-date")
|
|
|
|
type UpgradeVMConfig struct {
|
|
Executor Executor
|
|
|
|
FullVMName string
|
|
RepoFactory state.RepositoryFactory
|
|
StateFile state.File
|
|
|
|
TmpPath string
|
|
PluginPath string
|
|
Installer Installer
|
|
Fs afero.Fs
|
|
Git git.Factory
|
|
}
|
|
|
|
func NewUpgradeVM(config UpgradeVMConfig) *UpgradeVM {
|
|
return &UpgradeVM{
|
|
executor: config.Executor,
|
|
fullVMName: config.FullVMName,
|
|
repoFactory: config.RepoFactory,
|
|
stateFile: config.StateFile,
|
|
tmpPath: config.TmpPath,
|
|
pluginPath: config.PluginPath,
|
|
installer: config.Installer,
|
|
fs: config.Fs,
|
|
git: config.Git,
|
|
}
|
|
}
|
|
|
|
type UpgradeVM struct {
|
|
fullVMName string
|
|
executor Executor
|
|
|
|
repoFactory state.RepositoryFactory
|
|
|
|
stateFile state.File
|
|
|
|
tmpPath string
|
|
pluginPath string
|
|
|
|
installer Installer
|
|
fs afero.Fs
|
|
git git.Factory
|
|
}
|
|
|
|
func (u *UpgradeVM) Execute() error {
|
|
installInfo := u.stateFile.InstallationRegistry[u.fullVMName]
|
|
|
|
repoAlias, vmName := util.ParseQualifiedName(u.fullVMName)
|
|
organization, repo := util.ParseAlias(repoAlias)
|
|
|
|
repository, err := u.repoFactory.GetRepository(repoAlias)
|
|
if errors.Is(err, os.ErrNotExist) {
|
|
fmt.Printf("Warning - found a repository %s while upgrading %s "+
|
|
"which is no longer downloaded. You might need to re-add this "+
|
|
"repository and call update, or uninstall this vm to avoid noisy logs. "+
|
|
"Skipping...\n", repoAlias, u.fullVMName)
|
|
return nil
|
|
} else if err != nil {
|
|
return err
|
|
}
|
|
|
|
if _, err := repository.GetVM(vmName); err != nil {
|
|
fmt.Printf("Warning - found a vm while upgrading %s which is no "+
|
|
"longer registered in a repository. You should uninstall this VM to "+
|
|
"avoid noisy logs. Skipping...\n", u.fullVMName)
|
|
return nil
|
|
}
|
|
|
|
latest, err := u.git.GetLastModified(repository.GetPath(), fmt.Sprintf("vms/%s.%s", vmName, "yaml"))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if installInfo.Commit == latest {
|
|
return ErrAlreadyUpdated
|
|
}
|
|
|
|
fmt.Printf(
|
|
"Detected an upgrade for %s from %s to %s\n",
|
|
u.fullVMName,
|
|
installInfo.Commit,
|
|
latest,
|
|
)
|
|
wf := NewInstall(InstallConfig{
|
|
Name: u.fullVMName,
|
|
Plugin: vmName,
|
|
Organization: organization,
|
|
Repo: repo,
|
|
TmpPath: u.tmpPath,
|
|
PluginPath: u.pluginPath,
|
|
StateFile: u.stateFile,
|
|
Repository: repository,
|
|
Installer: u.installer,
|
|
Fs: u.fs,
|
|
})
|
|
|
|
fmt.Printf(
|
|
"Rebuilding binaries for %s@%s\n",
|
|
u.fullVMName,
|
|
latest,
|
|
)
|
|
return u.executor.Execute(wf)
|
|
}
|