@@ -28,7 +28,7 @@ func invitationToUserResource(invitation *github.Invitation) (*v2.Resource, erro
2828
2929 ret , err := resource .NewUserResource (
3030 login ,
31- resourceTypeUser ,
31+ resourceTypeInvitation ,
3232 invitation .GetID (),
3333 []resource.UserTraitOption {
3434 resource .WithEmail (invitation .GetEmail (), true ),
@@ -263,8 +263,7 @@ func (o *userResourceType) CreateAccount(
263263 }
264264
265265 invitation , resp , err := o .client .Organizations .CreateOrgInvitation (ctx , params .org , & github.CreateOrgInvitationOptions {
266- InviteeID : params .userID ,
267- Email : params .email ,
266+ Email : params .email ,
268267 })
269268 if err != nil {
270269 return nil , nil , nil , fmt .Errorf ("github-connectorv2: failed to invite user to org: %w" , err )
@@ -288,45 +287,25 @@ func (o *userResourceType) CreateAccount(
288287}
289288
290289type createUserParams struct {
291- org string
292- email * string
293- userID * int64
290+ org string
291+ email * string
294292}
295293
296294func getCreateUserParams (accountInfo * v2.AccountInfo ) (* createUserParams , error ) {
297- var (
298- pMap = accountInfo .Profile .AsMap ()
299- uID * int64
300- email * string
301- )
302-
295+ pMap := accountInfo .Profile .AsMap ()
303296 org , ok := pMap ["org" ].(string )
304297 if ! ok || org == "" {
305298 return nil , fmt .Errorf ("org is required" )
306299 }
307300
308301 e , emailExisted := pMap ["email" ].(string )
309- if e != "" {
310- email = & e
311- }
312-
313- userID , userIDExisted := pMap ["userID" ].(string )
314- if ! emailExisted && ! userIDExisted {
315- return nil , fmt .Errorf ("either email or userID should be provided" )
316- }
317-
318- if userIDExisted {
319- i , err := strconv .ParseInt (userID , 10 , 64 )
320- if err != nil {
321- return nil , err
322- }
323- uID = & i
302+ if ! emailExisted || e == "" {
303+ return nil , fmt .Errorf ("email is required" )
324304 }
325305
326306 return & createUserParams {
327- org : org ,
328- email : email ,
329- userID : uID ,
307+ org : org ,
308+ email : & e ,
330309 }, nil
331310}
332311
0 commit comments