diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 765be24..0cdb591 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -74,7 +74,7 @@ jobs: - name: Run analysis test and copy output run: | - RUNNER_IMG=localhost/kantra:latest ./kantra analyze --input $(pwd)/example-applications/example-1/ --output ./output/ --rules ./test-data/jni-native-code-test.windup.xml --target cloud-readiness + RUNNER_IMG=localhost/kantra:latest ./kantra analyze --input $(pwd)/example-applications/example-1/ --output ./output/ --rules ./test-data/jni-native-code-test.windup.xml --target cloud-readiness --run-local false # TODO (pgaikwad): Change this to a yaml test and run `kantra test` - name: Fail if analysis output does not match expected diff --git a/cmd/analyze.go b/cmd/analyze.go index 287fe17..0adab2f 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -148,6 +148,7 @@ type analyzeCommand struct { volumeName string providerContainerNames []string cleanup bool + runLocal bool // for containerless cmd reqMap map[string]string @@ -175,7 +176,7 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command { return err } } - if Settings.RunLocal { + if analyzeCmd.runLocal { err := analyzeCmd.setKantraDir() if err != nil { analyzeCmd.log.Error(err, "unable to get analyze reqs") @@ -200,12 +201,9 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command { defer stop() // ***** RUN CONTAINERLESS MODE ***** - if Settings.RunLocal { - if analyzeCmd.listProviders { - log.Info("\n containerless analysis mode set; only java provider supported") - return nil - } - log.Info("\n running analysis in containerless mode") + + if analyzeCmd.runLocal { + log.Info("\n --run-local set. running analysis in containerless mode") if analyzeCmd.listSources || analyzeCmd.listTargets { err := analyzeCmd.listLabelsContainerless(ctx) if err != nil { @@ -221,7 +219,7 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command { return nil } - log.Info("RUN_LOCAL not set. running analysis in container mode") + log.Info("--run-local not set. running analysis in container mode") // ******* RUN CONTAINERS ****** if analyzeCmd.overrideProviderSettings == "" { @@ -378,6 +376,7 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command { analyzeCommand.Flags().StringArrayVarP(&analyzeCmd.depFolders, "dependency-folders", "d", []string{}, "directory for dependencies") analyzeCommand.Flags().StringVar(&analyzeCmd.overrideProviderSettings, "override-provider-settings", "", "override the provider settings, the analysis pod will be run on the host network and no providers will be started up") analyzeCommand.Flags().StringArrayVar(&analyzeCmd.provider, "provider", []string{}, "specify which provider(s) to run") + analyzeCommand.Flags().BoolVar(&analyzeCmd.runLocal, "run-local", true, "run Java anlysis in containerless mode") return analyzeCommand } @@ -392,7 +391,7 @@ func (a *analyzeCommand) Validate(ctx context.Context) error { // Validate source labels if len(a.sources) > 0 { var sourcesRaw bytes.Buffer - if Settings.RunLocal { + if a.runLocal { a.fetchLabelsContainerless(ctx, true, false, &sourcesRaw) } else { a.fetchLabels(ctx, true, false, &sourcesRaw) @@ -413,7 +412,7 @@ func (a *analyzeCommand) Validate(ctx context.Context) error { // Validate target labels if len(a.targets) > 0 { var targetRaw bytes.Buffer - if Settings.RunLocal { + if a.runLocal { a.fetchLabelsContainerless(ctx, false, true, &targetRaw) } else { a.fetchLabels(ctx, false, true, &targetRaw) diff --git a/cmd/settings.go b/cmd/settings.go index cf4d5d4..0e58a0c 100644 --- a/cmd/settings.go +++ b/cmd/settings.go @@ -27,15 +27,6 @@ func (c *Config) Load() error { if err := c.loadCommandName(); err != nil { return err } - runContainerlessStr := os.Getenv("RUN_LOCAL") - if runContainerlessStr != "" && runContainerlessStr == "true" { - err := env.Set(c) - if err != nil { - return err - } - // do not need other env vars for containerless analysis - return nil - } if err := c.loadDefaultPodmanBin(); err != nil { return err }