Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion addon/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Tackle hub/addon integration.
package addon

import (
"fmt"
"os"

logapi "github.com/go-logr/logr"
Expand Down Expand Up @@ -80,6 +81,8 @@ type Adapter struct {
Task
// Log API.
Log logapi.Logger
// Wrap error API.
Wrap func(error, ...any) error
// Settings API.
Setting Setting
// Schema API
Expand Down Expand Up @@ -125,7 +128,7 @@ func (h *Adapter) Run(addon func() error) {
if pErr, cast := r.(error); cast {
err = pErr
} else {
panic(r)
err = fmt.Errorf("%#v", r)
}
}
if err != nil {
Expand Down Expand Up @@ -164,6 +167,7 @@ func newAdapter() (adapter *Adapter) {
richClient: richClient,
},
Log: Log,
Wrap: Wrap,
Setting: richClient.Setting,
Schema: richClient.Schema,
Application: richClient.Application,
Expand Down
26 changes: 16 additions & 10 deletions addon/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@

// Application returns the application associated with the task.
func (h *Task) Application() (r *api.Application, err error) {
appRef := h.task.Application
if appRef == nil {
err = &NotFound{}
ref := h.task.Application
if ref == nil {
err = Wrap(&NotFound{

Check failure on line 38 in addon/task.go

View workflow job for this annotation

GitHub Actions / vet

github.com/konveyor/tackle2-hub/binding.NotFound struct literal uses unkeyed fields

Check failure on line 38 in addon/task.go

View workflow job for this annotation

GitHub Actions / build

github.com/konveyor/tackle2-hub/binding.NotFound struct literal uses unkeyed fields
ResetError{Reason: "application not specified."},
})
return
}
r, err = h.richClient.Application.Get(appRef.ID)
r, err = h.richClient.Application.Get(ref.ID)
if err != nil {
return
}
r.Identities = []api.Ref{}
identities, err := h.richClient.Application.Identity(appRef.ID).List()
identities, err := h.richClient.Application.Identity(ref.ID).List()
if err != nil {
return
}
Expand All @@ -60,12 +62,14 @@

// Platform returns the platform associated with the task.
func (h *Task) Platform() (r *api.Platform, err error) {
appRef := h.task.Platform
if appRef == nil {
err = &NotFound{}
ref := h.task.Platform
if ref == nil {
err = Wrap(&NotFound{

Check failure on line 67 in addon/task.go

View workflow job for this annotation

GitHub Actions / vet

github.com/konveyor/tackle2-hub/binding.NotFound struct literal uses unkeyed fields

Check failure on line 67 in addon/task.go

View workflow job for this annotation

GitHub Actions / build

github.com/konveyor/tackle2-hub/binding.NotFound struct literal uses unkeyed fields
ResetError{Reason: "platform not specified."},
})
return
}
r, err = h.richClient.Platform.Get(appRef.ID)
r, err = h.richClient.Platform.Get(ref.ID)
return
}

Expand All @@ -75,7 +79,9 @@
func (h *Task) Addon(inject bool) (r *api.Addon, err error) {
name := h.task.Addon
if name == "" {
err = &NotFound{}
err = Wrap(&NotFound{

Check failure on line 82 in addon/task.go

View workflow job for this annotation

GitHub Actions / vet

github.com/konveyor/tackle2-hub/binding.NotFound struct literal uses unkeyed fields

Check failure on line 82 in addon/task.go

View workflow job for this annotation

GitHub Actions / build

github.com/konveyor/tackle2-hub/binding.NotFound struct literal uses unkeyed fields
ResetError{Reason: "addon not specified."},
})
return
}
r, err = h.richClient.Addon.Get(name)
Expand Down
Loading