Skip to content

Commit

Permalink
Fix the issue that old nighlty may cause error (#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklove committed Mar 11, 2021
1 parent b262d05 commit 9b97e23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pkg/environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ func (env *Environment) SelectInstalledVersion(component string, ver pkgver.Vers
versions := []string{}
for _, v := range installed {
vi, err := env.v1Repo.ComponentVersion(component, v, true)
if errors.Cause(err) == repository.ErrUnknownVersion {
continue
}
if err != nil {
return ver, err
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/repository/v1_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"bytes"
"crypto/sha256"
"encoding/hex"
stderrors "errors"
"fmt"
"io"
"os"
Expand All @@ -41,7 +40,10 @@ import (
)

// ErrUnknownComponent represents the specific component cannot be found in index.json
var ErrUnknownComponent = stderrors.New("unknown component")
var ErrUnknownComponent = errors.New("unknown component")

// ErrUnknownVersion represents the specific component version cannot be found in component.json
var ErrUnknownVersion = errors.New("unknown version")

// V1Repository represents a remote repository viewed with the v1 manifest design.
type V1Repository struct {
Expand Down Expand Up @@ -724,7 +726,7 @@ func (r *V1Repository) ComponentVersion(id, ver string, includeYanked bool) (*v1
}
vi := manifest.VersionItem(r.PlatformString(), ver, includeYanked)
if vi == nil {
return nil, errors.Errorf("version %s on %s for component %s not found", ver, r.PlatformString(), id)
return nil, errors.Annotatef(ErrUnknownVersion, "version %s on %s for component %s not found", ver, r.PlatformString(), id)
}
return vi, nil
}
Expand Down

0 comments on commit 9b97e23

Please sign in to comment.