Skip to content

Commit 19d0a8c

Browse files
Copiloteerhardt
andcommitted
Address additional review feedback
- Fix build errors in playground AppHost (use WellKnownPipelineTags) - Rename ApplicationModel to Model for consistency with PipelineContext - Rename Find* methods to GetSteps with overloads (tag/resource/both) - Update StepToResourceMap to use required initialization pattern - Update all tests to use new API naming Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
1 parent 3a44d2f commit 19d0a8c

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

playground/pipelines/Pipelines.AppHost/AppHost.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ await assignRoleTask.CompleteAsync(
225225
context.CancellationToken).ConfigureAwait(false);
226226
}
227227
}
228-
}, requiredBy: "upload-bind-mounts", dependsOn: WellKnownPipelineSteps.ProvisionInfrastructure);
228+
}, requiredBy: "upload-bind-mounts", dependsOn: WellKnownPipelineTags.ProvisionInfrastructure);
229229

230230
builder.Pipeline.AddStep("upload-bind-mounts", async (deployingContext) =>
231231
{
@@ -324,7 +324,7 @@ await uploadTask.CompleteAsync(
324324
totalUploads += fileCount;
325325
}
326326
}
327-
}, requiredBy: WellKnownPipelineSteps.DeployCompute, dependsOn: WellKnownPipelineSteps.ProvisionInfrastructure);
327+
}, requiredBy: WellKnownPipelineTags.DeployCompute, dependsOn: WellKnownPipelineTags.ProvisionInfrastructure);
328328

329329
builder.AddProject<Projects.Publishers_ApiService>("api-service")
330330
.WithComputeEnvironment(aasEnv)

src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private async Task ExecuteConfigurationCallbacksAsync(
190190
{
191191
Services = pipelineContext.Services,
192192
Steps = allSteps.AsReadOnly(),
193-
ApplicationModel = pipelineContext.Model,
193+
Model = pipelineContext.Model,
194194
StepToResourceMap = stepToResourceMap
195195
};
196196

src/Aspire.Hosting/Pipelines/PipelineConfigurationContext.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,42 @@ public class PipelineConfigurationContext
2525
/// <summary>
2626
/// Gets the distributed application model containing all resources.
2727
/// </summary>
28-
public required DistributedApplicationModel ApplicationModel { get; init; }
28+
public required DistributedApplicationModel Model { get; init; }
2929

3030
internal IReadOnlyDictionary<PipelineStep, IResource> StepToResourceMap { get; init; } = null!;
3131

3232
/// <summary>
33-
/// Finds all pipeline steps with the specified tag.
33+
/// Gets all pipeline steps with the specified tag.
3434
/// </summary>
3535
/// <param name="tag">The tag to search for.</param>
3636
/// <returns>A collection of steps that have the specified tag.</returns>
37-
public IEnumerable<PipelineStep> FindStepsByTag(string tag)
37+
public IEnumerable<PipelineStep> GetSteps(string tag)
3838
{
3939
ArgumentNullException.ThrowIfNull(tag);
4040
return Steps.Where(s => s.Tags.Contains(tag));
4141
}
4242

4343
/// <summary>
44-
/// Finds all pipeline steps associated with the specified resource.
44+
/// Gets all pipeline steps associated with the specified resource.
4545
/// </summary>
4646
/// <param name="resource">The resource to search for.</param>
4747
/// <returns>A collection of steps associated with the resource.</returns>
48-
public IEnumerable<PipelineStep> FindStepsByResource(IResource resource)
48+
public IEnumerable<PipelineStep> GetSteps(IResource resource)
4949
{
5050
ArgumentNullException.ThrowIfNull(resource);
5151
return StepToResourceMap.Where(kvp => kvp.Value == resource).Select(kvp => kvp.Key);
5252
}
5353

5454
/// <summary>
55-
/// Finds all pipeline steps with the specified tag that are associated with the specified resource.
55+
/// Gets all pipeline steps with the specified tag that are associated with the specified resource.
5656
/// </summary>
57-
/// <param name="tag">The tag to search for.</param>
5857
/// <param name="resource">The resource to search for.</param>
58+
/// <param name="tag">The tag to search for.</param>
5959
/// <returns>A collection of steps that have the specified tag and are associated with the resource.</returns>
60-
public IEnumerable<PipelineStep> FindStepsByTagAndResource(string tag, IResource resource)
60+
public IEnumerable<PipelineStep> GetSteps(IResource resource, string tag)
6161
{
62-
ArgumentNullException.ThrowIfNull(tag);
6362
ArgumentNullException.ThrowIfNull(resource);
64-
return FindStepsByResource(resource).Where(s => s.Tags.Contains(tag));
63+
ArgumentNullException.ThrowIfNull(tag);
64+
return GetSteps(resource).Where(s => s.Tags.Contains(tag));
6565
}
6666
}

tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ public async Task ExecuteAsync_ConfigurationCallback_CanModifyDependencies()
17781778
}
17791779

17801780
[Fact]
1781-
public async Task PipelineConfigurationContext_FindStepsByTag_ReturnsCorrectSteps()
1781+
public async Task PipelineConfigurationContext_GetStepsByTag_ReturnsCorrectSteps()
17821782
{
17831783
using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish, publisher: "default", isDeploy: true);
17841784
var pipeline = new DistributedApplicationPipeline();
@@ -1808,7 +1808,7 @@ public async Task PipelineConfigurationContext_FindStepsByTag_ReturnsCorrectStep
18081808

18091809
pipeline.AddPipelineConfiguration((configContext) =>
18101810
{
1811-
foundSteps.AddRange(configContext.FindStepsByTag("test-tag"));
1811+
foundSteps.AddRange(configContext.GetSteps("test-tag"));
18121812
return Task.CompletedTask;
18131813
});
18141814

@@ -1822,7 +1822,7 @@ public async Task PipelineConfigurationContext_FindStepsByTag_ReturnsCorrectStep
18221822
}
18231823

18241824
[Fact]
1825-
public async Task PipelineConfigurationContext_FindStepsByResource_ReturnsCorrectSteps()
1825+
public async Task PipelineConfigurationContext_GetStepsByResource_ReturnsCorrectSteps()
18261826
{
18271827
using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish, publisher: "default", isDeploy: true);
18281828

@@ -1856,10 +1856,10 @@ public async Task PipelineConfigurationContext_FindStepsByResource_ReturnsCorrec
18561856
})
18571857
.WithPipelineConfiguration((configContext) =>
18581858
{
1859-
var resource2Instance = configContext.ApplicationModel.Resources.FirstOrDefault(r => r.Name == "resource2");
1859+
var resource2Instance = configContext.Model.Resources.FirstOrDefault(r => r.Name == "resource2");
18601860
if (resource2Instance != null)
18611861
{
1862-
foundSteps.AddRange(configContext.FindStepsByResource(resource2Instance));
1862+
foundSteps.AddRange(configContext.GetSteps(resource2Instance));
18631863
}
18641864
});
18651865

@@ -1872,7 +1872,7 @@ public async Task PipelineConfigurationContext_FindStepsByResource_ReturnsCorrec
18721872
}
18731873

18741874
[Fact]
1875-
public async Task PipelineConfigurationContext_FindStepsByTagAndResource_ReturnsCorrectSteps()
1875+
public async Task PipelineConfigurationContext_GetStepsByResourceAndTag_ReturnsCorrectSteps()
18761876
{
18771877
using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish, publisher: "default", isDeploy: true);
18781878

@@ -1896,10 +1896,10 @@ public async Task PipelineConfigurationContext_FindStepsByTagAndResource_Returns
18961896
])
18971897
.WithPipelineConfiguration((configContext) =>
18981898
{
1899-
var resource1Instance = configContext.ApplicationModel.Resources.FirstOrDefault(r => r.Name == "resource1");
1899+
var resource1Instance = configContext.Model.Resources.FirstOrDefault(r => r.Name == "resource1");
19001900
if (resource1Instance != null)
19011901
{
1902-
foundSteps.AddRange(configContext.FindStepsByTagAndResource("build", resource1Instance));
1902+
foundSteps.AddRange(configContext.GetSteps(resource1Instance, "build"));
19031903
}
19041904
});
19051905

@@ -1953,7 +1953,7 @@ public async Task WithPipelineConfiguration_SyncOverload_ExecutesCallback()
19531953
}
19541954

19551955
[Fact]
1956-
public async Task ConfigurationCallback_CanAccessApplicationModel()
1956+
public async Task ConfigurationCallback_CanAccessModel()
19571957
{
19581958
using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish, publisher: "default", isDeploy: true);
19591959

@@ -1962,7 +1962,7 @@ public async Task ConfigurationCallback_CanAccessApplicationModel()
19621962
var resource = builder.AddResource(new CustomResource("test-resource"))
19631963
.WithPipelineConfiguration((configContext) =>
19641964
{
1965-
capturedResource = configContext.ApplicationModel.Resources.FirstOrDefault(r => r.Name == "test-resource");
1965+
capturedResource = configContext.Model.Resources.FirstOrDefault(r => r.Name == "test-resource");
19661966
});
19671967

19681968
var pipeline = new DistributedApplicationPipeline();
@@ -2069,9 +2069,9 @@ public async Task ConfigurationCallback_CanCreateComplexDependencyRelationships(
20692069
// and all deploy steps depend on all build steps
20702070
pipeline.AddPipelineConfiguration((configContext) =>
20712071
{
2072-
var provisionSteps = configContext.FindStepsByTag(WellKnownPipelineTags.ProvisionInfrastructure).ToList();
2073-
var buildSteps = configContext.FindStepsByTag(WellKnownPipelineTags.BuildCompute).ToList();
2074-
var deploySteps = configContext.FindStepsByTag(WellKnownPipelineTags.DeployCompute).ToList();
2072+
var provisionSteps = configContext.GetSteps(WellKnownPipelineTags.ProvisionInfrastructure).ToList();
2073+
var buildSteps = configContext.GetSteps(WellKnownPipelineTags.BuildCompute).ToList();
2074+
var deploySteps = configContext.GetSteps(WellKnownPipelineTags.DeployCompute).ToList();
20752075

20762076
foreach (var buildStep in buildSteps)
20772077
{

0 commit comments

Comments
 (0)