buildpacks / libcnb

A non-opinionated language binding for the Cloud Native Buildpack Buildpack and Extension specifications
Apache License 2.0
31 stars 13 forks source link

Add struct tag to Buildpack.Path field #86

Closed jghiloni closed 2 years ago

jghiloni commented 2 years ago

Most Go applications use github.com/burntsushi/toml as their toml parsing library. When struct tags are omitted, the library will do case-insensitive deserialization, so a property called path will successfully unmarshal into the Path struct field.

However, if youmarshal a Buildpack instance to toml, the Path field appears regardless of whether it is set or not, and technically violates the buildpack toml spec. This PR adds a struct tag to not only marshal the field to the path property in the resultant toml, but also adds the omitempty modifier to ignore the field altogether when not set.

This resolves #85

Signed-off-by: Josh Ghiloni jghiloni@vmware.com

dmikusa commented 2 years ago

I don't believe that path is part of the spec for buildpack.toml. My understanding is that libcnb adds this field so an author knows where the buildpack resides. I think we should just omit that field altogether if we're reading or writing a buildpack.toml.

jghiloni commented 2 years ago

That sounds good -- I'll add another commit changing that behavior