diff --git a/internal/provider/resources/deployment.go b/internal/provider/resources/deployment.go index 207db7b..95d1e75 100644 --- a/internal/provider/resources/deployment.go +++ b/internal/provider/resources/deployment.go @@ -308,21 +308,27 @@ func (r *DeploymentResource) Create(ctx context.Context, req resource.CreateRequ } var parameters map[string]interface{} - resp.Diagnostics.Append(plan.Parameters.Unmarshal(¶meters)...) - if resp.Diagnostics.HasError() { - return + if !plan.Parameters.IsNull() { + resp.Diagnostics.Append(plan.Parameters.Unmarshal(¶meters)...) + if resp.Diagnostics.HasError() { + return + } } var jobVariables map[string]interface{} - resp.Diagnostics.Append(plan.JobVariables.Unmarshal(&jobVariables)...) - if resp.Diagnostics.HasError() { - return + if !plan.JobVariables.IsNull() { + resp.Diagnostics.Append(plan.JobVariables.Unmarshal(&jobVariables)...) + if resp.Diagnostics.HasError() { + return + } } var parameterOpenAPISchema map[string]interface{} - resp.Diagnostics.Append(plan.ParameterOpenAPISchema.Unmarshal(¶meterOpenAPISchema)...) - if resp.Diagnostics.HasError() { - return + if !plan.ParameterOpenAPISchema.IsNull() { + resp.Diagnostics.Append(plan.ParameterOpenAPISchema.Unmarshal(¶meterOpenAPISchema)...) + if resp.Diagnostics.HasError() { + return + } } deployment, err := client.Create(ctx, api.DeploymentCreate{ @@ -473,15 +479,19 @@ func (r *DeploymentResource) Update(ctx context.Context, req resource.UpdateRequ } var parameters map[string]interface{} - resp.Diagnostics.Append(model.Parameters.Unmarshal(¶meters)...) - if resp.Diagnostics.HasError() { - return + if !model.Parameters.IsNull() { + resp.Diagnostics.Append(model.Parameters.Unmarshal(¶meters)...) + if resp.Diagnostics.HasError() { + return + } } var jobVariables map[string]interface{} - resp.Diagnostics.Append(model.JobVariables.Unmarshal(&jobVariables)...) - if resp.Diagnostics.HasError() { - return + if !model.JobVariables.IsNull() { + resp.Diagnostics.Append(model.JobVariables.Unmarshal(&jobVariables)...) + if resp.Diagnostics.HasError() { + return + } } payload := api.DeploymentUpdate{ diff --git a/internal/provider/resources/work_pool.go b/internal/provider/resources/work_pool.go index 190b80d..a0d92cc 100644 --- a/internal/provider/resources/work_pool.go +++ b/internal/provider/resources/work_pool.go @@ -199,9 +199,11 @@ func (r *WorkPoolResource) Create(ctx context.Context, req resource.CreateReques } baseJobTemplate := map[string]interface{}{} - resp.Diagnostics.Append(plan.BaseJobTemplate.Unmarshal(&baseJobTemplate)...) - if resp.Diagnostics.HasError() { - return + if !plan.BaseJobTemplate.IsNull() { + resp.Diagnostics.Append(plan.BaseJobTemplate.Unmarshal(&baseJobTemplate)...) + if resp.Diagnostics.HasError() { + return + } } client, err := r.client.WorkPools(plan.AccountID.ValueUUID(), plan.WorkspaceID.ValueUUID()) @@ -278,9 +280,11 @@ func (r *WorkPoolResource) Update(ctx context.Context, req resource.UpdateReques } baseJobTemplate := map[string]interface{}{} - resp.Diagnostics.Append(plan.BaseJobTemplate.Unmarshal(&baseJobTemplate)...) - if resp.Diagnostics.HasError() { - return + if !plan.BaseJobTemplate.IsNull() { + resp.Diagnostics.Append(plan.BaseJobTemplate.Unmarshal(&baseJobTemplate)...) + if resp.Diagnostics.HasError() { + return + } } client, err := r.client.WorkPools(plan.AccountID.ValueUUID(), plan.WorkspaceID.ValueUUID())