Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kusto_cluster_resource - allowed_fqdns and allowed_ip_ranges properties can be empty list when update #27529

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -342,11 +342,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 @@ -463,17 +463,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 @@ -692,18 +686,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
Loading