Skip to content

Commit

Permalink
Print detailed error when installing package. (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
harryge00 authored and kensipe committed Jan 28, 2020
1 parent 0ed9632 commit 8f66e34
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions pkg/kudoctl/packages/resolver/resolver.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package resolver

import (
"fmt"

"github.com/kudobuilder/kudo/pkg/kudoctl/clog"
"github.com/kudobuilder/kudo/pkg/kudoctl/http"
"github.com/kudobuilder/kudo/pkg/kudoctl/packages"
Expand Down Expand Up @@ -41,32 +39,24 @@ func New(repo *repo.Client) *PackageResolver {
// - an operator name in the remote repository
// in that order. Should there exist a local folder e.g. `cassandra` it will take precedence
// over the remote repository package with the same name.
func (m *PackageResolver) Resolve(name string, appVersion string, operatorVersion string) (*packages.Package, error) {
func (m *PackageResolver) Resolve(name string, appVersion string, operatorVersion string) (p *packages.Package, err error) {

// Local files/folder have priority
if _, err := m.local.fs.Stat(name); err == nil {
if _, err = m.local.fs.Stat(name); err == nil {
clog.V(2).Printf("local operator discovered: %v", name)
b, err := m.local.Resolve(name, appVersion, operatorVersion)
if err != nil {
return nil, err
}
return b, nil
p, err = m.local.Resolve(name, appVersion, operatorVersion)
return
}

clog.V(3).Printf("no local operator discovered, looking for http")
if http.IsValidURL(name) {
clog.V(3).Printf("operator using http protocol for %v", name)
b, err := m.uri.Resolve(name, appVersion, operatorVersion)
if err != nil {
return nil, err
}
return b, nil
p, err = m.uri.Resolve(name, appVersion, operatorVersion)
return
}

clog.V(3).Printf("no http discovered, looking for repository")
if b, err := m.repo.Resolve(name, appVersion, operatorVersion); err == nil {
return b, nil
}
p, err = m.repo.Resolve(name, appVersion, operatorVersion)

return nil, fmt.Errorf("resolver: unable to find packages for %v", name)
return
}

0 comments on commit 8f66e34

Please sign in to comment.