You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improvements to resource_gitlab_user Import (#193)
This change makes three improvements to the gitlab_user resource, resolving Issue #193.
Change #1:
The `password` attribute for gitlab_user has been changed from required to optional. There is no endpoint on the Gitlab `user` API for `password` (see: https://docs.gitlab.com/ee/api/users.html), so it is impossible for us to ever read this attribute to set state. The field should therefore only be necessary when we are performing a Create or Update action on a gitlab_user.
Change #2:
The resource's State Importer originally used `ImportStatePassthrough`, which essentially ensured that `terraform import` could only read the fields defined in the default Read method (in this case, `username`, `name`, `can_create_group`, and `projects_limit`, all of which are called in `resourceGitlabUserSetToState`, inside `resourceGitlabUserRead`). I have replaced the `ImportStatePassthrough` with an anonymous function that reuses `resourceGitlabUserSetToState` and additionally sets `email`, `is_admin`, and `is_external`. I did not modify the fields set in `resourceGitlabUserSetToState` because that function is intended to provide only a basic level of detail about a user (i.e., all the data we'd be able to pull for a user if we didn't have a token with Admin privileges). These fields can be easily extended in the future if need be.
Change #3:
The test for the gitlab_user resource has been updated to include the mandatory ImportState and ImportStateVerify elements in the final stage, per the Terraform `import` implementation documentation at https://www.terraform.io/docs/extend/resources/import.html. The `password` and `skip_confirmation` attributes are ignored because it is not possible to read them from the API (they are not part of the Read schema: https://docs.gitlab.com/ee/api/users.html)
0 commit comments