From ea6006bc5800b0de8deeac89c155c131ed12ebce Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Tue, 5 Mar 2024 15:27:30 -0500 Subject: [PATCH] :bug: run dep cli only when source is set to full Signed-off-by: Pranav Gaikwad --- cmd/analyze.go | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/cmd/analyze.go b/cmd/analyze.go index 69098d1..31ef75f 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -756,23 +756,28 @@ func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string) e return err } - a.log.Info("running dependency analysis", - "log", depsLogFilePath, "input", a.input, "output", a.output, "args", strings.Join(args, " ")) - a.log.Info("generating dependency log in file", "file", depsLogFilePath) - err = NewContainer(a.log).Run( - ctx, - WithStdout(dependencyLog), - WithStderr(dependencyLog), - WithVolumes(volumes), - WithEntrypointBin("/usr/bin/konveyor-analyzer-dep"), - WithEntrypointArgs( - fmt.Sprintf("--output-file=%s", DepsOutputMountPath), - fmt.Sprintf("--provider-settings=%s", ProviderSettingsMountPath), - ), - WithCleanup(a.cleanup), - ) - if err != nil { - return err + // run dependency analysis only when full mode is set + if a.mode == string(provider.FullAnalysisMode) { + a.log.Info("running dependency analysis", + "log", depsLogFilePath, "input", a.input, "output", a.output, "args", strings.Join(args, " ")) + a.log.Info("generating dependency log in file", "file", depsLogFilePath) + err = NewContainer(a.log).Run( + ctx, + WithStdout(dependencyLog), + WithStderr(dependencyLog), + WithVolumes(volumes), + WithEntrypointBin("/usr/bin/konveyor-analyzer-dep"), + WithEntrypointArgs( + fmt.Sprintf("--output-file=%s", DepsOutputMountPath), + fmt.Sprintf("--provider-settings=%s", ProviderSettingsMountPath), + ), + WithCleanup(a.cleanup), + ) + if err != nil { + return err + } + } else { + a.log.Info("skipping dependency analysis", "mode", a.mode) } return nil @@ -843,10 +848,13 @@ func (a *analyzeCommand) GenerateStaticReport(ctx context.Context) error { args := []string{} staticReportArgs := []string{"/usr/local/bin/js-bundle-generator", fmt.Sprintf("--analysis-output-list=%s", AnalysisOutputMountPath), - fmt.Sprintf("--deps-output-list=%s", DepsOutputMountPath), fmt.Sprintf("--output-path=%s", path.Join("/usr/local/static-report/output.js")), fmt.Sprintf("--application-name-list=%s", filepath.Base(a.input)), } + if a.mode == string(provider.FullAnalysisMode) { + staticReportArgs = append(staticReportArgs, + fmt.Sprintf("--deps-output-list=%s", DepsOutputMountPath)) + } cpArgs := []string{"&& cp -r", "/usr/local/static-report", OutputPath}