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

Switch UI to bubbletea #1888

Merged
merged 9 commits into from
Jul 6, 2023
Merged

Switch UI to bubbletea #1888

merged 9 commits into from
Jul 6, 2023

Conversation

wagoodman
Copy link
Contributor

@wagoodman wagoodman commented Jun 22, 2023

This PR adds a new bubbletea UI. This switch enables testing of each component, easier extension of components as-needed, single-point configurability when used as a lib (for grype). One of the larger changes with this PR isn't about how the lines are ultimately formatted but instead how all model updates are done in the same event loop without several continual background updates.

This PR also deprecates the existing jotframe-based UI (will be removed before syft 1.0).

Additionally makes the following changes:

  • fixes the attestation UI element to show up as soon as possible instead of when the first bytes arrive from the cosign execution.
  • adds report and notification event types and swaps over to using these for command results.
  • renames the CLI-only events to be prefixed with CLI to be more clear about the context of when the events are used (not part of the syft lib)
  • adds snapshot-based testing for UI components tested through the shared UI handler
  • adds the log redaction capabilities to allow for the UI to leverage filtering secrets in report output.
  • adds testing around the post-UI events (reports, notifications, app update notifications, etc)

Deferred work:

  • There is cleanup needed regarding events (which would be breaking technically), specifically:
    • monitor.GenericTask vs monitor.CatalogerTask seem to have semantic overlap. Can these be combined?
    • the monitor.CatalogerTask exposes progress.Manual instead of the read only progress.Progressable
    • The monitor.CatalogerTask doesn't have the ability to support multiple sub-tasks and may require a lot of rework to account for this.

Follow up PRs:

  • while working on this it was discovered that the application update UI element is broken. This requires major surgery now, however, if we wait until the port to the clio lib then this will automatically be fixed.

Closes #1441

@wagoodman wagoodman added enhancement New feature or request deprecated A functionality is being deprecated labels Jun 22, 2023
@github-actions
Copy link

github-actions bot commented Jun 22, 2023

Benchmark Test Results

Benchmark results from the latest changes vs base branch
goos: linux%0Agoarch: amd64%0Apkg: github.com/anchore/syft/test/integration%0Acpu: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz%0A                                                          │ ./.tmp/benchmark-2b605bf.txt │%0A                                                          │            sec/op            │%0AImagePackageCatalogers/alpmdb-cataloger-2                                   11.99m ±  1%25%0AImagePackageCatalogers/apkdb-cataloger-2                                    735.0µ ±  1%25%0AImagePackageCatalogers/binary-cataloger-2                                   203.0µ ±  2%25%0AImagePackageCatalogers/dpkgdb-cataloger-2                                   607.8µ ±  1%25%0AImagePackageCatalogers/dotnet-deps-cataloger-2                              1.266m ±  2%25%0AImagePackageCatalogers/go-module-binary-cataloger-2                         99.63µ ±  1%25%0AImagePackageCatalogers/java-cataloger-2                                     13.66m ±  1%25%0AImagePackageCatalogers/graalvm-native-image-cataloger-2                     96.37µ ±  1%25%0AImagePackageCatalogers/javascript-package-cataloger-2                       422.0µ ±  1%25%0AImagePackageCatalogers/nix-store-cataloger-2                                288.8µ ±  2%25%0AImagePackageCatalogers/php-composer-installed-cataloger-2                   829.3µ ±  1%25%0AImagePackageCatalogers/portage-cataloger-2                                  498.4µ ±  2%25%0AImagePackageCatalogers/python-package-cataloger-2                           3.455m ± 20%25%0AImagePackageCatalogers/r-package-cataloger-2                                217.4µ ± 15%25%0AImagePackageCatalogers/rpm-db-cataloger-2                                   576.4µ ±  1%25%0AImagePackageCatalogers/ruby-gemspec-cataloger-2                             956.2µ ±  1%25%0AImagePackageCatalogers/sbom-cataloger-2                                     121.6µ ±  0%25%0Ageomean                                                                     636.2µ%0A%0A                                                          │ ./.tmp/benchmark-2b605bf.txt │%0A                                                          │             B/op             │%0AImagePackageCatalogers/alpmdb-cataloger-2                                   5.114Mi ± 0%25%0AImagePackageCatalogers/apkdb-cataloger-2                                    204.7Ki ± 0%25%0AImagePackageCatalogers/binary-cataloger-2                                   30.18Ki ± 0%25%0AImagePackageCatalogers/dpkgdb-cataloger-2                                   169.1Ki ± 0%25%0AImagePackageCatalogers/dotnet-deps-cataloger-2                              405.5Ki ± 0%25%0AImagePackageCatalogers/go-module-binary-cataloger-2                         9.906Ki ± 0%25%0AImagePackageCatalogers/java-cataloger-2                                     2.826Mi ± 0%25%0AImagePackageCatalogers/graalvm-native-image-cataloger-2                     8.594Ki ± 0%25%0AImagePackageCatalogers/javascript-package-cataloger-2                       100.9Ki ± 0%25%0AImagePackageCatalogers/nix-store-cataloger-2                                49.13Ki ± 0%25%0AImagePackageCatalogers/php-composer-installed-cataloger-2                   186.6Ki ± 0%25%0AImagePackageCatalogers/portage-cataloger-2                                  119.9Ki ± 0%25%0AImagePackageCatalogers/python-package-cataloger-2                           1.003Mi ± 0%25%0AImagePackageCatalogers/r-package-cataloger-2                                53.29Ki ± 0%25%0AImagePackageCatalogers/rpm-db-cataloger-2                                   180.9Ki ± 0%25%0AImagePackageCatalogers/ruby-gemspec-cataloger-2                             144.1Ki ± 0%25%0AImagePackageCatalogers/sbom-cataloger-2                                     14.20Ki ± 0%25%0Ageomean                                                                     132.7Ki%0A%0A                                                          │ ./.tmp/benchmark-2b605bf.txt │%0A                                                          │          allocs/op           │%0AImagePackageCatalogers/alpmdb-cataloger-2                                    87.74k ± 0%25%0AImagePackageCatalogers/apkdb-cataloger-2                                     4.182k ± 0%25%0AImagePackageCatalogers/binary-cataloger-2                                     830.0 ± 0%25%0AImagePackageCatalogers/dpkgdb-cataloger-2                                    3.002k ± 0%25%0AImagePackageCatalogers/dotnet-deps-cataloger-2                               6.338k ± 0%25%0AImagePackageCatalogers/go-module-binary-cataloger-2                           281.0 ± 0%25%0AImagePackageCatalogers/java-cataloger-2                                      39.88k ± 0%25%0AImagePackageCatalogers/graalvm-native-image-cataloger-2                       228.0 ± 0%25%0AImagePackageCatalogers/javascript-package-cataloger-2                        1.404k ± 0%25%0AImagePackageCatalogers/nix-store-cataloger-2                                  895.0 ± 0%25%0AImagePackageCatalogers/php-composer-installed-cataloger-2                    4.079k ± 0%25%0AImagePackageCatalogers/portage-cataloger-2                                   2.268k ± 0%25%0AImagePackageCatalogers/python-package-cataloger-2                            16.43k ± 0%25%0AImagePackageCatalogers/r-package-cataloger-2                                  929.0 ± 0%25%0AImagePackageCatalogers/rpm-db-cataloger-2                                    3.989k ± 0%25%0AImagePackageCatalogers/ruby-gemspec-cataloger-2                              2.447k ± 0%25%0AImagePackageCatalogers/sbom-cataloger-2                                       394.0 ± 0%25%0Ageomean                                                                      2.582k

@wagoodman wagoodman force-pushed the use-bubbletea branch 2 times, most recently from ab94120 to a15a9db Compare June 22, 2023 18:41
@wagoodman wagoodman requested a review from a team June 22, 2023 18:43
@wagoodman wagoodman marked this pull request as ready for review June 22, 2023 18:54
@wagoodman wagoodman marked this pull request as draft June 22, 2023 18:59
@wagoodman wagoodman removed the request for review from a team June 22, 2023 18:59
@wagoodman wagoodman force-pushed the use-bubbletea branch 4 times, most recently from aa97bc7 to 37145c9 Compare June 23, 2023 17:35
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman marked this pull request as ready for review June 30, 2023 12:55
@wagoodman wagoodman requested a review from a team June 30, 2023 12:55
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@spiffcs spiffcs self-requested a review July 5, 2023 21:07
@spiffcs
Copy link
Contributor

spiffcs commented Jul 5, 2023

🟢 after pairing on the race condition in tests - thanks for the info!

@wagoodman wagoodman merged commit f8b832e into main Jul 6, 2023
@wagoodman wagoodman deleted the use-bubbletea branch July 6, 2023 13:00
spiffcs added a commit that referenced this pull request Jul 11, 2023
* main:
  feat: CLI flag for directory base (#1867)
  Fix CPE gen for k8s python client (#1921)
  chore: update iterations to protect against race (#1927)
  chore(deps): update bootstrap tools to latest versions (#1922)
  fix: Don't use the actual redis or grpc CPEs for gems (#1926)
  fix(install): return with right error code (#1915)
  Remove erroneous Java CPEs from generation (#1918)
  chore(deps): bump golang.org/x/net from 0.11.0 to 0.12.0 (#1916)
  Switch UI to bubbletea (#1888)
  fix: use filepath.EvalSymlinks if os.Readlink fails to evaluate the link (#1884)
  add file source digest support (#1914)
  chore(deps): update bootstrap tools to latest versions (#1908)
  chore(deps): bump golang.org/x/mod from 0.11.0 to 0.12.0 (#1912)
  chore(deps): bump golang.org/x/term from 0.9.0 to 0.10.0 (#1913)
  doc(readme): add installation section with scoop (#1909)
  Refactor source API (#1846)
  chore(deps): update bootstrap tools to latest versions (#1905)
This was referenced Jul 12, 2023
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* add bubbletea UI

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* swap pipeline to go 1.20.x and add attest guard for cosign binary

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* update note in developing.md about the required golang version

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix merge conflict for windows path handling

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* temp test for attest handler

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add addtional test iterations for background reader

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated A functionality is being deprecated enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace TUI library with bubbletea
2 participants