-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat(store): promote command #2082
base: main
Are you sure you want to change the base?
Conversation
To be undone before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just few minor comments but nothing major
|
||
name = "promote" | ||
help_msg = "Promote a charm from one channel to another on Charmhub." | ||
overview = "TODO" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think few words may be helpful as it'll land in the docs 😄
overview = "TODO" | |
overview = "TODO" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do - I've asked for your second review for other things ITMT
# Check snapcraft for equiv logic | ||
from_channel = charmcraft.store.models.ChannelData.from_str( | ||
parsed_args.from_channel | ||
) | ||
to_channel = charmcraft.store.models.ChannelData.from_str( | ||
parsed_args.to_channel | ||
) | ||
if None in (from_channel.track, to_channel.track): | ||
package_metadata = store.get_package_metadata(name) | ||
default_track = package_metadata.default_track | ||
if from_channel.track is None: | ||
from_channel = dataclasses.replace(from_channel, track=default_track) | ||
if to_channel.track is None: | ||
to_channel = dataclasses.replace(to_channel, track=default_track) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this logic, shouldn't we just make it explicit and error out if track is missing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both are missing, will it try to promote from default to default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we would want to error out rather than using the default track. An example command that would trigger both of these conditions is:
charmcraft promote --from-channel=candidate --to-channel=stable
In this case, we'll look up the default track (typically latest
) and insert it, so the command above is equivalent to:
charmcraft promote --from-channel=latest/candidate --to-channel=latest/stable
if the default track is latest
.
with emit.pause(): | ||
print( | ||
tabulate(presentable_candidates, tablefmt="plain", headers="keys"), | ||
file=sys.stderr, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why it can't be a progress as well (beside not logging it) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emit.progress
tries to represent it as a single line, even with permanent=True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work this way ? It seems to be a bit more consistent and does not leak the sys.stderr
implementation detail
with emit.pause(): | |
print( | |
tabulate(presentable_candidates, tablefmt="plain", headers="keys"), | |
file=sys.stderr, | |
) | |
with emit.open_stream() as stream: | |
print( | |
tabulate(presentable_candidates, tablefmt="plain", headers="keys"), | |
file=stream, | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open_stream()
doesn't result in a file-like object, just an integer with the file pointer, so you'd have to then open that, and it gets ugly.
@@ -463,7 +462,7 @@ requires-dist = [ | |||
{ name = "craft-platforms", specifier = "~=0.5" }, | |||
{ name = "craft-providers", specifier = ">=2.0.0" }, | |||
{ name = "craft-providers", specifier = ">=2.1.0" }, | |||
{ name = "craft-store", specifier = ">=3.1.0" }, | |||
{ name = "craft-store", git = "https://github.com/canonical/craft-store" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to update to the proper release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
with emit.pause(): | ||
print( | ||
tabulate(presentable_candidates, tablefmt="plain", headers="keys"), | ||
file=sys.stderr, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work this way ? It seems to be a bit more consistent and does not leak the sys.stderr
implementation detail
with emit.pause(): | |
print( | |
tabulate(presentable_candidates, tablefmt="plain", headers="keys"), | |
file=sys.stderr, | |
) | |
with emit.open_stream() as stream: | |
print( | |
tabulate(presentable_candidates, tablefmt="plain", headers="keys"), | |
file=stream, | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks reasonable under my assumptions, but I missed the complete context because the PR has no description.
# Check snapcraft for equiv logic | ||
from_channel = charmcraft.store.models.ChannelData.from_str( | ||
parsed_args.from_channel | ||
) | ||
to_channel = charmcraft.store.models.ChannelData.from_str( | ||
parsed_args.to_channel | ||
) | ||
if None in (from_channel.track, to_channel.track): | ||
package_metadata = store.get_package_metadata(name) | ||
default_track = package_metadata.default_track | ||
if from_channel.track is None: | ||
from_channel = dataclasses.replace(from_channel, track=default_track) | ||
if to_channel.track is None: | ||
to_channel = dataclasses.replace(to_channel, track=default_track) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both are missing, will it try to promote from default to default?
if not parsed_args.yes and not utils.confirm_with_user( | ||
"Did you mean to promote to a different track? (from " | ||
f"{from_channel.track} to {to_channel.track})", | ||
): | ||
emit.message("Cancelling.") | ||
return 64 # Replace with os.EX_USAGE once we drop Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't allow non-interactive promotion between tracks at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why not. As an example, in CI you might want to promote 3/edge
to latest/edge
No description provided.