Skip to content

Commit

Permalink
detect spring.application.name (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: haozhang <[email protected]>
  • Loading branch information
haoozhang and haozhang authored Dec 3, 2024
1 parent 05a38d8 commit 1064e5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli/azd/internal/appdetect/appdetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func (a AzureDepStorageAccount) ResourceDisplay() string {
}

type MetaData struct {
Name string
ContainsDependencySpringCloudAzureStarter bool
}

Expand Down
8 changes: 8 additions & 0 deletions cli/azd/internal/appdetect/spring_boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func detectAzureDependenciesByAnalyzingSpringBootProject(
parentProject: parentProject,
mavenProject: mavenProject,
}
detectSpringApplicationName(azdProject, &springBootProject)
detectDatabases(azdProject, &springBootProject)
detectServiceBus(azdProject, &springBootProject)
detectEventHubs(azdProject, &springBootProject)
Expand All @@ -102,6 +103,13 @@ func detectAzureDependenciesByAnalyzingSpringBootProject(
detectSpringCloudConfig(azdProject, &springBootProject)
}

func detectSpringApplicationName(azdProject *Project, springBootProject *SpringBootProject) {
var targetSpringAppName = "spring.application.name"
if appName, ok := springBootProject.applicationProperties[targetSpringAppName]; ok {
azdProject.MetaData.Name = appName
}
}

func detectDatabases(azdProject *Project, springBootProject *SpringBootProject) {
databaseDepMap := map[DatabaseDep]struct{}{}
for _, rule := range databaseDependencyRules {
Expand Down
6 changes: 3 additions & 3 deletions cli/azd/internal/repository/app_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,12 @@ func (i *Initializer) prjConfigFromDetect(
for _, dep := range svc.Dependencies {
switch dep {
case appdetect.JavaEurekaServer:
javaEurekaServerService, err = ServiceFromDetect(root, "", svc)
javaEurekaServerService, err = ServiceFromDetect(root, svc.MetaData.Name, svc)
if err != nil {
return config, err
}
case appdetect.JavaConfigServer:
javaConfigServerService, err = ServiceFromDetect(root, "", svc)
javaConfigServerService, err = ServiceFromDetect(root, svc.MetaData.Name, svc)
if err != nil {
return config, err
}
Expand All @@ -454,7 +454,7 @@ func (i *Initializer) prjConfigFromDetect(

svcMapping := map[string]string{}
for _, prj := range detect.Services {
svc, err := ServiceFromDetect(root, "", prj)
svc, err := ServiceFromDetect(root, prj.MetaData.Name, prj)
if err != nil {
return config, err
}
Expand Down

0 comments on commit 1064e5b

Please sign in to comment.