Skip to content
Open
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
11 changes: 11 additions & 0 deletions tools/code/common/Gateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace common;

public sealed record GatewayName : ResourceName, IResourceName<GatewayName>
{
public static GatewayName Managed { get; } = From("managed");

private GatewayName(string value) : base(value) { }

public static GatewayName From(string value) => new(value);
Expand Down Expand Up @@ -119,6 +121,15 @@ public static Option<GatewayInformationFile> TryParse(FileInfo? file, Management

public sealed record GatewayDto
{
public static GatewayDto Managed { get; } = new()
{
Properties = new GatewayContract
{
Description = null,
LocationData = null
}
};

[JsonPropertyName("properties")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public required GatewayContract Properties { get; init; }
Expand Down
8 changes: 6 additions & 2 deletions tools/code/extractor/Gateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ await list(cancellationToken)

async ValueTask extractGateway(GatewayName name, GatewayDto dto, CancellationToken cancellationToken)
{
await writeArtifacts(name, dto, cancellationToken);
if (name != GatewayName.Managed)
{
await writeArtifacts(name, dto, cancellationToken);
}
await extractGatewayApis(name, cancellationToken);
}
}
Expand Down Expand Up @@ -97,7 +100,8 @@ private static ListGateways GetListGateways(IServiceProvider provider)
IAsyncEnumerable<(GatewayName, GatewayDto)> listAll(CancellationToken cancellationToken)
{
var gatewaysUri = GatewaysUri.From(serviceUri);
return gatewaysUri.List(pipeline, cancellationToken);
return gatewaysUri.List(pipeline, cancellationToken)
.Append((GatewayName.Managed, GatewayDto.Managed));
}
}

Expand Down
2 changes: 2 additions & 0 deletions tools/code/publisher/Gateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private static PutGateways GetPutGateways(IServiceProvider provider)
await getPublisherFiles()
.Choose(tryParseName.Invoke)
.Where(isNameInSourceControl.Invoke)
.Where(name => name != GatewayName.Managed)
.Distinct()
.IterParallel(put.Invoke, cancellationToken);
};
Expand Down Expand Up @@ -203,6 +204,7 @@ private static DeleteGateways GetDeleteGateways(IServiceProvider provider)
await getPublisherFiles()
.Choose(tryParseName.Invoke)
.Where(name => isNameInSourceControl(name) is false)
.Where(name => name != GatewayName.Managed)
.Distinct()
.IterParallel(delete.Invoke, cancellationToken);
};
Expand Down
16 changes: 13 additions & 3 deletions tools/code/publisher/GatewayApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using LanguageExt.UnsafeValueAccess;

namespace publisher;

Expand Down Expand Up @@ -182,7 +183,9 @@ public static void ConfigureDeleteGatewayApis(IHostApplicationBuilder builder)
private static DeleteGatewayApis GetDeleteGatewayApis(IServiceProvider provider)
{
var getPublisherFiles = provider.GetRequiredService<GetPublisherFiles>();
var tryParseName = provider.GetRequiredService<TryParseGatewayApiName>();
var tryParseGatewayApiName = provider.GetRequiredService<TryParseGatewayApiName>();
var tryParseApiName = provider.GetRequiredService<TryParseApiName>();
var serviceDirectory = provider.GetRequiredService<ManagementServiceDirectory>();
var isNameInSourceControl = provider.GetRequiredService<IsGatewayApiNameInSourceControl>();
var delete = provider.GetRequiredService<DeleteGatewayApi>();
var activitySource = provider.GetRequiredService<ActivitySource>();
Expand All @@ -194,8 +197,15 @@ private static DeleteGatewayApis GetDeleteGatewayApis(IServiceProvider provider)

logger.LogInformation("Deleting gateway apis...");

await getPublisherFiles()
.Choose(tryParseName.Invoke)
var publisherFiles = getPublisherFiles();
var managedGatewayGatewayApis = publisherFiles.Select(x => tryParseApiName(x))
.Where(x => x.IsSome)
.Select(x => GatewayApiInformationFile.From(x.ValueUnsafe()!, GatewayName.Managed, serviceDirectory)
.ToFileInfo());

await publisherFiles
.Concat(managedGatewayGatewayApis)
.Choose(tryParseGatewayApiName.Invoke)
.Where(api => isNameInSourceControl(api.Name, api.GatewayName) is false)
.Distinct()
.IterParallel(delete.Invoke, cancellationToken);
Expand Down