@@ -3,6 +3,7 @@ package gitlab
3
3
import (
4
4
"fmt"
5
5
"strconv"
6
+ "strings"
6
7
"time"
7
8
8
9
"github.com/hashicorp/terraform/helper/schema"
@@ -40,11 +41,11 @@ func dataSourceGitlabUsers() *schema.Resource {
40
41
Type : schema .TypeBool ,
41
42
Optional : true ,
42
43
},
43
- "identities_extern_uid " : {
44
+ "extern_uid " : {
44
45
Type : schema .TypeString ,
45
46
Optional : true ,
46
47
},
47
- "identities_provider " : {
48
+ "extern_provider " : {
48
49
Type : schema .TypeString ,
49
50
Optional : true ,
50
51
},
@@ -175,71 +176,71 @@ func flattenGitlabUsers(users []*gitlab.User) []interface{} {
175
176
176
177
func expandGitlabUsersOptions (d * schema.ResourceData ) (* gitlab.ListUsersOptions , int , error ) {
177
178
listUsersOptions := & gitlab.ListUsersOptions {}
178
- optionsHash := ""
179
+ var optionsHash strings. Builder
179
180
180
181
if data , ok := d .GetOk ("order_by" ); ok {
181
182
orderBy := data .(string )
182
183
listUsersOptions .OrderBy = & orderBy
183
- optionsHash += orderBy
184
+ optionsHash . WriteString ( orderBy )
184
185
}
185
- optionsHash += ","
186
+ optionsHash . WriteString ( "," )
186
187
if data , ok := d .GetOk ("sort" ); ok {
187
188
sort := data .(string )
188
189
listUsersOptions .Sort = & sort
189
- optionsHash += sort
190
+ optionsHash . WriteString ( sort )
190
191
}
191
- optionsHash += ","
192
+ optionsHash . WriteString ( "," )
192
193
if data , ok := d .GetOk ("search" ); ok {
193
194
search := data .(string )
194
195
listUsersOptions .Search = & search
195
- optionsHash += search
196
+ optionsHash . WriteString ( search )
196
197
}
197
- optionsHash += ","
198
+ optionsHash . WriteString ( "," )
198
199
if data , ok := d .GetOk ("active" ); ok {
199
200
active := data .(bool )
200
201
listUsersOptions .Active = & active
201
- optionsHash += strconv .FormatBool (active )
202
+ optionsHash . WriteString ( strconv .FormatBool (active ) )
202
203
}
203
- optionsHash += ","
204
+ optionsHash . WriteString ( "," )
204
205
if data , ok := d .GetOk ("blocked" ); ok {
205
206
blocked := data .(bool )
206
207
listUsersOptions .Blocked = & blocked
207
- optionsHash += strconv .FormatBool (blocked )
208
+ optionsHash . WriteString ( strconv .FormatBool (blocked ) )
208
209
}
209
- optionsHash += ","
210
- if data , ok := d .GetOk ("identities_extern_uid " ); ok {
210
+ optionsHash . WriteString ( "," )
211
+ if data , ok := d .GetOk ("extern_uid " ); ok {
211
212
externalUID := data .(string )
212
213
listUsersOptions .ExternalUID = & externalUID
213
- optionsHash += externalUID
214
+ optionsHash . WriteString ( externalUID )
214
215
}
215
- optionsHash += ","
216
- if data , ok := d .GetOk ("identities_provider " ); ok {
216
+ optionsHash . WriteString ( "," )
217
+ if data , ok := d .GetOk ("extern_provider " ); ok {
217
218
provider := data .(string )
218
219
listUsersOptions .Provider = & provider
219
- optionsHash += provider
220
+ optionsHash . WriteString ( provider )
220
221
}
221
- optionsHash += ","
222
+ optionsHash . WriteString ( "," )
222
223
if data , ok := d .GetOk ("created_before" ); ok {
223
224
createdBefore := data .(string )
224
225
date , err := time .Parse ("2006-01-02" , createdBefore )
225
226
if err != nil {
226
227
return nil , 0 , fmt .Errorf ("created_before must be in yyyy-mm-dd format" )
227
228
}
228
229
listUsersOptions .CreatedBefore = & date
229
- optionsHash += createdBefore
230
+ optionsHash . WriteString ( createdBefore )
230
231
}
231
- optionsHash += ","
232
+ optionsHash . WriteString ( "," )
232
233
if data , ok := d .GetOk ("created_after" ); ok {
233
234
createdAfter := data .(string )
234
235
date , err := time .Parse ("2006-01-02" , createdAfter )
235
236
if err != nil {
236
237
return nil , 0 , fmt .Errorf ("created_after must be in yyyy-mm-dd format" )
237
238
}
238
239
listUsersOptions .CreatedAfter = & date
239
- optionsHash += createdAfter
240
+ optionsHash . WriteString ( createdAfter )
240
241
}
241
242
242
- id := schema .HashString (optionsHash )
243
+ id := schema .HashString (optionsHash . String () )
243
244
244
245
return listUsersOptions , id , nil
245
246
}
0 commit comments