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 @@ -30,4 +30,7 @@ internal static partial class DockerComposePublisherLoggerExtensions

[LoggerMessage(LogLevel.Warning, "Failed to get container image for resource '{ResourceName}', it will be skipped in the output.")]
internal static partial void FailedToGetContainerImage(this ILogger logger, string resourceName);

[LoggerMessage(LogLevel.Warning, "Not in publishing mode. Skipping writing docker-compose.yaml output file.")]
internal static partial void NotInPublishingMode(this ILogger logger);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ internal sealed class DockerComposePublishingContext(

internal async Task WriteModelAsync(DistributedApplicationModel model)
{
if (executionContext.IsRunMode)
if (!executionContext.IsPublishMode)
{
logger.NotInPublishingMode();
return;
}

Expand Down
60 changes: 60 additions & 0 deletions src/Aspire.Hosting.Kubernetes/Extensions/HelmExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Aspire.Hosting.Kubernetes.Extensions;

internal static class HelmExtensions
{
private const string DeploymentKey = "deployment";
private const string StatefulSetKey = "statefulset";
private const string ServiceKey = "service";
private const string PvcKey = "pvc";
private const string PvKey = "pv";
private const string ValuesSegment = ".Values";
public const string ParametersKey = "parameters";
public const string SecretsKey = "secrets";
public const string ConfigKey = "config";
public const string TemplateFileSeparator = "---";

public static string ToManifestFriendlyResourceName(this string name)
=> name.Replace("-", "_");

public static string ToHelmParameterExpression(this string parameterName, string resourceName)
=> $"{{{{ {ValuesSegment}.{ParametersKey}.{resourceName}.{parameterName} }}}}";

public static string ToHelmSecretExpression(this string parameterName, string resourceName)
=> $"{{{{ {ValuesSegment}.{SecretsKey}.{resourceName}.{parameterName} }}}}";

public static string ToHelmConfigExpression(this string parameterName, string resourceName)
=> $"{{{{ {ValuesSegment}.{ConfigKey}.{resourceName}.{parameterName} }}}}";

public static string ToConfigMapName(this string resourceName)
=> $"{resourceName}-{ConfigKey}";

public static string ToSecretName(this string resourceName)
=> $"{resourceName}-{SecretsKey}";

public static string ToDeploymentName(this string resourceName)
=> $"{resourceName}-{DeploymentKey}";

public static string ToStatefulSetName(this string resourceName)
=> $"{resourceName}-{StatefulSetKey}";

public static string ToServiceName(this string resourceName)
=> $"{resourceName}-{ServiceKey}";

public static string ToPvcName(this string resourceName, string volumeName)
=> $"{resourceName}-{volumeName}-{PvcKey}";

public static string ToPvName(this string resourceName, string volumeName)
=> $"{resourceName}-{volumeName}-{PvKey}";

public static bool IsHelmExpression(this string value)
=> value.Contains($"{{{{ {ValuesSegment}.", StringComparison.Ordinal);

public static bool IsHelmSecretExpression(this string value)
=> value.Contains($"{{{{ {ValuesSegment}.{SecretsKey}.", StringComparison.Ordinal);

public static bool IsConnectionString(this string value)
=> value.StartsWith("CONNECTIONSTRINGS__", StringComparison.OrdinalIgnoreCase);
}
Loading
Loading