Skip to content

Commit

Permalink
Fix import cycle
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Lucidi <slucidi@redhat.com>
  • Loading branch information
mansam committed Jun 20, 2024
1 parent 6aebfe6 commit fcfdd72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion importer/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) {
return
}
// best effort
_ = m.discover(app)
err := m.discover(app)
if err != nil {
imp.ErrorMessage = fmt.Sprintf("Failed to launch discovery tasks for Application '%s'", app.Name)
return
}

ok = true
return
Expand Down
10 changes: 8 additions & 2 deletions settings/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"time"

liberr "github.com/jortel/go-utils/error"
"github.com/konveyor/tackle2-hub/k8s"
crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/client-go/kubernetes/scheme"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
)

const (
Expand Down Expand Up @@ -295,7 +296,12 @@ func (r *Hub) Load() (err error) {

// discoveryTasks finds discovery tasks by their label
func (r *Hub) discoveryTasks() (tasks []string, err error) {
client, err := k8s.NewClient()
cfg, _ := config.GetConfig()
client, err := k8sclient.New(
cfg,
k8sclient.Options{
Scheme: scheme.Scheme,
})
if err != nil {
err = liberr.Wrap(err)
return
Expand Down

0 comments on commit fcfdd72

Please # to comment.