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

feat: single depGraph with subject #40

Merged
merged 1 commit into from
Jul 10, 2023
Merged

Conversation

tommyknows
Copy link
Contributor

This commit adds functionality to the sbom service, allowing users to pass in a single depGraph and a subject that will be honored.

To achieve this, we simply send the multi-depgraph body with only one depGraph, and the subject with it.

Additionally, I've switched from using raw strings to construct the body-JSON to using json.RawMessage and proper types / structs. This also means that I've had to make the Name and Version fields of the subject type public. And to make the subject's usage easier in external packages, I've made the Subject type itself public as well.

json.RawMessage is nice because it can be used to tell Go that a certain field is already raw JSON, and has never been fully decoded into a custom type. As such, when marshaling JSON, that RawMessage is simply added to the rest of the document without any changes.

This commit adds functionality to the sbom service, allowing users to
pass in a single depGraph *and* a subject that will be honored.

To achieve this, we simply send the multi-depgraph body with only one
depGraph, and the subject with it.

Additionally, I've switched from using raw strings to construct the
body-JSON to using `json.RawMessage` and proper types / structs. This
also means that I've had to make the `Name` and `Version` fields of the
`subject` type public. And to make the subject's usage easier in
external packages, I've made the `Subject` type itself public as well.

`json.RawMessage` is nice because it can be used to tell Go that a
certain field is already raw JSON, and has never been fully decoded into
a custom type. As such, when marshaling JSON, that `RawMessage` is
simply added to the rest of the document without any changes.
@tommyknows tommyknows requested a review from a team as a code owner June 27, 2023 12:02
@tommyknows tommyknows mentioned this pull request Jun 28, 2023
@tommyknows tommyknows merged commit c7df3a8 into main Jul 10, 2023
7 checks passed
@tommyknows tommyknows deleted the single-depgraph-with-subject branch July 10, 2023 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants