Skip to content

Commit 4b9f6d9

Browse files
Expose WithComputeEnvironment to polyglot AppHosts (#17093)
* Expose WithComputeEnvironment to polyglot AppHosts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update polyglot codegen snapshots Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7dda557 commit 4b9f6d9

15 files changed

Lines changed: 1345 additions & 512 deletions

File tree

src/Aspire.Hosting/ResourceBuilderExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4294,9 +4294,8 @@ public static IResourceBuilder<T> WithIconName<T>(this IResourceBuilder<T> build
42944294
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
42954295
/// <remarks>
42964296
/// This method allows associating a specific compute environment with the compute resource.
4297-
/// <para>This method is not available in polyglot app hosts.</para>
42984297
/// </remarks>
4299-
[AspireExportIgnore(Reason = "IComputeEnvironmentResource is a specialized interface — not ATS-compatible.")]
4298+
[AspireExport(Description = "Configures the compute environment for the compute resource")]
43004299
public static IResourceBuilder<T> WithComputeEnvironment<T>(this IResourceBuilder<T> builder, IResourceBuilder<IComputeEnvironmentResource> computeEnvironmentResource)
43014300
where T : IComputeResource
43024301
{

tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,12 @@ var WellKnownPipelineTags = struct {
759759
// Marker interfaces (from interface-metadata types)
760760
// ============================================================================
761761

762+
// ComputeEnvironmentResource marks types implementing IComputeEnvironmentResource.
763+
// Marker interface.
764+
type ComputeEnvironmentResource interface {
765+
handleReference
766+
}
767+
762768
// ConfigurationSection marks types implementing IConfigurationSection.
763769
// Marker interface.
764770
type ConfigurationSection interface {
@@ -1011,6 +1017,7 @@ type Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource interface {
10111017
WithCertificateTrustScope(scope CertificateTrustScope) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
10121018
WithChildRelationship(child Resource) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
10131019
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
1020+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
10141021
WithConfig(config *TestConfigDto) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
10151022
WithContainerCertificatePaths(options ...*WithContainerCertificatePathsOptions) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
10161023
WithContainerName(name string) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource
@@ -1550,6 +1557,19 @@ func (s *aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource) WithCommand(na
15501557
return s
15511558
}
15521559

1560+
// WithComputeEnvironment configures the compute environment for the compute resource
1561+
func (s *aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource {
1562+
if s.err != nil { return s }
1563+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
1564+
ctx := context.Background()
1565+
reqArgs := map[string]any{
1566+
"builder": s.handle.ToJSON(),
1567+
}
1568+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
1569+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
1570+
return s
1571+
}
1572+
15531573
// WithConfig configures the resource with a DTO
15541574
func (s *aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource) WithConfig(config *TestConfigDto) Aspire_Hosting_CodeGeneration_Go_TestsTestVaultResource {
15551575
if s.err != nil { return s }
@@ -2962,6 +2982,7 @@ type CSharpAppResource interface {
29622982
WithCertificateTrustScope(scope CertificateTrustScope) CSharpAppResource
29632983
WithChildRelationship(child Resource) CSharpAppResource
29642984
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) CSharpAppResource
2985+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) CSharpAppResource
29652986
WithConfig(config *TestConfigDto) CSharpAppResource
29662987
WithContainerRegistry(registry Resource) CSharpAppResource
29672988
WithCorrelationId(correlationId string) CSharpAppResource
@@ -3461,6 +3482,19 @@ func (s *cSharpAppResource) WithCommand(name string, displayName string, execute
34613482
return s
34623483
}
34633484

3485+
// WithComputeEnvironment configures the compute environment for the compute resource
3486+
func (s *cSharpAppResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) CSharpAppResource {
3487+
if s.err != nil { return s }
3488+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
3489+
ctx := context.Background()
3490+
reqArgs := map[string]any{
3491+
"builder": s.handle.ToJSON(),
3492+
}
3493+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
3494+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
3495+
return s
3496+
}
3497+
34643498
// WithConfig configures the resource with a DTO
34653499
func (s *cSharpAppResource) WithConfig(config *TestConfigDto) CSharpAppResource {
34663500
if s.err != nil { return s }
@@ -5806,6 +5840,7 @@ type ContainerResource interface {
58065840
WithCertificateTrustScope(scope CertificateTrustScope) ContainerResource
58075841
WithChildRelationship(child Resource) ContainerResource
58085842
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) ContainerResource
5843+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) ContainerResource
58095844
WithConfig(config *TestConfigDto) ContainerResource
58105845
WithContainerCertificatePaths(options ...*WithContainerCertificatePathsOptions) ContainerResource
58115846
WithContainerName(name string) ContainerResource
@@ -6344,6 +6379,19 @@ func (s *containerResource) WithCommand(name string, displayName string, execute
63446379
return s
63456380
}
63466381

6382+
// WithComputeEnvironment configures the compute environment for the compute resource
6383+
func (s *containerResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) ContainerResource {
6384+
if s.err != nil { return s }
6385+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
6386+
ctx := context.Background()
6387+
reqArgs := map[string]any{
6388+
"builder": s.handle.ToJSON(),
6389+
}
6390+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
6391+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
6392+
return s
6393+
}
6394+
63476395
// WithConfig configures the resource with a DTO
63486396
func (s *containerResource) WithConfig(config *TestConfigDto) ContainerResource {
63496397
if s.err != nil { return s }
@@ -9072,6 +9120,7 @@ type DotnetToolResource interface {
90729120
WithCertificateTrustScope(scope CertificateTrustScope) DotnetToolResource
90739121
WithChildRelationship(child Resource) DotnetToolResource
90749122
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) DotnetToolResource
9123+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) DotnetToolResource
90759124
WithConfig(config *TestConfigDto) DotnetToolResource
90769125
WithContainerRegistry(registry Resource) DotnetToolResource
90779126
WithCorrelationId(correlationId string) DotnetToolResource
@@ -9546,6 +9595,19 @@ func (s *dotnetToolResource) WithCommand(name string, displayName string, execut
95469595
return s
95479596
}
95489597

9598+
// WithComputeEnvironment configures the compute environment for the compute resource
9599+
func (s *dotnetToolResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) DotnetToolResource {
9600+
if s.err != nil { return s }
9601+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
9602+
ctx := context.Background()
9603+
reqArgs := map[string]any{
9604+
"builder": s.handle.ToJSON(),
9605+
}
9606+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
9607+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
9608+
return s
9609+
}
9610+
95499611
// WithConfig configures the resource with a DTO
95509612
func (s *dotnetToolResource) WithConfig(config *TestConfigDto) DotnetToolResource {
95519613
if s.err != nil { return s }
@@ -11664,6 +11726,7 @@ type ExecutableResource interface {
1166411726
WithCertificateTrustScope(scope CertificateTrustScope) ExecutableResource
1166511727
WithChildRelationship(child Resource) ExecutableResource
1166611728
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) ExecutableResource
11729+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) ExecutableResource
1166711730
WithConfig(config *TestConfigDto) ExecutableResource
1166811731
WithContainerRegistry(registry Resource) ExecutableResource
1166911732
WithCorrelationId(correlationId string) ExecutableResource
@@ -12132,6 +12195,19 @@ func (s *executableResource) WithCommand(name string, displayName string, execut
1213212195
return s
1213312196
}
1213412197

12198+
// WithComputeEnvironment configures the compute environment for the compute resource
12199+
func (s *executableResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) ExecutableResource {
12200+
if s.err != nil { return s }
12201+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
12202+
ctx := context.Background()
12203+
reqArgs := map[string]any{
12204+
"builder": s.handle.ToJSON(),
12205+
}
12206+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
12207+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
12208+
return s
12209+
}
12210+
1213512211
// WithConfig configures the resource with a DTO
1213612212
func (s *executableResource) WithConfig(config *TestConfigDto) ExecutableResource {
1213712213
if s.err != nil { return s }
@@ -16306,6 +16382,7 @@ type ProjectResource interface {
1630616382
WithCertificateTrustScope(scope CertificateTrustScope) ProjectResource
1630716383
WithChildRelationship(child Resource) ProjectResource
1630816384
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) ProjectResource
16385+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) ProjectResource
1630916386
WithConfig(config *TestConfigDto) ProjectResource
1631016387
WithContainerRegistry(registry Resource) ProjectResource
1631116388
WithCorrelationId(correlationId string) ProjectResource
@@ -16805,6 +16882,19 @@ func (s *projectResource) WithCommand(name string, displayName string, executeCo
1680516882
return s
1680616883
}
1680716884

16885+
// WithComputeEnvironment configures the compute environment for the compute resource
16886+
func (s *projectResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) ProjectResource {
16887+
if s.err != nil { return s }
16888+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
16889+
ctx := context.Background()
16890+
reqArgs := map[string]any{
16891+
"builder": s.handle.ToJSON(),
16892+
}
16893+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
16894+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
16895+
return s
16896+
}
16897+
1680816898
// WithConfig configures the resource with a DTO
1680916899
func (s *projectResource) WithConfig(config *TestConfigDto) ProjectResource {
1681016900
if s.err != nil { return s }
@@ -19203,6 +19293,7 @@ type TestDatabaseResource interface {
1920319293
WithCertificateTrustScope(scope CertificateTrustScope) TestDatabaseResource
1920419294
WithChildRelationship(child Resource) TestDatabaseResource
1920519295
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) TestDatabaseResource
19296+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) TestDatabaseResource
1920619297
WithConfig(config *TestConfigDto) TestDatabaseResource
1920719298
WithContainerCertificatePaths(options ...*WithContainerCertificatePathsOptions) TestDatabaseResource
1920819299
WithContainerName(name string) TestDatabaseResource
@@ -19741,6 +19832,19 @@ func (s *testDatabaseResource) WithCommand(name string, displayName string, exec
1974119832
return s
1974219833
}
1974319834

19835+
// WithComputeEnvironment configures the compute environment for the compute resource
19836+
func (s *testDatabaseResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) TestDatabaseResource {
19837+
if s.err != nil { return s }
19838+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
19839+
ctx := context.Background()
19840+
reqArgs := map[string]any{
19841+
"builder": s.handle.ToJSON(),
19842+
}
19843+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
19844+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
19845+
return s
19846+
}
19847+
1974419848
// WithConfig configures the resource with a DTO
1974519849
func (s *testDatabaseResource) WithConfig(config *TestConfigDto) TestDatabaseResource {
1974619850
if s.err != nil { return s }
@@ -21148,6 +21252,7 @@ type TestRedisResource interface {
2114821252
WithCertificateTrustScope(scope CertificateTrustScope) TestRedisResource
2114921253
WithChildRelationship(child Resource) TestRedisResource
2115021254
WithCommand(name string, displayName string, executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult, options ...*WithCommandOptions) TestRedisResource
21255+
WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) TestRedisResource
2115121256
WithConfig(config *TestConfigDto) TestRedisResource
2115221257
WithConnectionProperty(name string, value any) TestRedisResource
2115321258
WithConnectionString(connectionString *ReferenceExpression) TestRedisResource
@@ -21849,6 +21954,19 @@ func (s *testRedisResource) WithCommand(name string, displayName string, execute
2184921954
return s
2185021955
}
2185121956

21957+
// WithComputeEnvironment configures the compute environment for the compute resource
21958+
func (s *testRedisResource) WithComputeEnvironment(computeEnvironmentResource ComputeEnvironmentResource) TestRedisResource {
21959+
if s.err != nil { return s }
21960+
if computeEnvironmentResource != nil { if err := computeEnvironmentResource.Err(); err != nil { s.setErr(err); return s } }
21961+
ctx := context.Background()
21962+
reqArgs := map[string]any{
21963+
"builder": s.handle.ToJSON(),
21964+
}
21965+
reqArgs["computeEnvironmentResource"] = serializeValue(computeEnvironmentResource)
21966+
if _, err := s.client.invokeCapability(ctx, "Aspire.Hosting/withComputeEnvironment", reqArgs); err != nil { s.setErr(err) }
21967+
return s
21968+
}
21969+
2185221970
// WithConfig configures the resource with a DTO
2185321971
func (s *testRedisResource) WithConfig(config *TestConfigDto) TestRedisResource {
2185421972
if s.err != nil { return s }

0 commit comments

Comments
 (0)