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

Refactor Exporter in CLI #230

Merged
merged 1 commit into from
Apr 6, 2023
Merged

Refactor Exporter in CLI #230

merged 1 commit into from
Apr 6, 2023

Conversation

chrisgacsal
Copy link
Contributor

@chrisgacsal chrisgacsal commented Apr 3, 2023

Description

Split logic implemented by Exporter into state.Manager and presenter.Presenter interfaces to separate responsibilities of managing state of the TargetScan (e.g. moving its status to InProgress) and how the scan results are presented (e.g. pulished to VMClarity API, written to console/file, etc.). These two interfaces are grouped together in the cli.CLI making the functionality provided both available via a single object.

State

The state.Manager has two implementations:

  • state.VMClarity stores state updates to the VMClarity API
  • state.Local is responsible to store/manage state locally

Presenter

The presenter.Presenter has the following implementations:

  • presenter.ConsolePresenter allows printing scan results to the terminal/console
  • presenter.FilePresenter saves scan results to files
  • presenter.MultiPresenter allows combining multiple presenter.Presenter implementations
  • presenter.VMClarityPresenter responsible for publishing scan results to the VMClarity API

Type of Change

[ ] Bug Fix
[ ] New Feature
[ ] Breaking Change
[x] Refactor
[ ] Documentation
[ ] Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

cli/pkg/cli/state/state.go Outdated Show resolved Hide resolved
cli/pkg/cli/cli.go Outdated Show resolved Hide resolved
cli/pkg/cli/cli.go Outdated Show resolved Hide resolved
cli/pkg/cli/cli.go Outdated Show resolved Hide resolved
cli/pkg/cli/state/state.go Outdated Show resolved Hide resolved
cli/pkg/cli/state/null.go Outdated Show resolved Hide resolved
cli/cmd/root.go Outdated Show resolved Hide resolved
@chrisgacsal chrisgacsal force-pushed the refactor-cli branch 5 times, most recently from 2b3378d to 6a805d2 Compare April 5, 2023 07:38
@chrisgacsal chrisgacsal requested review from FrimIdan and a user April 5, 2023 07:39
@chrisgacsal chrisgacsal force-pushed the refactor-cli branch 4 times, most recently from 380b95b to 426ce34 Compare April 5, 2023 12:51
cli/cmd/root.go Outdated Show resolved Hide resolved
cli/pkg/presenter/vmclarity.go Outdated Show resolved Hide resolved
cli/pkg/presenter/writer.go Outdated Show resolved Hide resolved
cli/pkg/state/vmclarity.go Outdated Show resolved Hide resolved
cli/pkg/state/vmclarity.go Outdated Show resolved Hide resolved
ghost
ghost previously approved these changes Apr 6, 2023
ghost
ghost previously approved these changes Apr 6, 2023
@chrisgacsal chrisgacsal merged commit 95f1211 into main Apr 6, 2023
5 checks passed
@chrisgacsal chrisgacsal deleted the refactor-cli branch April 6, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants