MCPcopy Create free account
hub / github.com/Scalingo/cli / collaboratorUserIDs

Function collaboratorUserIDs

notifiers/create.go:75–111  ·  view source on GitHub ↗
(ctx context.Context, c *scalingo.Client, app string, usernames []string)

Source from the content-addressed store, hash-verified

73}
74
75func collaboratorUserIDs(ctx context.Context, c *scalingo.Client, app string, usernames []string) ([]string, error) {
76 ids := make([]string, 0, len(usernames))
77
78 collaborators, err := c.CollaboratorsList(ctx, app)
79 if err != nil {
80 return nil, errors.Wrapf(ctx, err, "fail to list collaborators")
81 }
82
83 scapp, err := c.AppsShow(ctx, app)
84 if err != nil {
85 return nil, errors.Wrapf(ctx, err, "fail to get application information")
86 }
87
88 var id string
89 for _, u := range usernames {
90 id = ""
91 if u == scapp.Owner.Username {
92 id = scapp.Owner.ID
93 } else {
94 for _, c := range collaborators {
95 if c.Username == u && c.Status == "pending" {
96 return nil, errors.Newf(ctx, "%v is a collaborator but their invitation is still pending", c.Username)
97 } else if c.Username == u {
98 id = c.UserID
99 break
100 }
101 }
102 }
103 if id == "" {
104 return nil, errors.Newf(ctx, "no such collaborator: %v", u)
105 }
106
107 ids = append(ids, id)
108 }
109
110 return ids, nil
111}

Callers 2

UpdateFunction · 0.85
ProvisionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected