Skip to content

Commit

Permalink
Merge pull request #2936 from clearbank/service_fabric_placement
Browse files Browse the repository at this point in the history
add service fabric cluster placement properties and capacities
  • Loading branch information
tombuildsstuff authored Feb 22, 2019
2 parents c76a793 + c646fce commit 570539d
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 87 deletions.
44 changes: 39 additions & 5 deletions azurerm/resource_arm_service_fabric_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import (
"fmt"
"log"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"

"github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down Expand Up @@ -232,6 +231,14 @@ func resourceArmServiceFabricCluster() *schema.Resource {
Required: true,
ForceNew: true,
},
"placement_properties": {
Type: schema.TypeMap,
Optional: true,
},
"capacities": {
Type: schema.TypeMap,
Optional: true,
},
"instance_count": {
Type: schema.TypeInt,
Required: true,
Expand Down Expand Up @@ -918,6 +925,25 @@ func expandServiceFabricClusterNodeTypes(input []interface{}) *[]servicefabric.N
HTTPGatewayEndpointPort: utils.Int32(int32(httpEndpointPort)),
DurabilityLevel: servicefabric.DurabilityLevel(durabilityLevel),
}

if props, ok := node["placement_properties"]; ok {
placementProperties := make(map[string]*string)
for key, value := range props.(map[string]interface{}) {
placementProperties[key] = utils.String(value.(string))
}

result.PlacementProperties = placementProperties
}

if caps, ok := node["capacities"]; ok {
capacities := make(map[string]*string)
for key, value := range caps.(map[string]interface{}) {
capacities[key] = utils.String(value.(string))
}

result.Capacities = capacities
}

if v := int32(node["reverse_proxy_endpoint_port"].(int)); v != 0 {
result.ReverseProxyEndpointPort = utils.Int32(v)
}
Expand Down Expand Up @@ -968,6 +994,14 @@ func flattenServiceFabricClusterNodeTypes(input *[]servicefabric.NodeTypeDescrip
output["name"] = *name
}

if placementProperties := v.PlacementProperties; placementProperties != nil {
output["placement_properties"] = placementProperties
}

if capacities := v.Capacities; capacities != nil {
output["capacities"] = capacities
}

if count := v.VMInstanceCount; count != nil {
output["instance_count"] = int(*count)
}
Expand Down Expand Up @@ -1003,7 +1037,7 @@ func flattenServiceFabricClusterNodeTypes(input *[]servicefabric.NodeTypeDescrip
}
output["application_ports"] = applicationPorts

ephermeralPorts := make([]interface{}, 0)
ephemeralPorts := make([]interface{}, 0)
if ports := v.EphemeralPorts; ports != nil {
r := make(map[string]interface{})
if start := ports.StartPort; start != nil {
Expand All @@ -1012,9 +1046,9 @@ func flattenServiceFabricClusterNodeTypes(input *[]servicefabric.NodeTypeDescrip
if end := ports.EndPort; end != nil {
r["end_port"] = int(*end)
}
ephermeralPorts = append(ephermeralPorts, r)
ephemeralPorts = append(ephemeralPorts, r)
}
output["ephemeral_ports"] = ephermeralPorts
output["ephemeral_ports"] = ephemeralPorts

results = append(results, output)
}
Expand Down
Loading

0 comments on commit 570539d

Please sign in to comment.