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

Downloading plugins uses an engine event #16094

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

PollRobots
Copy link
Contributor

@PollRobots PollRobots commented Apr 30, 2024

Description

When engine events are available, downloading a plugin will use the engine event, this allows the display of the download progress to be more cleanly integrated with the rest of the pulumi cli display

Creates a new engine event DownloadProgressEvent which is used to both track and display progress for downloads (currently just for plugins, but for policy in the future)

This displays the download progress in the cli for actions that use a deployment (up, preview etc.). The progress is displayed in the bottom third of the terminal

Fixes #15821

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Apr 30, 2024

Changelog

[uncommitted] (2024-05-14)

Features

  • [cli/display] Plugin download progress is integrated with terminal display
    #16094

@PollRobots PollRobots force-pushed the proberts/plugin-install-uses-events branch from a746903 to 2584c32 Compare April 30, 2024 23:30
@PollRobots PollRobots marked this pull request as ready for review April 30, 2024 23:31
@PollRobots PollRobots requested a review from a team as a code owner April 30, 2024 23:31
@PollRobots PollRobots force-pushed the proberts/plugin-install-uses-events branch from a30da2c to cb62091 Compare May 1, 2024 01:55
@@ -205,7 +205,7 @@ func TestTreeRenderCallsFrameOnTick(t *testing.T) {
terminalText := buf.String()
assert.Contains(t, terminalText, "pulumi:pulumi:Stack")
assert.Contains(t, terminalText, "System Messages")
assert.Contains(t, terminalText, strings.Repeat("a", 1000))
assert.Contains(t, terminalText, strings.Repeat("a", 70))
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I fixed the renderer to trim lines, I can "unfix" if you would prefer

Copy link
Member

Choose a reason for hiding this comment

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

No that's fine, easier if you pull little changes like that out to their own but no need now.

@@ -2,34 +2,34 @@

<{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> <{%underline%}><{%fg 12%}>Status<{%reset%}> <{%underline%}><{%fg 12%}>Info<{%reset%}>
<{%bold%}><{%reset%}> <{%reset%}> pulumi:pulumi:Stack project-stack <{%bold%}><{%reset%}><{%reset%}> <{%reset%}>Configuration:<{%reset%}>
 <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> <{%underline%}><{%fg 12%}>Status<{%reset%}> <{%underline%}><{%fg 12%}>Info<{%reset%}>
Copy link
Member

Choose a reason for hiding this comment

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

Why did all these change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way the frame/render logic in the tree renderer worked was fragile (and broken if system messages needed to be displayed) when I used the same mechanism to display the download progress --- which is both more common than system messages, and happens at a different stage in the lifecycle of the engine --- I had to fix the way the redraw logic worked, which means different outputs in these files.

I will also investigate whether we can make these outputs not use escape codes, which will make comparing easier (unless you can read VT100/ANSI escape codes without a crib)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the change, LMK what you think, I can always revert it within the PR, it does feel more readable to me

@PollRobots PollRobots force-pushed the proberts/plugin-install-uses-events branch 3 times, most recently from 73be3f2 to 9f31b04 Compare May 1, 2024 21:09
Paul Roberts added 6 commits May 14, 2024 10:16
When engine events are available, downloading a plugin will use the
engine event, this allows the display of the download progress to be
more cleanly integrated with the rest of the pulumi cli display
@PollRobots PollRobots force-pushed the proberts/plugin-install-uses-events branch from 9f31b04 to 94ac09a Compare May 14, 2024 17:25
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.

Change plugin download and installation to use engine events for progress
3 participants