diff --git a/.github/workflows/cli-ci.yml b/.github/workflows/cli-ci.yml index d4c5bf24065..83d9110d5a9 100644 --- a/.github/workflows/cli-ci.yml +++ b/.github/workflows/cli-ci.yml @@ -6,7 +6,7 @@ on: - "cli/**" - ".github/workflows/cli-ci.yml" - "go.mod" - branches: [main] + branches: [main, feature/sjad] permissions: contents: read diff --git a/.github/workflows/cspell-misc.yml b/.github/workflows/cspell-misc.yml index ca97973a812..6686685741c 100644 --- a/.github/workflows/cspell-misc.yml +++ b/.github/workflows/cspell-misc.yml @@ -2,7 +2,7 @@ name: misc on: pull_request: - branches: [main] + branches: [main, feature/sjad] paths-ignore: # Changes here should be kept in-sync with projects listed in cspell.misc.yaml - 'eng/**' # Not required diff --git a/.github/workflows/go-test-for-sjad-branch.yml b/.github/workflows/go-test-for-sjad-branch.yml new file mode 100644 index 00000000000..00a86a2992a --- /dev/null +++ b/.github/workflows/go-test-for-sjad-branch.yml @@ -0,0 +1,34 @@ +name: Go Test + +on: + pull_request: + branches: + - feature/sjad + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.23.1 + + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run tests + run: | + cd ./cli/azd + go test $(go list ./... | grep -v github.com/azure/azure-dev/cli/azd/test/functional) -cover \ No newline at end of file diff --git a/.vscode/cspell.misc.yaml b/.vscode/cspell.misc.yaml index b32078de70c..f23b3bf5fa6 100644 --- a/.vscode/cspell.misc.yaml +++ b/.vscode/cspell.misc.yaml @@ -41,3 +41,5 @@ overrides: - myimage - azureai - entra + - servicebus + - eventhubs diff --git a/cli/azd/.vscode/cspell.yaml b/cli/azd/.vscode/cspell.yaml index cc23a3fb0de..30e56b1fbf0 100644 --- a/cli/azd/.vscode/cspell.yaml +++ b/cli/azd/.vscode/cspell.yaml @@ -13,6 +13,14 @@ words: - usgovcloudapi - chinacloudapi - unmarshals + - springframework + - eventhubs + - jdbc + - datasource + - passwordless + - postgre + - mysqladmin + - sjad languageSettings: - languageId: go ignoreRegExpList: @@ -40,8 +48,7 @@ overrides: - azuredeps - filename: internal/appdetect/java.go words: - - springframework - - eventhubs + - chardata - filename: docs/docgen.go words: - alexwolf diff --git a/cli/azd/internal/repository/app_init.go b/cli/azd/internal/repository/app_init.go index b080c252e07..e5128f2323e 100644 --- a/cli/azd/internal/repository/app_init.go +++ b/cli/azd/internal/repository/app_init.go @@ -638,33 +638,31 @@ func (i *Initializer) prjConfigFromDetect( if err != nil { return config, err } - switch azureDep.(type) { + switch azureDep := azureDep.(type) { case appdetect.AzureDepServiceBus: - azureDepServiceBus := azureDep.(appdetect.AzureDepServiceBus) config.Resources["servicebus"] = &project.ResourceConfig{ Type: project.ResourceTypeMessagingServiceBus, Props: project.ServiceBusProps{ - Queues: azureDepServiceBus.Queues, - IsJms: azureDepServiceBus.IsJms, + Queues: azureDep.Queues, + IsJms: azureDep.IsJms, AuthType: authType, }, } case appdetect.AzureDepEventHubs: - azureDepEventHubs := azureDep.(appdetect.AzureDepEventHubs) - if azureDepEventHubs.UseKafka { + if azureDep.UseKafka { config.Resources["kafka"] = &project.ResourceConfig{ Type: project.ResourceTypeMessagingKafka, Props: project.KafkaProps{ - Topics: azureDepEventHubs.Names, + Topics: azureDep.Names, AuthType: authType, - SpringBootVersion: azureDepEventHubs.SpringBootVersion, + SpringBootVersion: azureDep.SpringBootVersion, }, } } else { config.Resources["eventhubs"] = &project.ResourceConfig{ Type: project.ResourceTypeMessagingEventHubs, Props: project.EventHubsProps{ - EventHubNames: azureDepEventHubs.Names, + EventHubNames: azureDep.Names, AuthType: authType, }, } @@ -673,7 +671,7 @@ func (i *Initializer) prjConfigFromDetect( config.Resources["storage"] = &project.ResourceConfig{ Type: project.ResourceTypeStorage, Props: project.StorageProps{ - Containers: azureDep.(appdetect.AzureDepStorageAccount).ContainerNames, + Containers: azureDep.ContainerNames, AuthType: authType, }, } @@ -709,11 +707,11 @@ func (i *Initializer) prjConfigFromDetect( } for _, azureDep := range svc.AzureDeps { - switch azureDep.(type) { + switch azureDep := azureDep.(type) { case appdetect.AzureDepServiceBus: resSpec.Uses = append(resSpec.Uses, "servicebus") case appdetect.AzureDepEventHubs: - if azureDep.(appdetect.AzureDepEventHubs).UseKafka { + if azureDep.UseKafka { resSpec.Uses = append(resSpec.Uses, "kafka") } else { resSpec.Uses = append(resSpec.Uses, "eventhubs") @@ -870,7 +868,9 @@ func processSpringCloudAzureDepByPrompt(console input.Console, ctx context.Conte switch continueOption { case 0: - return errors.New("you have to manually add dependency com.azure.spring:spring-cloud-azure-starter by following https://github.com/Azure/azure-sdk-for-java/wiki/Spring-Versions-Mapping") + return errors.New("you have to manually add dependency com.azure.spring:spring-cloud-azure-starter. " + + "And use right version according to this page: " + + "https://github.com/Azure/azure-sdk-for-java/wiki/Spring-Versions-Mapping") case 1: return nil case 2: diff --git a/cli/azd/internal/scaffold/bicep_env.go b/cli/azd/internal/scaffold/bicep_env.go index 330f83cbb60..fb410671969 100644 --- a/cli/azd/internal/scaffold/bicep_env.go +++ b/cli/azd/internal/scaffold/bicep_env.go @@ -74,7 +74,7 @@ func removeQuotationIfItIsASingleVariable(input string) string { if strings.HasPrefix(input, prefix) && strings.HasSuffix(input, suffix) { prefixTrimmed := strings.TrimPrefix(input, prefix) trimmed := strings.TrimSuffix(prefixTrimmed, suffix) - if strings.IndexAny(trimmed, "}") == -1 { + if !strings.ContainsAny(trimmed, "}") { return trimmed } else { return input @@ -128,8 +128,9 @@ var bicepEnv = map[ResourceType]map[ResourceInfoType]string{ ResourceInfoTypeDatabaseName: "postgreSqlDatabaseName", ResourceInfoTypeUsername: "postgreSqlDatabaseUser", ResourceInfoTypePassword: "postgreSqlDatabasePassword", - ResourceInfoTypeUrl: "'postgresql://${postgreSqlDatabaseUser}:${postgreSqlDatabasePassword}@${postgreServer.outputs.fqdn}:5432/${postgreSqlDatabaseName}'", - ResourceInfoTypeJdbcUrl: "'jdbc:postgresql://${postgreServer.outputs.fqdn}:5432/${postgreSqlDatabaseName}'", + ResourceInfoTypeUrl: "'postgresql://${postgreSqlDatabaseUser}:${postgreSqlDatabasePassword}@" + + "${postgreServer.outputs.fqdn}:5432/${postgreSqlDatabaseName}'", + ResourceInfoTypeJdbcUrl: "'jdbc:postgresql://${postgreServer.outputs.fqdn}:5432/${postgreSqlDatabaseName}'", }, ResourceTypeDbMySQL: { ResourceInfoTypeHost: "mysqlServer.outputs.fqdn", @@ -137,8 +138,9 @@ var bicepEnv = map[ResourceType]map[ResourceInfoType]string{ ResourceInfoTypeDatabaseName: "mysqlDatabaseName", ResourceInfoTypeUsername: "mysqlDatabaseUser", ResourceInfoTypePassword: "mysqlDatabasePassword", - ResourceInfoTypeUrl: "'mysql://${mysqlDatabaseUser}:${mysqlDatabasePassword}@${mysqlServer.outputs.fqdn}:3306/${mysqlDatabaseName}'", - ResourceInfoTypeJdbcUrl: "'jdbc:mysql://${mysqlServer.outputs.fqdn}:3306/${mysqlDatabaseName}'", + ResourceInfoTypeUrl: "'mysql://${mysqlDatabaseUser}:${mysqlDatabasePassword}@" + + "${mysqlServer.outputs.fqdn}:3306/${mysqlDatabaseName}'", + ResourceInfoTypeJdbcUrl: "'jdbc:mysql://${mysqlServer.outputs.fqdn}:3306/${mysqlDatabaseName}'", }, ResourceTypeDbRedis: { ResourceInfoTypeHost: "redis.outputs.hostName", diff --git a/cli/azd/internal/useragent_test.go b/cli/azd/internal/useragent_test.go index a33a53cda15..beb986ca485 100644 --- a/cli/azd/internal/useragent_test.go +++ b/cli/azd/internal/useragent_test.go @@ -15,16 +15,20 @@ func TestUserAgentStringScenarios(t *testing.T) { azDevIdentifier := fmt.Sprintf("azdev/%s %s", version, runtimeInfo()) t.Run("default", func(t *testing.T) { + t.Setenv("GITHUB_ACTIONS", "false") + t.Setenv(AzdUserAgentEnvVar, "") require.Equal(t, azDevIdentifier, UserAgent()) }) t.Run("withUserAgent", func(t *testing.T) { + t.Setenv("GITHUB_ACTIONS", "false") t.Setenv(AzdUserAgentEnvVar, "dev_user_agent") require.Equal(t, fmt.Sprintf("%s dev_user_agent", azDevIdentifier), UserAgent()) }) t.Run("onGitHubActions", func(t *testing.T) { t.Setenv("GITHUB_ACTIONS", "true") + t.Setenv(AzdUserAgentEnvVar, "") require.Equal(t, fmt.Sprintf("%s GhActions", azDevIdentifier), UserAgent()) }) diff --git a/cli/azd/pkg/project/project.go b/cli/azd/pkg/project/project.go index 31a38cd04a8..8cd4401086e 100644 --- a/cli/azd/pkg/project/project.go +++ b/cli/azd/pkg/project/project.go @@ -21,12 +21,6 @@ import ( "github.com/braydonk/yaml" ) -const ( - //nolint:lll - // todo(haozhan): update this line for sjad private preview, need to revert it when merge into azure-dev/main branch - projectSchemaAnnotation = "# yaml-language-server: $schema=https://raw.githubusercontent.com/azure-javaee/azure-dev/feature/sjad/schemas/alpha/azure.yaml.json" -) - func New(ctx context.Context, projectFilePath string, projectName string) (*ProjectConfig, error) { newProject := &ProjectConfig{ Name: projectName, @@ -298,9 +292,8 @@ func Save(ctx context.Context, projectConfig *ProjectConfig, projectFilePath str version = projectConfig.MetaSchemaVersion } - annotation := fmt.Sprintf( - "# yaml-language-server: $schema=https://raw.githubusercontent.com/azure-javaee/azure-dev/feature/sjad/schemas/%s/azure.yaml.json", - version) + annotation := fmt.Sprintf("# yaml-language-server: $schema=https://raw.githubusercontent.com/azure-javaee/"+ + "azure-dev/feature/sjad/schemas/%s/azure.yaml.json", version) projectFileContents := bytes.NewBufferString(annotation + "\n\n") _, err = projectFileContents.Write(projectBytes) if err != nil { diff --git a/cli/azd/pkg/project/scaffold_gen.go b/cli/azd/pkg/project/scaffold_gen.go index b86b49e54e5..9f8d04862a9 100644 --- a/cli/azd/pkg/project/scaffold_gen.go +++ b/cli/azd/pkg/project/scaffold_gen.go @@ -381,7 +381,7 @@ func printEnvListAboutUses(infraSpec *scaffold.InfraSpec, projectConfig *Project } console.Message(ctx, fmt.Sprintf("\nInformation about environment variables:\n"+ "In azure.yaml, '%s' uses '%s'. \n"+ - "The 'uses' relashipship is implemented by environment variables. \n"+ + "The 'uses' relationship is implemented by environment variables. \n"+ "Please make sure your application used the right environment variable. \n"+ "Here is the list of environment variables: ", userResourceName, usedResourceName)) @@ -406,7 +406,7 @@ func printEnvListAboutUses(infraSpec *scaffold.InfraSpec, projectConfig *Project printHintsAboutUseHostContainerApp(userResourceName, usedResourceName, console, ctx) default: return fmt.Errorf("resource (%s) uses (%s), but the type of (%s) is (%s), "+ - "which is doen't add necessary environment variable", + "which is doesn't add necessary environment variable", userResource.Name, usedResource.Name, usedResource.Name, usedResource.Type) } console.Message(ctx, "\n") @@ -449,7 +449,6 @@ func handleContainerAppProps( if err != nil { return err } - return nil } port := props.Port @@ -565,8 +564,8 @@ func printHintsAboutUseHostContainerApp(userResourceName string, usedResourceNam if console == nil { return } - console.Message(ctx, fmt.Sprintf("Environemnt variables in %s:", userResourceName)) + console.Message(ctx, fmt.Sprintf("Environment variables in %s:", userResourceName)) console.Message(ctx, fmt.Sprintf("%s_BASE_URL=xxx", strings.ToUpper(usedResourceName))) - console.Message(ctx, fmt.Sprintf("Environemnt variables in %s:", usedResourceName)) + console.Message(ctx, fmt.Sprintf("Environment variables in %s:", usedResourceName)) console.Message(ctx, fmt.Sprintf("%s_BASE_URL=xxx", strings.ToUpper(userResourceName))) } diff --git a/cli/azd/pkg/project/scaffold_gen_environment_variables.go b/cli/azd/pkg/project/scaffold_gen_environment_variables.go index f02ea084f6c..e1224f54fdd 100644 --- a/cli/azd/pkg/project/scaffold_gen_environment_variables.go +++ b/cli/azd/pkg/project/scaffold_gen_environment_variables.go @@ -20,67 +20,82 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypePassword: return []scaffold.Env{ { - Name: "POSTGRES_USERNAME", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), + Name: "POSTGRES_USERNAME", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), }, { - Name: "POSTGRES_PASSWORD", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePassword), + Name: "POSTGRES_PASSWORD", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePassword), }, { - Name: "POSTGRES_HOST", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeHost), + Name: "POSTGRES_HOST", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeHost), }, { - Name: "POSTGRES_DATABASE", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeDatabaseName), + Name: "POSTGRES_DATABASE", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeDatabaseName), }, { - Name: "POSTGRES_PORT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePort), + Name: "POSTGRES_PORT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePort), }, { - Name: "POSTGRES_URL", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUrl), + Name: "POSTGRES_URL", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUrl), }, { - Name: "spring.datasource.url", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeJdbcUrl), + Name: "spring.datasource.url", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeJdbcUrl), }, { - Name: "spring.datasource.username", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), + Name: "spring.datasource.username", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), }, { - Name: "spring.datasource.password", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePassword), + Name: "spring.datasource.password", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePassword), }, }, nil case internal.AuthTypeUserAssignedManagedIdentity: return []scaffold.Env{ { - Name: "POSTGRES_USERNAME", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), + Name: "POSTGRES_USERNAME", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), }, { - Name: "POSTGRES_HOST", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeHost), + Name: "POSTGRES_HOST", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeHost), }, { - Name: "POSTGRES_DATABASE", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeDatabaseName), + Name: "POSTGRES_DATABASE", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeDatabaseName), }, { - Name: "POSTGRES_PORT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePort), + Name: "POSTGRES_PORT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypePort), }, { - Name: "spring.datasource.url", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeJdbcUrl), + Name: "spring.datasource.url", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeJdbcUrl), }, { - Name: "spring.datasource.username", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), + Name: "spring.datasource.username", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbPostgres, scaffold.ResourceInfoTypeUsername), }, { Name: "spring.datasource.azure.passwordless-enabled", @@ -95,67 +110,82 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypePassword: return []scaffold.Env{ { - Name: "MYSQL_USERNAME", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), + Name: "MYSQL_USERNAME", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), }, { - Name: "MYSQL_PASSWORD", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePassword), + Name: "MYSQL_PASSWORD", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePassword), }, { - Name: "MYSQL_HOST", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeHost), + Name: "MYSQL_HOST", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeHost), }, { - Name: "MYSQL_DATABASE", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeDatabaseName), + Name: "MYSQL_DATABASE", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeDatabaseName), }, { - Name: "MYSQL_PORT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePort), + Name: "MYSQL_PORT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePort), }, { - Name: "MYSQL_URL", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUrl), + Name: "MYSQL_URL", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUrl), }, { - Name: "spring.datasource.url", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeJdbcUrl), + Name: "spring.datasource.url", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeJdbcUrl), }, { - Name: "spring.datasource.username", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), + Name: "spring.datasource.username", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), }, { - Name: "spring.datasource.password", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePassword), + Name: "spring.datasource.password", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePassword), }, }, nil case internal.AuthTypeUserAssignedManagedIdentity: return []scaffold.Env{ { - Name: "MYSQL_USERNAME", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), + Name: "MYSQL_USERNAME", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), }, { - Name: "MYSQL_HOST", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeHost), + Name: "MYSQL_HOST", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeHost), }, { - Name: "MYSQL_PORT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePort), + Name: "MYSQL_PORT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypePort), }, { - Name: "MYSQL_DATABASE", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeDatabaseName), + Name: "MYSQL_DATABASE", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeDatabaseName), }, { - Name: "spring.datasource.url", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeJdbcUrl), + Name: "spring.datasource.url", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeJdbcUrl), }, { - Name: "spring.datasource.username", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), + Name: "spring.datasource.username", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMySQL, scaffold.ResourceInfoTypeUsername), }, { Name: "spring.datasource.azure.passwordless-enabled", @@ -170,28 +200,34 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypePassword: return []scaffold.Env{ { - Name: "REDIS_HOST", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeHost), + Name: "REDIS_HOST", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeHost), }, { - Name: "REDIS_PORT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypePort), + Name: "REDIS_PORT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypePort), }, { - Name: "REDIS_ENDPOINT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeEndpoint), + Name: "REDIS_ENDPOINT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeEndpoint), }, { - Name: "REDIS_URL", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeUrl), + Name: "REDIS_URL", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeUrl), }, { - Name: "REDIS_PASSWORD", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypePassword), + Name: "REDIS_PASSWORD", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypePassword), }, { - Name: "spring.data.redis.url", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeUrl), + Name: "spring.data.redis.url", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbRedis, scaffold.ResourceInfoTypeUrl), }, }, nil default: @@ -202,16 +238,19 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypeUserAssignedManagedIdentity: return []scaffold.Env{ { - Name: "MONGODB_URL", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMongo, scaffold.ResourceInfoTypeUrl), + Name: "MONGODB_URL", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMongo, scaffold.ResourceInfoTypeUrl), }, { - Name: "spring.data.mongodb.uri", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMongo, scaffold.ResourceInfoTypeUrl), + Name: "spring.data.mongodb.uri", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMongo, scaffold.ResourceInfoTypeUrl), }, { - Name: "spring.data.mongodb.database", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbMongo, scaffold.ResourceInfoTypeDatabaseName), + Name: "spring.data.mongodb.database", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbMongo, scaffold.ResourceInfoTypeDatabaseName), }, }, nil default: @@ -222,12 +261,14 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypeUserAssignedManagedIdentity: return []scaffold.Env{ { - Name: "spring.cloud.azure.cosmos.endpoint", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbCosmos, scaffold.ResourceInfoTypeEndpoint), + Name: "spring.cloud.azure.cosmos.endpoint", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbCosmos, scaffold.ResourceInfoTypeEndpoint), }, { - Name: "spring.cloud.azure.cosmos.database", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeDbCosmos, scaffold.ResourceInfoTypeDatabaseName), + Name: "spring.cloud.azure.cosmos.database", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeDbCosmos, scaffold.ResourceInfoTypeDatabaseName), }, }, nil default: @@ -255,8 +296,9 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, Value: scaffold.PlaceHolderForServiceIdentityClientId(), }, { - Name: "spring.jms.servicebus.namespace", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeNamespace), + Name: "spring.jms.servicebus.namespace", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeNamespace), }, { Name: "spring.jms.servicebus.connection-string", @@ -270,8 +312,9 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, Value: "premium", }, { - Name: "spring.jms.servicebus.connection-string", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeConnectionString), + Name: "spring.jms.servicebus.connection-string", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeConnectionString), }, { Name: "spring.jms.servicebus.passwordless-enabled", @@ -309,19 +352,22 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, Value: scaffold.PlaceHolderForServiceIdentityClientId(), }, { - Name: "spring.cloud.azure.servicebus.namespace", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeNamespace), + Name: "spring.cloud.azure.servicebus.namespace", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeNamespace), }, }, nil case internal.AuthTypeConnectionString: return []scaffold.Env{ { - Name: "spring.cloud.azure.servicebus.namespace", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeNamespace), + Name: "spring.cloud.azure.servicebus.namespace", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeNamespace), }, { - Name: "spring.cloud.azure.servicebus.connection-string", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeConnectionString), + Name: "spring.cloud.azure.servicebus.connection-string", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingServiceBus, scaffold.ResourceInfoTypeConnectionString), }, { Name: "spring.cloud.azure.servicebus.credential.managed-identity-enabled", @@ -349,8 +395,9 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, } else { springBootVersionDecidedInformation = []scaffold.Env{ { - Name: "spring.cloud.stream.binders.kafka.environment.spring.main.sources", - Value: "com.azure.spring.cloud.autoconfigure.implementation.eventhubs.kafka.AzureEventHubsKafkaAutoConfiguration", + Name: "spring.cloud.stream.binders.kafka.environment.spring.main.sources", + Value: "com.azure.spring.cloud.autoconfigure.implementation.eventhubs.kafka" + + ".AzureEventHubsKafkaAutoConfiguration", }, } } @@ -361,8 +408,9 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, // Not add this: spring.cloud.azure.eventhubs.connection-string = "" // because of this: https://github.com/Azure/azure-sdk-for-java/issues/42880 { - Name: "spring.cloud.stream.kafka.binder.brokers", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingKafka, scaffold.ResourceInfoTypeEndpoint), + Name: "spring.cloud.stream.kafka.binder.brokers", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingKafka, scaffold.ResourceInfoTypeEndpoint), }, { Name: "spring.cloud.azure.eventhubs.credential.managed-identity-enabled", @@ -376,12 +424,14 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypeConnectionString: commonInformation = []scaffold.Env{ { - Name: "spring.cloud.stream.kafka.binder.brokers", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingKafka, scaffold.ResourceInfoTypeEndpoint), + Name: "spring.cloud.stream.kafka.binder.brokers", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingKafka, scaffold.ResourceInfoTypeEndpoint), }, { - Name: "spring.cloud.azure.eventhubs.connection-string", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingKafka, scaffold.ResourceInfoTypeConnectionString), + Name: "spring.cloud.azure.eventhubs.connection-string", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingKafka, scaffold.ResourceInfoTypeConnectionString), }, { Name: "spring.cloud.azure.eventhubs.credential.managed-identity-enabled", @@ -411,19 +461,22 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, Value: scaffold.PlaceHolderForServiceIdentityClientId(), }, { - Name: "spring.cloud.azure.eventhubs.namespace", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingEventHubs, scaffold.ResourceInfoTypeNamespace), + Name: "spring.cloud.azure.eventhubs.namespace", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingEventHubs, scaffold.ResourceInfoTypeNamespace), }, }, nil case internal.AuthTypeConnectionString: return []scaffold.Env{ { - Name: "spring.cloud.azure.eventhubs.namespace", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingEventHubs, scaffold.ResourceInfoTypeNamespace), + Name: "spring.cloud.azure.eventhubs.namespace", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingEventHubs, scaffold.ResourceInfoTypeNamespace), }, { - Name: "spring.cloud.azure.eventhubs.connection-string", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeMessagingEventHubs, scaffold.ResourceInfoTypeConnectionString), + Name: "spring.cloud.azure.eventhubs.connection-string", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeMessagingEventHubs, scaffold.ResourceInfoTypeConnectionString), }, { Name: "spring.cloud.azure.eventhubs.credential.managed-identity-enabled", @@ -442,8 +495,9 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypeUserAssignedManagedIdentity: return []scaffold.Env{ { - Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.account-name", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeStorage, scaffold.ResourceInfoTypeAccountName), + Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.account-name", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeStorage, scaffold.ResourceInfoTypeAccountName), }, { Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.credential.managed-identity-enabled", @@ -461,12 +515,14 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypeConnectionString: return []scaffold.Env{ { - Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.account-name", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeStorage, scaffold.ResourceInfoTypeAccountName), + Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.account-name", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeStorage, scaffold.ResourceInfoTypeAccountName), }, { - Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.connection-string", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeStorage, scaffold.ResourceInfoTypeConnectionString), + Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.connection-string", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeStorage, scaffold.ResourceInfoTypeConnectionString), }, { Name: "spring.cloud.azure.eventhubs.processor.checkpoint-store.credential.managed-identity-enabled", @@ -485,8 +541,9 @@ func getResourceConnectionEnvs(usedResource *ResourceConfig, case internal.AuthTypeUserAssignedManagedIdentity: return []scaffold.Env{ { - Name: "AZURE_OPENAI_ENDPOINT", - Value: scaffold.ToResourceConnectionEnv(scaffold.ResourceTypeOpenAiModel, scaffold.ResourceInfoTypeEndpoint), + Name: "AZURE_OPENAI_ENDPOINT", + Value: scaffold.ToResourceConnectionEnv( + scaffold.ResourceTypeOpenAiModel, scaffold.ResourceInfoTypeEndpoint), }, }, nil default: