Skip to content

Commit

Permalink
Remove feature flag toggling infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
rorbech committed Apr 2, 2024
1 parent 550ba8f commit 0ea91fc
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions Tools/DeployApps/BaasClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public class FunctionReturn
};";

private readonly HttpClient _client = new();
private readonly HttpClient _privateclient = new();

private readonly string? _clusterName;

Expand Down Expand Up @@ -197,9 +196,6 @@ private BaasClient(Uri baseUri, string differentiator, TextWriter output, string
_clusterName = clusterName;
Differentiator = differentiator;
_output = output;

_privateclient.BaseAddress = new Uri(baseUri, "api/private/v1.0/");
_privateclient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/json");
}

public static async Task<BaasClient> Docker(Uri baseUri, string differentiator, TextWriter output)
Expand Down Expand Up @@ -297,7 +293,6 @@ private async Task Authenticate(string provider, object credentials)

_refreshToken = authDoc!["refresh_token"].AsString;
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authDoc["access_token"].AsString);
_privateclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authDoc["access_token"].AsString);
}

public static async Task<Uri> GetOrDeployContainer(string baasaasApiKey, string differentiator, TextWriter output)
Expand Down Expand Up @@ -560,15 +555,6 @@ public async Task SetAutomaticRecoveryEnabled(BaasApp app, bool enabled)
{
development_mode_enabled = true,
});

// Retrieve feature flags
// var features = await GetPrivateAsync<BsonDocument>($"groups/{_groupId}/apps/{app}/features");
// ENABLE LEGACY MIXED SUPPORT
// await PostPrivateAsync<BsonDocument>($"features/legacy_mixed_type", new { app_ids = new []{$"{appId}"}, action = "enable"} );
// await PostPrivateAsync<BsonDocument>($"features/bypass_legacy_mixed_type", new { app_ids = new []{$"{appId}"}, action = "disable"} );
// DISABLE LEGACY MIXED SUPPORT - Default on latest test server - https://github.com/10gen/baas/blob/master/etc/configs/test_config.json#L303
// await PostPrivateAsync<BsonDocument>($"features/legacy_mixed_type", new { app_ids = new []{$"{appId}"}, action = "disable"} );
// await PostPrivateAsync<BsonDocument>($"features/bypass_legacy_mixed_type", new { app_ids = new []{$"{appId}"}, action = "enable"} );
return (app, mongoServiceId);
}

Expand Down Expand Up @@ -713,16 +699,10 @@ private async Task RefreshAccessTokenAsync()

private Task<T?> PostAsync<T>(string relativePath, object obj) => SendAsync<T>(HttpMethod.Post, relativePath, obj);

private Task<T?> PostPrivateAsync<T>(string relativePath, object obj) => SendPrivateAsync<T>(HttpMethod.Post, relativePath, obj);

private Task<T?> GetAsync<T>(string relativePath) => SendAsync<T>(HttpMethod.Get, relativePath);

private Task<T?> GetPrivateAsync<T>(string relativePath) => SendPrivateAsync<T>(HttpMethod.Get, relativePath);

private Task<T?> PutAsync<T>(string relativePath, object obj) => SendAsync<T>(HttpMethod.Put, relativePath, obj);

private Task<T?> PutPrivateAsync<T>(string relativePath, object obj) => SendPrivateAsync<T>(HttpMethod.Put, relativePath, obj);

private Task<T?> PatchAsync<T>(string relativePath, object obj) => SendAsync<T>(new HttpMethod("PATCH"), relativePath, obj);

private async Task<T?> SendAsync<T>(HttpMethod method, string relativePath, object? payload = null)
Expand Down Expand Up @@ -756,37 +736,6 @@ private async Task RefreshAccessTokenAsync()
return default;
}

private async Task<T?> SendPrivateAsync<T>(HttpMethod method, string relativePath, object? payload = null)
{
using var message = new HttpRequestMessage(method, new Uri(relativePath, UriKind.Relative));
if (payload != null)
{
message.Content = GetJsonContent(payload);
}

var response = await _privateclient.SendAsync(message);
if (!response.IsSuccessStatusCode)
{
if (response.StatusCode == HttpStatusCode.Unauthorized && _refreshToken != null)
{
await RefreshAccessTokenAsync();
return await SendAsync<T>(method, relativePath, payload);
}

var content = await response.Content.ReadAsStringAsync();
throw new Exception($"An error ({response.StatusCode}) occurred while executing {method} {relativePath}: {content}");
}

var json = await response.Content.ReadAsStringAsync();

if (!string.IsNullOrWhiteSpace(json))
{
return BsonSerializer.Deserialize<T>(json);
}

return default;
}

public static HttpContent GetJsonContent(object obj)
{
string jsonContent;
Expand Down

0 comments on commit 0ea91fc

Please sign in to comment.