Skip to content

Commit

Permalink
Update containerless docs & reqs (#381) (#386)
Browse files Browse the repository at this point in the history
update containerless docs

Signed-off-by: Emily McMullan <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Co-authored-by: Emily McMullan <[email protected]>
  • Loading branch information
konveyor-ci-bot[bot] and eemcmullan authored Nov 25, 2024
1 parent 0d0102c commit 55eef9a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
29 changes: 28 additions & 1 deletion cmd/analyze-bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)}
Expand Down
6 changes: 6 additions & 0 deletions cmd/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"
"os/exec"
"runtime"
)

func (a *analyzeCommand) CleanAnalysisResources(ctx context.Context) error {
Expand Down Expand Up @@ -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{
Expand Down
13 changes: 9 additions & 4 deletions docs/containerless.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
# 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:

```sh
mv $HOME/kantra.<os>.<arch>/<os>-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.<os>.<arch> $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 <java-app> --output <output-dir> --rules <java-rules>
kantra analyze --input <java-app> --output <output-dir> --rules <java-rules>
```

0 comments on commit 55eef9a

Please sign in to comment.