-
Notifications
You must be signed in to change notification settings - Fork 228
extension: support existing
resource for ai build start
#5193
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -56,6 +56,7 @@ message GetResourceTypeResponse { | |
// AddResourceRequest is a request to add a new composability resource. | ||
message AddResourceRequest { | ||
ComposedResource resource = 1; | ||
string ExistingId = 2; | ||
} | ||
|
||
// AddResourceResponse is the response of AddResource operation. | ||
|
@@ -69,6 +70,7 @@ message ComposedResource { | |
string type = 2; | ||
bytes config = 3; | ||
repeated string uses = 4; | ||
string resource_id = 5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the |
||
} | ||
|
||
// ComposedResourceType represents a type of composability resource. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ import ( | |
"fmt" | ||
|
||
"github.com/azure/azure-dev/cli/azd/pkg/azdext" | ||
"github.com/azure/azure-dev/cli/azd/pkg/environment" | ||
"github.com/azure/azure-dev/cli/azd/pkg/environment/azdcontext" | ||
"github.com/azure/azure-dev/cli/azd/pkg/infra" | ||
"github.com/azure/azure-dev/cli/azd/pkg/lazy" | ||
"github.com/azure/azure-dev/cli/azd/pkg/project" | ||
"google.golang.org/grpc/codes" | ||
|
@@ -19,15 +21,20 @@ import ( | |
// composeService exposes features of the AZD composability model to the Extensions Framework layer. | ||
type composeService struct { | ||
azdext.UnimplementedComposeServiceServer | ||
|
||
lazyAzdContext *lazy.Lazy[*azdcontext.AzdContext] | ||
env *environment.Environment | ||
envManager environment.Manager | ||
} | ||
|
||
func NewComposeService( | ||
lazyAzdContext *lazy.Lazy[*azdcontext.AzdContext], | ||
env *environment.Environment, | ||
envManager environment.Manager, | ||
) azdext.ComposeServiceServer { | ||
return &composeService{ | ||
lazyAzdContext: lazyAzdContext, | ||
env: env, | ||
envManager: envManager, | ||
} | ||
} | ||
Comment on lines
29
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to be careful adding non-lazy dependencies to the gRPC server side services because the component initialization can fail. For example, try running the command in a fold that doesn't have an azd project or environment yet and this will likely fail. Take a look at some of the other gRPC services for examples to use lazy components. |
||
|
||
|
@@ -56,10 +63,25 @@ func (c *composeService) AddResource( | |
} | ||
|
||
projectConfig.Resources[req.Resource.Name] = &project.ResourceConfig{ | ||
Name: req.Resource.Name, | ||
Type: project.ResourceType(req.Resource.Type), | ||
Props: resourceProps, | ||
Uses: req.Resource.Uses, | ||
Name: req.Resource.Name, | ||
Type: project.ResourceType(req.Resource.Type), | ||
Props: resourceProps, | ||
Uses: req.Resource.Uses, | ||
ResourceId: req.ExistingId, | ||
} | ||
|
||
if req.ExistingId != "" { | ||
// add existing:true to azure.yaml | ||
if resource, exists := projectConfig.Resources[req.Resource.Name]; exists { | ||
resource.Existing = true | ||
} | ||
// save resource id to env | ||
c.env.DotenvSet(infra.ResourceIdName(req.Resource.Name), req.ExistingId) | ||
|
||
err = c.envManager.Save(ctx, c.env) | ||
if err != nil { | ||
return nil, fmt.Errorf("saving environment: %w", err) | ||
} | ||
} | ||
|
||
if err := project.Save(ctx, projectConfig, azdContext.ProjectPath()); err != nil { | ||
|
@@ -162,10 +184,11 @@ func (c *composeService) ListResources( | |
return nil, fmt.Errorf("marshaling resource config: %w", err) | ||
} | ||
composedResource := &azdext.ComposedResource{ | ||
Name: resource.Name, | ||
Type: string(resource.Type), | ||
Config: resourceConfigBytes, | ||
Uses: resource.Uses, | ||
Name: resource.Name, | ||
Type: string(resource.Type), | ||
Config: resourceConfigBytes, | ||
Uses: resource.Uses, | ||
ResourceId: resource.ResourceId, | ||
} | ||
composedResources = append(composedResources, composedResource) | ||
} | ||
|
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.
Are this used?
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.
Why do we need to add all of these new non-words?
Uh oh!
There was an error while loading. Please reload this page.
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.
Added due to spell check error: https://github.com/Azure/azure-dev/actions/runs/15026950586/job/42229968592