-
Notifications
You must be signed in to change notification settings - Fork 588
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
Add template func hasField
, update README
#1754
Conversation
Hey, thanks @jlehman9 ! would you be able to add a simple test that executes this function with a template? |
hasField
, update README
I have no idea what I'm doing since I don't really know Go, but I think I've got tests working that test the hasField function. Let me know if there is anything else I can do/fix/etc. |
It looks like there are quite a few failing tests due to the changes, maybe just make a new test? Also, you'll need to sign-off your commits. |
- Adds the template function hasField. - Allows template to check if a field is defined in a struct - Update README.md to document custom template functions. Signed-off-by: Lehman, Alex <alex.lehman@gtri.gatech.edu>
Signed-off-by: Lehman, Alex <alex.lehman@gtri.gatech.edu>
This reverts commit df49fa9. Signed-off-by: Lehman, Alex <alex.lehman@gtri.gatech.edu>
Create a new test and supporting test functions for the new hasField template function Signed-off-by: Lehman, Alex <alex.lehman@gtri.gatech.edu>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I believe I've undone my previous poor commit, created a separate test, re-signed the bad commit, and ensured all of the tests pass on my local machine. Hopefully all is good? Previously I had improperly assumed that the failing tests were all due to my local environment, mainly due to not having docker daemon installed since I usually run docker from minikube but the tests couldn't see that. Sorry about that! |
Thanks for the contribution @jlehman9! |
* main: chore(deps): bump modernc.org/sqlite from 1.21.2 to 1.22.0 (#1758) chore: go-rpmdb update (#1757) chore(deps): bump github.com/CycloneDX/cyclonedx-go from 0.7.1-0.20221222100750-41a1ac565cce to 0.7.1 (#1706) fix: Improve pnpm support (#1752) feat: Add template func `hasField` (#1754) fix: only cache java packages and not source content (#1750) Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Lehman, Alex <alex.lehman@gtri.gatech.edu>
This came from an issue I faced trying to write a CSV template function that grabbed vendor/author/publisher data. Unfortunately those fields aren't always defined for every package, and attempting to access them will cause Syft to exit with something like
* template: csv.tmpl:3:55: executing "csv.tmpl" at <.Metadata.Author>: can't evaluate field Author in type interface {}
I figured it would also be good to document the where the functions are defined in the
README.md
so others can see they exist and offer new ones.Thanks to @kzantow for the help discovering this solution!