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: Add pulumi module #3055

Merged
merged 6 commits into from
Oct 5, 2021
Merged

Conversation

iwahbe
Copy link
Contributor

@iwahbe iwahbe commented Sep 12, 2021

Description

Adds a module for Pulumi. The module can display:

  • The current stack
  • The Pulumi CLI version.

Motivation and Context

It is useful to see what stack your commands are operating on (Can delete test, don't delete prod...). When hacking on or debugging pulumi, it is useful to see what version you are using.

Screenshots (if appropriate):

Screen Shot 2021-09-11 at 7 24 37 PM

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

In addition to unit and integration tests, I have been dogfooding this feature for about a week.

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@iwahbe iwahbe changed the title feat(pulumi) Add pulumi module feat: Add pulumi module Sep 12, 2021
@chipbuster
Copy link
Contributor

@iwahbe Thanks for the PR! It looks like our clippy check isn't happy about a &mut in the code: you can either look at what's going on in the CI window above or install clippy locally to check it out.

Looking forward to getting this merged!

@iwahbe
Copy link
Contributor Author

iwahbe commented Sep 14, 2021

@iwahbe Thanks for the PR! It looks like our clippy check isn't happy about a &mut in the code: you can either look at what's going on in the CI window above or install clippy locally to check it out.

Sorry about that. Fixed now.

I implicitly assumed that if there was a valid (parsable) Pulumi.yaml,
then it would have contents. We now allow it to be empty.
Copy link
Contributor

@chipbuster chipbuster left a comment

Choose a reason for hiding this comment

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

Not gonna lie: I had no idea what pulumi did going into this, and after reading this PR and skimming the website, I'm still not 100% sure.

However, this looks generally pretty good. It looks like you missed adding a description for this in the description function (not really your fault--there's way too much to keep track of when adding a new module) and there's a few small changes/additions I'd like to see in the module itself.

| ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol$stack]($style) "` | The format string for the module. |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"🚀 "` | A format string shown before the Pulumi stack. |
Copy link
Contributor

Choose a reason for hiding this comment

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

I must admit, I'm somewhat surprised this one hasn't been used already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any connection between Pulumi and a rocket? Looking on their site, the default symbol looks pretty close to a cube. I wonder if one of the nerd-font cube symbols might be a better fit.

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 don't have strong opinions. I changed it to (which is a cube, when rendered)

@@ -123,6 +124,7 @@ pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
"package" => package::module(context),
"perl" => perl::module(context),
"php" => php::module(context),
"pulumi" => pulumi::module(context),
"purescript" => purescript::module(context),
"python" => python::module(context),
"rlang" => rlang::module(context),
Copy link
Contributor

Choose a reason for hiding this comment

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

We will also need a description for the module here. It would be near line 211 of this file, but the web interface won't let me actually mark that line, so the comment is going here :(

@@ -0,0 +1,295 @@
#![warn(missing_docs)]
use sha1::{Digest, Sha1};
Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to say in advance: I'm not at all familiar with pulumi, so forgive me if some of these questions are naive.

/// can return results like `3.12.0-alpha.1630554544+f89e9a29.dirty`, which we
/// don't want to see. Instead we display that as `3.12.0-alpha`.
fn parse_version(version: &str) -> &str {
&version[0..version
Copy link
Contributor

Choose a reason for hiding this comment

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

While elegant in a functional sense, this takes a while to unpack and understand. Is there a reason we can't just increment a counter until we see three '.' characters (or hit the end of string) and then slice up to that index?

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 find the functional style easier to read. I will change it to be explicitly imperative on my next commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

For functional style, I personally would have gone with a split-take-join method, but I understand not wanting to cause additional allocations. Perhaps the thing to do to make this easier to understand would have been to name the last index with its own variable?

src/modules/pulumi.rs Show resolved Hide resolved
src/modules/pulumi.rs Outdated Show resolved Hide resolved
src/modules/pulumi.rs Show resolved Hide resolved
src/modules/pulumi.rs Outdated Show resolved Hide resolved
src/modules/pulumi.rs Show resolved Hide resolved
Copy link
Contributor

@chipbuster chipbuster 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 to me! 👍

@chipbuster
Copy link
Contributor

The hazards of pulling in additional crates.

Looks like we have a build failure in zvariant, which is a dependency of our notification feature for long-running jobs. I suspect that this is a regression on nightly, since the rules on variable size shouldn't have changed recently.

I think the simplest thing to do will be to wait a few days for nightly to shake itself out, then see if the issue is gone. If this hasn't been rebuilt by mid-week to see if the issue is gone, feel free to ping here to request a rerun of the CI.

@chipbuster
Copy link
Contributor

rust-lang/rust#89125 got merged 8hrs ago. Hopefully the 2021-09-21 nightly builds correctly and then we'll be off to the races.

@iwahbe
Copy link
Contributor Author

iwahbe commented Sep 22, 2021

Doesn't seem like. Hopefully it will be fixed it in the near future.

@iwahbe
Copy link
Contributor Author

iwahbe commented Sep 29, 2021

It seems like all checks are passing now.

@chipbuster
Copy link
Contributor

@iwahbe Thank you for taking the time to write a PR!

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.

None yet

2 participants