Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bug Fixes

* Fix `databricks_pipeline` so that `photon`, `serverless`, `continuous` and `development` set to `false` are sent in the create/update request if specified ([#5806](https://github.com/databricks/terraform-provider-databricks/pull/5806)).

### Documentation

### Exporter
Expand Down
8 changes: 8 additions & 0 deletions pipelines/resource_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import (
// DefaultTimeout is the default amount of time that Terraform will wait when creating, updating and deleting pipelines.
const DefaultTimeout = 20 * time.Minute

// booleanForceSendFields are optional boolean fields whose zero value (false)
// is meaningful and must be sent to the platform. Without ForceSendFields the
// Go SDK omits them, so an explicit `photon = false` (etc.) would be dropped
// and the platform would apply its own default instead.
var booleanForceSendFields = []string{"photon", "serverless", "continuous", "development"}

func adjustForceSendFields(clusterList *[]pipelines.PipelineCluster) {
for i := range *clusterList {
cluster := &((*clusterList)[i])
Expand All @@ -39,6 +45,7 @@ func Create(w *databricks.WorkspaceClient, ctx context.Context, d *schema.Resour
var createPipelineRequest createPipelineRequestStruct
common.DataToStructPointer(d, pipelineSchema, &createPipelineRequest)
adjustForceSendFields(&createPipelineRequest.Clusters)
common.SetForceSendFields(&createPipelineRequest.CreatePipeline, d, booleanForceSendFields)

createdPipeline, err := w.Pipelines.Create(ctx, createPipelineRequest.CreatePipeline)
if err != nil {
Expand Down Expand Up @@ -71,6 +78,7 @@ func Update(w *databricks.WorkspaceClient, ctx context.Context, d *schema.Resour
common.DataToStructPointer(d, pipelineSchema, &updatePipelineRequest)
updatePipelineRequest.EditPipeline.PipelineId = d.Id()
adjustForceSendFields(&updatePipelineRequest.Clusters)
common.SetForceSendFields(&updatePipelineRequest.EditPipeline, d, booleanForceSendFields)
err := w.Pipelines.Update(ctx, updatePipelineRequest.EditPipeline)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pipelines/resource_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var createRequest = pipelines.CreatePipeline{
},
Edition: "ADVANCED",
Channel: "CURRENT",
// TestResourcePipelineCreate sets continuous = false in its HCL, so it is force-sent.
ForceSendFields: []string{"Continuous"},
}

var updateRequest = pipelines.EditPipeline{
Expand Down
Loading