Skip to content

Commit 24d43d8

Browse files
committed
Debug to detect when default_branch is set in .tf file
WIP for fixing #299 where Terraform tries to reset the `default_branch` to null after a repository is added on GitLab side. The `default_branch` defaults to `master` on GitLab side, but it is only set if the repository is not empty. Otherwise it is `null` on remote side. The commit generates the following output, which shows no trace of `null` value from remote. 2020/06/19 20:55:55 [DEBUG] gitlab.Project default_branch (string) "" 2020/06/19 20:55:55 [DEBUG] d.Get default_branch (string) "" 2020/06/19 20:55:55 [DEBUG] d.GetOk default_branch (string) "" - false 2020/06/19 20:55:55 [DEBUG] d.HasChange default_branch false 2020/06/19 20:55:55 [DEBUG] d.GetChange default_branch (string) "", (string) "" But the actual response shows that `null` was returned in JSON. 2020/06/19 20:55:55 [DEBUG] GitLab API Response Details: ... "default_branch": null,
1 parent 52ed810 commit 24d43d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gitlab/resource_gitlab_project.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,16 @@ func resourceGitlabProjectSetToState(d *schema.ResourceData, project *gitlab.Pro
213213
d.Set("name", project.Name)
214214
d.Set("path", project.Path)
215215
d.Set("description", project.Description)
216+
217+
log.Printf("[DEBUG] gitlab.Project default_branch (%T) %#v", project.DefaultBranch, project.DefaultBranch)
218+
default_branch := d.Get("default_branch")
219+
db, ok := d.GetOk("default_branch")
220+
changed := d.HasChange("default_branch")
221+
old, new := d.GetChange("default_branch")
222+
log.Printf("[DEBUG] d.Get default_branch (%T) %#v", default_branch, default_branch)
223+
log.Printf("[DEBUG] d.GetOk default_branch (%T) %#v - %#v", db, db, ok)
224+
log.Printf("[DEBUG] d.HasChange default_branch %#v", changed)
225+
log.Printf("[DEBUG] d.GetChange default_branch (%T) %#v, (%T) %#v", old, old, new, new)
216226
d.Set("default_branch", project.DefaultBranch)
217227
d.Set("request_access_enabled", project.RequestAccessEnabled)
218228
d.Set("issues_enabled", project.IssuesEnabled)

0 commit comments

Comments
 (0)