-
Notifications
You must be signed in to change notification settings - Fork 113
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
Write sbom.legacy.json files for newer platform api #825
Conversation
Signed-off-by: Natalie Arellano <[email protected]>
215eefe
to
7707bea
Compare
func WriteTOML(path string, data interface{}) error { | ||
if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil { | ||
return err | ||
} | ||
f, err := os.Create(path) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
return toml.NewEncoder(f).Encode(data) | ||
} | ||
|
||
func ReadGroup(path string) (buildpack.Group, error) { | ||
var group buildpack.Group | ||
_, err := toml.DecodeFile(path, &group) | ||
return group, err | ||
} | ||
|
||
func ReadOrder(path string) (buildpack.Order, error) { | ||
var order struct { | ||
Order buildpack.Order `toml:"order"` | ||
} | ||
_, err := toml.DecodeFile(path, &order) | ||
return order.Order, err | ||
} |
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.
These functions are unused. I think we forgot to delete them in an earlier PR.
builder.go
Outdated
if err := encoding.WriteJSON(filepath.Join(b.LayersDir, "sbom", "launch", "sbom.legacy.json"), launchBOM); err != nil { | ||
return nil, errors.Wrap(err, "encoding launch bom") | ||
} | ||
launchBOM = []buildpack.BOMEntry{} // zero out bom in <layers>/config/metadata.toml |
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.
This will have the effect of producing a null bom, as opposed to omitting it, because of here. I don't think this is what we want...
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.
Fixed in db5d4af - thanks @jabrown85 for the suggestion!
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Due to limitations of our TOML library, we can't add MarshalTOML to the top-level struct. Signed-off-by: Natalie Arellano <[email protected]>
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.
Added a couple suggestions, but overall looks good to me!
Signed-off-by: Natalie Arellano <[email protected]>
Resolves #808