Skip to content

Commit

Permalink
Don't call pulumi version in the WhoAmI method (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed Mar 22, 2023
1 parent 37e80e6 commit 1556ea9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sdk/Pulumi.Automation/LocalWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,15 @@ public override async Task RemoveAllConfigAsync(string stackName, IEnumerable<st
/// <inheritdoc/>
public override async Task<WhoAmIResult> WhoAmIAsync(CancellationToken cancellationToken = default)
{
var version = await this.RunCommandAsync(new[] { "version" }, cancellationToken).ConfigureAwait(false);
if (!SemVersion.TryParse(version.StandardOutput.Trim(), SemVersionStyles.AllowLowerV, out var semVersion))
var version = this._pulumiVersion;
if (version == null)
{
// Assume an old version. Doesn't really matter what this is as long as it's pre-3.58.
semVersion = new SemVersion(3, 0);
version = new SemVersion(3, 0);
}

// 3.58 added the --json flag (https://github.com/pulumi/pulumi/releases/tag/v3.58.0)
if (semVersion >= new SemVersion(3, 58))
if (version >= new SemVersion(3, 58))
{
// Use the new --json style
var result = await this.RunCommandAsync(new[] { "whoami", "--json" }, cancellationToken).ConfigureAwait(false);
Expand Down

0 comments on commit 1556ea9

Please sign in to comment.