Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Nullable>enable</Nullable>

<AspireMajorVersion>13</AspireMajorVersion>
<AspireVersion>$(AspireMajorVersion).0.0-preview.1.25523.9</AspireVersion>
<AspireVersion>$(AspireMajorVersion).0.0-preview.1.25526.2</AspireVersion>
<AspireAppHostSdkVersion>$(AspireVersion)</AspireAppHostSdkVersion>
<AspirePreviewSuffix>preview.1.25474.7</AspirePreviewSuffix>
<AspNetCoreVersion>9.0.0</AspNetCoreVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ public abstract class ActiveMQServerResourceBase(string name, ParameterResource?
/// <inheritdoc />
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create(
$"{scheme}://{UserNameReference}:{PasswordParameter}@{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");
$"{scheme}://{UserNameReference}:{PasswordParameter:uri}@{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");

/// <summary>
/// Gets the primary endpoint for the ActiveMQ server.
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new EndpointReference(this, PrimaryEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the parameter that contains the ActiveMQ server username.
/// </summary>
Expand All @@ -49,7 +59,24 @@ public abstract class ActiveMQServerResourceBase(string name, ParameterResource?
UserNameParameter is not null ?
ReferenceExpression.Create($"{UserNameParameter}") :
ReferenceExpression.Create($"{DefaultUserName}");


/// <summary>
/// Gets the connection URI expression for the ActiveMQ server.
/// </summary>
/// <remarks>
/// Format: <c>{scheme}://{user}:{password}@{host}:{port}</c>.
/// </remarks>
public ReferenceExpression UriExpression => ConnectionStringExpression;

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Username", UserNameReference);
yield return new("Password", ReferenceExpression.Create($"{PasswordParameter:uri}"));
yield return new("Uri", UriExpression);
}

private static T ThrowIfNull<T>([NotNull] T? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
=> argument ?? throw new ArgumentNullException(paramName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,35 @@ public class EventStoreResource(string name) : ContainerResource(name), IResourc
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, HttpEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the connection string for the EventStore server.
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create(
$"esdb://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}?tls=false");

/// <summary>
/// Gets the connection URI expression for the EventStore server.
/// </summary>
/// <remarks>
/// Format: <c>esdb://{host}:{port}?tls=false</c>.
/// </remarks>
public ReferenceExpression UriExpression => ConnectionStringExpression;

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Uri", UriExpression);
}
}
25 changes: 25 additions & 0 deletions src/CommunityToolkit.Aspire.Hosting.Flagd/FlagdResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public class FlagdResource(string name) : ContainerResource(name), IResourceWith
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpointReference ??= new(this, HttpEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the health check HTTP endpoint for the flagd server.
/// </summary>
Expand All @@ -41,4 +51,19 @@ public class FlagdResource(string name) : ContainerResource(name), IResourceWith
ReferenceExpression.Create(
$"{PrimaryEndpoint.Property(EndpointProperty.Scheme)}://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}"
);

/// <summary>
/// Gets the connection URI expression for the flagd server.
/// </summary>
/// <remarks>
/// Format: <c>http://{host}:{port}</c>.
/// </remarks>
public ReferenceExpression UriExpression => ConnectionStringExpression;

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Uri", UriExpression);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,34 @@ public class GoFeatureFlagResource(string name) : ContainerResource(name), IReso
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the connection string expression for the GO Feature Flag instance.
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create($"Endpoint=http://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");

/// <summary>
/// Gets the connection URI expression for the GO Feature Flag instance.
/// </summary>
/// <remarks>
/// Format: <c>http://{host}:{port}</c>.
/// </remarks>
public ReferenceExpression UriExpression => ReferenceExpression.Create($"http://{Host}:{Port}");

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Uri", UriExpression);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,34 @@ public class MailPitContainerResource(string name) : ContainerResource(name), IR
private EndpointReference? _smtpEndpoint;
private EndpointReference SmtpEndpoint => _smtpEndpoint ??= new EndpointReference(this, SmtpEndpointName);

/// <summary>
/// Gets the host endpoint reference for the SMTP endpoint.
/// </summary>
public EndpointReferenceExpression Host => SmtpEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for the SMTP endpoint.
/// </summary>
public EndpointReferenceExpression Port => SmtpEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// ConnectionString for MailPit smtp endpoint in the form of smtp://host:port.
/// </summary>
public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create(
$"Endpoint={SmtpEndpoint.Scheme}://{SmtpEndpoint.Property(EndpointProperty.Host)}:{SmtpEndpoint.Property(EndpointProperty.Port)}");

/// <summary>
/// Gets the connection URI expression for the MailPit SMTP endpoint.
/// </summary>
/// <remarks>
/// Format: <c>smtp://{host}:{port}</c>.
/// </remarks>
public ReferenceExpression UriExpression => ReferenceExpression.Create($"{SmtpEndpoint.Scheme}://{Host}:{Port}");

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Uri", UriExpression);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public MeilisearchResource(string name, ParameterResource masterKey) : base(name
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the parameter that contains the Meilisearch superuser password.
/// </summary>
Expand All @@ -32,5 +42,21 @@ public MeilisearchResource(string name, ParameterResource masterKey) : base(name
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create($"Endpoint=http://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)};MasterKey={MasterKeyParameter}");

/// <summary>
/// Gets the connection URI expression for the Meilisearch server.
/// </summary>
/// <remarks>
/// Format: <c>http://{host}:{port}</c>.
/// </remarks>
public ReferenceExpression UriExpression => ReferenceExpression.Create($"http://{Host}:{Port}");

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("MasterKey", ReferenceExpression.Create($"{MasterKeyParameter}"));
yield return new("Uri", UriExpression);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public sealed class MinioContainerResource(string name, ParameterResource rootUs
/// Gets the primary endpoint for the MinIO. This endpoint is used for all API calls over HTTP.
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName);

/// <summary>
/// Gets the connection string expression for the Minio
/// </summary>
public ReferenceExpression ConnectionStringExpression => GetConnectionString();

/// <summary>
/// Gets the connection string for the MinIO server.
/// </summary>
Expand All @@ -49,7 +49,7 @@ public sealed class MinioContainerResource(string name, ParameterResource rootUs

return ConnectionStringExpression.GetValueAsync(cancellationToken);
}

/// <summary>
/// Gets the connection string for the MinIO server.
/// </summary>
Expand All @@ -61,7 +61,7 @@ private ReferenceExpression GetConnectionString()
$"Endpoint=http://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");

builder.Append($";AccessKey={RootUser}");
builder.Append($";SecretKey={PasswordParameter}");
builder.Append($";SecretKey={PasswordParameter:uri}");

return builder.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class OllamaModelResource(string name, string modelName, OllamaResource p
/// </summary>
public string ModelName { get; } = ThrowIfNull(modelName);

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() =>
Parent.CombineProperties([
new("Model", ReferenceExpression.Create($"{ModelName}"))
]);

private static T ThrowIfNull<T>([NotNull] T? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
=> argument ?? throw new ArgumentNullException(paramName);
}
25 changes: 25 additions & 0 deletions src/CommunityToolkit.Aspire.Hosting.Ollama/OllamaResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public class OllamaResource(string name) : ContainerResource(name), IResourceWit
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpointReference ??= new(this, OllamaEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the connection string expression for the Ollama server.
/// </summary>
Expand All @@ -35,6 +45,14 @@ public class OllamaResource(string name) : ContainerResource(name), IResourceWit
$"Endpoint={PrimaryEndpoint.Property(EndpointProperty.Scheme)}://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}"
);

/// <summary>
/// Gets the connection URI expression for the Ollama server.
/// </summary>
/// <remarks>
/// Format: <c>http://{host}:{port}</c>.
/// </remarks>
public ReferenceExpression UriExpression => ReferenceExpression.Create($"{PrimaryEndpoint.Property(EndpointProperty.Scheme)}://{Host}:{Port}");

/// <summary>
/// Adds a model to the list of models to download on initial startup.
/// </summary>
Expand All @@ -47,4 +65,11 @@ public void AddModel(string modelName)
_models.Add(modelName);
}
}

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Uri", UriExpression);
}
}
25 changes: 25 additions & 0 deletions src/CommunityToolkit.Aspire.Hosting.Ollama/OpenWebUIResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,31 @@ public class OpenWebUIResource(string name) : ContainerResource(name), IResource
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName);

/// <summary>
/// Gets the host endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Host => PrimaryEndpoint.Property(EndpointProperty.Host);

/// <summary>
/// Gets the port endpoint reference for this resource.
/// </summary>
public EndpointReferenceExpression Port => PrimaryEndpoint.Property(EndpointProperty.Port);

/// <summary>
/// Gets the connection string expression for the Open WebUI endpoint.
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create(
$"{PrimaryEndpoint.Property(EndpointProperty.Url)}");

/// <summary>
/// Gets the connection URI expression for the Open WebUI endpoint.
/// </summary>
/// <remarks>
/// Format: <c>http://{host}:{port}</c>. The scheme reflects the endpoint configuration and may be <c>https</c> when TLS is enabled.
/// </remarks>
public ReferenceExpression UriExpression => ConnectionStringExpression;

private readonly List<OllamaResource> ollamaResources = [];

/// <summary>
Expand All @@ -42,4 +60,11 @@ internal void AddOllamaResource(OllamaResource ollamaResource)

ollamaResources.Add(ollamaResource);
}

IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties()
{
yield return new("Host", ReferenceExpression.Create($"{Host}"));
yield return new("Port", ReferenceExpression.Create($"{Port}"));
yield return new("Uri", UriExpression);
}
}
Loading
Loading