-
Notifications
You must be signed in to change notification settings - Fork 37
✨ Add binding methods for analysis. #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package binding | ||
|
|
||
| import "github.com/konveyor/tackle2-hub/shared/api" | ||
|
|
||
| // Analysis API. | ||
| type Analysis struct { | ||
| client *Client | ||
| } | ||
|
|
||
| // Create an Analysis. | ||
| func (h *Analysis) Create(r *api.Analysis) (err error) { | ||
| err = h.client.Post(api.AnalysesRoute, &r) | ||
| return | ||
| } | ||
|
|
||
| // Get an Analysis by ID. | ||
| func (h *Analysis) Get(id uint) (r *api.Analysis, err error) { | ||
| r = &api.Analysis{} | ||
| path := Path(api.AnalysisRoute).Inject(Params{api.ID: id}) | ||
| err = h.client.Get(path, r) | ||
| return | ||
| } | ||
|
|
||
| // Delete an Analysis by ID. | ||
| func (h *Analysis) Delete(id uint) (err error) { | ||
| path := Path(api.AnalysisRoute).Inject(Params{api.ID: id}) | ||
| err = h.client.Delete(path) | ||
| return | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -79,8 +79,8 @@ func (h *Application) Facts(id uint) (f AppFacts) { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Analysis returns the analysis API. | ||||||||||||||||||||||
| func (h *Application) Analysis(id uint) (a Analysis) { | ||||||||||||||||||||||
| a = Analysis{ | ||||||||||||||||||||||
| func (h *Application) Analysis(id uint) (a AppAnalysis) { | ||||||||||||||||||||||
| a = AppAnalysis{ | ||||||||||||||||||||||
| client: h.client, | ||||||||||||||||||||||
| appId: id, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
@@ -288,8 +288,8 @@ func (h *AppFacts) Replace(facts api.Map) (err error) { | |||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Analysis sub-resource API. | ||||||||||||||||||||||
| type Analysis struct { | ||||||||||||||||||||||
| // AppAnalysis sub-resource API. | ||||||||||||||||||||||
| type AppAnalysis struct { | ||||||||||||||||||||||
| client *Client | ||||||||||||||||||||||
| appId uint | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
@@ -310,7 +310,7 @@ type Analysis struct { | |||||||||||||||||||||
| // The encoding must be: | ||||||||||||||||||||||
| // - application/json | ||||||||||||||||||||||
| // - application/x-yaml | ||||||||||||||||||||||
| func (h *Analysis) Create(manifest, encoding string) (r *api.Analysis, err error) { | ||||||||||||||||||||||
| func (h *AppAnalysis) Create(manifest, encoding string) (r *api.Analysis, err error) { | ||||||||||||||||||||||
| switch encoding { | ||||||||||||||||||||||
| case "": | ||||||||||||||||||||||
| encoding = api.MIMEJSON | ||||||||||||||||||||||
|
|
@@ -330,6 +330,27 @@ func (h *Analysis) Create(manifest, encoding string) (r *api.Analysis, err error | |||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Get the latest analysis for an application. | ||||||||||||||||||||||
| func (h *AppAnalysis) Get() (r *api.Analysis, err error) { | ||||||||||||||||||||||
| path := Path(api.AppAnalysisRoute).Inject(Params{api.ID: h.appId}) | ||||||||||||||||||||||
| err = h.client.Get(path, &r) | ||||||||||||||||||||||
| return | ||||||||||||||||||||||
|
Comment on lines
+334
to
+337
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find client.go in shared/binding
fd -a "client.go" shared/binding
# Check Client.Get signature
rg -n "func .* Get\(" -g 'client.go' shared/binding -A 3Repository: konveyor/tackle2-hub Length of output: 456 🏁 Script executed: # Read the full Client.Get implementation
sed -n '99,150p' shared/binding/client.goRepository: konveyor/tackle2-hub Length of output: 1084 🏁 Script executed: # Check how other similar Get methods are implemented in other binding files
fd -a "\.go" shared/binding -type f | head -20 | xargs grep -l "func.*Get.*\*.*error" | head -5
# Look for similar patterns in other binding files
rg "err = h\.client\.Get\(" shared/binding -B 5 -A 2 | head -50Repository: konveyor/tackle2-hub Length of output: 2774 🏁 Script executed: # Get the exact context around line 334-337
sed -n '330,340p' shared/binding/application.goRepository: konveyor/tackle2-hub Length of output: 342 Initialize the response object before Get. 🐛 Proposed fix func (h *AppAnalysis) Get() (r *api.Analysis, err error) {
path := Path(api.AppAnalysisRoute).Inject(Params{api.ID: h.appId})
- err = h.client.Get(path, &r)
+ r = &api.Analysis{}
+ err = h.client.Get(path, r)
return
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // GetInsights Insights analysis for an application. | ||||||||||||||||||||||
| func (h *AppAnalysis) GetInsights() (r []api.Insight, err error) { | ||||||||||||||||||||||
| path := Path(api.AppAnalysisInsightsRoute).Inject(Params{api.ID: h.appId}) | ||||||||||||||||||||||
| err = h.client.Get(path, &r) | ||||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // GetDependencies dependencies for an application. | ||||||||||||||||||||||
| func (h *AppAnalysis) GetDependencies() (r []api.TechDependency, err error) { | ||||||||||||||||||||||
| path := Path(api.AppAnalysisDepsRoute).Inject(Params{api.ID: h.appId}) | ||||||||||||||||||||||
| err = h.client.Get(path, &r) | ||||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // AppManifest sub-resource API. | ||||||||||||||||||||||
| type AppManifest struct { | ||||||||||||||||||||||
| client *Client | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
Archivedfield in ThinModel.ThinWithsetsr.Archived = m.Archived(line 20), butThinModeldoesn't setm.Archived = r.Archived. This asymmetry could cause data loss when converting the resource back to a model.🐛 Proposed fix
func (r *Analysis) ThinModel() (m *model.Analysis) { m = &model.Analysis{} m.Effort = r.Effort m.Commit = r.Commit + m.Archived = r.Archived m.Insights = []model.Insight{} return }📝 Committable suggestion
🤖 Prompt for AI Agents