Skip to content

Commit d592329

Browse files
committed
Revert "Merge pull request #600 from Azure/rossgrambo/allocation_id"
This reverts commit 51d4ad7, reversing changes made to d551536.
1 parent d294da4 commit d592329

File tree

5 files changed

+0
-353
lines changed

5 files changed

+0
-353
lines changed

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/Extensions/StringExtensions.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,5 @@ public static string NormalizeNull(this string s)
3939
{
4040
return s == LabelFilter.Null ? null : s;
4141
}
42-
43-
public static string ToBase64String(this string s)
44-
{
45-
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
46-
47-
return Convert.ToBase64String(bytes);
48-
}
4942
}
5043
}

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureManagementConstants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ internal class FeatureManagementConstants
4343
public const string ETag = "ETag";
4444
public const string FeatureFlagId = "FeatureFlagId";
4545
public const string FeatureFlagReference = "FeatureFlagReference";
46-
public const string AllocationId = "AllocationId";
4746

4847
// Dotnet schema keys
4948
public const string DotnetSchemaSectionName = "FeatureManagement";

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureManagementKeyValueAdapter.cs

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Microsoft.Extensions.Configuration.AzureAppConfiguration.Extensions;
66
using System;
77
using System.Collections.Generic;
8-
using System.Diagnostics;
98
using System.Linq;
109
using System.Net.Mime;
1110
using System.Security.Cryptography;
@@ -324,98 +323,12 @@ private List<KeyValuePair<string, string>> ProcessMicrosoftSchemaFeatureFlag(Fea
324323
keyValues.Add(new KeyValuePair<string, string>($"{telemetryPath}:{FeatureManagementConstants.Metadata}:{FeatureManagementConstants.ETag}", setting.ETag.ToString()));
325324

326325
keyValues.Add(new KeyValuePair<string, string>($"{telemetryPath}:{FeatureManagementConstants.Enabled}", telemetry.Enabled.ToString()));
327-
328-
if (featureFlag.Allocation != null)
329-
{
330-
string allocationId = CalculateAllocationId(featureFlag);
331-
332-
if (allocationId != null)
333-
{
334-
keyValues.Add(new KeyValuePair<string, string>($"{telemetryPath}:{FeatureManagementConstants.Metadata}:{FeatureManagementConstants.AllocationId}", allocationId));
335-
}
336-
}
337326
}
338327
}
339328

340329
return keyValues;
341330
}
342331

343-
private string CalculateAllocationId(FeatureFlag flag)
344-
{
345-
Debug.Assert(flag.Allocation != null);
346-
347-
StringBuilder inputBuilder = new StringBuilder();
348-
349-
// Seed
350-
inputBuilder.Append($"seed={flag.Allocation.Seed ?? string.Empty}");
351-
352-
var allocatedVariants = new HashSet<string>();
353-
354-
// DefaultWhenEnabled
355-
if (flag.Allocation.DefaultWhenEnabled != null)
356-
{
357-
allocatedVariants.Add(flag.Allocation.DefaultWhenEnabled);
358-
}
359-
360-
inputBuilder.Append($"\ndefault_when_enabled={flag.Allocation.DefaultWhenEnabled ?? string.Empty}");
361-
362-
// Percentiles
363-
inputBuilder.Append("\npercentiles=");
364-
365-
if (flag.Allocation.Percentile != null && flag.Allocation.Percentile.Any())
366-
{
367-
IEnumerable<FeaturePercentileAllocation> sortedPercentiles = flag.Allocation.Percentile
368-
.Where(p => p.From != p.To)
369-
.OrderBy(p => p.From)
370-
.ToList();
371-
372-
allocatedVariants.UnionWith(sortedPercentiles.Select(p => p.Variant));
373-
374-
inputBuilder.Append(string.Join(";", sortedPercentiles.Select(p => $"{p.From},{p.Variant.ToBase64String()},{p.To}")));
375-
}
376-
377-
// If there's no custom seed and no variants allocated, stop now and return null
378-
if (flag.Allocation.Seed == null &&
379-
!allocatedVariants.Any())
380-
{
381-
return null;
382-
}
383-
384-
// Variants
385-
inputBuilder.Append("\nvariants=");
386-
387-
if (allocatedVariants.Any() && flag.Variants != null && flag.Variants.Any())
388-
{
389-
IEnumerable<FeatureVariant> sortedVariants = flag.Variants
390-
.Where(variant => allocatedVariants.Contains(variant.Name))
391-
.OrderBy(variant => variant.Name)
392-
.ToList();
393-
394-
inputBuilder.Append(string.Join(";", sortedVariants.Select(v =>
395-
{
396-
var variantValue = string.Empty;
397-
398-
if (v.ConfigurationValue.ValueKind != JsonValueKind.Null && v.ConfigurationValue.ValueKind != JsonValueKind.Undefined)
399-
{
400-
variantValue = v.ConfigurationValue.SerializeWithSortedKeys();
401-
}
402-
403-
return $"{v.Name.ToBase64String()},{(variantValue)}";
404-
})));
405-
}
406-
407-
// Example input string
408-
// input == "seed=123abc\ndefault_when_enabled=Control\npercentiles=0,Blshdk,20;20,Test,100\nvariants=TdLa,standard;Qfcd,special"
409-
string input = inputBuilder.ToString();
410-
411-
using (SHA256 sha256 = SHA256.Create())
412-
{
413-
byte[] truncatedHash = new byte[15];
414-
Array.Copy(sha256.ComputeHash(Encoding.UTF8.GetBytes(input)), truncatedHash, 15);
415-
return truncatedHash.ToBase64Url();
416-
}
417-
}
418-
419332
private FormatException CreateFeatureFlagFormatException(string jsonPropertyName, string settingKey, string foundJsonValueKind, string expectedJsonValueKind)
420333
{
421334
return new FormatException(string.Format(

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/JsonElementExtensions.cs

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)