Skip to content

Commit

Permalink
fix: use local version on download failure (#1123)
Browse files Browse the repository at this point in the history
We already have the check above to continue on this type of error
  • Loading branch information
chase-crumbaugh authored Nov 26, 2024
1 parent 9aaf0da commit 6014094
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/model/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"gopkg.in/yaml.v3"
)

const ErrDownloadFailed = errors.Error("failed to download Speakeasy version")
const ErrInstallFailed = errors.Error("failed to install Speakeasy version")

type Command interface {
Init() (*cobra.Command, error) // TODO: make private when rootCmd is refactored?
Expand Down Expand Up @@ -137,7 +137,7 @@ func (c ExecutableCommand[F]) Init() (*cobra.Command, error) {
err := runWithVersionFromWorkflowFile(cmd)
if err == nil {
return nil
} else if !errors.Is(err, ErrDownloadFailed) { // Don't fail on download failure. Proceed using the current CLI version, as if it was run with --pinned
} else if !errors.Is(err, ErrInstallFailed) { // Don't fail on download failure. Proceed using the current CLI version, as if it was run with --pinned
return err
}
logger := log.From(cmd.Context())
Expand Down Expand Up @@ -285,7 +285,7 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error {
if desiredVersion == "latest" {
latest, err := updates.GetLatestVersion(ctx, artifactArch)
if err != nil {
return ErrDownloadFailed
return ErrInstallFailed
}
desiredVersion = latest.String()

Expand Down Expand Up @@ -324,7 +324,7 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error {
func runWithVersion(cmd *cobra.Command, artifactArch, desiredVersion string) error {
vLocation, err := updates.InstallVersion(cmd.Context(), desiredVersion, artifactArch, 30)
if err != nil {
return err
return ErrInstallFailed.Wrap(err)
}

cmdParts := utils.GetCommandParts(cmd)
Expand Down

0 comments on commit 6014094

Please sign in to comment.