Skip to content

Commit b4ab7dc

Browse files
fix: do not provide local_path for project if the scm_type is git (#13)
1 parent c8fe96c commit b4ab7dc

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

awx/resource_project.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf
177177
if d.Get("scm_credential_id").(int) > 0 {
178178
credentials = strconv.Itoa(d.Get("scm_credential_id").(int))
179179
}
180-
_, err := awxService.UpdateProject(id, map[string]interface{}{
180+
181+
data := map[string]interface{}{
181182
"name": d.Get("name").(string),
182183
"description": d.Get("description").(string),
183-
"local_path": d.Get("local_path").(string),
184184
"scm_type": d.Get("scm_type").(string),
185185
"scm_url": d.Get("scm_url").(string),
186186
"scm_branch": d.Get("scm_branch").(string),
@@ -190,7 +190,14 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf
190190
"organization": d.Get("organization_id").(int),
191191
"scm_update_on_launch": d.Get("scm_update_on_launch").(bool),
192192
"scm_update_cache_timeout": d.Get("scm_update_cache_timeout").(int),
193-
}, map[string]string{})
193+
}
194+
195+
// Cannot change local_path for git-based projects
196+
if d.Get("local_path").(string) != "" && d.Get("scm_type").(string) != "git" {
197+
data["local_path"] = d.Get("local_path").(string)
198+
}
199+
200+
_, err := awxService.UpdateProject(id, data, map[string]string{})
194201
if err != nil {
195202
return buildDiagnosticsMessage("Update: Fail To Update Project", "Fail to get Project with ID %v, got %s", id, err.Error())
196203
}

0 commit comments

Comments
 (0)