diff --git a/awx/resource_project.go b/awx/resource_project.go index a07e0bce..2f55df95 100644 --- a/awx/resource_project.go +++ b/awx/resource_project.go @@ -177,20 +177,38 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf if d.Get("scm_credential_id").(int) > 0 { credentials = strconv.Itoa(d.Get("scm_credential_id").(int)) } - _, err := awxService.UpdateProject(id, map[string]interface{}{ - "name": d.Get("name").(string), - "description": d.Get("description").(string), - "local_path": d.Get("local_path").(string), - "scm_type": d.Get("scm_type").(string), - "scm_url": d.Get("scm_url").(string), - "scm_branch": d.Get("scm_branch").(string), - "scm_clean": d.Get("scm_clean").(bool), - "scm_delete_on_update": d.Get("scm_delete_on_update").(bool), - "credential": credentials, - "organization": d.Get("organization_id").(int), - "scm_update_on_launch": d.Get("scm_update_on_launch").(bool), - "scm_update_cache_timeout": d.Get("scm_update_cache_timeout").(int), - }, map[string]string{}) + params := make(map[string]interface{}) + if d.Get("scm_type").(string) == "" { + params = map[string]interface{}{ + "name": d.Get("name").(string), + "description": d.Get("description").(string), + "local_path": d.Get("local_path").(string), + "scm_type": d.Get("scm_type").(string), + "scm_url": d.Get("scm_url").(string), + "scm_branch": d.Get("scm_branch").(string), + "scm_clean": d.Get("scm_clean").(bool), + "scm_delete_on_update": d.Get("scm_delete_on_update").(bool), + "credential": credentials, + "organization": d.Get("organization_id").(int), + "scm_update_on_launch": d.Get("scm_update_on_launch").(bool), + "scm_update_cache_timeout": d.Get("scm_update_cache_timeout").(int), + } + } else { + params = map[string]interface{}{ + "name": d.Get("name").(string), + "description": d.Get("description").(string), + "scm_type": d.Get("scm_type").(string), + "scm_url": d.Get("scm_url").(string), + "scm_branch": d.Get("scm_branch").(string), + "scm_clean": d.Get("scm_clean").(bool), + "scm_delete_on_update": d.Get("scm_delete_on_update").(bool), + "credential": credentials, + "organization": d.Get("organization_id").(int), + "scm_update_on_launch": d.Get("scm_update_on_launch").(bool), + "scm_update_cache_timeout": d.Get("scm_update_cache_timeout").(int), + } + } + _, err := awxService.UpdateProject(id, params, map[string]string{}) if err != nil { return buildDiagnosticsMessage("Update: Fail To Update Project", "Fail to get Project with ID %v, got %s", id, err.Error()) }