Files
lpm/workflow/upgrade.go
zeekay 7d7127a687 deps: update to latest luxfi packages
- Update node v1.16.15 → v1.19.8
- Update crypto v1.17.0 → v1.17.4
- Update database v1.2.0 → v1.2.1
- Update geth v1.16.34 → v1.16.35
- Update ids v1.1.0 → v1.1.1
- Update Go 1.25 → 1.25.1
- Update copyright year to 2025
2025-09-30 00:05:18 +00:00

87 lines
1.6 KiB
Go

// Copyright (C) 2019-2025, Lux Partners Limited. All rights reserved.
// See the file LICENSE for licensing terms.
package workflow
import (
"fmt"
"github.com/spf13/afero"
"github.com/luxfi/lpm/git"
"github.com/luxfi/lpm/state"
)
type UpgradeConfig struct {
Executor Executor
RepoFactory state.RepositoryFactory
StateFile state.File
TmpPath string
PluginPath string
Installer Installer
Git git.Factory
Fs afero.Fs
}
func NewUpgrade(config UpgradeConfig) *Upgrade {
return &Upgrade{
executor: config.Executor,
repoFactory: config.RepoFactory,
tmpPath: config.TmpPath,
pluginPath: config.PluginPath,
installer: config.Installer,
stateFile: config.StateFile,
git: config.Git,
fs: config.Fs,
}
}
type Upgrade struct {
executor Executor
repoFactory state.RepositoryFactory
stateFile state.File
tmpPath string
pluginPath string
installer Installer
git git.Factory
fs afero.Fs
}
func (u *Upgrade) Execute() error {
upgraded := false
for name := range u.stateFile.InstallationRegistry {
wf := NewUpgradeVM(UpgradeVMConfig{
Executor: u.executor,
FullVMName: name,
RepoFactory: u.repoFactory,
StateFile: u.stateFile,
TmpPath: u.tmpPath,
PluginPath: u.pluginPath,
Installer: u.installer,
Git: u.git,
Fs: u.fs,
})
if err := u.executor.Execute(wf); err == ErrAlreadyUpdated {
continue
} else if err != nil {
return err
}
upgraded = true
}
if !upgraded {
fmt.Printf("No changes detected.\n")
return nil
}
return nil
}