Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-net i…
Browse files Browse the repository at this point in the history
…nto feature/mgmt-track2
  • Loading branch information
m-nash committed May 10, 2021
2 parents 9f4c8ce + d369751 commit 5e6030f
Show file tree
Hide file tree
Showing 315 changed files with 39,973 additions and 15,996 deletions.
8 changes: 6 additions & 2 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
],
// cspell is not case sensitive
// Sort words alphabetically to make this list easier to use
"words": [],
"words": ["azsdk", "pwsh"],
"overrides": [
{ "filename": "**/sdk/formrecognizer/**/*.cs", "words": ["ZhHant"] }
{ "filename": "**/sdk/formrecognizer/**/*.cs", "words": ["ZhHant"] },
{
"filename": "**/eng/pipelines/templates/jobs/ci.yml",
"words": ["warnaserror"]
}
],
"allowCompoundWords": true
}
4 changes: 2 additions & 2 deletions eng/CHECKENFORCER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
format: v0.1-alpha
minimumCheckRuns: 1
timeout: 5
timeout: 10
message: >
This pull request is protected by [Check Enforcer](https://aka.ms/azsdk/check-enforcer).

Expand Down Expand Up @@ -62,4 +62,4 @@ message: >
## For track 1 management-plane SDKs

Please open a separate PR and to your service SDK path in [this file](https://github.com/Azure/azure-sdk-for-net/blob/master/eng/pipelines/mgmt.yml). Once that PR has been merged, you can re-run the pipeline to trigger the verification.


5 changes: 4 additions & 1 deletion eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@
<RequiredTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net461;netcoreapp2.1;netcoreapp3.1;net5.0</RequiredTargetFrameworks>
</PropertyGroup>

<Import Project="$(RepoRoot)/sdk/core/Azure.Core/src/Azure.Core.props" Condition="'$(IsMgmtLibrary)' == 'true'"/>
<ItemGroup Condition="'$(IsMgmtLibrary)' == 'true'">
<PackageReference Include="Azure.Core" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
Expand Down
9 changes: 5 additions & 4 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@
<PackageReference Update="Microsoft.CSharp" Version="4.5.0" />

<!-- Azure SDK packages -->
<PackageReference Update="Azure.Core" Version="1.13.0" />
<PackageReference Update="Azure.Communication.Common" Version="1.0.0" />
<PackageReference Update="Azure.Core" Version="1.14.0" />
<PackageReference Update="Azure.Core.Amqp" Version="1.1.0-beta.1" Condition="'$(HasReleaseVersion)' == 'false'"/>
<PackageReference Update="Azure.Core.Experimental" Version="0.1.0-preview.10" />
<PackageReference Update="Azure.Core.Experimental" Version="0.1.0-preview.12" />
<PackageReference Update="Azure.Messaging.EventHubs" Version="5.4.0" />
<PackageReference Update="Azure.Messaging.EventGrid" Version="4.0.0" />
<PackageReference Update="Azure.Messaging.ServiceBus" Version="7.2.0-beta.2" Condition="'$(HasReleaseVersion)' == 'false'"/>
Expand All @@ -89,8 +90,8 @@

<!-- Other approved packages -->
<PackageReference Update="Microsoft.Azure.Amqp" Version="2.4.13" />
<PackageReference Update="Microsoft.Identity.Client" Version="4.23.0" />
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" Version="2.16.6" />
<PackageReference Update="Microsoft.Identity.Client" Version="4.30.1" />
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" Version="2.18.4" />
<!-- TODO: Make sure this package is arch-board approved -->
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="5.4.0" />

Expand Down
5 changes: 5 additions & 0 deletions eng/common/scripts/Prepare-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ if ($null -eq $newVersionParsed)
-packageType $packageProperties.SDKType `
-packageNewLibrary $packageProperties.IsNewSDK

if ($LASTEXITCODE -ne 0) {
Write-Error "Updating of the Devops Release WorkItem failed."
exit 1
}

if ($releaseTrackingOnly)
{
Write-Host
Expand Down
10 changes: 8 additions & 2 deletions eng/common/scripts/Update-DevOps-Release-WorkItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ param(
Set-StrictMode -Version 3

if (!(Get-Command az -ErrorAction SilentlyContinue)) {
Write-Host 'You must have the Azure CLI installed: https://aka.ms/azure-cli'
Write-Error 'You must have the Azure CLI installed: https://aka.ms/azure-cli'
exit 1
}

az extension show -n azure-devops > $null
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}

az extension show -n azure-devops *> $null
if (!$?){
Write-Host 'Installing azure-devops extension'
az extension add --name azure-devops
Expand Down
6 changes: 3 additions & 3 deletions eng/mgmt/mgmtmetadata/resources_resource-manager.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ AutoRest installed successfully.
Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/resources/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --tag=package-templatespecs-2021-03-preview --csharp.output-folder=C:\repos\azure-sdk-for-net\sdk\resources\Microsoft.Azure.Management.Resource\src\Generated\TemplateSpecs
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/resources/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --tag=package-templatespecs-2021-05 --csharp.output-folder=C:\repos\azure-sdk-for-net\sdk\resources\Microsoft.Azure.Management.Resource\src\Generated\TemplateSpecs
Autorest CSharp Version: 2.3.82
2021-04-20 23:49:12 UTC
2021-05-04 21:49:01 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 5047dfdf585969892ac035ffdfbc57623f0bf1c5
Commit: a7292a40170e8ebb10ad12332022798c2fe72f8a
AutoRest information
Requested version: v2
Bootstrapper version: autorest@2.0.4413
1 change: 1 addition & 0 deletions eng/pipelines/templates/jobs/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
name: azsdk-pool-mms-ubuntu-1804-general
vmImage: MMSUbuntu18.04
steps:
- template: /eng/common/pipelines/templates/steps/check-spelling.yml
- task: UsePythonVersion@0
displayName: "Use Python 3.6"
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

Expand All @@ -28,6 +29,4 @@
<Compile Include="$(AzureCoreSharedSources)TaskExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\core\Azure.Core\src\Azure.Core.props" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class AnomalyDetectorRecordedTestSanitizer : RecordedTestSanitizer
public AnomalyDetectorRecordedTestSanitizer()
: base()
{
JsonPathSanitizers.Add("$..accessToken");
JsonPathSanitizers.Add("$..source");
AddJsonPathSanitizer("$..accessToken");
AddJsonPathSanitizer("$..source");
// TODO: Remove when re-recording
LegacyConvertJsonDateTokens = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Release History

## 1.1.0-beta.3 (Unreleased)
## 1.1.0-beta.3 (2021-05-11)

### Key Bug Fixes

- `FeatureFlagFilter` now allows parameter modification.

## 1.1.0-beta.2 (2021-04-06)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public partial class FeatureFlagConfigurationSetting : Azure.Data.AppConfigurati
public partial class FeatureFlagFilter
{
public FeatureFlagFilter(string name) { }
public FeatureFlagFilter(string name, System.Collections.Generic.IReadOnlyDictionary<string, object> parameters) { }
public FeatureFlagFilter(string name, System.Collections.Generic.IDictionary<string, object> parameters) { }
public string Name { get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Parameters { get { throw null; } }
public System.Collections.Generic.IDictionary<string, object> Parameters { get { throw null; } }
}
public partial class SecretReferenceConfigurationSetting : Azure.Data.AppConfiguration.ConfigurationSetting
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<!-- Import the Azure.Core project -->
<Import Project="$(MSBuildThisFileDirectory)..\..\..\core\Azure.Core\src\Azure.Core.props" />

<ItemGroup>
<Compile Include="$(AzureCoreSharedSources)Argument.cs" LinkBase="Shared" />
<Compile Include="$(AzureCoreSharedSources)AzureResourceProviderNamespaceAttribute.cs" LinkBase="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public class FeatureFlagConfigurationSetting : ConfigurationSetting
private string _description;
private string _displayName;
private bool _isEnabled;
private ObservableCollection<FeatureFlagFilter> _clientFilters;
private IList<FeatureFlagFilter> _clientFilters;

internal FeatureFlagConfigurationSetting()
{
SetClientFilters();
_clientFilters = new List<FeatureFlagFilter>();
}

/// <summary>
Expand All @@ -58,15 +58,14 @@ internal FeatureFlagConfigurationSetting()
/// <param name="featureId">The identified of the feature flag.</param>
/// <param name="isEnabled">The value indicating whether the feature flag is enabled.</param>
/// <param name="label">A label used to group this configuration setting with others.</param>
public FeatureFlagConfigurationSetting(string featureId, bool isEnabled, string label = null)
public FeatureFlagConfigurationSetting(string featureId, bool isEnabled, string label = null): this()
{
_isValidValue = true;
Key = KeyPrefix + featureId;
Label = label;
IsEnabled = isEnabled;
ContentType = FeatureFlagContentType;
FeatureId = featureId;
SetClientFilters();
}

/// <summary>
Expand Down Expand Up @@ -159,7 +158,7 @@ internal override void SetValue(string value)

internal override string GetValue()
{
return _originalValue ??= FormatValue();
return _isValidValue ? FormatValue() : _originalValue;
}

private string FormatValue()
Expand Down Expand Up @@ -256,7 +255,7 @@ private bool TryParseValue()
}
}

SetClientFilters(newFilters);
_clientFilters = newFilters;
}
catch (Exception)
{
Expand Down Expand Up @@ -302,7 +301,7 @@ private static object ReadParameterValue(in JsonElement element)
{
list.Add(ReadParameterValue(item));
}
return list.ToArray();
return list;
default:
throw new NotSupportedException("Not supported value kind " + element.ValueKind);
}
Expand Down Expand Up @@ -370,17 +369,6 @@ private void CheckValid()
}
}

private void SetClientFilters(ObservableCollection<FeatureFlagFilter> newCollection = null)
{
if (_clientFilters != null)
{
_clientFilters.CollectionChanged -= OnFiltersCollectionChange;
}

_clientFilters = newCollection ?? new ObservableCollection<FeatureFlagFilter>();
_clientFilters.CollectionChanged += OnFiltersCollectionChange;
}

private void OnFiltersCollectionChange(object sender, NotifyCollectionChangedEventArgs e)
{
CheckValidWrite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class FeatureFlagFilter
/// </summary>
/// <param name="name">The name of the feature filter. For example: PercentageFilter, TimeWindowFilter, TargetingFilter.</param>
/// <param name="parameters">Parameters of the feature filter.</param>
public FeatureFlagFilter(string name, IReadOnlyDictionary<string, object> parameters)
public FeatureFlagFilter(string name, IDictionary<string, object> parameters)
{
Name = name;
Parameters = parameters;
Expand All @@ -37,6 +37,6 @@ public FeatureFlagFilter(string name, IReadOnlyDictionary<string, object> parame
/// <summary>
/// Gets the parameters of the feature filter.
/// </summary>
public IReadOnlyDictionary<string, object> Parameters { get; }
public IDictionary<string, object> Parameters { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -1484,6 +1485,58 @@ public async Task CanAddAndGetMultipleSecretReferences()
}
}

[RecordedTest]
public async Task CanModifyTheFilterParameterValues()
{
ConfigurationClient service = GetClient();

var testSetting1 = new FeatureFlagConfigurationSetting(GenerateKeyId(), true)
{
FeatureId = "my_feature",
ClientFilters =
{
new FeatureFlagFilter("Microsoft.Targeting", new Dictionary<string, object>()
{
{"Audience", new Dictionary<string, object>()
{
{
"Groups", new List<object>()
{
new Dictionary<string, object>()
{
{"Name", "Group1"},
{"RolloutPercentage", 100},
}
}
}
}}
})
}
};

try
{
await service.AddConfigurationSettingAsync(testSetting1);

var selectedSetting = (FeatureFlagConfigurationSetting)await service.GetConfigurationSettingAsync(testSetting1.Key);
var audience = (IDictionary) selectedSetting.ClientFilters[0].Parameters["Audience"];
var groups = (IList) audience["Groups"];

groups.Add(new Dictionary<string, object>()
{
{"Name", "Group2"},
{"RolloutPercentage", 50},
});

var resultingSetting = await service.SetConfigurationSettingAsync(selectedSetting);
Assert.AreEqual("{\"id\":\"my_feature\",\"enabled\":true,\"conditions\":{\"client_filters\":[{\"name\":\"Microsoft.Targeting\",\"parameters\":{\"Audience\":{\"Groups\":[{\"Name\":\"Group1\",\"RolloutPercentage\":100},{\"Name\":\"Group2\",\"RolloutPercentage\":50}]}}}]}}", resultingSetting.Value.Value);
}
finally
{
AssertStatus200(await service.DeleteConfigurationSettingAsync(testSetting1));
}
}

private static void AssertStatus200(Response response) => Assert.AreEqual(200, response.Status);
}
}
Loading

0 comments on commit 5e6030f

Please sign in to comment.