oscope-dev / scope

Scoping user machines
https://oscope-dev.github.io/scope/
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Use templates for report rendering #124

Closed noizwaves closed 5 months ago

noizwaves commented 5 months ago

This PR refactors the report rendering implementation to use jinja templates. This paves the way for per-location or configurable templates.

Tests of report rendering were also added. There is a lot of new code added here, and some feels duplicative. I'd like to follow up this PR with a refactoring one that massages things a little more.

Manual test output to follow in comments.

noizwaves commented 5 months ago

cargo run doctor run --working-dir examples/ --only fail

There was an error!

When running scope doctor run scope ran into an error

Additional Capture Data

Name Value
node
nodeVersion File node -v was not executable or it did not exist.
ruby
username adam

Group fail

Action fail/file-exists


Check Command: echo "found file examples//file-mod.txt"

Output:

found file examples//file-mod.txt
Name Value
Exit code 0
Started at 2024-05-16 14:57:49.092031418 UTC
Finished at 2024-05-16 14:57:49.093622701 UTC

Check Command: test -f examples//file-mod.txt

Name Value
Exit code 1
Started at 2024-05-16 14:57:49.093781036 UTC
Finished at 2024-05-16 14:57:49.095098898 UTC

Fix Command: echo examples//file-mod.txt

Output:

examples//file-mod.txt
Name Value
Exit code 0
Started at 2024-05-16 14:57:49.095241627 UTC
Finished at 2024-05-16 14:57:49.096706633 UTC

Verify Command: echo "found file examples//file-mod.txt"

Output:

found file examples//file-mod.txt
Name Value
Exit code 0
Started at 2024-05-16 14:57:49.096911474 UTC
Finished at 2024-05-16 14:57:49.098248701 UTC

Verify Command: test -f examples//file-mod.txt

Name Value
Exit code 1
Started at 2024-05-16 14:57:49.098382405 UTC
Finished at 2024-05-16 14:57:49.099697047 UTC

Additional Capture Data

Name Value
who am i uid=1000(adam) gid=1000(adam) groups=1000(adam),4(adm),27(sudo),124(lpadmin),999(docker)
noizwaves commented 5 months ago

cargo run report --working-dir examples/ -- echo foobar

There was an error!

When running echo foobar scope ran into an error

Command echo foobar

Output:

foobar
Name Value
Exit code 0
Started at 2024-05-16 14:56:31.136405913 UTC
Finished at 2024-05-16 14:56:31.138138872 UTC

Additional Capture Data

Name Value
node
nodeVersion File node -v was not executable or it did not exist.
ruby
username adam