forked from integrations/terraform-provider-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_user.go
More file actions
52 lines (40 loc) · 1.17 KB
/
util_user.go
File metadata and controls
52 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package github
import "strconv"
// userIdentity represents a GitHub user by their login.
type userIdentity struct {
login string
}
// userCollaborator represents a GitHub user collaborator with its identity and permission level.
type userCollaborator struct {
userIdentity
permission string
invitationID *int64
}
// flatten converts the userCollaborator into a format suitable for Terraform schema.
func (u userCollaborator) flatten() any {
m := map[string]any{
"username": u.login,
"permission": u.permission,
}
return m
}
// userCollaborators is a slice of userCollaborator.
type userCollaborators []userCollaborator
// flatten converts the userCollaborators slice into a format suitable for Terraform schema.
func (uc userCollaborators) flatten() any {
items := make([]any, len(uc))
for i, u := range uc {
items[i] = u.flatten()
}
return items
}
// flattenInvitations converts the userCollaborators slice into a format suitable for Terraform schema.
func (uc userCollaborators) flattenInvitations() any {
m := make(map[string]any)
for _, u := range uc {
if u.invitationID != nil {
m[u.login] = strconv.FormatInt(*u.invitationID, 10)
}
}
return m
}