-
Notifications
You must be signed in to change notification settings - Fork 63
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
Adding minor versions: Versioning refactor proposal #152
Comments
@swinslow for visibility - we had a chat about this last week. |
I believe Part 1 / Goal 1 from your list should now be complete, with #146 merged? |
Yup! Going to move on to part 2!!
…On Wed, Aug 3, 2022, 2:54 PM Steve Winslow ***@***.***> wrote:
I believe Part 1 / Goal 1 from your list should now be complete, with #146
<#146> merged?
—
Reply to this email directly, view it on GitHub
<#152 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXLDBUQCA2DE6QFFHZCT53VXK55HANCNFSM54AJMETQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Regarding Part 2: common working struct: I would suggest this is always the latest SPDX version, and each version has a function to convert from the prior version (much of this could be handled through reflection). Of course this may be lossy when going between major versions, but I suspect in the long term it will result in fewer problems than trying to convert every version to a common working model that changes over time. The nice thing about this is it would at least allow converting an older SPDX version to a newer one, so it could cover half of the conversion case. |
Adding reference to issue which is related to this |
Done from the awesome work from @kzantow !! 🎉 |
Versioning refactor proposal
This design document covers a proposal for refactoring SPDX versioned structs with the goal of making the process of adding a new semantic minor version of the SPDX spec easier (e.g. with the coming introduction of 2.3).
Linked Issues:
Goals
Considerations and assumptions
Design proposal
Part 1: Re-organize structs
Addresses: Goal 1
The way in which version structs are usually defined in goal, taking suite from projects such as kubernetes, is through the use of sub-packages. For example, with a format of type Document, with versions v1 and v2, the way to define them within the go project would be:
In the SPDX case this would be:
With SPDX 3 on the way, the folders can be organized as:
Part 2: Creating a common working struct
Addresses: Goals 2, 3, 4
The idea here revolves around performing most operations around SPDX structures within a single versioned struct. Similar to what other projects like containerd and other OCI libraries that need to handle operations across multiple versions of images (and specs), having a core canonical structure that expresses all the information required is going to make things easier to work with.
In the case of how SPDX semantic versioning is done, this comes fairly naturally. All new SPDX minor version are additive and backward compatible. Therefore, the latest version of the SPDX struct can be used as the common struct to perform operations on - with the possibility of adding additional metadata when required to "convert" back to the original format. This is a form of generics that works well because of how SPDX versions are defined.
Each SPDX minor version will have a conversion function where it can then be converted to the core struct. For example, there will be:
Each struct within the minor versions would have a conversion function:
The struct may look something like:
Each package can then implement functions just on the Core struct (for example, licensediff):
In addition to the code de-duplication, another bonus here is that we can operate on documents of different versions as well, while preserving version information within the metadata.
Alternatives
Struct codegen
This involves creating code that will generate the appropriate structs and helper functions for the SPDX objects. Given that a new release of SPDX spec doesn't happen that often, this probably may be overkill.
Golang generics
At the moment, generics are limited in their implementation and will generics based on struct fields are not implemented. This means for most of our uses for generics for would not be possible today. However, golang release notes do indicate that this may be supported in the future, but with no definite promises/roadmap. It is notable that code that is produced as part of this design proposal will be needed for use in generics as well, and so is a good stepping stone towards it.
The text was updated successfully, but these errors were encountered: