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

🐛 Handle case when Running source only #102

Closed
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
9 changes: 7 additions & 2 deletions builder/deps.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package builder

import (
"bytes"
"io"
"os"

output "github.com/konveyor/analyzer-lsp/output/v1/konveyor"
"github.com/konveyor/tackle2-hub/api"
"gopkg.in/yaml.v2"
"io"
"os"
)

// Deps builds dependencies.
Expand All @@ -15,6 +17,9 @@ type Deps struct {

// Reader returns a reader.
func (b *Deps) Reader() (r io.Reader) {
if _, err := os.Stat(b.Path); os.IsNotExist(err) {
return bytes.NewReader([]byte{})
}
r, w := io.Pipe()
go func() {
var err error
Expand Down
2 changes: 1 addition & 1 deletion cmd/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *Analyzer) options(output string) (options command.Options, err error) {
if err != nil {
return
}
err = r.Scope.AddOptions(&options)
err = r.Scope.AddOptions(&options, r.Mode)
if err != nil {
return
}
Expand Down
17 changes: 11 additions & 6 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/gin-gonic/gin/binding"
"github.com/konveyor/tackle2-addon-analyzer/builder"
"github.com/konveyor/tackle2-addon/ssh"
hub "github.com/konveyor/tackle2-hub/addon"
"github.com/konveyor/tackle2-hub/api"
Expand Down Expand Up @@ -92,6 +93,15 @@ func main() {
if err != nil {
return
}
depAnalyzer := DepAnalyzer{}
depAnalyzer.Data = d
deps, err := depAnalyzer.Run()
if deps == nil {
deps = &builder.Deps{}
}
if err != nil && d.Mode.WithDeps {
return
}
//
// Run analysis.
analyzer := Analyzer{}
Expand All @@ -100,12 +110,7 @@ func main() {
if err != nil {
return
}
depAnalyzer := DepAnalyzer{}
depAnalyzer.Data = d
deps, err := depAnalyzer.Run()
if err != nil {
return
}

//
// Post report.
appAnalysis := addon.Application.Analysis(application.ID)
Expand Down
4 changes: 2 additions & 2 deletions cmd/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type Scope struct {
}

// AddOptions adds analyzer options.
func (r *Scope) AddOptions(options *command.Options) (err error) {
if !r.WithKnownLibs {
func (r *Scope) AddOptions(options *command.Options, mode Mode) (err error) {
if !r.WithKnownLibs && mode.WithDeps {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all other other work, in @jortel fix, this needs to be better documented and add comments

options.Add(
"--dep-label-selector",
"!konveyor.io/dep-source=open-source")
Expand Down
Loading