@@ -11,7 +11,6 @@ import (
1111 "strings"
1212 "time"
1313
14- "github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
1514 "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
1615 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3"
1716 "github.com/azure/azure-dev/cli/azd/pkg/azdext"
@@ -84,11 +83,11 @@ func parseAgentIdentityInfo(projectResourceID string) (*agentIdentityInfo, error
8483 }
8584
8685 // AI account scope is the project resource ID up to (but not including) "/projects/{project}"
87- projectIdx := strings .Index (projectResourceID , "/projects/" )
88- if projectIdx == - 1 {
86+ before , _ , ok := strings .Cut (projectResourceID , "/projects/" )
87+ if ! ok {
8988 return nil , fmt .Errorf ("could not derive AI account scope from project resource ID: %s" , projectResourceID )
9089 }
91- info .AccountScope = projectResourceID [: projectIdx ]
90+ info .AccountScope = before
9291
9392 return info , nil
9493}
@@ -294,7 +293,7 @@ func assignRoleToIdentity(
294293
295294 // Check for existing assignment
296295 pager := client .NewListForScopePager (scope , & armauthorization.RoleAssignmentsClientListForScopeOptions {
297- Filter : to . Ptr ("atScope()" ),
296+ Filter : new ("atScope ()"),
298297 })
299298
300299 alreadyExists := false
@@ -328,8 +327,8 @@ func assignRoleToIdentity(
328327 principalType := armauthorization .PrincipalTypeServicePrincipal
329328 parameters := armauthorization.RoleAssignmentCreateParameters {
330329 Properties : & armauthorization.RoleAssignmentProperties {
331- RoleDefinitionID : to . Ptr (fullRoleDefinitionID ),
332- PrincipalID : to . Ptr (principalID ),
330+ RoleDefinitionID : new (fullRoleDefinitionID ),
331+ PrincipalID : new (principalID ),
333332 PrincipalType : & principalType ,
334333 },
335334 }
0 commit comments