Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Nov 20, 2023
1 parent ecda019 commit d346a8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func resourceSpringCloudContainerDeployment() *pluginsdk.Resource {
DiffSuppressFunc: pluginsdk.SuppressJsonDiff,
},

"application_performance_monitoring_resource_ids": {
"application_performance_monitoring_ids": {
Type: pluginsdk.TypeList,
Optional: true,
MinItems: 1,
Expand Down Expand Up @@ -219,7 +219,7 @@ func resourceSpringCloudContainerDeploymentCreateUpdate(d *pluginsdk.ResourceDat
},
DeploymentSettings: &appplatform.DeploymentSettings{
AddonConfigs: addonConfig,
Apms: expandSpringCloudDeploymentApms(d.Get("application_performance_monitoring_resource_ids").([]interface{})),
Apms: expandSpringCloudDeploymentApms(d.Get("application_performance_monitoring_ids").([]interface{})),
EnvironmentVariables: expandSpringCloudDeploymentEnvironmentVariables(d.Get("environment_variables").(map[string]interface{})),
ResourceRequests: expandSpringCloudContainerDeploymentResourceRequests(d.Get("quota").([]interface{})),
},
Expand Down Expand Up @@ -274,9 +274,11 @@ func resourceSpringCloudContainerDeploymentRead(d *pluginsdk.ResourceData, meta
if err := d.Set("addon_json", flattenSpringCloudAppAddon(settings.AddonConfigs)); err != nil {
return fmt.Errorf("setting `addon_json`: %s", err)
}
if err := d.Set("application_performance_monitoring_resource_ids", flattenSpringCloudDeploymentApms(settings.Apms)); err != nil {
return fmt.Errorf("setting `application_performance_monitoring_resource_ids`: %+v", err)
apmIds, err := flattenSpringCloudDeploymentApms(settings.Apms)
if err != nil {
return fmt.Errorf("setting `application_performance_monitoring_ids`: %+v", err)
}
d.Set("application_performance_monitoring_ids", apmIds)
}
if source, ok := resp.Properties.Source.AsCustomContainerUserSourceInfo(); ok && source != nil {
if container := source.CustomContainer; container != nil {
Expand Down Expand Up @@ -350,18 +352,17 @@ func expandSpringCloudDeploymentApms(input []interface{}) *[]appplatform.ApmRefe
return pointer.To(result)
}

func flattenSpringCloudDeploymentApms(input *[]appplatform.ApmReference) []interface{} {
func flattenSpringCloudDeploymentApms(input *[]appplatform.ApmReference) ([]interface{}, error) {
if input == nil {
return nil
return nil, nil
}
result := make([]interface{}, 0)
for _, v := range *input {
id, err := appplatform2.ParseApmIDInsensitively(*v.ResourceID)
if err != nil {
log.Printf("[WARN] invalid APM ID %q: %+v", *v.ResourceID, err)
continue
return nil, err
}
result = append(result, id.ID())
}
return result
return result, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ func (r SpringCloudContainerDeploymentResource) complete(data acceptance.TestDat
%[1]s
resource "azurerm_spring_cloud_container_deployment" "test" {
name = "acctest-scjd%[2]s"
spring_cloud_app_id = azurerm_spring_cloud_app.test.id
instance_count = 2
arguments = ["-cp", "/app/resources:/app/classes:/app/libs/*", "hello.Application"]
application_performance_monitoring_resource_ids = [azurerm_spring_cloud_application_insights_application_performance_monitoring.test.id]
commands = ["java"]
name = "acctest-scjd%[2]s"
spring_cloud_app_id = azurerm_spring_cloud_app.test.id
instance_count = 2
arguments = ["-cp", "/app/resources:/app/classes:/app/libs/*", "hello.Application"]
application_performance_monitoring_ids = [azurerm_spring_cloud_application_insights_application_performance_monitoring.test.id]
commands = ["java"]
environment_variables = {
"Foo" : "Bar"
"Env" : "Staging"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The following arguments are supported:

* `addon_json` - (Optional) A JSON object that contains the addon configurations of the Spring Cloud Container Deployment.

* `application_performance_monitoring_resource_ids` - (Optional) Specifies a list of Spring Cloud Application Performance Monitoring IDs.
* `application_performance_monitoring_ids` - (Optional) Specifies a list of Spring Cloud Application Performance Monitoring IDs.

* `arguments` - (Optional) Specifies the arguments to the entrypoint. The docker image's `CMD` is used if not specified.

Expand Down

0 comments on commit d346a8b

Please sign in to comment.