Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ private FeatureDefinition ParseMicrosoftSchemaFeatureDefinition(IConfigurationSe
{
Name = section[MicrosoftFeatureManagementFields.Name],
ConfigurationValue = section.GetSection(MicrosoftFeatureManagementFields.VariantDefinitionConfigurationValue),
ConfigurationReference = section[MicrosoftFeatureManagementFields.VariantDefinitionConfigurationReference],
StatusOverride = statusOverride
};

Expand Down
18 changes: 0 additions & 18 deletions src/Microsoft.FeatureManagement/FeatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ public IEnumerable<ISessionManager> SessionManagers
/// </summary>
public ILogger Logger { get; set; }

/// <summary>
/// The configuration reference for feature variants.
/// </summary>
public IConfiguration Configuration { get; set; }

/// <summary>
/// The targeting context accessor for feature variant allocation.
/// </summary>
Expand Down Expand Up @@ -860,19 +855,6 @@ private Variant GetVariantFromVariantDefinition(VariantDefinition variantDefinit
{
variantConfiguration = variantDefinition.ConfigurationValue;
}
else if (!string.IsNullOrEmpty(variantDefinition.ConfigurationReference))
{
if (Configuration == null)
{
Logger?.LogWarning($"Cannot use {nameof(variantDefinition.ConfigurationReference)} as no instance of {nameof(IConfiguration)} is present.");

return null;
}
else
{
variantConfiguration = Configuration.GetSection(variantDefinition.ConfigurationReference);
}
}

return new Variant()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ internal static class MicrosoftFeatureManagementFields
// Variants keywords
public const string VariantsSectionName = "variants";
public const string VariantDefinitionConfigurationValue = "configuration_value";
public const string VariantDefinitionConfigurationReference = "configuration_reference";
public const string VariantDefinitionStatusOverride = "status_override";

// Telemetry keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public static IFeatureManagementBuilder AddFeatureManagement(this IServiceCollec
SessionManagers = sp.GetRequiredService<IEnumerable<ISessionManager>>(),
Cache = sp.GetRequiredService<IMemoryCache>(),
Logger = sp.GetRequiredService<ILoggerFactory>().CreateLogger<FeatureManager>(),
Configuration = sp.GetService<IConfiguration>(),
TargetingContextAccessor = sp.GetService<ITargetingContextAccessor>(),
AssignerOptions = sp.GetRequiredService<IOptions<TargetingEvaluationOptions>>().Value
});
Expand Down Expand Up @@ -137,7 +136,6 @@ public static IFeatureManagementBuilder AddScopedFeatureManagement(this IService
SessionManagers = sp.GetRequiredService<IEnumerable<ISessionManager>>(),
Cache = sp.GetRequiredService<IMemoryCache>(),
Logger = sp.GetRequiredService<ILoggerFactory>().CreateLogger<FeatureManager>(),
Configuration = sp.GetService<IConfiguration>(),
TargetingContextAccessor = sp.GetService<ITargetingContextAccessor>(),
AssignerOptions = sp.GetRequiredService<IOptions<TargetingEvaluationOptions>>().Value
});
Expand Down
5 changes: 0 additions & 5 deletions src/Microsoft.FeatureManagement/VariantDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public class VariantDefinition
/// </summary>
public IConfigurationSection ConfigurationValue { get; set; }

/// <summary>
/// A reference pointing to the configuration for this variant of the feature.
/// </summary>
public string ConfigurationReference { get; set; }

/// <summary>
/// Overrides the state of the feature if this variant has been assigned.
/// </summary>
Expand Down
6 changes: 0 additions & 6 deletions tests/Tests.FeatureManagement/FeatureManagementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,6 @@ public async Task UsesVariants()
Variant variant = await featureManager.GetVariantAsync(Features.VariantFeaturePercentileOn, cancellationToken);

Assert.Equal("Big", variant.Name);
Assert.Equal("green", variant.Configuration["Color"]);
Assert.False(await featureManager.IsEnabledAsync(Features.VariantFeaturePercentileOn, cancellationToken));

variant = await featureManager.GetVariantAsync(Features.VariantFeaturePercentileOff, cancellationToken);
Expand Down Expand Up @@ -1541,11 +1540,6 @@ public async Task VariantsInvalidScenarios()

Assert.Null(variant);

// Verify that ConfigurationValue has priority over ConfigurationReference
variant = await featureManager.GetVariantAsync(Features.VariantFeatureBothConfigurations, cancellationToken);

Assert.Equal("600px", variant.Configuration.Value);

// Verify that an exception is thrown for invalid StatusOverride value
FeatureManagementException e = await Assert.ThrowsAsync<FeatureManagementException>(async () =>
{
Expand Down
1 change: 0 additions & 1 deletion tests/Tests.FeatureManagement/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ static class Features
public const string VariantFeatureNoVariants = "VariantFeatureNoVariants";
public const string VariantFeatureNoAllocation = "VariantFeatureNoAllocation";
public const string VariantFeatureAlwaysOffNoAllocation = "VariantFeatureAlwaysOffNoAllocation";
public const string VariantFeatureBothConfigurations = "VariantFeatureBothConfigurations";
public const string VariantFeatureInvalidStatusOverride = "VariantFeatureInvalidStatusOverride";
public const string VariantFeatureInvalidFromTo = "VariantFeatureInvalidFromTo";
public const string VariantImplementationFeature = "VariantImplementationFeature";
Expand Down
32 changes: 2 additions & 30 deletions tests/Tests.FeatureManagement/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
},
"AllowedHosts": "*",

"ShoppingCart": {
"Big": {
"Size": 600,
"Color": "green"
},
"Small": {
"Size": 300,
"Color": "gray"
}
},

"feature_management": {
"feature_flags": [
{
Expand Down Expand Up @@ -209,7 +198,6 @@
"variants": [
{
"name": "Big",
"configuration_reference": "ShoppingCart:Big",
"status_override": "Disabled"
}
],
Expand All @@ -232,8 +220,7 @@
"enabled": true,
"variants": [
{
"name": "Big",
"configuration_reference": "ShoppingCart:Big"
"name": "Big"
}
],
"allocation": {
Expand All @@ -255,8 +242,7 @@
"enabled": false,
"variants": [
{
"name": "Big",
"configuration_reference": "ShoppingCart:Big"
"name": "Big"
}
],
"allocation": {
Expand Down Expand Up @@ -410,20 +396,6 @@
"enabled": true
}
},
{
"id": "VariantFeatureBothConfigurations",
"enabled": true,
"variants": [
{
"name": "Small",
"configuration_value": "600px",
"configuration_reference": "ShoppingCart:Small"
}
],
"allocation": {
"default_when_enabled": "Small"
}
},
{
"id": "VariantFeatureInvalidStatusOverride",
"enabled": true,
Expand Down