Skip to content

Commit

Permalink
Update kusto_cluster_resource.go (#27529)
Browse files Browse the repository at this point in the history
  • Loading branch information
hqhqhqhqhqhqhqhqhqhqhq authored Nov 21, 2024
1 parent 778c935 commit 0b71a09
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions internal/services/kusto/kusto_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ func resourceKustoClusterCreate(d *pluginsdk.ResourceData, meta interface{}) err
}

if v, ok := d.GetOk("allowed_fqdns"); ok {
clusterProperties.AllowedFqdnList, _ = expandKustoListString(v.([]interface{}))
clusterProperties.AllowedFqdnList = expandKustoListString(v.([]interface{}))
}

if v, ok := d.GetOk("allowed_ip_ranges"); ok {
clusterProperties.AllowedIPRangeList, _ = expandKustoListString(v.([]interface{}))
clusterProperties.AllowedIPRangeList = expandKustoListString(v.([]interface{}))
}

restrictOutboundNetworkAccess := clusters.ClusterNetworkAccessFlagDisabled
Expand Down Expand Up @@ -441,17 +441,11 @@ func resourceKustoClusterUpdate(d *pluginsdk.ResourceData, meta interface{}) err
}

if d.HasChange("allowed_fqdns") {
props.AllowedFqdnList, err = expandKustoListString(d.Get("allowed_fqdns").([]interface{}))
if err != nil {
return err
}
props.AllowedFqdnList = expandKustoListString(d.Get("allowed_fqdns").([]interface{}))
}

if d.HasChange("allowed_ip_ranges") {
props.AllowedIPRangeList, err = expandKustoListString(d.Get("allowed_ip_ranges").([]interface{}))
if err != nil {
return err
}
props.AllowedIPRangeList = expandKustoListString(d.Get("allowed_ip_ranges").([]interface{}))
}

if d.HasChange("auto_stop_enabled") {
Expand Down Expand Up @@ -661,18 +655,14 @@ func flattenOptimizedAutoScale(optimizedAutoScale *clusters.OptimizedAutoscale)
}
}

func expandKustoListString(input []interface{}) (*[]string, error) {
if len(input) == 0 {
return nil, fmt.Errorf("list of string is empty")
}

func expandKustoListString(input []interface{}) *[]string {
result := make([]string, 0)

for _, v := range input {
result = append(result, v.(string))
}

return &result, nil
return &result
}

func expandKustoClusterSku(input []interface{}) (*clusters.AzureSku, error) {
Expand Down

0 comments on commit 0b71a09

Please sign in to comment.