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

Add docs for analyze and dev #109

Merged
merged 2 commits into from
Nov 2, 2023
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
48 changes: 1 addition & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ Flags:
Use "kantra [command] --help" for more information about a command.
```

Additionally, two environment variables control the container runtime and the kantra image: `PODMAN_BIN` and `RUNNER_IMG`:
- `PODMAN_BIN`: path to your container runtime (podman or docker); ie: `PODMAN_BIN=/usr/local/bin/docker`
- `RUNNER_IMG`: the tag of the kantra image to invoke; ie: `RUNNER_IMG=localhost/kantra:latest`

### Analyze

Expand Down Expand Up @@ -210,50 +207,7 @@ To run `transform rules` on application source code, run:
kantra transform rules --input=<path/to/xmlrules> --output=<path/to/output/dir>
```

## Quick Demos

Once you have kantra installed, these examples will help you run both an
analyze and a transform command.

### Analyze

- Get the example application to run analysis on
`git clone https://github.com/konveyor/example-applications`

- List available target technologies
`kantra analyze --list-targets`

- Run analysis with a specified target technology
`kantra analyze --input=<path-to/example-applications/example-1> --output=<path-to-output-dir> --target=cloud-readiness`

- Several analysis reports will have been created in your specified output path:

```sh
$ ls ./output/ -1
analysis.log
dependencies.yaml
dependency.log
output.yaml
static-report
```

`output.yaml` is the file that contains issues report.
`static-report` contains the static HTML report.
`dependencies.yaml`contains a dependencies report.

### Transform

- Get the example application to transform source code
`git clone https://github.com/ivargrimstad/jakartaee-duke`

- View available OpenRewrite recipes
`kantra transform openrewrite --list-targets`

- Run a recipe on the example application
`kantra transform openrewrite --input=<path-to/jakartaee-duke> --target=jakarta-imports`

- Inspect the `jakartaee-duke` application source code diff to see the transformation

### analyze and transform [examples](./docs/example.md)

## Code of Conduct
Refer to Konveyor's Code of Conduct [here](https://github.com/konveyor/community/blob/main/CODE_OF_CONDUCT.md).
11 changes: 11 additions & 0 deletions docs/analyzer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Analyzer-lsp Documentation

### kantra analyze runs [analyzer-lsp](https://github.com/konveyor/analyzer-lsp)

- To better understand how rules are used in analysis, see the [rules](https://github.com/konveyor/analyzer-lsp/blob/main/docs/rules.md)
documentation

- If a rule is matched, it creates a [violation](https://github.com/konveyor/analyzer-lsp/blob/main/docs/violations.md)

- [Labels](https://github.com/konveyor/analyzer-lsp/blob/main/docs/labels.md)
can be used to filter in and out rules
16 changes: 16 additions & 0 deletions docs/developer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Running kantra

Two environment variables control the container runtime and the kantra image: `PODMAN_BIN` and `RUNNER_IMG`:
- `PODMAN_BIN`: path to your container runtime (podman or docker)
- `RUNNER_IMG`: the tag of the kantra image to invoke

#### example:
eemcmullan marked this conversation as resolved.
Show resolved Hide resolved

`podman build -f Dockerfile -t kantra:dev`

`RUNNER_IMG=kantra:dev PODMAN_BIN=/usr/local/bin/podman go run main.go analyze --input=<path-to-src-application> --output=./output`

#### Helpful flags:

- To increase logs for debugging, you can set `--log-level` (default is 5)
- ie: `--log-level=7`
41 changes: 41 additions & 0 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Once you have kantra installed, these examples will help you run both an
analyze and a transform command.

### Analyze

- Get the example application to run analysis on
`git clone https://github.com/konveyor/example-applications`

- List available target technologies
`kantra analyze --list-targets`

- Run analysis with a specified target technology
`kantra analyze --input=<path-to/example-applications/example-1> --output=<path-to-output-dir> --target=cloud-readiness`

- Several analysis reports will have been created in your specified output path:

```sh
$ ls ./output/ -1
analysis.log
dependencies.yaml
dependency.log
output.yaml
static-report
```

`output.yaml` is the file that contains issues report.
`static-report` contains the static HTML report.
`dependencies.yaml`contains a dependencies report.

### Transform

- Get the example application to transform source code
`git clone https://github.com/ivargrimstad/jakartaee-duke`

- View available OpenRewrite recipes
`kantra transform openrewrite --list-targets`

- Run a recipe on the example application
`kantra transform openrewrite --input=<path-to/jakartaee-duke> --target=jakarta-imports`

- Inspect the `jakartaee-duke` application source code diff to see the transformation
15 changes: 15 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Output


#### Default rules:

- the analyze command runs against a set of packaged rules [here](https://github.com/konveyor/rulesets/)
- `--label-selector` and/or `--target` can filter these rules
- `--rules` can be provided to run analyze on rules outside of this set

#### `--rules` + `--target`

- In kantra, if a rule is given as well as a target, but the given rule **does not**
have the target label, the given rule will not match.
- You must add the target label to the custom rule (if applicable) in
order to run this rule.