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

pybridge: Implement cockpit-bridge --version; some small cleanups #19234

Merged
merged 4 commits into from
Aug 31, 2023

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Aug 24, 2023

It was defined in argparse, but entirely ignored, so that it started the
protocol. Also add it to the manpage.

This also unbreaks the regular cockpit/ws container builds, as they use
--version to define the tag.

Add an integration test which exercises all non-protocol options.

Fixes #19233


See https://quay.io/repository/cockpit/ws?tab=tags , this stopped updating since we moved Fedora 38 to the pybridge.

@@ -270,6 +271,9 @@ def main(*, beipack: bool = False) -> None:
if args.packages:
Packages().show()
return
elif args.version:
print(f'Version: {__version__}\nProtocol: 1')
Copy link
Member Author

Choose a reason for hiding this comment

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

The C bridge looks like this:

Version: 287
Protocol: 1
Payloads: dbus-json3 http-stream1 http-stream2 stream packet fsread1 
    fsreplace1 fswatch1 fslist1 null echo websocket-stream1 
Authorization: crypt1

The "Authorization: crypt1" is hardcoded in the C bridge, and thus not really useful. We could implement "Payloads:" if we care, but I doubt it's actually useful.

Copy link
Member

Choose a reason for hiding this comment

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

For some reason the inconsistency of how we get the two newlines printed out is bothering me. I will ignore that little nag, though. :)

@martinpitt martinpitt force-pushed the pybridge-version branch 3 times, most recently from 2362493 to 09f5d87 Compare August 24, 2023 08:22
@martinpitt
Copy link
Member Author

Meh, this isn't worth the renaming, I backed out that commit from this PR.

test/verify/check-connection Outdated Show resolved Hide resolved
src/cockpit/bridge.py Outdated Show resolved Hide resolved
Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

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

As usual: the main part of the patch is fine but there's lots of bickering over the beifang ;)

src/cockpit/bridge.py Show resolved Hide resolved
src/cockpit/bridge.py Outdated Show resolved Hide resolved
@@ -270,6 +271,9 @@ def main(*, beipack: bool = False) -> None:
if args.packages:
Packages().show()
return
elif args.version:
print(f'Version: {__version__}\nProtocol: 1')
Copy link
Member

Choose a reason for hiding this comment

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

For some reason the inconsistency of how we get the two newlines printed out is bothering me. I will ignore that little nag, though. :)

@@ -62,12 +62,12 @@ def export(self, path: str, obj: bus.BaseObject) -> None:
class Bridge(Router, PackagesListener):
internal_bus: InternalBus
packages: Optional[Packages]
bridge_rules: List[JsonObject]
bridge_configs: List[BridgeConfig]
Copy link
Member

Choose a reason for hiding this comment

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

The commit message for this part is no longer accurate, since this was never a JsonObject...

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

This previously initialized `self.bridge_rules`, but never actually
updated it, due to the `bridge_configs` vs. `bridge_rules` confusion.
Change both the class member and the local variable to `bridge_configs`
to become consistent with `Packages.get_bridge_configs()`.

Fix the type of this rules list. mypy spotted this after fixing the
variable confusion.
It has never been in the manpage, it isn't implemented (it just starts
the protocol), and the C version's output is next to useless for users.

We can implement this if/when we ever get an use case.
It was defined in argparse, but entirely ignored, so that it started the
protocol. Also add it to the manpage.

This also unbreaks the regular cockpit/ws container builds, as they use
--version to define the tag.

Add an integration test which exercises all non-protocol options.

Fixes cockpit-project#19233
args: argparse.Namespace

def __init__(self, args: argparse.Namespace):
self.internal_bus = InternalBus(EXPORTS)
self.bridge_rules = []
self.bridge_configs = []
Copy link
Member

Choose a reason for hiding this comment

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

I guess () would be nicer here, but no biggie.

Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

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

Looks good now, thanks!

@martinpitt martinpitt merged commit 6a848af into cockpit-project:main Aug 31, 2023
33 checks passed
@martinpitt martinpitt deleted the pybridge-version branch August 31, 2023 10:43
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.

Command cockpit-bridge --version doesn't exit peacefully
2 participants