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

Implement for_packages_append on Resource #43

Closed
JonoYang opened this issue Jul 29, 2022 · 3 comments
Closed

Implement for_packages_append on Resource #43

JonoYang opened this issue Jul 29, 2022 · 3 comments
Assignees

Comments

@JonoYang
Copy link
Contributor

We are updating the application package scanning process on scancode.io in nexB/scancode.io#447. We are implementing the package assembly step from scancode-toolkit in scancode.io. The assembly methods from packagedcode associates Resources to packages by appending the package_uid to the for_packages attribute on Resources. This method of associating Resources to Packages does not work on scancode.io because for_packages is an property on CodebaseResource that generates a list of purls from DiscoveredPackages associated with a CodebaseResource.

A solution would be to create a method on the Resource class named for_packages_append that appends a package_uid to Resource.for_packages. This extra level of indirection allows us to create a different implementation on CodebaseResource for associating Packages to Resources using the same interface.

@JonoYang JonoYang self-assigned this Jul 29, 2022
@pombredanne
Copy link
Member

re:

A solution would be to create a method on the Resource class named for_packages_append that appends a package_uid to Resource.for_packages

This can work.

An alternative could be use a new Codebase argument that would be the Resource class to use... today this class is crafted based on the provided attributes

def _build_resource_class(self, *args, **kwargs):

Another possibility could be to add and pass a add_to_package(resource, ...) method as an argument to the assemble(..., package_adder=add_to_package, ...) functions?
With a default that would be using a list-backed implementation... and then in SCIO you would have a Django db-backed implmentation of the same function and you would call it when you call assemble?

@JonoYang
Copy link
Contributor Author

JonoYang commented Jul 29, 2022

Another possibility could be to add and pass a add_to_package(resource, ...) method as an argument to the assemble(..., package_adder=add_to_package, ...) functions?
With a default that would be using a list-backed implementation... and then in SCIO you would have a Django db-backed implmentation of the same function and you would call it when you call assemble?

I like this approach better than the one I posted before. It makes more sense to pass in the package adding function as an argument into assemble than to add a method to Resource that deals with an attribute that may not be there.

@pombredanne
Copy link
Member

This has been implemented and merged in nexB/scancode-toolkit#3035
Thanks!

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

2 participants