Skip to content

chore: expose manifest reading and jsonwall as packages - #182

Merged
niemeyer merged 23 commits into
canonical:mainfrom
letFunny:move-jsonwall-manifest
Jan 27, 2025
Merged

niemeyer merged 23 commits into
canonical:mainfrom
letFunny:move-jsonwall-manifest

Conversation

@letFunny

@letFunny letFunny commented Dec 13, 2024 •

Copy link
Copy Markdown
Collaborator
  • 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

@cjdcordeiro cjdcordeiro left a comment

Copy link
Copy Markdown
Collaborator

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

@cjdcordeiro cjdcordeiro left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Comment thread pkg/manifest/manifest.go Resolved
Comment thread pkg/manifest/manifest_test.go Resolved
@letFunny letFunny added the Blocked Waiting for something external label Jan 8, 2025
@letFunny

letFunny commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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.

Comment thread internal/apache/testutil/manifest.go Outdated
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: Apache-2.0

package testutil

Copy link
Copy Markdown
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.

Comment thread internal/apache/util/util.go Outdated
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0

package util

Copy link
Copy Markdown
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

@cjdcordeiro cjdcordeiro left a comment

Copy link
Copy Markdown
Collaborator

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

@niemeyer niemeyer left a comment

Copy link
Copy Markdown
Contributor

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:

Comment thread cmd/chisel/cmd_info.go Resolved
Comment thread pkg/manifest/manifest.go Outdated
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread internal/manifestutil/manifestutil.go Resolved
Comment thread internal/setup/setup.go Outdated
Package string
Name string
Essential []SliceKey
Essential []SetupKey

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@niemeyer niemeyer left a comment

Copy link
Copy Markdown
Contributor

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
@letFunny
letFunny deleted the move-jsonwall-manifest branch April 30, 2025 08:27
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