Skip to content

Code reorg - #234

Open
ckreibich wants to merge 18 commits into
masterfrom
topic/christian/code-reorg
Open

Code reorg#234
ckreibich wants to merge 18 commits into
masterfrom
topic/christian/code-reorg

Conversation

@ckreibich

Copy link
Copy Markdown
Member

@bbannier this is the bulk of the changes I've been sitting on that we've discussed. In essence it's moving all of the commands out of zkg into zeekpkg.cli, the introduction of a config class, a UI abstraction, and some minor tweaks.

Some minor behavior changes slipped in there that don't need to be there, such as 04a8580. We could postpone these until later — I don't feel strongly.

I'll make this a draft PR since I imagine you have opinions about it, and I don't mean for this to cause conflicts with other PRs in flight.

@bbannier
bbannier force-pushed the topic/christian/code-reorg branch from b2b7a57 to 61783ff Compare July 6, 2026 16:17
Comment thread zeekpkg/config.py Outdated
Comment thread zeekpkg/config.py Outdated
Comment thread zeekpkg/logs.py Outdated
Comment thread zeekpkg/manager.py Outdated
Comment thread zeekpkg/config.py Outdated
Comment thread zeekpkg/manager.py Outdated
Comment on lines +3165 to +3168
# XXX instead of magic handling of tarfiles, it'd be nicer
# to have separate keywords for shipping archives.
# Since it only seems to make sense for pre-built plugins
# and their dependencies, perhaps plugin_archive.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suspect this could be implemented on top of #236, maybe let's add a comment there and I can work on incorporating it, or let's add an issue sketching what you had in mind.

Comment thread zeekpkg/logs.py Outdated
Comment thread zeekpkg/config.py
Comment thread zeekpkg/ui.py
Comment thread zeekpkg/cli.py
@ckreibich

Copy link
Copy Markdown
Member Author

Okay Benjamin, I'm getting on this one now — will work in edits and rebase, then take out of draft.

@ckreibich
ckreibich force-pushed the topic/christian/code-reorg branch from 61783ff to 6c8d8a4 Compare August 14, 2026 01:12
This moves all directory information into a new Config class that captures zkg's
internal configuration, based on its config file.

The motivation here is that the Manager class does not need to manage this
information, and by making it available from a central configuration, other
classes can also leverage it (as opposed to having to live in the Manager).

It includes various consistency fixes: the zeek_dist path is only used when
actually present, and saving the configuration always uses a canonical
ordering (alphabetically, first by sections, then by options in each section).
The tests shouldn't reach out to Github for the default package source, unless
they explicitly need to.
Given that we already have a class for package sources, it makes more sense for
that functionality to live in that class, instead of the manager.

This also introduces a small tweak to the behavior of the refresh command,
prohibiting the use of "--push" without "--aggregate". There is no other local
modification to source repo clones.
@ckreibich
ckreibich force-pushed the topic/christian/code-reorg branch from 6c8d8a4 to a1a3a45 Compare August 14, 2026 01:40
@ckreibich ckreibich changed the title Code reorg, v1 Code reorg Aug 14, 2026
@ckreibich
ckreibich marked this pull request as ready for review August 14, 2026 01:42
@ckreibich

Copy link
Copy Markdown
Member Author

Alright! This is a full rebase and things seem to be working pretty well. This still has minor feature changes, which I think we should actually aim to keep for Zeek 9 (particularly aligning the handling of test and build logs, putting them in one place). But we can take that out of this one for subsequent PRs, doesn't matter to me.

@ckreibich

Copy link
Copy Markdown
Member Author

Btw I don't feel strongly about whether this should make Zeek 9 still. It's a big change to mainly put in place cleanups. I could also see shipping what's currently in master with 9 (so your new bundling approach etc), and considering this PR the starting point for all of the upcoming work.

@ckreibich
ckreibich force-pushed the topic/christian/code-reorg branch 2 times, most recently from 2b76cf6 to 9eae9d5 Compare August 17, 2026 23:55
@ckreibich
ckreibich requested a review from bbannier August 18, 2026 00:01
ckreibich and others added 12 commits August 17, 2026 17:16
Also, no longer create the `zkg.test_command` logs buried in the test clone.
This mirrors how we already produce the `<package>-build.log` in the log
directory for packages that have a `build_command`.
This avoids circular dependencies when removing the amount of from-import
statements into the toplevel zeekpkg module, in the next changeset.
The zeekpkg.cli module produces the argument parser and contains the various
commands. It leaves a single print() in zkg.py (redundantly to
_util.print_error()), which is temporary until we introduce a UI abstraction.
This further shrinks the toplevel zkg script.
The "zkg list" command would previously preserve any opening quotation marks,
but since it cuts off the description after the first sentence this would look
broken. Such surrounding quotes are now never rendered in the output.
This provides UserInterface, an abstract base class for user input/output.
Implementations can adapt to the environment (TTY, file I/O, etc).
It includes one implementation, PlainUI, for basic plaintext I/O.
Future additions might be textualize/rich etc.

This also generalizes the notion of InstallWorker into a range of activities
undertaken by zkg, which allows treating trackable ones via a progress bar, etc.

This does not alter the current split of messages to stdout/stderr. It tweaks
the message prefix slightly for consistency, which touches a few baselines but
makes no deeper changes otherwise.
There is no more templating around PY_MOD_INSTALL_DIR etc.
@ckreibich
ckreibich force-pushed the topic/christian/code-reorg branch from 9eae9d5 to c6fdb8a Compare August 18, 2026 00:18
@ckreibich

Copy link
Copy Markdown
Member Author

All yours Benjamin. I missed one change in our conversation today, 40f995d. It'd be nice to have because it's long been too onerous to locate test log output, but we can take it out of this PR.

If I've not addressed any of your comments at this point, that's an oversight.

@bbannier bbannier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for iterating. I went through all the issues and resolved most of them. I left a small number open which were about creating concrete follow-up issues.

After that I made another pass and ran a few tests, and found a few remaining regressions which I opened issues for. I believe most of these should be simple to fix.

Comment thread zeekpkg/config.py
Comment thread zeekpkg/config.py
Comment thread zkg Outdated
Comment thread zeekpkg/config.py

@bbannier bbannier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks good for me but for a tiny regression, opened a new issue.

I went through and again resolved all addressed threads. We still have open issues where you wanted to create issues for existing bugs/shortcomings, could you do that before moving on?

Comment thread zkg
zeekpkg.UI.error("Permission problems prevent zkg from creating internal state")
if not args.user:
zeekpkg.UI.error(
"Consider the --user flag to manage zkg state via {home_config_dir()}/config",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was an f-string before.

Suggested change
"Consider the --user flag to manage zkg state via {home_config_dir()}/config",
f"Consider the --user flag to manage zkg state via {home_config_dir()}/config",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants