Skip to content

Commit

Permalink
support for azs
Browse files Browse the repository at this point in the history
  • Loading branch information
saamalik committed Jan 18, 2021
1 parent b475aa4 commit 0f2dcfe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/e2e/azure/resource_cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ resource "spectrocloud_cluster_azure" "cluster" {
name = "master-pool"
count = 1
instance_type = "Standard_D2_v3"
azs = []
disk {
size_gb = 65
type = "Standard_LRS"
Expand All @@ -47,6 +48,7 @@ resource "spectrocloud_cluster_azure" "cluster" {
name = "worker-basic"
count = 1
instance_type = "Standard_D2_v3"
azs = []
}

}
2 changes: 2 additions & 0 deletions examples/resources/spectrocloud_cluster_azure/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "spectrocloud_cluster_azure" "cluster" {
name = "master-pool"
count = 1
instance_type = "Standard_D2_v3"
azs = []
disk {
size_gb = 65
type = "Standard_LRS"
Expand All @@ -56,6 +57,7 @@ resource "spectrocloud_cluster_azure" "cluster" {
name = "worker-basic"
count = 1
instance_type = "Standard_D2_v3"
azs = []
}

}
1 change: 1 addition & 0 deletions spectrocloud/cluster_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func resourceMachinePoolAzureHash(v interface{}) int {
buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
buf.WriteString(fmt.Sprintf("%d-", m["count"].(int)))
buf.WriteString(fmt.Sprintf("%s-", m["instance_type"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["azs"].(*schema.Set).GoString()))

// TODO(saamalik) fix for disk
//buf.WriteString(fmt.Sprintf("%d-", d["size_gb"].(int)))
Expand Down
17 changes: 16 additions & 1 deletion spectrocloud/resource_cluster_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ func resourceClusterAzure() *schema.Resource {
},
},
},
"azs": {
Type: schema.TypeSet,
Required: true,
Set: schema.HashString,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
Expand Down Expand Up @@ -274,6 +282,8 @@ func flattenMachinePoolConfigsAzure(machinePools []*models.V1alpha1AzureMachineP
oi["update_strategy"] = machinePool.UpdateStrategy.Type
oi["instance_type"] = machinePool.InstanceType

oi["azs"] = machinePool.Azs

if machinePool.OsDisk != nil {
d := make(map[string]interface{})
d["size_gb"] = machinePool.OsDisk.DiskSizeGB
Expand Down Expand Up @@ -425,9 +435,14 @@ func toMachinePoolAzure(machinePool interface{}) *models.V1alpha1AzureMachinePoo
diskType = disk0["type"].(string)
}

azs := make([]string, 0)
for _, az := range m["azs"].(*schema.Set).List() {
azs = append(azs, az.(string))
}

mp := &models.V1alpha1AzureMachinePoolConfigEntity{
CloudConfig: &models.V1alpha1AzureMachinePoolCloudConfigEntity{
//Azs: nil,
Azs: azs,
InstanceType: m["instance_type"].(string),
OsDisk: &models.V1alpha1AzureOSDisk{
DiskSizeGB: int32(diskSize),
Expand Down

0 comments on commit 0f2dcfe

Please sign in to comment.