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

feat(store): promote command #2082

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat(store): promote command #2082

wants to merge 2 commits into from

Conversation

lengau
Copy link
Collaborator

@lengau lengau commented Jan 16, 2025

No description provided.

@lengau lengau requested review from dariuszd21 and mr-cal January 16, 2025 23:52
@lengau lengau marked this pull request as ready for review January 16, 2025 23:52
Copy link
Contributor

@dariuszd21 dariuszd21 left a 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"
Copy link
Contributor

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 😄

Suggested change
overview = "TODO"
overview = "TODO"

Copy link
Collaborator Author

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

Comment on lines +886 to +899
# 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)
Copy link
Contributor

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 ?

Copy link
Contributor

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?

charmcraft/application/commands/store.py Show resolved Hide resolved
Comment on lines +950 to +954
with emit.pause():
print(
tabulate(presentable_candidates, tablefmt="plain", headers="keys"),
file=sys.stderr,
)
Copy link
Contributor

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) ?

Copy link
Collaborator Author

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.

Copy link
Contributor

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

Suggested change
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,
)

charmcraft/application/commands/store.py Show resolved Hide resolved
@@ -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" },
Copy link
Contributor

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

Copy link
Contributor

@dariuszd21 dariuszd21 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!

Comment on lines +950 to +954
with emit.pause():
print(
tabulate(presentable_candidates, tablefmt="plain", headers="keys"),
file=sys.stderr,
)
Copy link
Contributor

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

Suggested change
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,
)

Copy link
Contributor

@cmatsuoka cmatsuoka left a 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.

Comment on lines +886 to +899
# 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)
Copy link
Contributor

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?

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.

3 participants