Skip to content

Commit 478f7e5

Browse files
committed
handle when description is empty
1 parent fe8e0fa commit 478f7e5

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

internal/provider/devhub_workflow_resource.go

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,17 @@ func (r *workflowResource) Create(ctx context.Context, req resource.CreateReques
283283
}
284284

285285
var inputs []devhub.WorkflowInput
286-
for _, input := range plan.Inputs {
287-
inputs = append(inputs, devhub.WorkflowInput{
288-
Key: input.Key.ValueString(),
289-
Description: input.Description.ValueString(),
290-
Type: input.Type.ValueString(),
291-
})
286+
for _, planInput := range plan.Inputs {
287+
input := devhub.WorkflowInput{
288+
Key: planInput.Key.ValueString(),
289+
Type: planInput.Type.ValueString(),
290+
}
291+
292+
if planInput.Description.ValueString() != "" {
293+
input.Description = planInput.Description.ValueString()
294+
}
295+
296+
inputs = append(inputs, input)
292297
}
293298

294299
var steps []devhub.WorkflowStep
@@ -416,12 +421,17 @@ func (r *workflowResource) Read(ctx context.Context, req resource.ReadRequest, r
416421
}
417422

418423
var stateInputs []workflowInputModel
419-
for _, input := range workflow.Inputs {
420-
stateInputs = append(stateInputs, workflowInputModel{
421-
Key: types.StringValue(input.Key),
422-
Description: types.StringValue(input.Description),
423-
Type: types.StringValue(input.Type),
424-
})
424+
for _, stateInput := range workflow.Inputs {
425+
input := workflowInputModel{
426+
Key: types.StringValue(stateInput.Key),
427+
Type: types.StringValue(stateInput.Type),
428+
}
429+
430+
if stateInput.Description != "" {
431+
input.Description = types.StringValue(stateInput.Description)
432+
}
433+
434+
stateInputs = append(stateInputs, input)
425435
}
426436

427437
state.Inputs = stateInputs
@@ -498,12 +508,17 @@ func (r *workflowResource) Update(ctx context.Context, req resource.UpdateReques
498508
}
499509

500510
var inputs []devhub.WorkflowInput
501-
for _, input := range plan.Inputs {
502-
inputs = append(inputs, devhub.WorkflowInput{
503-
Key: input.Key.ValueString(),
504-
Description: input.Description.ValueString(),
505-
Type: input.Type.ValueString(),
506-
})
511+
for _, planInput := range plan.Inputs {
512+
input := devhub.WorkflowInput{
513+
Key: planInput.Key.ValueString(),
514+
Type: planInput.Type.ValueString(),
515+
}
516+
517+
if planInput.Description.ValueString() != "" {
518+
input.Description = planInput.Description.ValueString()
519+
}
520+
521+
inputs = append(inputs, input)
507522
}
508523

509524
var steps []devhub.WorkflowStep

internal/provider/devhub_workflow_resource_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ func TestAccWorkflowResource(t *testing.T) {
1919
Check: resource.ComposeAggregateTestCheckFunc(
2020
resource.TestCheckResourceAttr("devhub_workflow.test", "name", name),
2121
resource.TestCheckResourceAttr("devhub_workflow.test", "inputs.0.key", "user_id"),
22-
resource.TestCheckResourceAttr("devhub_workflow.test", "inputs.0.description", "User ID"),
2322
resource.TestCheckResourceAttr("devhub_workflow.test", "inputs.0.type", "string"),
2423
resource.TestCheckResourceAttr("devhub_workflow.test", "steps.0.name", "approval-step"),
2524
resource.TestCheckResourceAttr("devhub_workflow.test", "steps.0.approval_action.reviews_required", "1"),
@@ -61,7 +60,6 @@ func TestAccWorkflowResource(t *testing.T) {
6160
Check: resource.ComposeAggregateTestCheckFunc(
6261
resource.TestCheckResourceAttr("devhub_workflow.test", "name", name+"_updated"),
6362
resource.TestCheckResourceAttr("devhub_workflow.test", "inputs.0.key", "user_id"),
64-
resource.TestCheckResourceAttr("devhub_workflow.test", "inputs.0.description", "User ID"),
6563
resource.TestCheckResourceAttr("devhub_workflow.test", "inputs.0.type", "string"),
6664
resource.TestCheckResourceAttr("devhub_workflow.test", "steps.0.name", "approval-step"),
6765
resource.TestCheckResourceAttr("devhub_workflow.test", "steps.0.approval_action.reviews_required", "1"),
@@ -103,7 +101,6 @@ resource "devhub_workflow" "test" {
103101
inputs = [
104102
{
105103
key = "user_id"
106-
description = "User ID"
107104
type = "string"
108105
}
109106
]

0 commit comments

Comments
 (0)