Skip to content

Commit 6b9d9d4

Browse files
committed
Rename PulumiCmd -> PulumiCommand
1 parent c2b66fa commit 6b9d9d4

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

sdk/Pulumi.Automation.Tests/LocalPulumiCmdTests.cs sdk/Pulumi.Automation.Tests/LocalPulumiCommandTests.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
namespace Pulumi.Automation.Tests
1414
{
15-
public class LocalPulumiCmdTests
15+
public class LocalPulumiCommandTests
1616
{
1717
[Fact]
1818
public async Task CheckVersionCommand()
1919
{
20-
var localCmd = await LocalPulumiCmd.CreateAsync();
20+
var localCmd = await LocalPulumiCommand.CreateAsync();
2121
var extraEnv = new Dictionary<string, string?>();
2222
var args = new[] { "version" };
2323

@@ -64,7 +64,7 @@ private List<string> Lines(string s)
6464
public async Task InstallDefaultRoot()
6565
{
6666
var requestedVersion = new SemVersion(3, 102, 0);
67-
await LocalPulumiCmd.Install(new LocalPulumiCmdOptions { Version = requestedVersion });
67+
await LocalPulumiCommand.Install(new LocalPulumiCommandOptions { Version = requestedVersion });
6868
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
6969
var pulumiBin = Path.Combine(home, ".pulumi", "versions", requestedVersion.ToString(), "bin", "pulumi");
7070
Assert.True(File.Exists(pulumiBin));
@@ -78,13 +78,13 @@ public async Task InstallTwice()
7878
try
7979
{
8080
var requestedVersion = new SemVersion(3, 102, 0);
81-
await LocalPulumiCmd.Install(new LocalPulumiCmdOptions { Version = requestedVersion, Root = tempDir });
81+
await LocalPulumiCommand.Install(new LocalPulumiCommandOptions { Version = requestedVersion, Root = tempDir });
8282
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
8383
var pulumiBin = Path.Combine(home, ".pulumi", "versions", requestedVersion.ToString(), "bin", "pulumi");
8484
FileInfo fi1 = new FileInfo(pulumiBin);
8585
var t1 = fi1.CreationTime;
8686
// Install again with the same options
87-
await LocalPulumiCmd.Install(new LocalPulumiCmdOptions { Version = requestedVersion, Root = tempDir });
87+
await LocalPulumiCommand.Install(new LocalPulumiCommandOptions { Version = requestedVersion, Root = tempDir });
8888
FileInfo fi2 = new FileInfo(pulumiBin);
8989
var t2 = fi2.CreationTime;
9090
Assert.Equal(t1, t2);
@@ -105,18 +105,18 @@ public async Task VersionCheck()
105105
{
106106
// Install an old version
107107
var installed_version = new SemVersion(3, 99, 0);
108-
await LocalPulumiCmd.Install(new LocalPulumiCmdOptions { Version = installed_version, Root = dirPath });
108+
await LocalPulumiCommand.Install(new LocalPulumiCommandOptions { Version = installed_version, Root = dirPath });
109109

110110
// Try to create a command with a more recent version
111111
var requested_version = new SemVersion(3, 102, 0);
112-
await Assert.ThrowsAsync<InvalidOperationException>(() => LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions
112+
await Assert.ThrowsAsync<InvalidOperationException>(() => LocalPulumiCommand.CreateAsync(new LocalPulumiCommandOptions
113113
{
114114
Version = requested_version,
115115
Root = dirPath
116116
}));
117117

118118
// Opting out of the version check works
119-
await LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions
119+
await LocalPulumiCommand.CreateAsync(new LocalPulumiCommandOptions
120120
{
121121
Version = requested_version,
122122
Root = dirPath,
@@ -135,13 +135,13 @@ public void PulumiEnvironment()
135135
var env = new Dictionary<string, string?>{
136136
{"PATH", "/usr/bin"}
137137
};
138-
var newEnv = LocalPulumiCmd.PulumiEnvironment(env, "pulumi", false);
138+
var newEnv = LocalPulumiCommand.PulumiEnvironment(env, "pulumi", false);
139139
Assert.Equal("/usr/bin", newEnv["PATH"]);
140140

141141
env = new Dictionary<string, string?>{
142142
{"PATH", "/usr/bin"}
143143
};
144-
newEnv = LocalPulumiCmd.PulumiEnvironment(env, "/some/install/root/bin/pulumi", false);
144+
newEnv = LocalPulumiCommand.PulumiEnvironment(env, "/some/install/root/bin/pulumi", false);
145145
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
146146
{
147147
Assert.Equal("/some/install/root/bin;/usr/bin", newEnv["PATH"]);
@@ -173,12 +173,12 @@ public void ValidVersionTheory(string currentVersion, bool errorExpected, bool o
173173

174174
if (errorExpected)
175175
{
176-
void ValidatePulumiVersion() => LocalPulumiCmd.ParseAndValidatePulumiVersion(testMinVersion, currentVersion, optOut);
176+
void ValidatePulumiVersion() => LocalPulumiCommand.ParseAndValidatePulumiVersion(testMinVersion, currentVersion, optOut);
177177
Assert.Throws<InvalidOperationException>(ValidatePulumiVersion);
178178
}
179179
else
180180
{
181-
LocalPulumiCmd.ParseAndValidatePulumiVersion(testMinVersion, currentVersion, optOut);
181+
LocalPulumiCommand.ParseAndValidatePulumiVersion(testMinVersion, currentVersion, optOut);
182182
}
183183
}
184184

sdk/Pulumi.Automation/Commands/IPulumiCmd.cs sdk/Pulumi.Automation/Commands/IPulumiCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Pulumi.Automation.Commands
1111
{
12-
public interface IPulumiCmd
12+
public interface IPulumiCommand
1313
{
1414
SemVersion? Version { get; }
1515

sdk/Pulumi.Automation/Commands/LocalPulumiCmd.cs sdk/Pulumi.Automation/Commands/LocalPulumiCommand.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
namespace Pulumi.Automation.Commands
2323
{
2424
/// <summary>
25-
/// Options to configure a <see cref="LocalPulumiCmd"/> instance.
25+
/// Options to configure a <see cref="LocalPulumiCommand"/> instance.
2626
/// </summary>
27-
public class LocalPulumiCmdOptions
27+
public class LocalPulumiCommandOptions
2828
{
2929
/// <summary>
3030
/// The version of the Pulumi CLI to install or the minimum version requirement for an existing installation.
@@ -41,9 +41,9 @@ public class LocalPulumiCmdOptions
4141
}
4242

4343
/// <summary>
44-
/// A <see cref="IPulumiCmd"/> implementation that uses a locally installed Pulumi CLI.
44+
/// A <see cref="IPulumiCommand"/> implementation that uses a locally installed Pulumi CLI.
4545
/// </summary>
46-
public class LocalPulumiCmd : IPulumiCmd
46+
public class LocalPulumiCommand : IPulumiCommand
4747
{
4848
// TODO: move to shared place with LocalWorkspace
4949
private static string SkipVersionCheckVar = "PULUMI_AUTOMATION_API_SKIP_VERSION_CHECK";
@@ -57,13 +57,13 @@ public class LocalPulumiCmd : IPulumiCmd
5757
public SemVersion? Version { get => _version; }
5858

5959
/// <summary>
60-
/// Creates a new LocalPulumiCmd instance.
60+
/// Creates a new LocalPulumiCommand instance.
6161
/// </summary>
62-
/// <param name="options">Options to configure the LocalPulumiCmd.</param>
62+
/// <param name="options">Options to configure the LocalPulumiCommand.</param>
6363
/// <param name="cancellationToken">A cancellation token.</param>
6464
/// <returns></returns>
65-
public static async Task<LocalPulumiCmd> CreateAsync(
66-
LocalPulumiCmdOptions? options = null,
65+
public static async Task<LocalPulumiCommand> CreateAsync(
66+
LocalPulumiCommandOptions? options = null,
6767
CancellationToken cancellationToken = default)
6868
{
6969
var command = "pulumi";
@@ -80,10 +80,10 @@ public static async Task<LocalPulumiCmd> CreateAsync(
8080

8181
var optOut = options?.SkipVersionCheck ?? Environment.GetEnvironmentVariable(SkipVersionCheckVar) != null;
8282
var version = await GetPulumiVersionAsync(minimumVersion, command, optOut, cancellationToken);
83-
return new LocalPulumiCmd(command, version);
83+
return new LocalPulumiCommand(command, version);
8484
}
8585

86-
private LocalPulumiCmd(string command, SemVersion? version)
86+
private LocalPulumiCommand(string command, SemVersion? version)
8787
{
8888
_command = command;
8989
_version = version;
@@ -104,11 +104,11 @@ private LocalPulumiCmd(string command, SemVersion? version)
104104
}
105105

106106
/// <summary>
107-
/// Installs the Pulumi CLI if it is not already installed and returns a new LocalPulumiCmd instance.
107+
/// Installs the Pulumi CLI if it is not already installed and returns a new LocalPulumiCommand instance.
108108
/// </summary>
109-
/// <param name="options">Options to configure the LocalPulumiCmd.</param>
109+
/// <param name="options">Options to configure the LocalPulumiCommand.</param>
110110
/// <param name="cancellationToken">A cancellation token.</param>
111-
public static async Task<LocalPulumiCmd> Install(LocalPulumiCmdOptions? options = null, CancellationToken cancellationToken = default)
111+
public static async Task<LocalPulumiCommand> Install(LocalPulumiCommandOptions? options = null, CancellationToken cancellationToken = default)
112112
{
113113
var _assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
114114
if (_assemblyVersion == null)
@@ -118,7 +118,7 @@ public static async Task<LocalPulumiCmd> Install(LocalPulumiCmdOptions? options
118118
var assemblyVersion = new SemVersion(_assemblyVersion.Major, _assemblyVersion.Minor, _assemblyVersion.Build);
119119
var version = options?.Version ?? assemblyVersion;
120120
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
121-
var optionsWithDefaults = new LocalPulumiCmdOptions
121+
var optionsWithDefaults = new LocalPulumiCommandOptions
122122
{
123123
Version = version,
124124
Root = options?.Root ?? Path.Combine(home, ".pulumi", "versions", version.ToString())
@@ -285,22 +285,22 @@ private async Task<CommandResult> RunAsyncInner(
285285
stdErrPipe = PipeTarget.Merge(stdErrPipe, PipeTarget.ToDelegate(onStandardError));
286286
}
287287

288-
var pulumiCmd = Cli.Wrap("pulumi")
288+
var pulumiCommand = Cli.Wrap("pulumi")
289289
.WithArguments(PulumiArgs(args, eventLogFile), escape: true)
290290
.WithWorkingDirectory(workingDir)
291291
.WithEnvironmentVariables(PulumiEnvironment(additionalEnv, _command, debugCommands: eventLogFile != null))
292292
.WithStandardOutputPipe(stdOutPipe)
293293
.WithStandardErrorPipe(stdErrPipe)
294294
.WithValidation(CommandResultValidation.None); // we check non-0 exit code ourselves
295295

296-
var pulumiCmdResult = await pulumiCmd.ExecuteAsync(cancellationToken);
296+
var pulumiCommandResult = await pulumiCommand.ExecuteAsync(cancellationToken);
297297

298298
var result = new CommandResult(
299-
pulumiCmdResult.ExitCode,
299+
pulumiCommandResult.ExitCode,
300300
standardOutput: stdOutBuffer.ToString(),
301301
standardError: stdErrBuffer.ToString());
302302

303-
if (pulumiCmdResult.ExitCode != 0)
303+
if (pulumiCommandResult.ExitCode != 0)
304304
{
305305
throw CommandException.CreateFromResult(result);
306306
}

sdk/Pulumi.Automation/LocalWorkspace.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static async Task<LocalWorkspace> CreateAsync(
7878
LocalWorkspaceOptions? options = null,
7979
CancellationToken cancellationToken = default)
8080
{
81-
var cmd = options?.PulumiCmd ?? await LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions
81+
var cmd = options?.PulumiCommand ?? await LocalPulumiCommand.CreateAsync(new LocalPulumiCommandOptions
8282
{
8383
SkipVersionCheck = OptOutOfVersionCheck(options?.EnvironmentVariables)
8484
}, cancellationToken);
@@ -287,7 +287,7 @@ private static async Task<WorkspaceStack> CreateStackHelperAsync(
287287
throw new ArgumentNullException(nameof(args.ProjectSettings));
288288

289289
var ws = new LocalWorkspace(
290-
await LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions
290+
await LocalPulumiCommand.CreateAsync(new LocalPulumiCommandOptions
291291
{
292292
SkipVersionCheck = OptOutOfVersionCheck(),
293293
}, cancellationToken),
@@ -304,7 +304,7 @@ private static async Task<WorkspaceStack> CreateStackHelperAsync(
304304
CancellationToken cancellationToken)
305305
{
306306
var ws = new LocalWorkspace(
307-
await LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions
307+
await LocalPulumiCommand.CreateAsync(new LocalPulumiCommandOptions
308308
{
309309
SkipVersionCheck = OptOutOfVersionCheck()
310310
}, cancellationToken),
@@ -316,7 +316,7 @@ await LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions
316316
}
317317

318318
internal LocalWorkspace(
319-
IPulumiCmd cmd,
319+
IPulumiCommand cmd,
320320
LocalWorkspaceOptions? options,
321321
CancellationToken cancellationToken)
322322
: base(cmd)

sdk/Pulumi.Automation/LocalWorkspaceOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class LocalWorkspaceOptions
2525
/// <summary>
2626
/// The Pulumi CLI installation to use.
2727
/// </summary>
28-
public Commands.IPulumiCmd? PulumiCmd { get; set; }
28+
public Commands.IPulumiCommand? PulumiCommand { get; set; }
2929

3030
/// <summary>
3131
/// The secrets provider to user for encryption and decryption of stack secrets.

sdk/Pulumi.Automation/RemoteWorkspace.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private static async Task<RemoteWorkspaceStack> CreateStackHelperAsync(
112112
};
113113

114114
var ws = new LocalWorkspace(
115-
await LocalPulumiCmd.CreateAsync(new LocalPulumiCmdOptions(), cancellationToken),
115+
await LocalPulumiCommand.CreateAsync(new LocalPulumiCommandOptions(), cancellationToken),
116116
localArgs,
117117
cancellationToken);
118118
await ws.ReadyTask.ConfigureAwait(false);

sdk/Pulumi.Automation/Workspace.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ namespace Pulumi.Automation
2323
/// </summary>
2424
public abstract class Workspace : IDisposable
2525
{
26-
internal readonly IPulumiCmd _cmd;
26+
internal readonly IPulumiCommand _cmd;
2727

28-
internal Workspace(IPulumiCmd cmd)
28+
internal Workspace(IPulumiCommand cmd)
2929
{
3030
this._cmd = cmd;
3131
}

0 commit comments

Comments
 (0)