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

Bake ext.api.get_artifact_vulnerabilities into ext.api.get_artifacts #11

Open
pederhan opened this issue Nov 30, 2022 · 0 comments
Open

Comments

@pederhan
Copy link
Member

pederhan commented Nov 30, 2022

The two functions ext.api.get_artifacts and ext.api.get_artifact_vulnerabilities do more or less the same thing, except the latter also fetches the Harbor vulnerability report for the artifacts and populates the report field of the resulting ArtifactInfo objects.

They also operate on somewhat different resources; ext.api.get_artifacts can take a list of Projects or Repositories, while ext.api.get_artifact_vulnerabilities can only take a list of Projects.

Having two similar functions who have differing APIs (Project/Repos vs only Projects), where one directly calls the other is convoluted and inconsistent.

get_artifacts

https://github.com/pederhan/harborapi/blob/6b4e9f9c3fdf233819af0e33d862c63607f9f283/harborapi/ext/api.py#L245-L247

get_artifact_vulnerabilites

https://github.com/pederhan/harborapi/blob/6b4e9f9c3fdf233819af0e33d862c63607f9f283/harborapi/ext/api.py#L322-L329

Solution

We can add with_report as an optional parameter to ext.api.get_artifacts, where the reports are fetched if this parameter is True. By implementing the code found in ext.api.get_artifact_vulnerabilities, we can combine the functionality of both functions into a single function.

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

No branches or pull requests

1 participant