Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Aspire.Hosting.Azure;
/// </remarks>
/// <param name="name">The name of the resource.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure NAT Gateway resource.</param>
public class AzureNatGatewayResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
public sealed class AzureNatGatewayResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure)
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Aspire.Hosting.Azure;
/// </remarks>
/// <param name="name">The name of the resource.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure Network Security Group resource.</param>
public class AzureNetworkSecurityGroupResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
public sealed class AzureNetworkSecurityGroupResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure)
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Aspire.Hosting.Azure;
/// </remarks>
/// <param name="name">The name of the resource.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure Network Security Perimeter resource.</param>
public class AzureNetworkSecurityPerimeterResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
public sealed class AzureNetworkSecurityPerimeterResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure)
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure;
/// <param name="subnet">The subnet where the private endpoint will be created.</param>
/// <param name="target">The target Azure resource to connect via private link.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure Private Endpoint resource.</param>
public class AzurePrivateEndpointResource(
public sealed class AzurePrivateEndpointResource(
string name,
AzureSubnetResource subnet,
IAzurePrivateEndpointTarget target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Aspire.Hosting.Azure;
/// </remarks>
/// <param name="name">The name of the resource.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure Public IP Address resource.</param>
public class AzurePublicIPAddressResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
public sealed class AzurePublicIPAddressResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure)
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.Azure.Network/AzureSubnetResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Aspire.Hosting.Azure;
/// </remarks>
/// <ats-remarks />
[AspireExport]
public class AzureSubnetResource : Resource, IResourceWithParent<AzureVirtualNetworkResource>
public sealed class AzureSubnetResource : Resource, IResourceWithParent<AzureVirtualNetworkResource>
{
// Backing field holds either string or ParameterResource
private readonly object _addressPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Aspire.Hosting.Azure;
/// <param name="name">The name of the resource.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure Virtual Network resource.</param>
[AspireExport]
public class AzureVirtualNetworkResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
public sealed class AzureVirtualNetworkResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure)
{
private const string DefaultAddressPrefix = "10.0.0.0/16";
Expand Down
2 changes: 2 additions & 0 deletions src/Aspire.Hosting.Azure/AzureRoleAssignmentResource.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.Azure;
Expand All @@ -19,6 +20,7 @@ namespace Aspire.Hosting.Azure;
/// <param name="ownerResource">The Aspire resource that owns this set of role assignments, or <see langword="null"/> for global role assignments granted to the deployment principal.</param>
/// <param name="identityResource">The user-assigned managed identity whose principal receives the role assignments, or <see langword="null"/> for global role assignments granted to the deployment principal.</param>
/// <param name="configureInfrastructure">Callback to configure the Azure role assignment resources.</param>
[Experimental("ASPIREAZURE003", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
public sealed class AzureRoleAssignmentResource(
string name,
AzureProvisioningResource targetAzureResource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ namespace Aspire.Hosting.Azure;
/// <summary>
/// An annotation that points to the resource that contains the role assignments for an Azure resource.
/// </summary>
#pragma warning disable ASPIREAZURE003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
internal sealed class RoleAssignmentResourceAnnotation(AzureRoleAssignmentResource rolesResource) : IResourceAnnotation
{
/// <summary>
/// The resource that contains the role assignments for the Azure resource.
/// </summary>
public AzureRoleAssignmentResource RolesResource { get; } = rolesResource;
}
#pragma warning restore ASPIREAZURE003
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Aspire.Hosting;
/// </summary>
[Experimental("ASPIREBLAZOR001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
[AspireExport]
public class BlazorWasmAppResource(string name, string projectPath) : Resource(name), IResourceWithEnvironment, IResourceWithParent
public sealed class BlazorWasmAppResource(string name, string projectPath) : Resource(name), IResourceWithEnvironment, IResourceWithParent
{
/// <summary>Fully-qualified path to the .csproj file.</summary>
public string ProjectPath { get; } = projectPath;
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.JavaScript/BunAppResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ namespace Aspire.Hosting.JavaScript;
/// <param name="command">The command to execute.</param>
/// <param name="workingDirectory">The working directory to use for the command.</param>
[AspireExport(ExposeProperties = true)]
public class BunAppResource(string name, string command, string workingDirectory)
public sealed class BunAppResource(string name, string command, string workingDirectory)
: JavaScriptAppResource(name, command, workingDirectory), IResourceWithServiceDiscovery, IContainerFilesDestinationResource;
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.JavaScript/NextJsAppResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ namespace Aspire.Hosting.JavaScript;
/// <param name="workingDirectory">The working directory from which the application command is executed.</param>
[AspireExport(ExposeProperties = true)]
[Experimental("ASPIREJAVASCRIPT001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
public class NextJsAppResource(string name, string command, string workingDirectory)
public sealed class NextJsAppResource(string name, string command, string workingDirectory)
: JavaScriptAppResource(name, command, workingDirectory);
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.JavaScript/ViteAppResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Aspire.Hosting.JavaScript;
/// <param name="command">The command to execute the Vite application, such as the script or entry point.</param>
/// <param name="workingDirectory">The working directory from which the Vite application command is executed.</param>
[AspireExport(ExposeProperties = true)]
public class ViteAppResource(string name, string command, string workingDirectory)
public sealed class ViteAppResource(string name, string command, string workingDirectory)
: JavaScriptAppResource(name, command, workingDirectory)
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Aspire.Hosting.Kubernetes;
/// </code>
/// </example>
[AspireExport]
public class KubernetesHelmChartResource : Resource, IResourceWithParent<KubernetesEnvironmentResource>
public sealed class KubernetesHelmChartResource : Resource, IResourceWithParent<KubernetesEnvironmentResource>
{
/// <summary>
/// Initializes a new instance of <see cref="KubernetesHelmChartResource"/>.
Expand Down
8 changes: 4 additions & 4 deletions src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public class AllocatedEndpoint
/// <param name="port">The port number of the endpoint.</param>
/// <param name="targetPortExpression">A string representing how to retrieve the target port of the <see cref="AllocatedEndpoint"/> instance.</param>
/// <param name="bindingMode">The binding mode of the endpoint.</param>
/// <param name="networkID">The network identifier for the network associated with the endpoint.</param>
/// <param name="networkId">The network identifier for the network associated with the endpoint.</param>
public AllocatedEndpoint(
EndpointAnnotation endpoint,
string address, int port,
EndpointBindingMode bindingMode,
string? targetPortExpression = null,
NetworkIdentifier? networkID = null
NetworkIdentifier? networkId = null
)
{
ArgumentNullException.ThrowIfNull(endpoint);
Expand All @@ -63,7 +63,7 @@ public AllocatedEndpoint(
BindingMode = bindingMode;
Port = port;
TargetPortExpression = targetPortExpression;
NetworkID = networkID ?? endpoint.DefaultNetworkID;
NetworkId = networkId ?? endpoint.DefaultNetworkId;
}

/// <summary>
Expand Down Expand Up @@ -139,7 +139,7 @@ public AllocatedEndpoint(EndpointAnnotation endpoint, string address, int port,
/// <summary>
/// Gets the network identifier for the network associated with the <see cref="AllocatedEndpoint"/> instance.
/// </summary>
public NetworkIdentifier NetworkID { get; private set; }
public NetworkIdentifier NetworkId { get; private set; }

/// <summary>
/// Returns a string representation of the allocated endpoint URI.
Expand Down
52 changes: 26 additions & 26 deletions src/Aspire.Hosting/ApplicationModel/EndpointAnnotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class EndpointAnnotation : IResourceAnnotation
private bool? _tlsEnabled;
private bool _isProxied = true;
private bool? _isExplicitlyProxied;
private readonly NetworkIdentifier _networkID;
private readonly NetworkIdentifier _networkId;

/// <summary>
/// Initializes a new instance of <see cref="EndpointAnnotation"/>.
Expand Down Expand Up @@ -97,7 +97,7 @@ bool isProxied
/// Initializes a new instance of <see cref="EndpointAnnotation"/>.
/// </summary>
/// <param name="protocol">Network protocol: TCP or UDP are supported today, others possibly in future.</param>
/// <param name="networkID">The ID of the network that is the "default" network for the Endpoint.
/// <param name="networkId">The ID of the network that is the "default" network for the Endpoint.
/// Clients connected to the same network can reach the endpoint without any routing or network address translation.</param>
/// <param name="uriScheme">If a service is URI-addressable, this is the URI scheme to use for constructing service URI.</param>
/// <param name="transport">Transport that is being used (e.g. http, http2, http3 etc).</param>
Expand All @@ -108,7 +108,7 @@ bool isProxied
/// <param name="isProxied">Specifies if the endpoint will be proxied by DCP. Defaults to <see langword="null"/>.</param>
public EndpointAnnotation(
ProtocolType protocol,
NetworkIdentifier? networkID,
NetworkIdentifier? networkId,
string? uriScheme = null,
string? transport = null,
[EndpointName] string? name = null,
Expand Down Expand Up @@ -136,17 +136,17 @@ public EndpointAnnotation(
_targetPort = targetPort;
IsExternal = isExternal ?? false;
IsExplicitlyProxied = isProxied;
_networkID = networkID ?? KnownNetworkIdentifiers.LocalhostNetwork;
_networkId = networkId ?? KnownNetworkIdentifiers.LocalhostNetwork;
#pragma warning disable CS0618 // Type or member is obsolete
AllAllocatedEndpoints.TryAdd(_networkID, AllocatedEndpointSnapshot);
AllAllocatedEndpoints.TryAdd(_networkId, AllocatedEndpointSnapshot);
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
/// Initializes a new instance of <see cref="EndpointAnnotation"/>.
/// </summary>
/// <param name="protocol">Network protocol: TCP or UDP are supported today, others possibly in future.</param>
/// <param name="networkID">The ID of the network that is the "default" network for the Endpoint.
/// <param name="networkId">The ID of the network that is the "default" network for the Endpoint.
/// Clients connected to the same network can reach the endpoint without any routing or network address translation.</param>
/// <param name="uriScheme">If a service is URI-addressable, this is the URI scheme to use for constructing service URI.</param>
/// <param name="transport">Transport that is being used (e.g. http, http2, http3 etc).</param>
Expand All @@ -157,7 +157,7 @@ public EndpointAnnotation(
/// <param name="isProxied">Specifies if the endpoint will be proxied by DCP.</param>
public EndpointAnnotation(
ProtocolType protocol,
NetworkIdentifier? networkID,
NetworkIdentifier? networkId,
string? uriScheme,
string? transport,
[EndpointName] string? name,
Expand All @@ -167,7 +167,7 @@ public EndpointAnnotation(
bool isProxied
) : this(
protocol,
networkID,
networkId,
uriScheme,
transport,
name,
Expand Down Expand Up @@ -334,7 +334,7 @@ public bool TlsEnabled
/// <summary>
/// Gets the ID of the network that is the "default" network for the Endpoint (the one the Endpoint is associated with and can be reached without routing or network address translation).
/// </summary>
public NetworkIdentifier DefaultNetworkID => _networkID;
public NetworkIdentifier DefaultNetworkId => _networkId;

/// <summary>
/// Gets or sets the default <see cref="AllocatedEndpoint"/> for this Endpoint.
Expand Down Expand Up @@ -364,9 +364,9 @@ public AllocatedEndpoint? AllocatedEndpoint
}
else
{
if (_networkID != value.NetworkID)
if (_networkId != value.NetworkId)
{
throw new InvalidOperationException($"The default AllocatedEndpoint's network ID must match the EndpointAnnotation network ID ('{_networkID}'). The attempted AllocatedEndpoint belongs to '{value.NetworkID}'.");
throw new InvalidOperationException($"The default AllocatedEndpoint's network ID must match the EndpointAnnotation network ID ('{_networkId}'). The attempted AllocatedEndpoint belongs to '{value.NetworkId}'.");
}
AllocatedEndpointSnapshot.SetValue(value);
}
Expand All @@ -390,9 +390,9 @@ public AllocatedEndpoint? AllocatedEndpoint
/// Represents an AllocatedEndpoint snapshot associated with a specific network.
/// </summary>
/// <param name="Snapshot">AllocatedEndpoint snapshot</param>
/// <param name="NetworkID">The ID of the network that is associated with the AllocatedEndpoint snapshot.</param>
[DebuggerDisplay("NetworkID = {NetworkID}, Endpoint = {Snapshot}")]
public record class NetworkEndpointSnapshot(ValueSnapshot<AllocatedEndpoint> Snapshot, NetworkIdentifier NetworkID);
/// <param name="NetworkId">The ID of the network that is associated with the AllocatedEndpoint snapshot.</param>
[DebuggerDisplay("NetworkId = {NetworkId}, Endpoint = {Snapshot}")]
public record class NetworkEndpointSnapshot(ValueSnapshot<AllocatedEndpoint> Snapshot, NetworkIdentifier NetworkId);

/// <summary>
/// Holds a list of <see cref="NetworkEndpointSnapshot"/> for an Endpoint, providing thread-safe enumeration and addition.
Expand All @@ -419,49 +419,49 @@ IEnumerator IEnumerable.GetEnumerator()
/// Adds an AllocatedEndpoint snapshot for a specific network if one does not already exist.
/// </summary>
[Obsolete("This method is for internal use only and will be marked internal in a future Aspire release. Use AddOrUpdateAllocatedEndpoint instead.")]
public bool TryAdd(NetworkIdentifier networkID, ValueSnapshot<AllocatedEndpoint> snapshot)
public bool TryAdd(NetworkIdentifier networkId, ValueSnapshot<AllocatedEndpoint> snapshot)
{
lock (_snapshots)
{
if (_snapshots.Any(s => s.NetworkID.Equals(networkID)))
if (_snapshots.Any(s => s.NetworkId.Equals(networkId)))
{
return false;
}
_snapshots.Add(new NetworkEndpointSnapshot(snapshot, networkID));
_snapshots.Add(new NetworkEndpointSnapshot(snapshot, networkId));
return true;
}
}

/// <summary>
/// Adds or updates an AllocatedEndpoint value associated with a specific network in the snapshot list.
/// </summary>
public void AddOrUpdateAllocatedEndpoint(NetworkIdentifier networkID, AllocatedEndpoint endpoint)
public void AddOrUpdateAllocatedEndpoint(NetworkIdentifier networkId, AllocatedEndpoint endpoint)
{
if (endpoint.NetworkID != networkID)
if (endpoint.NetworkId != networkId)
{
throw new ArgumentException($"AllocatedEndpoint must use the same network as the {nameof(networkID)} parameter", nameof(endpoint));
throw new ArgumentException($"AllocatedEndpoint must use the same network as the {nameof(networkId)} parameter", nameof(endpoint));
}
var nes = GetSnapshotFor(networkID);
var nes = GetSnapshotFor(networkId);
nes.Snapshot.SetValue(endpoint);
}

/// <summary>
/// Gets an AllocatedEndpoint for a given network ID, waiting for it to appear if it is not already present.
/// </summary>
public Task<AllocatedEndpoint> GetAllocatedEndpointAsync(NetworkIdentifier networkID, CancellationToken cancellationToken = default)
public Task<AllocatedEndpoint> GetAllocatedEndpointAsync(NetworkIdentifier networkId, CancellationToken cancellationToken = default)
{
var nes = GetSnapshotFor(networkID);
var nes = GetSnapshotFor(networkId);
return nes.Snapshot.GetValueAsync(cancellationToken);
}

private NetworkEndpointSnapshot GetSnapshotFor(NetworkIdentifier networkID)
private NetworkEndpointSnapshot GetSnapshotFor(NetworkIdentifier networkId)
{
lock (_snapshots)
{
var nes = _snapshots.FirstOrDefault(s => s.NetworkID.Equals(networkID));
var nes = _snapshots.FirstOrDefault(s => s.NetworkId.Equals(networkId));
if (nes is null)
{
nes = new NetworkEndpointSnapshot(new ValueSnapshot<AllocatedEndpoint>(), networkID);
nes = new NetworkEndpointSnapshot(new ValueSnapshot<AllocatedEndpoint>(), networkId);
_snapshots.Add(nes);
}
return nes;
Expand Down
Loading
Loading