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

chore: expose manifest reading and jsonwall as packages #182

Merged
merged 23 commits into from
Jan 27, 2025

Conversation

letFunny
Copy link
Collaborator

@letFunny letFunny commented Dec 13, 2024

  • Have you signed the CLA?

References:

Relevant excerpts:

/pkg
Library code that's ok to use by external applications (e.g., /pkg/mypubliclib). Other projects will import these libraries > expecting them to work, so think twice before you put something here
link

@letFunny letFunny changed the title chose: expose manifest reading and jsonwall as packages chore: expose manifest reading and jsonwall as packages Dec 13, 2024
@letFunny letFunny added the Polish Refactorings, etc label Dec 13, 2024
@letFunny letFunny mentioned this pull request Dec 13, 2024
Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll likely need to add the new licensing headers to each one of these source files

@letFunny letFunny marked this pull request as ready for review January 7, 2025 10:22
Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding the licensing headers. they lgtm

@cjdcordeiro
Copy link
Collaborator

Note

pls ignore the failed RTD check. I've enabled the automatic generation of PR docs, which will start passing once #185 is merged

@letFunny letFunny requested a review from cjdcordeiro January 7, 2025 17:55
@letFunny letFunny added the Blocked Waiting for something external label Jan 8, 2025
@letFunny
Copy link
Collaborator Author

letFunny commented Jan 8, 2025

I am blocking this until we solve all the questions regarding copyright and licensing.

@letFunny letFunny removed the Blocked Waiting for something external label Jan 16, 2025
@@ -0,0 +1,89 @@
package main
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Comment for reviewer]: This script for the CI is the only new code, the rest is all moved.

@@ -0,0 +1,54 @@
// SPDX-License-Identifier: Apache-2.0

package testutil
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question for reviewer]: I am not fond of naming this one testutil because it could conflict with the regular internal/testutil, however I wanted to convey that this functions are only to be used in tests.

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0

package util
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is util just like we discussed.

[Comment for reviewer]: I have also moved the packages under the apache/ namespace so that the license difference is visual in the directory structure. I am not sure that is the best way to organize it.

@letFunny letFunny added the Priority Look at me first label Jan 16, 2025
Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of the licenses and adding the CI ;) it lgtm from a structural point of view

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Probably final details:

// Validate checks that the Manifest is valid. Note that to do that it has to
// load practically the whole manifest into memory and unmarshall all the
// entries.
func Validate(manifest *Manifest) (err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we exposing this right now? We may get in trouble by making this public without considering the details of cross-version support. Right now all this function cares about is "Can the chisel bin handle this file?", and today that's trivial because there's literally zero features from Chisel that allow reading it on request, so lots of uncertainty. Once we make this logic public, though, people are free to link against their own code, and this function will need to do a good job of reporting about all past and future versions of the manifest, which it currently does not.

This issue makes me wonder whether we're missing something else. Before this PR goes in, can we please have a printout by godoc of the public/ packages in some pastebin, so we can have a quick review on the API alone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed the exports in the meeting but probably we went over them too fast. This is the pastebin: https://pastebin.canonical.com/p/cDwhTmqpvr/.

In the case of the Validate is was thinking about it in terms of compatibility with the linked current version of the library and to also check for internal consistency. I am not sure I understand what you are saying, but given that we also include the manifest type and fields, isn't there a reasonable expectation that if we change the format old versions of Chisel won't be able to read it anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember the many issues we had to overcome recently about changing chisel.yaml and the consequences for past and future revisions? Now imagine such issues on a file that is actually impossible to update, because there are baked images out there carrying the old format for good. Not only that, but we also have code out there, that we cannot update ourselves, that manipulate such files.

isn't there a reasonable expectation that if we change the format old versions of Chisel won't be able to read it anyway?

Have you reviewed the existing code with the mindset that it must not trust on details that could break future tweaking of the file? It's quite possible that it's totally okay, but I haven't at least. Let me draw a trivial analogy: imagine a JSON parser - depending on how you build it, it's possible you can break the parser without breaking the format. One is a specification, the other is an algorithm. Does that make more sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One is a specification, the other is an algorithm

That made the point clear, I get it now.

@@ -43,7 +43,7 @@ type Package struct {
type Slice struct {
Package string
Name string
Essential []SliceKey
Essential []SetupKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a "setup key"? This used to be the key for a package slice, thus SliceKey.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you had decided that it was a better name when you used it in your previous comment :). I see now that it was a typo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry about that.

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the changes.

@niemeyer niemeyer merged commit ad87b0b into canonical:main Jan 27, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Polish Refactorings, etc Priority Look at me first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants