diff --git a/cmd/analyze-bin.go b/cmd/analyze-bin.go index f549036..6577fd9 100644 --- a/cmd/analyze-bin.go +++ b/cmd/analyze-bin.go @@ -215,7 +215,31 @@ func (a *analyzeCommand) RunAnalysisContainerless(ctx context.Context) error { } func (a *analyzeCommand) ValidateContainerless(ctx context.Context) error { - // validate mvn and openjdk install + // validate mvn, python, and openjdk install + // windows does not use python3 as executable name + if runtime.GOOS == "windows" { + cmd := exec.Command("python", "--version") + output, err := cmd.Output() + if err != nil { + return err + } + version := strings.TrimSpace(string(output)) + pythonVersionStr := strings.Split(version, " ") + versionStr := strings.Split(pythonVersionStr[1], ".") + versionInt, err := strconv.Atoi(versionStr[0]) + if err != nil { + return err + } + if versionInt < 3 { + return fmt.Errorf("%w cannot find requirement python3; ensure python3 is installed", err) + } + } else { + _, pythonErr := exec.LookPath("python3") + if pythonErr != nil { + return fmt.Errorf("%w cannot find requirement python3; ensure python3 is installed", pythonErr) + + } + } _, mvnErr := exec.LookPath("mvn") if mvnErr != nil { return fmt.Errorf("%w cannot find requirement maven; ensure maven is installed", mvnErr) @@ -238,6 +262,9 @@ func (a *analyzeCommand) ValidateContainerless(ctx context.Context) error { return fmt.Errorf("cannot find requirement openjdk17+; ensure openjdk17+ is installed") } } + if os.Getenv("JAVA_HOME") == "" { + return fmt.Errorf("JAVA_HOME is not set; ensure JAVA_HOME is set") + } // Validate .kantra in home directory and its content (containerless) requiredDirs := []string{a.kantraDir, filepath.Join(a.kantraDir, RulesetsLocation), filepath.Join(a.kantraDir, JavaBundlesLocation), filepath.Join(a.kantraDir, JDTLSBinLocation)} diff --git a/cmd/cleanup.go b/cmd/cleanup.go index 083589d..cdf3078 100644 --- a/cmd/cleanup.go +++ b/cmd/cleanup.go @@ -4,6 +4,7 @@ import ( "context" "os" "os/exec" + "runtime" ) func (a *analyzeCommand) CleanAnalysisResources(ctx context.Context) error { @@ -83,6 +84,11 @@ func (a *analyzeCommand) RmProviderContainers(ctx context.Context) error { } func (a *analyzeCommand) cleanlsDirs() error { + // TODO clean this up for windows + // currently a perm issue with deleting these dirs + if runtime.GOOS == "windows" { + return nil + } a.log.V(7).Info("removing language server dirs") // this assumes dirs created in wd lsDirs := []string{ diff --git a/docs/containerless.md b/docs/containerless.md index 03b72a0..e52caa6 100644 --- a/docs/containerless.md +++ b/docs/containerless.md @@ -1,10 +1,12 @@ # Run Containerless Kantra -Have OpenJDK 17+ and Maven installed +Have OpenJDK 17+, Maven, and python3 installed + +Have $JAVA_HOME set. ## Download kantra and requirements: -Download appropriate zip for your OS [here](https://github.com/konveyor/kantra/releases/tag/v0.6.0-alpha.1) +Download appropriate zip for your OS [here](https://github.com/konveyor/kantra/releases/tag/v0.6.0-alpha.2) ## Move kantra binary to your $PATH: @@ -12,14 +14,17 @@ Download appropriate zip for your OS [here](https://github.com/konveyor/kantra/r mv $HOME/kantra../-kantra /usr/bin ``` -### Move requirements to kantra known location: +### Move requirements to kantra known location, or run kantra from the current directory: +*Note:* kantra will first look for these requirements in the current dir, and fall back to the path below. + ```sh mv $HOME/kantra.. $HOME/.kantra ``` ## Run analysis: +Kantra will default to running containerless analysis. To run analysis in containers, use the `--run-local=false` option. ```sh -kantra analyze-bin --input --output --rules +kantra analyze --input --output --rules ```