Skip to content

Commit

Permalink
Better recognition of workflow states when importing team
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Nov 22, 2022
1 parent 230a640 commit 3cff85f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.1.0 (Unreleased)
## 0.2.1

FEATURES:
### Enhancements
* Improve recognition of existing workflows when importing a team

## 0.2.0 (First release)
9 changes: 8 additions & 1 deletion internal/provider/resource_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ func (r *TeamResource) Read(ctx context.Context, req resource.ReadRequest, resp
canceledWorkflowState := findWorkflowStateType(workflowStatesResponse.WorkflowStates.Nodes, "canceled", 4)

if backlogWorkflowState == nil || unstartedWorkflowState == nil || startedWorkflowState == nil || completedWorkflowState == nil || canceledWorkflowState == nil {
resp.Diagnostics.AddError("Client Error", "Unable to find all workflow states in a new team")
resp.Diagnostics.AddError("Client Error", "Unable to find all workflow states when reading team")
return
}

Expand Down Expand Up @@ -1195,6 +1195,13 @@ func findWorkflowStateType(workflowStates []getTeamWorkflowStatesWorkflowStatesW
}
}

// If unable to find the exact workflow with the exact position, return the first one with the correct type
for _, workflowState := range workflowStates {
if workflowState.Type == ty {
return &workflowState
}
}

return nil
}

Expand Down

0 comments on commit 3cff85f

Please sign in to comment.