Skip to content

Commit

Permalink
✨ Add support for verbosity. (#68)
Browse files Browse the repository at this point in the history
Add support for verbosity. This mainly applies to reporting in task
activity.

When requested, the command output is included (live) in the activity
log. This provides more detail and better insight into what the command
is doing _currently_.

Requires:
- konveyor/tackle2-hub#577
- konveyor/tackle2-addon#50

---------

Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel authored Dec 19, 2023
1 parent b9eb18a commit 386d508
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
10 changes: 8 additions & 2 deletions cmd/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ type Analyzer struct {
// Run analyzer.
func (r *Analyzer) Run() (b *builder.Issues, err error) {
output := path.Join(Dir, "report.yaml")
cmd := command.Command{Path: "/usr/bin/konveyor-analyzer"}
cmd := command.New("/usr/bin/konveyor-analyzer")
cmd.Options, err = r.options(output)
if err != nil {
return
}
if Verbosity > 0 {
cmd.Reporter.Verbosity = command.LiveOutput
}
b = &builder.Issues{Path: output}
err = cmd.Run()
return
Expand Down Expand Up @@ -75,11 +78,14 @@ type DepAnalyzer struct {
// Run analyzer.
func (r *DepAnalyzer) Run() (b *builder.Deps, err error) {
output := path.Join(Dir, "deps.yaml")
cmd := command.Command{Path: "/usr/bin/konveyor-analyzer-dep"}
cmd := command.New("/usr/bin/konveyor-analyzer-dep")
cmd.Options, err = r.options(output)
if err != nil {
return
}
if Verbosity > 0 {
cmd.Reporter.Verbosity = command.LiveOutput
}
b = &builder.Deps{Path: output}
err = cmd.Run()
if err != nil {
Expand Down
14 changes: 10 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package main

import (
"errors"
"os"
"path"
"time"

"github.com/gin-gonic/gin/binding"
"github.com/konveyor/tackle2-addon/ssh"
hub "github.com/konveyor/tackle2-hub/addon"
"github.com/konveyor/tackle2-hub/api"
"github.com/konveyor/tackle2-hub/nas"
"os"
"path"
"time"
)

var (
Expand All @@ -21,6 +22,7 @@ var (
RuleDir = ""
OptDir = ""
Source = "Analysis"
Verbosity = 0
)

func init() {
Expand All @@ -34,6 +36,8 @@ func init() {

// Data Addon data passed in the secret.
type Data struct {
// Verbosity level.
Verbosity int `json:"verbosity"`
// Mode options.
Mode Mode `json:"mode"`
// Scope options.
Expand All @@ -51,7 +55,9 @@ func main() {
// Get the addon data associated with the task.
d := &Data{}
err = addon.DataWith(d)
if err != nil {
if err == nil {
Verbosity = d.Verbosity
} else {
return
}
//
Expand Down
2 changes: 1 addition & 1 deletion cmd/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (r *Rules) convert() (err error) {
if err != nil {
return
}
cmd := command.Command{Path: "/usr/bin/windup-shim"}
cmd := command.New("/usr/bin/windup-shim")
cmd.Options.Add("convert")
cmd.Options.Add("--outputdir", output)
cmd.Options.Add(RuleDir)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.18
require (
github.com/gin-gonic/gin v1.9.0
github.com/konveyor/analyzer-lsp v0.0.0-20230712145100-60dc2048444c
github.com/konveyor/tackle2-addon v0.3.0-beta.3.0.20231122051613-31d1afa8ce1c
github.com/konveyor/tackle2-hub v0.3.0-beta.2
github.com/konveyor/tackle2-addon v0.3.0-rc.2.0.20231219212054-1119ca451542
github.com/konveyor/tackle2-hub v0.3.0-rc.2.0.20231219211826-f09d0b24c0e6
github.com/onsi/gomega v1.27.6
github.com/rogpeppe/go-internal v1.10.0
go.lsp.dev/uri v0.3.0
Expand Down Expand Up @@ -57,7 +57,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBF
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/konveyor/analyzer-lsp v0.0.0-20230712145100-60dc2048444c h1:DbOZO3cNmLBJ5Z6iXyl7Fb3ejWxicHAa3OHI++0KJd4=
github.com/konveyor/analyzer-lsp v0.0.0-20230712145100-60dc2048444c/go.mod h1:+k6UreVv8ztI29/RyQN8/71AAmB0aWwQoWwZd3yR8sc=
github.com/konveyor/tackle2-addon v0.3.0-beta.3.0.20231122051613-31d1afa8ce1c h1:7lLxdzpFs/rwvLTm+saFrNz3Tqn6+/l5s2J01iRgGdA=
github.com/konveyor/tackle2-addon v0.3.0-beta.3.0.20231122051613-31d1afa8ce1c/go.mod h1:KQ1rdOjbrv8huxW7UnmojHGkdZLevOHpaQN9dcyZgfQ=
github.com/konveyor/tackle2-hub v0.3.0-beta.2 h1:1YTYX7ktHWmowNWElQtOzBldWflZe81Z89nxYMVRFzM=
github.com/konveyor/tackle2-hub v0.3.0-beta.2/go.mod h1:2ApwTxjVnIb3tP7XZKCEQdITsOgNHOeJ6qvchDsINFE=
github.com/konveyor/tackle2-addon v0.3.0-rc.2.0.20231219212054-1119ca451542 h1:Oywrm7FmnIensv4eP3E1UW2AeB0FfMi5Esoz6l54rRQ=
github.com/konveyor/tackle2-addon v0.3.0-rc.2.0.20231219212054-1119ca451542/go.mod h1:2ULCt88EGBK/N8bOCaerrUNlRw/VCZVXfXRBwmngNj4=
github.com/konveyor/tackle2-hub v0.3.0-rc.2.0.20231219211826-f09d0b24c0e6 h1:xPLwmNqA3QxVaqqnhF6v/T2ZMTCom2GcROD2BEJIHnQ=
github.com/konveyor/tackle2-hub v0.3.0-rc.2.0.20231219211826-f09d0b24c0e6/go.mod h1:ZR4A0+Wp0H3QZkMohPnvZjxcolVORP3jdHV9Uwb/PoE=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand All @@ -157,8 +157,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA=
github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand Down

0 comments on commit 386d508

Please sign in to comment.