Skip to content

Commit

Permalink
adding attachment info and upload of analysis (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn-hurley committed Aug 1, 2024
1 parent 8daeadc commit a1e6a5e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
33 changes: 32 additions & 1 deletion analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/hex"
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions analysis/analyzer_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ var AnalyzeDataDefault = addon.Data{
Tagger: addon.Tagger{
Enabled: true,
},
Verbosity: 1,
}
11 changes: 2 additions & 9 deletions hack/addon/analyzerstructs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -63,7 +59,6 @@ type Scope struct {
} `json:"packages"`
}

//
// Rules settings.
type Rules struct {
Path string `json:"path"`
Expand All @@ -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"`
Expand Down

0 comments on commit a1e6a5e

Please sign in to comment.