diff --git a/analysis/analysis_test.go b/analysis/analysis_test.go index 8bfe6b5..b56d1c1 100644 --- a/analysis/analysis_test.go +++ b/analysis/analysis_test.go @@ -7,6 +7,7 @@ import ( "encoding/hex" "fmt" "os" + "path/filepath" "sort" "strings" "testing" @@ -149,12 +150,26 @@ func TestApplicationAnalysis(t *testing.T) { if task.State == "Running" { t.Error("Timed out running the test. Details:") pp.Println(tasks) + dir, err := os.MkdirTemp("", "attachments") + if err != nil { + t.Error(err) + } + printAllAtachmentsOnTask(task, dir) + //if this is still running after timeout, then we should move on, this wont work + return + } if task.State != "Succeeded" { t.Error("Analyze Task failed. Details:") - pp.Println(task) pp.Println(tasks) + dir, err := os.MkdirTemp("", "attachments") + if err != nil { + t.Error(err) + } + printAllAtachmentsOnTask(task, dir) + // If the task was unsuccessful there is no reason to continue execution. + return } if debug { pp.Println(task) @@ -361,3 +376,19 @@ func getDefaultToken() string { } return string(decrypted) } + +func printAllAtachmentsOnTask(task *api.Task, dir string) error { + for _, attachement := range task.Attached { + err := RichClient.File.Get(attachement.ID, dir) + if err != nil { + return err + } + b, err := os.ReadFile(filepath.Join(dir, attachement.Name)) + if err != nil { + return err + } + pp.Println(string(b)) + } + + return nil +} diff --git a/analysis/analyzer_defaults.go b/analysis/analyzer_defaults.go index b4d7446..b63ebf9 100644 --- a/analysis/analyzer_defaults.go +++ b/analysis/analyzer_defaults.go @@ -34,4 +34,5 @@ var AnalyzeDataDefault = addon.Data{ Tagger: addon.Tagger{ Enabled: true, }, + Verbosity: 1, } diff --git a/hack/addon/analyzerstructs.go b/hack/addon/analyzerstructs.go index 4da85e9..e293a5f 100644 --- a/hack/addon/analyzerstructs.go +++ b/hack/addon/analyzerstructs.go @@ -9,7 +9,6 @@ import ( // Originally from https://github.com/konveyor/tackle2-addon-windup/blob/main/cmd as of 2023-06-26 // Would love replace this when https://github.com/konveyor/tackle2-addon-windup/issues/98 gets resolved. -// // Data Addon data passed in the secret. type Data struct { // Output directory within application bucket. @@ -25,10 +24,10 @@ type Data struct { // Rules options. Rules Rules `json:"rules"` // Tagger options. - Tagger Tagger `json:"tagger"` + Tagger Tagger `json:"tagger"` + Verbosity int `json:"verbosity"` } -// // Mode settings. type Mode struct { Binary bool `json:"binary"` @@ -45,15 +44,12 @@ type Mode struct { //} } -// // Sources list of sources. type Sources []string -// // Targets list of target. type Targets []string -// // Scope settings. type Scope struct { WithKnown bool `json:"withKnown"` @@ -63,7 +59,6 @@ type Scope struct { } `json:"packages"` } -// // Rules settings. type Rules struct { Path string `json:"path"` @@ -72,14 +67,12 @@ type Rules struct { Labels Labels `json:"labels"` } -// // Labels collection. type Labels struct { Included []string `json:"included,omitempty"` Excluded []string `json:"excluded,omitempty"` } -// // Tagger tags an application. type Tagger struct { Enabled bool `json:"enabled"`