Skip to content
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

Detect spring.application.name and show in azure.yaml #62

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
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Name -> ApplicationName

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please create another PR to merge detectSpringApplicationName , detectSpringCloudAzure, detectSpringCloudEureka, detectSpringCloudConfig into new func: detectMetadata?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in this PR #63

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
Loading