-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Terraform trying to set default_branch
to null
#343
Conversation
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,
After understanding what |
Setting default branch on an empty repo results in an error.
|
default_branch
is set in .tf filedefault_branch
to null
It would be nice to see a regression test for this, since it's difficult to tell just by looking at the change how it will behave. |
This looks simple enough, can we get this merged please ? |
With the ongoing governmental terror in Belarus, I am emotionally drained, and can not think clearly to write the tests, sorry. |
@armsnyder WDYT about this? @abitrolly no worries. take care!!!! |
@roidelapluie The PR looks like an improvement, so I'm fine with merging. I think it could be improved further at a later time by using the |
Merging due to customer request and Maintainer approval |
Thanks to* I hope :) |
Fixes #299 where Terraform tries to reset the
default_branch
to null for non-empty repositories if not set in .tfThe
default_branch
defaults tomaster
on GitLab side, but it is only set if the repository is not empty. Otherwise it isnull
on remote side.The debug in 24d43d8 showed no trace of
null
value from remote.But the actual response shows that
null
was returned in JSON.The fix is to skip the change if TF is trying to set null value for remote side. This PR also adds a warning if
default_branch
is specified in .tf file, but the remote repo is empty. And also removes more specific check forinitilize_with_readme
towards the generic case above.default_branch
should not make assumptions on how the repo was created.