Skip to content

Commit

Permalink
SCALRCORE-18527 > Fix bug with null vcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Vang committed Apr 12, 2021
1 parent d649d4f commit e8a03a9
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions scalr/resource_scalr_workspace.go
Expand Up @@ -233,26 +233,15 @@ func resourceScalrWorkspaceRead(d *schema.ResourceData, meta interface{}) error

var vcsRepo []interface{}
if workspace.VCSRepo != nil {
vcsConfig := map[string]interface{}{
vcsRepo = append(vcsRepo, map[string]interface{}{
"branch": workspace.VCSRepo.Branch,
"identifier": workspace.VCSRepo.Identifier,
"path": workspace.VCSRepo.Path,
"trigger-prefixes": workspace.VCSRepo.TriggerPrefixes,
}

// Get and assert the VCS repo configuration block.
if v, ok := d.GetOk("vcs_repo"); ok {
if vcsRepo, ok := v.([]interface{})[0].(map[string]interface{}); ok {
// Only set the branch if one is configured.
if branch, ok := vcsRepo["branch"].(string); ok && branch != "" {
vcsConfig["branch"] = workspace.VCSRepo.Branch
}
}
}

vcsRepo = append(vcsRepo, vcsConfig)
"trigger_prefixes": workspace.VCSRepo.TriggerPrefixes,
})
}

d.Set("vcs_repo", vcsRepo)

return nil
}

Expand Down

0 comments on commit e8a03a9

Please sign in to comment.