|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 | "log" |
7 | | - "slices" |
8 | 7 | "strings" |
9 | 8 | "time" |
10 | 9 |
|
@@ -440,105 +439,6 @@ func setPinnedStatus(ctx context.Context, d *schema.ResourceData, clusterAPI com |
440 | 439 | return d.Set("is_pinned", pinnedEvent == compute.EventTypePinned) |
441 | 440 | } |
442 | 441 |
|
443 | | -func RemoveUnnecessaryFieldsFromForceSendFields(cluster any) error { |
444 | | - switch clusterSpec := cluster.(type) { |
445 | | - case *compute.ClusterSpec: |
446 | | - if clusterSpec.AwsAttributes != nil { |
447 | | - newAwsAttributesForceSendFields := []string{} |
448 | | - // These fields should never be 0. |
449 | | - unnecessaryFieldNamesForAwsAttributes := []string{ |
450 | | - "SpotBidPricePercent", |
451 | | - "EbsVolumeCount", |
452 | | - "EbsVolumeIops", |
453 | | - "EbsVolumeSize", |
454 | | - "EbsVolumeThroughput", |
455 | | - } |
456 | | - for _, field := range clusterSpec.AwsAttributes.ForceSendFields { |
457 | | - if !slices.Contains(unnecessaryFieldNamesForAwsAttributes, field) { |
458 | | - newAwsAttributesForceSendFields = append(newAwsAttributesForceSendFields, field) |
459 | | - } |
460 | | - } |
461 | | - clusterSpec.AwsAttributes.ForceSendFields = newAwsAttributesForceSendFields |
462 | | - } |
463 | | - if clusterSpec.GcpAttributes != nil { |
464 | | - newGcpAttributesForceSendFields := []string{} |
465 | | - // Should never be 0. |
466 | | - unnecessaryFieldNamesForGcpAttributes := []string{ |
467 | | - "BootDiskSize", |
468 | | - } |
469 | | - for _, field := range clusterSpec.GcpAttributes.ForceSendFields { |
470 | | - if !slices.Contains(unnecessaryFieldNamesForGcpAttributes, field) { |
471 | | - newGcpAttributesForceSendFields = append(newGcpAttributesForceSendFields, field) |
472 | | - } |
473 | | - } |
474 | | - clusterSpec.GcpAttributes.ForceSendFields = newGcpAttributesForceSendFields |
475 | | - } |
476 | | - if clusterSpec.AzureAttributes != nil { |
477 | | - newAzureAttributesForceSendFields := []string{} |
478 | | - // Should never be 0. |
479 | | - unnecessaryFieldNamesForAzureAttributes := []string{ |
480 | | - "FirstOnDemand", |
481 | | - "SpotBidMaxPrice", |
482 | | - } |
483 | | - for _, field := range clusterSpec.AzureAttributes.ForceSendFields { |
484 | | - if !slices.Contains(unnecessaryFieldNamesForAzureAttributes, field) { |
485 | | - newAzureAttributesForceSendFields = append(newAzureAttributesForceSendFields, field) |
486 | | - } |
487 | | - } |
488 | | - clusterSpec.AzureAttributes.ForceSendFields = newAzureAttributesForceSendFields |
489 | | - } |
490 | | - return nil |
491 | | - case *compute.EditCluster: |
492 | | - if clusterSpec.AwsAttributes != nil { |
493 | | - newAwsAttributesForceSendFields := []string{} |
494 | | - // These fields should never be 0. |
495 | | - unnecessaryFieldNamesForAwsAttributes := []string{ |
496 | | - "SpotBidPricePercent", |
497 | | - "EbsVolumeCount", |
498 | | - "EbsVolumeIops", |
499 | | - "EbsVolumeSize", |
500 | | - "EbsVolumeThroughput", |
501 | | - } |
502 | | - for _, field := range clusterSpec.AwsAttributes.ForceSendFields { |
503 | | - if !slices.Contains(unnecessaryFieldNamesForAwsAttributes, field) { |
504 | | - newAwsAttributesForceSendFields = append(newAwsAttributesForceSendFields, field) |
505 | | - } |
506 | | - } |
507 | | - clusterSpec.AwsAttributes.ForceSendFields = newAwsAttributesForceSendFields |
508 | | - } |
509 | | - if clusterSpec.GcpAttributes != nil { |
510 | | - newGcpAttributesForceSendFields := []string{} |
511 | | - // Should never be 0. |
512 | | - unnecessaryFieldNamesForGcpAttributes := []string{ |
513 | | - "BootDiskSize", |
514 | | - } |
515 | | - for _, field := range clusterSpec.GcpAttributes.ForceSendFields { |
516 | | - if !slices.Contains(unnecessaryFieldNamesForGcpAttributes, field) { |
517 | | - newGcpAttributesForceSendFields = append(newGcpAttributesForceSendFields, field) |
518 | | - } |
519 | | - } |
520 | | - clusterSpec.GcpAttributes.ForceSendFields = newGcpAttributesForceSendFields |
521 | | - } |
522 | | - if clusterSpec.AzureAttributes != nil { |
523 | | - newAzureAttributesForceSendFields := []string{} |
524 | | - // Should never be 0. |
525 | | - unnecessaryFieldNamesForAzureAttributes := []string{ |
526 | | - "FirstOnDemand", |
527 | | - "SpotBidMaxPrice", |
528 | | - } |
529 | | - for _, field := range clusterSpec.AzureAttributes.ForceSendFields { |
530 | | - if !slices.Contains(unnecessaryFieldNamesForAzureAttributes, field) { |
531 | | - newAzureAttributesForceSendFields = append(newAzureAttributesForceSendFields, field) |
532 | | - } |
533 | | - } |
534 | | - clusterSpec.AzureAttributes.ForceSendFields = newAzureAttributesForceSendFields |
535 | | - } |
536 | | - return nil |
537 | | - default: |
538 | | - return fmt.Errorf(unsupportedExceptCreateEditClusterSpecErr, cluster, "*", "*", "*") |
539 | | - } |
540 | | -} |
541 | | - |
542 | 442 | func resourceClusterRead(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error { |
543 | 443 | w, err := c.WorkspaceClient() |
544 | 444 | if err != nil { |
@@ -674,7 +574,6 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, c *commo |
674 | 574 | Autoscale: cluster.Autoscale, |
675 | 575 | }) |
676 | 576 | } else { |
677 | | - err = RemoveUnnecessaryFieldsFromForceSendFields(&cluster) |
678 | 577 | if err != nil { |
679 | 578 | return err |
680 | 579 | } |
|
0 commit comments