-
Notifications
You must be signed in to change notification settings - Fork 939
Add conditional mode to ReferenceExpression with polyglot codegen support #14919
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 2 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
a8bad02
Add a new deferred value provider for tls connection properties
danegsta a5aa70a
Respond to PR feedback
danegsta 19280d2
Update comment
danegsta 9bde1bc
Update baselines for code generation tests
danegsta 3fbf2ef
Update comments with links to redis scheme registrations
danegsta 0ecdf86
Make DeferredValueProvider async, use appropriate string comparison
danegsta fc4a4b5
Relax scheme constraints in manifest schema
danegsta 42a8315
Omit the manifest schema going forward. Keeps schema tests to avoid r…
danegsta 6c1d3e9
Merge remote-tracking branch 'upstream/release/13.2' into danegsta/re…
danegsta c47ee79
Add ConditionalReferenceExpression with polyglot codegen support
danegsta c914fcf
Fix outdated code generation snapshots
danegsta c2a6b4b
Fix CRE marshaller test to use pattern matching for auto-generated name
danegsta f277a91
Merge remote-tracking branch 'upstream/release/13.2' into danegsta/re…
danegsta 02747ac
Update TwoPassScanning snapshots after merge with release/13.2
danegsta af482ba
Merge ConditionalReferenceExpression into ReferenceExpression
danegsta b433616
Ensure snapshots get updated
danegsta a20d5b7
Add explicit matchValue parameter to CreateConditional
danegsta 2a77de0
Reorder matchValue parameter in polyglot language definitions
danegsta c58d780
Fix CreateConditional callers in RemoteHost tests
danegsta 6e13b90
Handle conditional ReferenceExpression in Azure publishing paths
danegsta 96eaa09
Resolve static conditionals at publish time, emit ternary only for pa…
danegsta 415b3d3
Add test cases for all conditional expression branches
danegsta 8bada82
Add tests for nested parameters and nested conditionals in Bicep
danegsta 556d29b
Fix Go Handle.ToJSON return type for map compatibility
danegsta 2f3177b
Implement Serialize for Rust ReferenceExpression
danegsta b45f0c6
Add Deserialize impl for Rust ReferenceExpression
danegsta e831995
Remove handle mode from ReferenceExpression in Go, Rust, Python, Java
danegsta 081599d
Rename Go factory to NewConditionalReferenceExpression
danegsta 03655e5
Wrap format and args in Option in Rust ReferenceExpression
danegsta 1188db2
Revert ReferenceExpressionTypeId skip blocks from Python and TypeScri…
danegsta 3d867a6
Revert transport.go Handle.ToJSON return type to map[string]string
danegsta 1cc9f31
Remove low-value ConditionalReferenceExpression tests
danegsta 3ad5a25
Fix TypeScript base.ts: import wrapIfHandle for conditional mode
danegsta bf5a740
Fix incorrect use of wrapIfHandle in ReferenceExpression serialization
danegsta abbd868
Disable HTTPS certificate for Redis in EndToEnd test AppHost
danegsta 75b7b8c
Add conditional ReferenceExpression support to App Service, Docker Co…
danegsta 09d773b
Use Helm ternary for parameter-based conditionals in Kubernetes publi…
danegsta 7a00975
Fix BuildHelmTernary fallback detection and add HelmExtensions tests
danegsta 0052dbc
Use Helm if/else for conditionals with expression branches
danegsta 1f48c5b
Resolve merge conflict in Java two-pass scanning snapshot
danegsta 434aac0
Populate ValueProviders for conditional ReferenceExpressions
danegsta d4edea5
Remove Redis connection string caching and fix manifest conditional r…
danegsta 0acd987
Update Go and Rust expression key from $refExpr to $expr
danegsta 51c4b97
Add tests for conditional ReferenceExpression ValueProviders and Refe…
danegsta 3b85a72
Add conditional ReferenceExpression tests to ResourceDependencyTests
danegsta 8c03ad2
Fix ExpressionResolver to handle conditional ReferenceExpressions
danegsta 30cbdc3
Simplify Helm conditional to if/else only with case-insensitive compa…
danegsta 0a0623a
Use toLower for case-insensitive Bicep conditional comparison
danegsta 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
74 changes: 74 additions & 0 deletions
74
src/Aspire.Hosting/ApplicationModel/DeferredValueProvider.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,74 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.ApplicationModel; | ||
|
|
||
| /// <summary> | ||
| /// A general-purpose value provider that resolves its value and manifest expression lazily via callbacks. | ||
| /// This enables dynamic values to be embedded in <see cref="ReferenceExpression"/> instances, where the | ||
| /// actual value is determined at resolution time rather than at expression build time. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// Use this type when a portion of a connection string or expression depends on state that isn't known | ||
| /// until later in the application lifecycle (e.g., whether TLS has been enabled on an endpoint). | ||
| /// </para> | ||
| /// <para> | ||
| /// Callbacks receive a <see cref="ValueProviderContext"/> that provides access to the execution context, | ||
| /// the calling resource, and network information. When no separate manifest expression callback is provided, | ||
| /// the value callback is used for both <see cref="GetValueAsync(ValueProviderContext, CancellationToken)"/> and <see cref="ValueExpression"/>. A | ||
| /// <see langword="null"/> return from the value callback is treated as an empty string for the manifest expression. | ||
| /// </para> | ||
| /// </remarks> | ||
| public class DeferredValueProvider : IValueProvider, IManifestExpressionProvider | ||
| { | ||
|
danegsta marked this conversation as resolved.
Outdated
|
||
| private readonly Func<ValueProviderContext, string?> _valueCallback; | ||
| private readonly Func<string>? _manifestExpressionCallback; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="DeferredValueProvider"/> with a context-free callback. | ||
| /// </summary> | ||
| /// <param name="valueCallback">A callback that returns the value. A <see langword="null"/> return is treated | ||
| /// as an empty string for the manifest expression. Called each time the value is resolved.</param> | ||
| /// <param name="manifestExpressionCallback">An optional callback that returns the manifest expression string. | ||
| /// When <see langword="null"/>, the <paramref name="valueCallback"/> is used for both runtime and manifest values.</param> | ||
| public DeferredValueProvider(Func<string?> valueCallback, Func<string>? manifestExpressionCallback = null) | ||
|
danegsta marked this conversation as resolved.
Outdated
|
||
| { | ||
| ArgumentNullException.ThrowIfNull(valueCallback); | ||
| _valueCallback = _ => valueCallback(); | ||
| _manifestExpressionCallback = manifestExpressionCallback; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="DeferredValueProvider"/> with a context-aware callback. | ||
| /// </summary> | ||
| /// <param name="valueCallback">A callback that receives a <see cref="ValueProviderContext"/> and returns | ||
| /// the value. A <see langword="null"/> return is treated as an empty string for the manifest expression. | ||
| /// Called each time the value is resolved.</param> | ||
| /// <param name="manifestExpressionCallback">An optional callback that returns the manifest expression string. | ||
| /// When <see langword="null"/>, the <paramref name="valueCallback"/> is invoked with an empty | ||
| /// <see cref="ValueProviderContext"/> for the manifest expression.</param> | ||
| public DeferredValueProvider(Func<ValueProviderContext, string?> valueCallback, Func<string>? manifestExpressionCallback = null) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(valueCallback); | ||
| _valueCallback = valueCallback; | ||
| _manifestExpressionCallback = manifestExpressionCallback; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public string ValueExpression => _manifestExpressionCallback is not null | ||
| ? _manifestExpressionCallback() | ||
|
danegsta marked this conversation as resolved.
Outdated
|
||
| : _valueCallback(new ValueProviderContext()) ?? ""; | ||
|
|
||
| /// <inheritdoc /> | ||
| public ValueTask<string?> GetValueAsync(CancellationToken cancellationToken = default) | ||
| { | ||
| return GetValueAsync(new ValueProviderContext(), cancellationToken); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public ValueTask<string?> GetValueAsync(ValueProviderContext context, CancellationToken cancellationToken = default) | ||
| { | ||
| return new(_valueCallback(context)); | ||
| } | ||
| } | ||
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
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.