Skip to content

Commit c5d241d

Browse files
committed
fix: fix podman issue on windows
1 parent f9675d1 commit c5d241d

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

src/AWS.Deploy.CLI/Commands/DeployCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ private void DisplayOutputResources(List<DisplayedResourceItem> displayedResourc
189189
directoryManager,
190190
awsServiceHandler,
191191
optionSettingHandler,
192-
deployToolWorkspaceMetadata);
192+
deployToolWorkspaceMetadata,
193+
systemCapabilityEvaluator);
193194

194195
// Determine what recommendations are possible for the project.
195196
var recommendations = await GenerateDeploymentRecommendations(orchestrator, deploymentProjectPath);

src/AWS.Deploy.CLI/ServerMode/Controllers/DeploymentController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ private Orchestrator CreateOrchestrator(SessionState state, IServiceProvider? se
795795
serviceProvider.GetRequiredService<IDirectoryManager>(),
796796
serviceProvider.GetRequiredService<IAWSServiceHandler>(),
797797
serviceProvider.GetRequiredService<IOptionSettingHandler>(),
798-
serviceProvider.GetRequiredService<IDeployToolWorkspaceMetadata>()
798+
serviceProvider.GetRequiredService<IDeployToolWorkspaceMetadata>(),
799+
serviceProvider.GetRequiredService<ISystemCapabilityEvaluator>()
799800
);
800801
}
801802
}

src/AWS.Deploy.Orchestration/Orchestrator.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Globalization;
67
using System.Linq;
78
using System.Threading.Tasks;
89
using Amazon.EC2.Model;
@@ -43,6 +44,7 @@ public class Orchestrator
4344
internal readonly IAWSServiceHandler? _awsServiceHandler;
4445
private readonly IOptionSettingHandler? _optionSettingHandler;
4546
internal readonly IDeployToolWorkspaceMetadata? _workspaceMetadata;
47+
internal readonly ISystemCapabilityEvaluator? _systemCapabilityEvaluator;
4648

4749
public Orchestrator(
4850
OrchestratorSession session,
@@ -59,7 +61,8 @@ public Orchestrator(
5961
IDirectoryManager directoryManager,
6062
IAWSServiceHandler awsServiceHandler,
6163
IOptionSettingHandler optionSettingHandler,
62-
IDeployToolWorkspaceMetadata deployToolWorkspaceMetadata)
64+
IDeployToolWorkspaceMetadata deployToolWorkspaceMetadata,
65+
ISystemCapabilityEvaluator systemCapabilityEvaluator)
6366
{
6467
_session = session;
6568
_interactiveService = interactiveService;
@@ -76,6 +79,7 @@ public Orchestrator(
7679
_awsServiceHandler = awsServiceHandler;
7780
_optionSettingHandler = optionSettingHandler;
7881
_workspaceMetadata = deployToolWorkspaceMetadata;
82+
_systemCapabilityEvaluator = systemCapabilityEvaluator;
7983
}
8084

8185
public Orchestrator(OrchestratorSession session, IRecipeHandler recipeHandler)
@@ -261,11 +265,18 @@ public async Task CreateDeploymentBundle(CloudApplication cloudApplication, Reco
261265
{
262266
if (_interactiveService == null)
263267
throw new InvalidOperationException($"{nameof(_interactiveService)} is null as part of the orchestrator object");
268+
if (_systemCapabilityEvaluator == null)
269+
throw new InvalidOperationException($"{nameof(_systemCapabilityEvaluator)} is null as part of the orchestrator object");
264270

265271
if (recommendation.Recipe.DeploymentBundle == DeploymentBundleTypes.Container)
266272
{
273+
var installedContainerAppInfo = await _systemCapabilityEvaluator.GetInstalledContainerAppInfo(recommendation);
274+
var commandName = installedContainerAppInfo?.AppName?.ToLower();
275+
if (string.IsNullOrEmpty(commandName))
276+
throw new ContainerBuildFailedException(DeployToolErrorCode.ContainerBuildFailed, "No container app (Docker or Podman) is currently installed/running on your system.", -1);
277+
267278
_interactiveService.LogSectionStart("Creating deployment image",
268-
"Using the docker CLI to perform a docker build to create a container image.");
279+
$"Using the {CultureInfo.CurrentCulture.TextInfo.ToTitleCase(commandName)} CLI to create a container image.");
269280
try
270281
{
271282
await CreateContainerDeploymentBundle(cloudApplication, recommendation);

src/AWS.Deploy.Orchestration/SystemCapabilityEvaluator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ private async Task<ContainerAppInfo> HasPodmanInstalledAndRunningAsync()
105105
{
106106
var processExitCode = -1;
107107
var containerType = "";
108-
var command = "podman info --format=json | jq -r '.host.os'";
108+
var command = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
109+
"powershell -NoProfile -Command \"(podman info --format=json | ConvertFrom-Json).host.os\"" :
110+
"podman info --format=json | jq -r '.host.os'";
109111

110112
var cancellationTokenSource = new CancellationTokenSource();
111113
cancellationTokenSource.CancelAfter(CAPABILITY_EVALUATION_TIMEOUT_MS);

test/AWS.Deploy.CLI.IntegrationTests/SaveCdkDeploymentProject/RecommendationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ private async Task<Orchestrator> GetOrchestrator(string targetApplicationProject
263263
directoryManager,
264264
new Mock<IAWSServiceHandler>().Object,
265265
new OptionSettingHandler(new Mock<IValidatorFactory>().Object),
266-
deployToolWorkspaceMetadata);
266+
deployToolWorkspaceMetadata,
267+
new Mock<ISystemCapabilityEvaluator>().Object);
267268
}
268269

269270
private async Task<string> GetCustomRecipeId(string recipeFilePath)

test/AWS.Deploy.CLI.UnitTests/ApplyPreviousSettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public ApplyPreviousSettingsTests()
5555
var optionSettingHandler = new OptionSettingHandler(validatorFactory);
5656
_recipeHandler = new RecipeHandler(_deploymentManifestEngine, _orchestratorInteractiveService, _directoryManager, _fileManager, optionSettingHandler, validatorFactory);
5757
_optionSettingHandler = new OptionSettingHandler(new ValidatorFactory(_serviceProvider.Object));
58-
_orchestrator = new Orchestrator(null!, _orchestratorInteractiveService, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, _optionSettingHandler, null!);
58+
_orchestrator = new Orchestrator(null!, _orchestratorInteractiveService, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, _optionSettingHandler, null!, null!);
5959
}
6060

6161
private async Task<RecommendationEngine> BuildRecommendationEngine(string testProjectName)

0 commit comments

Comments
 (0)