Skip to content
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

Adding attachment info and upload of analysis #164

Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading