Skip to content

Commit

Permalink
Merge pull request #131 from criteo/update-timeout
Browse files Browse the repository at this point in the history
Add timeout option for update command
  • Loading branch information
bhou authored Feb 9, 2024
2 parents 3af1e39 + 1b80b9f commit 01f55ce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"time"

"github.com/criteo/command-launcher/internal/config"
"github.com/criteo/command-launcher/internal/console"
Expand All @@ -17,6 +18,7 @@ import (
type UpdateFlags struct {
Package bool
Self bool
Timeout time.Duration
}

var (
Expand Down Expand Up @@ -49,7 +51,7 @@ Check the update of %s and its commands.
SelfUpdateRootUrl: viper.GetString(config.SELF_UPDATE_BASE_URL_KEY),
User: u,
CurrentVersion: appCtx.AppVersion(),
Timeout: viper.GetDuration(config.SELF_UPDATE_TIMEOUT_KEY),
Timeout: updateFlags.Timeout,
}
selfUpdater.CheckUpdateAsync()
err := selfUpdater.Update()
Expand All @@ -71,7 +73,7 @@ Check the update of %s and its commands.
LocalRepo: localRepo,
CmdRepositoryBaseUrl: viper.GetString(config.COMMAND_REPOSITORY_BASE_URL_KEY),
User: u,
Timeout: viper.GetDuration(config.SELF_UPDATE_TIMEOUT_KEY),
Timeout: updateFlags.Timeout,
EnableCI: enableCI,
PackageLockFile: packageLockFile,
}
Expand All @@ -94,6 +96,7 @@ Check the update of %s and its commands.

updateCmd.Flags().BoolVarP(&updateFlags.Package, "package", "p", false, "Update packages and commands")
updateCmd.Flags().BoolVarP(&updateFlags.Self, "self", "s", false, "Self update")
updateCmd.Flags().DurationVarP(&updateFlags.Timeout, "timeout", "t", 10*time.Second, "Timeout for update operations")

rootCmd.AddCommand(updateCmd)
}

0 comments on commit 01f55ce

Please sign in to comment.