@@ -10,6 +10,7 @@ import (
1010 "log"
1111 "sync"
1212
13+ "github.com/azure/azure-dev/cli/azd/internal/mapper"
1314 "github.com/azure/azure-dev/cli/azd/pkg/async"
1415 "github.com/azure/azure-dev/cli/azd/pkg/azdext"
1516 "github.com/azure/azure-dev/cli/azd/pkg/extensions"
@@ -231,7 +232,13 @@ func (efs *ExternalFrameworkService) Restore(
231232 return nil , fmt .Errorf ("received empty restore response" )
232233 }
233234
234- return efs .fromProtoServiceRestoreResult (restoreResp .RestoreResult ), nil
235+ var result * ServiceRestoreResult
236+ err = mapper .Convert (restoreResp .RestoreResult , & result )
237+ if err != nil {
238+ return nil , fmt .Errorf ("converting restore result: %w" , err )
239+ }
240+
241+ return result , nil
235242}
236243
237244// Build builds the source for the framework service
@@ -273,7 +280,13 @@ func (efs *ExternalFrameworkService) Build(
273280 return nil , fmt .Errorf ("received empty build response" )
274281 }
275282
276- return efs .fromProtoServiceBuildResult (buildResp .BuildResult ), nil
283+ var result * ServiceBuildResult
284+ err = mapper .Convert (buildResp .BuildResult , & result )
285+ if err != nil {
286+ return nil , fmt .Errorf ("converting build result: %w" , err )
287+ }
288+
289+ return result , nil
277290}
278291
279292// Package packages the source suitable for deployment
@@ -315,7 +328,13 @@ func (efs *ExternalFrameworkService) Package(
315328 return nil , fmt .Errorf ("received empty package response" )
316329 }
317330
318- return fromProtoServicePackageResult (packageResp .PackageResult , nil ), nil
331+ var result * ServicePackageResult
332+ err = mapper .Convert (packageResp .PackageResult , & result )
333+ if err != nil {
334+ return nil , fmt .Errorf ("converting package result: %w" , err )
335+ }
336+
337+ return result , nil
319338}
320339
321340// Private methods for gRPC communication
@@ -445,37 +464,13 @@ func (efs *ExternalFrameworkService) toProtoServiceConfig(serviceConfig *Service
445464 return nil , nil
446465 }
447466
448- image , err := serviceConfig .Image .Envsubst (func (name string ) string {
449- return "" // Use empty resolver for now, similar to service_target_external.go
450- })
467+ var protoConfig * azdext.ServiceConfig
468+ err := mapper .Convert (serviceConfig , & protoConfig )
451469 if err != nil {
452- return nil , fmt .Errorf ("failed to resolve image value: %w" , err )
453- }
454-
455- return & azdext.ServiceConfig {
456- Name : serviceConfig .Name ,
457- RelativePath : serviceConfig .RelativePath ,
458- Host : string (serviceConfig .Host ),
459- Language : string (serviceConfig .Language ),
460- OutputPath : serviceConfig .OutputPath ,
461- Image : image ,
462- }, nil
463- }
464-
465- // Convert proto ServiceRestoreResult to local type
466- func (efs * ExternalFrameworkService ) fromProtoServiceRestoreResult (
467- protoResult * azdext.ServiceRestoreResult ,
468- ) * ServiceRestoreResult {
469- if protoResult == nil {
470- return nil
471- }
472-
473- result := & ServiceRestoreResult {}
474- if len (protoResult .Details ) > 0 {
475- result .Details = stringMapToDetailsInterface (protoResult .Details )
470+ return nil , fmt .Errorf ("converting service config: %w" , err )
476471 }
477472
478- return result
473+ return protoConfig , nil
479474}
480475
481476// Convert ServiceRestoreResult to proto message
@@ -484,47 +479,38 @@ func (efs *ExternalFrameworkService) toProtoServiceRestoreResult(result *Service
484479 return nil
485480 }
486481
487- details := detailsInterfaceToStringMap (result .Details )
488- protoResult := & azdext.ServiceRestoreResult {}
489- if len (details ) > 0 {
490- protoResult .Details = details
482+ var protoResult * azdext.ServiceRestoreResult
483+ err := mapper .Convert (result , & protoResult )
484+ if err != nil {
485+ // Fallback to basic conversion
486+ details := detailsInterfaceToStringMap (result .Details )
487+ protoResult = & azdext.ServiceRestoreResult {}
488+ if len (details ) > 0 {
489+ protoResult .Details = details
490+ }
491491 }
492492
493493 return protoResult
494494}
495495
496- // Convert proto ServiceBuildResult to local type
497- func (efs * ExternalFrameworkService ) fromProtoServiceBuildResult (
498- protoResult * azdext.ServiceBuildResult ,
499- ) * ServiceBuildResult {
500- if protoResult == nil {
501- return nil
502- }
503-
504- result := & ServiceBuildResult {
505- Restore : efs .fromProtoServiceRestoreResult (protoResult .Restore ),
506- }
507-
508- if len (protoResult .Details ) > 0 {
509- result .Details = stringMapToDetailsInterface (protoResult .Details )
510- }
511-
512- return result
513- }
514-
515496// Convert ServiceBuildResult to proto message
516497func (efs * ExternalFrameworkService ) toProtoServiceBuildResult (result * ServiceBuildResult ) * azdext.ServiceBuildResult {
517498 if result == nil {
518499 return nil
519500 }
520501
521- details := detailsInterfaceToStringMap (result .Details )
522- protoResult := & azdext.ServiceBuildResult {
523- Restore : efs .toProtoServiceRestoreResult (result .Restore ),
524- }
502+ var protoResult * azdext.ServiceBuildResult
503+ err := mapper .Convert (result , & protoResult )
504+ if err != nil {
505+ // Fallback to basic conversion
506+ details := detailsInterfaceToStringMap (result .Details )
507+ protoResult = & azdext.ServiceBuildResult {
508+ Restore : efs .toProtoServiceRestoreResult (result .Restore ),
509+ }
525510
526- if len (details ) > 0 {
527- protoResult .Details = details
511+ if len (details ) > 0 {
512+ protoResult .Details = details
513+ }
528514 }
529515
530516 return protoResult
0 commit comments