Skip to content

Commit

Permalink
Doh! Only run this selection menu if its actually a compose build.. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
prom3theu5 authored May 1, 2024
1 parent 19d206f commit 7f3759a
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@ public override async Task<bool> ExecuteAsync()
return true;
}

if (CurrentState.ComposeBuilds?.Any() == false)
{
SelectComposeItemsToIncludeAsComposeBuilds();
}

if (CurrentState.ComposeBuilds?.Any() == true)
{
Logger.MarkupLine("[bold]Compose builds selected:[/]");
foreach (var composeBuild in CurrentState.ComposeBuilds)
{
Logger.MarkupLine($"[blue] - {composeBuild}[/]");
}
}
HandleComposeOutputBuildSelectionForDockerfiles();

var dockerfileProcessor = Services.GetRequiredKeyedService<IResourceProcessor>(AspireComponentLiterals.Dockerfile) as DockerfileProcessor;

Expand All @@ -41,6 +29,28 @@ public override async Task<bool> ExecuteAsync()
return true;
}

private void HandleComposeOutputBuildSelectionForDockerfiles()
{
if (string.IsNullOrEmpty(CurrentState.OutputFormat) || OutputFormat.FromValue(CurrentState.OutputFormat) != OutputFormat.DockerCompose)
{
return;
}

if (CurrentState.ComposeBuilds?.Any() == false)
{
SelectComposeItemsToIncludeAsComposeBuilds();
}

if (CurrentState.ComposeBuilds?.Any() == true)
{
Logger.MarkupLine("[bold]Compose builds selected:[/]");
foreach (var composeBuild in CurrentState.ComposeBuilds)
{
Logger.MarkupLine($"[blue] - {composeBuild}[/]");
}
}
}

private void CacheContainerDetails(DockerfileProcessor? dockerfileProcessor)
{
foreach (var resource in CurrentState.SelectedDockerfileComponents.Where(resource => CurrentState.ComposeBuilds?.Contains(resource.Key) != true))
Expand Down Expand Up @@ -129,7 +139,7 @@ private bool HasSelectedDockerfileComponents()

public override void ValidateNonInteractiveState()
{
if (!CurrentState.NonInteractive || !HasSelectedDockerfileComponents())
if (!CurrentState.NonInteractive || !HasSelectedDockerfileComponents() || OutputFormat.FromValue(CurrentState.OutputFormat) != OutputFormat.DockerCompose)
{
return;
}
Expand Down

0 comments on commit 7f3759a

Please sign in to comment.