- 
                Notifications
    You must be signed in to change notification settings 
- Fork 39
Adding Snapshot References Feature #689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            44 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      02ac2d2
              
                feat: defined snapshot reference content type and Json Property
              
              
                t-vvidyasaga 69c2f64
              
                added snapshot reference content type to content type extensions
              
              
                t-vvidyasaga 002db4e
              
                updated the snapshot reference content type to include the charset
              
              
                t-vvidyasaga 011cb88
              
                Implementing snapshot references
              
              
                t-vvidyasaga 1b137bb
              
                Fixed the behavior of an edge case and moved file to a better locatio…
              
              
                t-vvidyasaga 540ef4f
              
                created unit tests for Snapshot References
              
              
                t-vvidyasaga 68d80f5
              
                Removed unnecessary comments from tests
              
              
                t-vvidyasaga 1a5345f
              
                removed extra comments and cleaned up code
              
              
                t-vvidyasaga bdc4ff6
              
                modified test and added set up for testing snapshot references
              
              
                t-vvidyasaga 244042b
              
                adding more integration tests for snapshot references
              
              
                t-vvidyasaga be4794b
              
                removed client and cancellation token from snapshot reference class a…
              
              
                t-vvidyasaga 3ceb262
              
                updated namespaces for all files and created parser class
              
              
                t-vvidyasaga a0c4193
              
                additional file to update namespace
              
              
                t-vvidyasaga 6778996
              
                Modified the code to directly use the content type instead of copying
              
              
                t-vvidyasaga 0b958e3
              
                Used object initializer pattern and passed in cancellationTokens to a…
              
              
                t-vvidyasaga 44f84ce
              
                fixed comment and updated TestContext format
              
              
                t-vvidyasaga f8e6293
              
                updated behavior to throw exception if snapshot name is null
              
              
                t-vvidyasaga cdf559b
              
                Moved the exception error messages from inline to ErrorMessages class…
              
              
                t-vvidyasaga bded75d
              
                Added Request tracing and case for snapshot reference is registered f…
              
              
                t-vvidyasaga 7bb3bbe
              
                added test case to test adding snapshot reference to register but not…
              
              
                t-vvidyasaga 9357dab
              
                updating request tracing to only tracking use of snapshot references
              
              
                t-vvidyasaga f8033d9
              
                removing request tracing logic for Snapshot References count
              
              
                t-vvidyasaga 6b12553
              
                added comments and returning SnapshotReference type from Parse()
              
              
                t-vvidyasaga b321889
              
                removed second way of checking for snapshot references type and updat…
              
              
                t-vvidyasaga ead364b
              
                removed redundant error message
              
              
                t-vvidyasaga 712038e
              
                removed unnecessary code
              
              
                t-vvidyasaga 8779fcf
              
                fixed whitespace issues and made error message clearer
              
              
                t-vvidyasaga b24f20c
              
                updating naming and removing old telemetry code
              
              
                t-vvidyasaga 8aee706
              
                updated namespace and directory to SnapshotReference
              
              
                t-vvidyasaga aeb9fb7
              
                Added new JsonFields type
              
              
                t-vvidyasaga a96558d
              
                fixed error regarding same namespace and type
              
              
                t-vvidyasaga 6b47242
              
                Updated the Parse logic to handle all exceptions instead of LoadSnaps…
              
              
                t-vvidyasaga 003a1b8
              
                updated comments to method
              
              
                t-vvidyasaga 532fee3
              
                removed the update and reset snapshot reference request tracing metho…
              
              
                t-vvidyasaga 516009a
              
                removed requestTracing for SnapshotReference from refresh
              
              
                t-vvidyasaga d929178
              
                reverting previous change
              
              
                t-vvidyasaga fece7d8
              
                Made these keyvault integration tests more resilient
              
              
                t-vvidyasaga 34019ee
              
                Cleaning up code
              
              
                t-vvidyasaga bdb3c15
              
                More nit changes
              
              
                t-vvidyasaga a1860a0
              
                updated request tracing for snapshot references in refresh
              
              
                t-vvidyasaga fe65c7e
              
                Merge branch 'main' into t-vvidyasagar/snapshot-references
              
              
                t-vvidyasaga 4d18993
              
                making the key vault integration test more resilient
              
              
                t-vvidyasaga ad5ef58
              
                correction to which test needed resilience
              
              
                t-vvidyasaga 4846750
              
                merge from main
              
              
                t-vvidyasaga File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            10 changes: 10 additions & 0 deletions
          
          10 
        
  src/Microsoft.Extensions.Configuration.AzureAppConfiguration/SnapshotReference/JsonFields.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.SnapshotReference | ||
| { | ||
| internal static class JsonFields | ||
| { | ||
| public const string SnapshotName = "snapshot_name"; | ||
| } | ||
| } | 
        
          
          
            11 changes: 11 additions & 0 deletions
          
          11 
        
  ...oft.Extensions.Configuration.AzureAppConfiguration/SnapshotReference/SnapshotReference.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
|  | ||
| namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.SnapshotReference | ||
| { | ||
| internal class SnapshotReference | ||
| { | ||
| public string SnapshotName { get; set; } | ||
| } | ||
| } | 
        
          
          
            10 changes: 10 additions & 0 deletions
          
          10 
        
  ...sions.Configuration.AzureAppConfiguration/SnapshotReference/SnapshotReferenceConstants.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.SnapshotReference | ||
| { | ||
| internal class SnapshotReferenceConstants | ||
| { | ||
| public const string ContentType = "application/json; profile=\"https://azconfig.io/mime-profiles/snapshot-ref\"; charset=utf-8"; | ||
| } | ||
| } | 
        
          
          
            78 changes: 78 additions & 0 deletions
          
          78 
        
  ...tensions.Configuration.AzureAppConfiguration/SnapshotReference/SnapshotReferenceParser.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using Azure.Data.AppConfiguration; | ||
| using System; | ||
| using System.Text.Json; | ||
|  | ||
| namespace Microsoft.Extensions.Configuration.AzureAppConfiguration.SnapshotReference | ||
| { | ||
| /// <summary> | ||
| /// Provides parsing functionality for snapshot reference configuration settings. | ||
| /// </summary> | ||
| internal static class SnapshotReferenceParser | ||
| { | ||
| /// <summary> | ||
| /// Parses a snapshot name from a configuration setting containing snapshot reference JSON. | ||
| /// </summary> | ||
| /// <param name="setting">The configuration setting containing the snapshot reference JSON.</param> | ||
| /// <returns>The snapshot reference containing a valid, non-empty snapshot name.</returns> | ||
| /// <exception cref="ArgumentNullException">Thrown when the setting is null.</exception> | ||
| /// <exception cref="FormatException">Thrown when the setting contains invalid JSON, invalid snapshot reference format, or empty/whitespace snapshot name.</exception> | ||
| public static SnapshotReference Parse(ConfigurationSetting setting) | ||
| { | ||
| if (setting == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(setting)); | ||
| } | ||
|  | ||
| if (string.IsNullOrWhiteSpace(setting.Value)) | ||
| { | ||
| throw new FormatException(string.Format(ErrorMessages.SnapshotReferenceInvalidFormat, setting.Key, setting.Label)); | ||
| } | ||
|  | ||
| try | ||
| { | ||
| var reader = new Utf8JsonReader(System.Text.Encoding.UTF8.GetBytes(setting.Value)); | ||
|  | ||
| if (reader.Read() && reader.TokenType != JsonTokenType.StartObject) | ||
| { | ||
| throw new FormatException(string.Format(ErrorMessages.SnapshotReferenceInvalidFormat, setting.Key, setting.Label)); | ||
| } | ||
|  | ||
| while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) | ||
| { | ||
| if (reader.TokenType != JsonTokenType.PropertyName) | ||
| { | ||
| continue; | ||
| } | ||
|  | ||
| if (reader.GetString() == JsonFields.SnapshotName) | ||
| { | ||
| if (reader.Read() && reader.TokenType == JsonTokenType.String) | ||
| { | ||
| string snapshotName = reader.GetString(); | ||
| if (string.IsNullOrWhiteSpace(snapshotName)) | ||
| { | ||
| throw new FormatException(string.Format(ErrorMessages.SnapshotReferenceInvalidFormat, setting.Key, setting.Label)); | ||
| } | ||
|  | ||
| return new SnapshotReference { SnapshotName = snapshotName }; | ||
| } | ||
|  | ||
| throw new FormatException(string.Format(ErrorMessages.SnapshotReferenceInvalidJsonProperty, setting.Key, setting.Label, JsonFields.SnapshotName, reader.TokenType)); | ||
| } | ||
|  | ||
| // Skip unknown properties | ||
| reader.Skip(); | ||
| } | ||
|  | ||
| throw new FormatException(string.Format(ErrorMessages.SnapshotReferencePropertyMissing, setting.Key, setting.Label, JsonFields.SnapshotName)); | ||
| } | ||
| catch (JsonException jsonEx) | ||
| { | ||
| throw new FormatException(string.Format(ErrorMessages.SnapshotReferenceInvalidFormat, setting.Key, setting.Label), jsonEx); | ||
| } | ||
| } | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.