Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
batphonghan committed Nov 1, 2023
1 parent df860ca commit ce716ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions shared/services/stader/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,16 @@ func (c *Client) MigrateLegacyConfig(legacyConfigFilePath string, legacySettings
}

// Install the Stader service
func (c *Client) InstallService(verbose, noDeps bool, network, version, path string, dataPath string) error {
func (c *Client) InstallService(verbose, noDeps bool, network, version, path, dataPath string) error {
return c.executeScript(verbose, noDeps, network, version, path, dataPath, InstallerURL)
}

// Install the Stader service
// Update the Stader package files
func (c *Client) UpdateStaderPackage(verbose, noDeps bool, network, version, path, dataPath string) error {
return c.executeScript(verbose, noDeps, network, version, path, dataPath, UpdateURL)
}

// Install the Stader service
func (c *Client) executeScript(verbose, noDeps bool, network, version, path, dataPath, url string) error {

func (c *Client) executeScript(verbose, noDeps bool, network, version, path, dataPath, remoteURL string) error {
downloader, err := c.getDownloader()
if err != nil {
return err
Expand All @@ -532,7 +530,7 @@ func (c *Client) executeScript(verbose, noDeps bool, network, version, path, dat
}

// Initialize installation command
cmd, err := c.newCommand(fmt.Sprintf("%s %s | sh -s -- %s", downloader, fmt.Sprintf(url, version), strings.Join(flags, " ")))
cmd, err := c.newCommand(fmt.Sprintf("%s %s | sh -s -- %s", downloader, fmt.Sprintf(remoteURL, version), strings.Join(flags, " ")))

if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions stader-cli/service/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
{
Name: "export-eth1-data",
Usage: "Exports the execution client (eth1) chain data to an external folder. Use this if you want to back up your chain data before switching execution clients.",
UsageText: "rocketpool service export-eth1-data target-folder",
UsageText: "stader-cli service export-eth1-data target-folder",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force",
Expand Down Expand Up @@ -515,7 +515,7 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
{
Name: "import-eth1-data",
Usage: "Imports execution client (eth1) chain data from an external folder. Use this if you want to restore the data from an execution client that you previously backed up.",
UsageText: "rocketpool service import-eth1-data source-folder",
UsageText: "stader-cli service import-eth1-data source-folder",
Action: func(c *cli.Context) error {

// Validate args
Expand Down
4 changes: 2 additions & 2 deletions stader-cli/service/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func migrate(c *cli.Context) (runBeforeUpgrades, rundAfterUpgrades []ConfigUpgra
if needInstall {
runBeforeUpgrades = append([]ConfigUpgrader{
{
upgradeFunc: install,
upgradeFunc: updateStaderPackage,
version: v0,
},
}, runBeforeUpgrades...)
Expand Down Expand Up @@ -144,7 +144,7 @@ func upgradeFuncV140(c *cli.Context) error {
return nil
}

func install(c *cli.Context) error {
func updateStaderPackage(c *cli.Context) error {
staderClient, err := stader.NewClientFromCtx(c)
if err != nil {
return fmt.Errorf("error NewClientFromCtx: %w", err)
Expand Down

0 comments on commit ce716ef

Please sign in to comment.