@@ -156,13 +156,13 @@ func resourceGitlabUserCreate(ctx context.Context, d *schema.ResourceData, meta
156
156
d .SetId (fmt .Sprintf ("%d" , user .ID ))
157
157
158
158
if d .Get ("state" ) == "blocked" {
159
- err := client .Users .BlockUser (user .ID )
159
+ err := client .Users .BlockUser (user .ID , gitlab . WithContext ( ctx ) )
160
160
161
161
if err != nil {
162
162
return diag .FromErr (err )
163
163
}
164
164
} else if d .Get ("state" ) == "deactivated" {
165
- err := client .Users .DeactivateUser (user .ID )
165
+ err := client .Users .DeactivateUser (user .ID , gitlab . WithContext ( ctx ) )
166
166
167
167
if err != nil {
168
168
return diag .FromErr (err )
@@ -245,24 +245,24 @@ func resourceGitlabUserUpdate(ctx context.Context, d *schema.ResourceData, meta
245
245
// NOTE: yes, this can be written much more consice, however, for the sake of understanding the behavior,
246
246
// of the API and the allowed state transitions of GitLab, let's keep it as-is and enjoy the readability.
247
247
if newState == "active" && oldState == "blocked" {
248
- err = client .Users .UnblockUser (id )
248
+ err = client .Users .UnblockUser (id , gitlab . WithContext ( ctx ) )
249
249
} else if newState == "active" && oldState == "deactivated" {
250
- err = client .Users .ActivateUser (id )
250
+ err = client .Users .ActivateUser (id , gitlab . WithContext ( ctx ) )
251
251
} else if newState == "blocked" && oldState == "active" {
252
- err = client .Users .BlockUser (id )
252
+ err = client .Users .BlockUser (id , gitlab . WithContext ( ctx ) )
253
253
} else if newState == "blocked" && oldState == "deactivated" {
254
- err = client .Users .BlockUser (id )
254
+ err = client .Users .BlockUser (id , gitlab . WithContext ( ctx ) )
255
255
} else if newState == "deactivated" && oldState == "active" {
256
- err = client .Users .DeactivateUser (id )
256
+ err = client .Users .DeactivateUser (id , gitlab . WithContext ( ctx ) )
257
257
} else if newState == "deactivated" && oldState == "blocked" {
258
258
// a blocked user cannot be deactivated, GitLab will return an error, like:
259
259
// `403 Forbidden - A blocked user cannot be deactivated by the API`
260
260
// we have to unblock the user first
261
- err = client .Users .UnblockUser (id )
261
+ err = client .Users .UnblockUser (id , gitlab . WithContext ( ctx ) )
262
262
if err != nil {
263
263
return diag .FromErr (err )
264
264
}
265
- err = client .Users .DeactivateUser (id )
265
+ err = client .Users .DeactivateUser (id , gitlab . WithContext ( ctx ) )
266
266
}
267
267
268
268
if err != nil {
0 commit comments