Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update containerless docs & reqs #381

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
```
Loading