-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/8.0] Hook which rewrites the container registry in annotatio…
…ns. (#3583) * Hook which rewrites the container registry in annotations. * Change to using options instead of extension method. --------- Co-authored-by: Mitch Denny <midenn@microsoft.com>
- Loading branch information
1 parent
05c1b15
commit 3cc2faa
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Aspire.Hosting/Lifecycle/ContainerRegistryCheckHook.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Hosting.ApplicationModel; | ||
using Aspire.Hosting.Lifecycle; | ||
|
||
namespace Aspire.Hosting; | ||
|
||
internal class ContainerRegistryHook(DistributedApplicationOptions options) : IDistributedApplicationLifecycleHook | ||
{ | ||
public Task BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken = default) | ||
{ | ||
|
||
var resourcesWithContainerImages = appModel.Resources | ||
.SelectMany(r => r.Annotations.OfType<ContainerImageAnnotation>() | ||
.Select(cia => new { Resource = r, Annotation = cia })); | ||
|
||
foreach (var resourceWithContainerImage in resourcesWithContainerImages) | ||
{ | ||
resourceWithContainerImage.Annotation.Registry = options.ContainerRegistryOverride; | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters