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 source creation and add --from flag #2610

Merged
merged 47 commits into from Feb 27, 2024

Conversation

kzantow
Copy link
Contributor

@kzantow kzantow commented Feb 8, 2024

This PR makes the following high-level changes:

  • The source.Detect function has been removed, instead use:
  • the syft.GetSource function, which has been added as the entrypoint to use syft defined sources
  • 3 source types have been moved to their respective packages:
    • source/filesource
    • source/directorysource
    • source/stereoscopesource
  • A --from flag is added, allowing the user to select the source(s) to use
  • An exported source/sourceproviders package has been added which defines the set of tagged providers Syft implements, available by calling the the All function

Closes #1783

TODO:

  • determine if/what replacement test should be implemented for syft/source/detection_test.go, as there isn't the same need to test the "detection" aspect, but there probably are still some valid test cases here
  • revisit error handling from sources e.g. should we display each file not found with potentially more info?
  • is the testutil.Chdir(t, "..") acceptable? (at least as part of this PR to limit the changes)
  • correct behavior for generateSBOMForAttestation?

Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some of the source/* packages should be a little more consistent:

  • filesource: good as is
  • directory -> directorysource
  • stereoscope -> stereoscopesource

syft/source_providers.go Outdated Show resolved Hide resolved
syft/source/provider.go Outdated Show resolved Hide resolved
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
syft/get_source.go Outdated Show resolved Hide resolved
syft/testutil/chdir.go Outdated Show resolved Hide resolved
syft/get_source.go Outdated Show resolved Hide resolved
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great refactor! 💯

Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
@kzantow kzantow merged commit a978966 into anchore:main Feb 27, 2024
11 checks passed
@kzantow kzantow deleted the feat/from-flag branch February 27, 2024 21:44
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.

Allow source type input via CLI flag (not scheme)
2 participants