diff --git a/Directory.Packages.props b/Directory.Packages.props
index 1f67f49a5..eea93b757 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -13,8 +13,6 @@
-
-
diff --git a/src/tooling/Elastic.Documentation.Tooling/ExternalCommands/ExternalCommandExecutor.cs b/src/tooling/Elastic.Documentation.Tooling/ExternalCommands/ExternalCommandExecutor.cs
index 363b60987..5c51e9940 100644
--- a/src/tooling/Elastic.Documentation.Tooling/ExternalCommands/ExternalCommandExecutor.cs
+++ b/src/tooling/Elastic.Documentation.Tooling/ExternalCommands/ExternalCommandExecutor.cs
@@ -12,6 +12,7 @@ namespace Elastic.Documentation.Tooling.ExternalCommands;
public abstract class ExternalCommandExecutor(DiagnosticsCollector collector, IDirectoryInfo workingDirectory)
{
protected IDirectoryInfo WorkingDirectory => workingDirectory;
+ protected DiagnosticsCollector Collector => collector;
protected void ExecIn(Dictionary environmentVars, string binary, params string[] args)
{
var arguments = new ExecArguments(binary, args)
@@ -77,13 +78,13 @@ string[] CaptureOutput()
}
- protected string Capture(string binary, params string[] args) => Capture(false, binary, args);
-
- protected string Capture(bool muteExceptions, string binary, params string[] args)
+ protected string Capture(string binary, params string[] args) => Capture(false, 10, binary, args);
+ protected string Capture(bool muteExceptions, string binary, params string[] args) => Capture(muteExceptions, 10, binary, args);
+ protected string Capture(bool muteExceptions, int attempts, string binary, params string[] args)
{
// Try 10 times to capture the output of the command, if it fails, we'll throw an exception on the last try
Exception? e = null;
- for (var i = 0; i <= 9; i++)
+ for (var i = 1; i <= attempts; i++)
{
try
{
diff --git a/src/tooling/docs-assembler/Cli/DeployCommands.cs b/src/tooling/docs-assembler/Cli/DeployCommands.cs
index 9ece2c445..fcf96d817 100644
--- a/src/tooling/docs-assembler/Cli/DeployCommands.cs
+++ b/src/tooling/docs-assembler/Cli/DeployCommands.cs
@@ -6,9 +6,6 @@
using System.IO.Abstractions;
using System.Text.Json;
using Actions.Core.Services;
-using Amazon.CloudFront;
-using Amazon.CloudFrontKeyValueStore;
-using Amazon.CloudFrontKeyValueStore.Model;
using Amazon.S3;
using Amazon.S3.Transfer;
using ConsoleAppFramework;
@@ -20,12 +17,6 @@
namespace Documentation.Assembler.Cli;
-internal enum KvsOperation
-{
- Puts,
- Deletes
-}
-
internal sealed class DeployCommands(ILoggerFactory logger, ICoreService githubActionsService)
{
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
@@ -144,74 +135,11 @@ public async Task UpdateRedirects(
}
var kvsName = $"elastic-docs-v3-{environment}-redirects-kvs";
+ var cloudFrontClient = new AwsCloudFrontKeyValueStoreProxy(collector, new FileSystem().DirectoryInfo.New(Directory.GetCurrentDirectory()));
- var cfClient = new AmazonCloudFrontClient();
- var kvsClient = new AmazonCloudFrontKeyValueStoreClient();
-
- ConsoleApp.Log("Describing KVS");
- var describeResponse = await cfClient.DescribeKeyValueStoreAsync(new Amazon.CloudFront.Model.DescribeKeyValueStoreRequest { Name = kvsName }, ctx);
-
- var kvsArn = describeResponse.KeyValueStore.ARN;
- var eTag = describeResponse.ETag;
- var existingRedirects = new HashSet();
-
- var listKeysRequest = new ListKeysRequest { KvsARN = kvsArn };
- ListKeysResponse listKeysResponse;
-
- do
- {
- listKeysResponse = await kvsClient.ListKeysAsync(listKeysRequest, ctx);
- foreach (var item in listKeysResponse.Items)
- _ = existingRedirects.Add(item.Key);
- listKeysRequest.NextToken = listKeysResponse.NextToken;
- }
- while (!string.IsNullOrEmpty(listKeysResponse.NextToken));
-
- var toPut = sourcedRedirects
- .Select(kvp => new PutKeyRequestListItem { Key = kvp.Key, Value = kvp.Value });
- var toDelete = existingRedirects
- .Except(sourcedRedirects.Keys)
- .Select(k => new DeleteKeyRequestListItem { Key = k });
-
- ConsoleApp.Log("Updating redirects in KVS");
- const int batchSize = 50;
-
- eTag = await ProcessBatchUpdatesAsync(kvsClient, kvsArn, eTag, toPut, batchSize, KvsOperation.Puts, ctx);
- _ = await ProcessBatchUpdatesAsync(kvsClient, kvsArn, eTag, toDelete, batchSize, KvsOperation.Deletes, ctx);
+ cloudFrontClient.UpdateRedirects(kvsName, sourcedRedirects);
await collector.StopAsync(ctx);
return collector.Errors;
}
-
- private static async Task ProcessBatchUpdatesAsync(
- IAmazonCloudFrontKeyValueStore kvsClient,
- string kvsArn,
- string eTag,
- IEnumerable