Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Aspire.Hosting/Ats/AtsCapabilityScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ private static Dictionary<string, List<AtsTypeRef>> BuildTypeCompatibilityMap(
IsInterface = false
};

// Register under its own type ID so base types with derived types
// are included when expanding capabilities that target them directly
AddToCompatibilityMap(typeToCompatibleTypes, typeInfo.AtsTypeId, concreteTypeRef);

// Register under each implemented interface
foreach (var iface in typeInfo.ImplementedInterfaces)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,207 @@ func (s *ContainerResource) WithContainerRegistry(registry *IResource) (*IResour
return result.(*IResource), nil
}

// WithBindMount adds a bind mount
func (s *ContainerResource) WithBindMount(source string, target string, isReadOnly bool) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["source"] = SerializeValue(source)
reqArgs["target"] = SerializeValue(target)
reqArgs["isReadOnly"] = SerializeValue(isReadOnly)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withBindMount", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithEntrypoint sets the container entrypoint
func (s *ContainerResource) WithEntrypoint(entrypoint string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["entrypoint"] = SerializeValue(entrypoint)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withEntrypoint", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithImageTag sets the container image tag
func (s *ContainerResource) WithImageTag(tag string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["tag"] = SerializeValue(tag)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withImageTag", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithImageRegistry sets the container image registry
func (s *ContainerResource) WithImageRegistry(registry string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["registry"] = SerializeValue(registry)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withImageRegistry", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithImage sets the container image
func (s *ContainerResource) WithImage(image string, tag string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["image"] = SerializeValue(image)
reqArgs["tag"] = SerializeValue(tag)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withImage", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithImageSHA256 sets the image SHA256 digest
func (s *ContainerResource) WithImageSHA256(sha256 string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["sha256"] = SerializeValue(sha256)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withImageSHA256", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithContainerRuntimeArgs adds runtime arguments for the container
func (s *ContainerResource) WithContainerRuntimeArgs(args []string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["args"] = SerializeValue(args)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerRuntimeArgs", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithLifetime sets the lifetime behavior of the container resource
func (s *ContainerResource) WithLifetime(lifetime ContainerLifetime) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["lifetime"] = SerializeValue(lifetime)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withLifetime", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithImagePullPolicy sets the container image pull policy
func (s *ContainerResource) WithImagePullPolicy(pullPolicy ImagePullPolicy) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["pullPolicy"] = SerializeValue(pullPolicy)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withImagePullPolicy", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// PublishAsContainer configures the resource to be published as a container
func (s *ContainerResource) PublishAsContainer() (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
result, err := s.Client().InvokeCapability("Aspire.Hosting/publishAsContainer", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithDockerfile configures the resource to use a Dockerfile
func (s *ContainerResource) WithDockerfile(contextPath string, dockerfilePath string, stage string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["contextPath"] = SerializeValue(contextPath)
reqArgs["dockerfilePath"] = SerializeValue(dockerfilePath)
reqArgs["stage"] = SerializeValue(stage)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withDockerfile", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithContainerName sets the container name
func (s *ContainerResource) WithContainerName(name string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["name"] = SerializeValue(name)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerName", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithBuildArg adds a build argument from a parameter resource
func (s *ContainerResource) WithBuildArg(name string, value *ParameterResource) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["name"] = SerializeValue(name)
reqArgs["value"] = SerializeValue(value)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildArg", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithBuildSecret adds a build secret from a parameter resource
func (s *ContainerResource) WithBuildSecret(name string, value *ParameterResource) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["name"] = SerializeValue(name)
reqArgs["value"] = SerializeValue(value)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withBuildSecret", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithEndpointProxySupport configures endpoint proxy support
func (s *ContainerResource) WithEndpointProxySupport(proxyEnabled bool) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["proxyEnabled"] = SerializeValue(proxyEnabled)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withEndpointProxySupport", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithDockerfileBaseImage sets the base image for a Dockerfile build
func (s *ContainerResource) WithDockerfileBaseImage(buildImage string, runtimeImage string) (*IResource, error) {
reqArgs := map[string]any{
Expand All @@ -2594,6 +2795,19 @@ func (s *ContainerResource) WithDockerfileBaseImage(buildImage string, runtimeIm
return result.(*IResource), nil
}

// WithContainerNetworkAlias adds a network alias for the container
func (s *ContainerResource) WithContainerNetworkAlias(alias string) (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["alias"] = SerializeValue(alias)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withContainerNetworkAlias", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithMcpServer configures an MCP server endpoint on the resource
func (s *ContainerResource) WithMcpServer(path string, endpointName string) (*IResourceWithEndpoints, error) {
reqArgs := map[string]any{
Expand Down Expand Up @@ -2633,6 +2847,18 @@ func (s *ContainerResource) WithOtlpExporterProtocol(protocol OtlpProtocol) (*IR
return result.(*IResourceWithEnvironment), nil
}

// PublishAsConnectionString publishes the resource as a connection string
func (s *ContainerResource) PublishAsConnectionString() (*ContainerResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
result, err := s.Client().InvokeCapability("Aspire.Hosting/publishAsConnectionString", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// WithRequiredCommand adds a required command dependency
func (s *ContainerResource) WithRequiredCommand(command string, helpLink string) (*IResource, error) {
reqArgs := map[string]any{
Expand Down Expand Up @@ -3394,6 +3620,21 @@ func (s *ContainerResource) WithPipelineConfiguration(callback func(...any) any)
return result.(*IResource), nil
}

// WithVolume adds a volume
func (s *ContainerResource) WithVolume(target string, name string, isReadOnly bool) (*ContainerResource, error) {
reqArgs := map[string]any{
"resource": SerializeValue(s.Handle()),
}
reqArgs["target"] = SerializeValue(target)
reqArgs["name"] = SerializeValue(name)
reqArgs["isReadOnly"] = SerializeValue(isReadOnly)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withVolume", reqArgs)
if err != nil {
return nil, err
}
return result.(*ContainerResource), nil
}

// GetResourceName gets the resource name
func (s *ContainerResource) GetResourceName() (*string, error) {
reqArgs := map[string]any{
Expand Down Expand Up @@ -5256,6 +5497,59 @@ func (s *ExecutableResource) WithDockerfileBaseImage(buildImage string, runtimeI
return result.(*IResource), nil
}

// PublishAsDockerFile publishes the executable as a Docker container
func (s *ExecutableResource) PublishAsDockerFile() (*ExecutableResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
result, err := s.Client().InvokeCapability("Aspire.Hosting/publishAsDockerFile", reqArgs)
if err != nil {
return nil, err
}
return result.(*ExecutableResource), nil
}

// PublishAsDockerFileWithConfigure publishes an executable as a Docker file with optional container configuration
func (s *ExecutableResource) PublishAsDockerFileWithConfigure(configure func(...any) any) (*ExecutableResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
if configure != nil {
reqArgs["configure"] = RegisterCallback(configure)
}
result, err := s.Client().InvokeCapability("Aspire.Hosting/publishAsDockerFileWithConfigure", reqArgs)
if err != nil {
return nil, err
}
return result.(*ExecutableResource), nil
}

// WithExecutableCommand sets the executable command
func (s *ExecutableResource) WithExecutableCommand(command string) (*ExecutableResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["command"] = SerializeValue(command)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withExecutableCommand", reqArgs)
if err != nil {
return nil, err
}
return result.(*ExecutableResource), nil
}

// WithWorkingDirectory sets the executable working directory
func (s *ExecutableResource) WithWorkingDirectory(workingDirectory string) (*ExecutableResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["workingDirectory"] = SerializeValue(workingDirectory)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withWorkingDirectory", reqArgs)
if err != nil {
return nil, err
}
return result.(*ExecutableResource), nil
}

// WithMcpServer configures an MCP server endpoint on the resource
func (s *ExecutableResource) WithMcpServer(path string, endpointName string) (*IResourceWithEndpoints, error) {
reqArgs := map[string]any{
Expand Down Expand Up @@ -8251,6 +8545,46 @@ func (s *ProjectResource) WithOtlpExporterProtocol(protocol OtlpProtocol) (*IRes
return result.(*IResourceWithEnvironment), nil
}

// WithReplicas sets the number of replicas
func (s *ProjectResource) WithReplicas(replicas float64) (*ProjectResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
reqArgs["replicas"] = SerializeValue(replicas)
result, err := s.Client().InvokeCapability("Aspire.Hosting/withReplicas", reqArgs)
if err != nil {
return nil, err
}
return result.(*ProjectResource), nil
}

// DisableForwardedHeaders disables forwarded headers for the project
func (s *ProjectResource) DisableForwardedHeaders() (*ProjectResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
result, err := s.Client().InvokeCapability("Aspire.Hosting/disableForwardedHeaders", reqArgs)
if err != nil {
return nil, err
}
return result.(*ProjectResource), nil
}

// PublishAsDockerFile publishes a project as a Docker file with optional container configuration
func (s *ProjectResource) PublishAsDockerFile(configure func(...any) any) (*ProjectResource, error) {
reqArgs := map[string]any{
"builder": SerializeValue(s.Handle()),
}
if configure != nil {
reqArgs["configure"] = RegisterCallback(configure)
}
result, err := s.Client().InvokeCapability("Aspire.Hosting/publishProjectAsDockerFileWithConfigure", reqArgs)
if err != nil {
return nil, err
}
return result.(*ProjectResource), nil
}

// WithRequiredCommand adds a required command dependency
func (s *ProjectResource) WithRequiredCommand(command string, helpLink string) (*IResource, error) {
reqArgs := map[string]any{
Expand Down
Loading
Loading