- 
                Notifications
    You must be signed in to change notification settings 
- Fork 715
Mark ParameterResource.Value as obsolete in favor of GetValueAsync and direct usage #10363
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
Changes from all commits
7c655e7
              3039482
              81468a6
              2df044f
              2912149
              30f0d4d
              28648c8
              585692b
              a363d59
              1613da6
              1f7016a
              899cbe9
              2d8d525
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|  | @@ -117,9 +117,9 @@ private async Task WriteAzureArtifactsOutputAsync(IPublishingStep step, Distribu | |||||||||||||||||
| .Where(r => !r.IsExcludedFromPublish()) | ||||||||||||||||||
| .ToList(); | ||||||||||||||||||
|  | ||||||||||||||||||
| MapParameter(environment.ResourceGroupName); | ||||||||||||||||||
| MapParameter(environment.Location); | ||||||||||||||||||
| MapParameter(environment.PrincipalId); | ||||||||||||||||||
| await MapParameterAsync(environment.ResourceGroupName, cancellationToken).ConfigureAwait(false); | ||||||||||||||||||
| await MapParameterAsync(environment.Location, cancellationToken).ConfigureAwait(false); | ||||||||||||||||||
| await MapParameterAsync(environment.PrincipalId, cancellationToken).ConfigureAwait(false); | ||||||||||||||||||
|  | ||||||||||||||||||
| var resourceGroupParam = ParameterLookup[environment.ResourceGroupName]; | ||||||||||||||||||
| MainInfrastructure.Add(resourceGroupParam); | ||||||||||||||||||
|  | @@ -163,14 +163,14 @@ private async Task WriteAzureArtifactsOutputAsync(IPublishingStep step, Distribu | |||||||||||||||||
| // Map parameters from existing resources | ||||||||||||||||||
| if (resource.TryGetLastAnnotation<ExistingAzureResourceAnnotation>(out var existingAnnotation)) | ||||||||||||||||||
| { | ||||||||||||||||||
| Visit(existingAnnotation.ResourceGroup, MapParameter); | ||||||||||||||||||
| Visit(existingAnnotation.Name, MapParameter); | ||||||||||||||||||
| await VisitAsync(existingAnnotation.ResourceGroup, MapParameterAsync, cancellationToken).ConfigureAwait(false); | ||||||||||||||||||
| await VisitAsync(existingAnnotation.Name, MapParameterAsync, cancellationToken).ConfigureAwait(false); | ||||||||||||||||||
| } | ||||||||||||||||||
|  | ||||||||||||||||||
| // Map parameters for the resource itself | ||||||||||||||||||
| foreach (var parameter in resource.Parameters) | ||||||||||||||||||
| { | ||||||||||||||||||
| Visit(parameter.Value, MapParameter); | ||||||||||||||||||
| await VisitAsync(parameter.Value, MapParameterAsync, cancellationToken).ConfigureAwait(false); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|  | ||||||||||||||||||
|  | @@ -359,7 +359,7 @@ await task.SucceedAsync( | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|  | ||||||||||||||||||
| private void MapParameter(object? candidate) | ||||||||||||||||||
| private async Task MapParameterAsync(object candidate, CancellationToken cancellationToken = default) | ||||||||||||||||||
| { | ||||||||||||||||||
| 
      Comment on lines
    
      +362
     to 
      363
    
   
     | ||||||||||||||||||
| private async Task MapParameterAsync(object candidate, CancellationToken cancellationToken = default) | |
| { | |
| private async Task MapParameterAsync(object? candidate, CancellationToken cancellationToken = default) | |
| { | |
| if (candidate is null) | |
| { | |
| return; | |
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -122,8 +122,15 @@ private static HelmExpressionWithValue AllocateParameter(ParameterResource param | |
| formattedName.ToHelmSecretExpression(resource.Name) : | ||
| formattedName.ToHelmConfigExpression(resource.Name); | ||
|  | ||
| var value = parameter.Default is null || parameter.Secret ? null : parameter.Value; | ||
| return new(expression, value); | ||
| // Store the parameter itself for deferred resolution instead of resolving the value immediately | ||
| if (parameter.Default is null || parameter.Secret) | ||
| { | ||
| return new(expression, (string?)null); | ||
| } | ||
| else | ||
| { | ||
| return new(expression, parameter); | ||
| 
     | ||
| } | ||
| } | ||
|  | ||
| private static HelmExpressionWithValue ResolveUnknownValue(IManifestExpressionProvider parameter, IResource resource) | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove uses of parameter.Value in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use GetValueAsync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've removed all uses of parameter.Value in AzurePublishingContext.cs by refactoring the code to use tuple destructuring pattern
foreach (var (key, value) in resource.Parameters)instead of accessing the.Valueproperty on KeyValuePair instances. This eliminates parameter.Value accesses while maintaining the same functionality. (356b979)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm revert this. That's not what I meant. I mean ParameterResource.Value should be replaced with ParameterResource.GetValueAsync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Replaced
ParameterLookup[p].Value.Compile()withnew IdentifierExpression(ParameterLookup[p].BicepIdentifier)to avoid using the obsolete .Value property and directly use the parameter's Bicep identifier. (c8b72bb)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the tuple destructuring changes and correctly replaced
ParameterLookup[p].Value.Compile()withnew IdentifierExpression(ParameterLookup[p].BicepIdentifier)to avoid using the obsolete property. (4ba6c15)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo that change as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the AzurePublishingContext.cs file to the original synchronous Visit(parameter.Value, MapParameter) call as requested. (e6e6dda)