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

disable: cli disable progress refactor #3028

Merged
merged 7 commits into from
Apr 3, 2024

Conversation

orndorffgrant
Copy link
Collaborator

@orndorffgrant orndorffgrant commented Mar 28, 2024

Why is this needed?

This refactors the disable cli command to use the progress api for printing messages to the user, which will allow the api for disable to be implemented without hacking around prompts deep in the call stack.

Test Steps

CI and tests should all pass

Checklist

  • I have updated or added any unit tests accordingly
  • I have updated or added any integration tests accordingly
  • Changes here need to be documented, and this was done in:

Does this PR require extra reviews?

  • Yes
  • No

Copy link

Jira: This PR is not related to a Jira item. (The PR title does not include a SC-#### reference)

GitHub Issues: No GitHub issues are fixed by this PR. (No commits have Fixes: #### references)

Launchpad Bugs: No Launchpad bugs are fixed by this PR. (No commits have LP: #### references)

Documentation: The changes in this PR do not require documentation changes.

👍 this comment to confirm that this is correct.

Copy link

github-actions bot commented Mar 28, 2024

🌎 This PR changes translatable messages. 🌏

Please select which scenarios apply. For further explanation, please read our policy on message changes.

  • New messages are being added.
    • We will ask translators to take a look and add translations if they have time, but it will not block this PR.
  • Existing messages are being changed.
    • ⚠️ Please add a comment with justification of why messages are being altered.
    • If the changes are trivial (e.g. a typo fix), then translations must be preserved.
    • If the changes are substantial, then we will ask translators to take a look and update translations if they have time, but it will not block this PR.
  • Existing messages are being deleted.
    • No special action needed.

@orndorffgrant orndorffgrant force-pushed the cli-disable-progress-refactor branch 9 times, most recently from 50aa367 to 5f02aff Compare April 1, 2024 17:29
@orndorffgrant orndorffgrant changed the title wip: Cli disable progress refactor disable: cli disable progress refactor Apr 1, 2024
@orndorffgrant orndorffgrant marked this pull request as ready for review April 1, 2024 17:46
@orndorffgrant orndorffgrant mentioned this pull request Apr 1, 2024
5 tasks

def get_title(cfg: UAConfig, ent_name: str, variant=""):
try:
return entitlement_factory(cfg, ent_name, variant=variant)(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check, what is the advantage of this approach ? We are now creating the entitlement object to fetch the title, which is not necessary.

Is that because of we might miss a variant title by using ENTITLEMENT_NAME_TO_TITLE ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is unfortunately necessary for cis, because the title depends on self.called_name

Copy link
Member

Choose a reason for hiding this comment

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

I cry so much everytime this kind of comment pops out somewhere
We need to kill this horrible bug

@@ -216,7 +186,9 @@ def action_enable(args, *, cfg, **kwargs) -> int:
if json_output:
progress = api.ProgressWrapper()
else:
progress = api.ProgressWrapper(CLIEnableProgress())
progress = api.ProgressWrapper(
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though this is not a problem introduced in this PR, but I noticed that we are now creating the same entitlement object on lines 155 and 193. I think we should only do that once

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep I can consolidate them

def _on_event(self, event: str, payload):
if event == "info":
print(payload)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nit, but I think we can remove the empty return here

@orndorffgrant
Copy link
Collaborator Author

@lucasmoura updated!

@orndorffgrant orndorffgrant merged commit 39d7c44 into main Apr 3, 2024
24 checks passed
@orndorffgrant orndorffgrant deleted the cli-disable-progress-refactor branch April 3, 2024 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants