Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create temp directory only if necessary #1014

Merged
merged 2 commits into from
Nov 28, 2023
Merged
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
12 changes: 10 additions & 2 deletions src/Aspire.Hosting/Dcp/Locations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@

namespace Aspire.Hosting.Dcp;

internal sealed class Locations(string basePath)
internal sealed class Locations
{
public string DcpSessionDir => basePath;
stbau04 marked this conversation as resolved.
Show resolved Hide resolved
private string? _basePath;

public string DcpSessionDir => GetOrCreateBasePath();

public string DcpKubeconfigPath => Path.Combine(DcpSessionDir, "kubeconfig");

public string DcpLogSocket => Path.Combine(DcpSessionDir, "output.sock");

private string GetOrCreateBasePath()
{
_basePath ??= Directory.CreateTempSubdirectory("aspire.").FullName;
return _basePath;
}
}
3 changes: 1 addition & 2 deletions src/Aspire.Hosting/DistributedApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public DistributedApplicationBuilder(DistributedApplicationOptions options)
_innerBuilder.Services.AddHostedService<DcpHostService>();

// We need a unique path per application instance
var path = Directory.CreateTempSubdirectory("aspire.").FullName;
_innerBuilder.Services.AddSingleton(new Locations(path));
_innerBuilder.Services.AddSingleton(new Locations());
_innerBuilder.Services.AddSingleton<KubernetesService>();

// Publishing support
Expand Down