MCPcopy Index your code
hub / github.com/rilldata/rill / createGithubRepoFlow

Function createGithubRepoFlow

cli/cmd/project/connect_github.go:233–345  ·  view source on GitHub ↗
(ctx context.Context, ch *cmdutil.Helper, localGitPath string)

Source from the content-addressed store, hash-verified

231}
232
233func createGithubRepoFlow(ctx context.Context, ch *cmdutil.Helper, localGitPath string) error {
234 // Get the admin client
235 c, err := ch.Client()
236 if err != nil {
237 return err
238 }
239
240 res, err := c.GetGithubUserStatus(ctx, &adminv1.GetGithubUserStatusRequest{})
241 if err != nil {
242 return err
243 }
244
245 if !res.HasAccess {
246 ch.Telemetry(ctx).RecordBehavioralLegacy(activity.BehavioralEventGithubConnectedStart)
247
248 if res.GrantAccessUrl != "" {
249 // Print instructions to grant access
250 ch.Print("Open this URL in your browser to grant Rill access to Github:\n\n")
251 ch.Print("\t" + res.GrantAccessUrl + "\n\n")
252
253 // Open browser if possible
254 if ch.Interactive {
255 _ = browser.Open(res.GrantAccessUrl)
256 }
257 }
258 }
259
260 // Poll for permission granted
261 pollCtx, cancel := context.WithTimeout(ctx, pollTimeout)
262 defer cancel()
263 var pollRes *adminv1.GetGithubUserStatusResponse
264 for {
265 select {
266 case <-pollCtx.Done():
267 return pollCtx.Err()
268 case <-time.After(pollInterval):
269 // Ready to check again.
270 }
271
272 // Poll for access to the Github's user account
273 pollRes, err = c.GetGithubUserStatus(ctx, &adminv1.GetGithubUserStatusRequest{})
274 if err != nil {
275 return err
276 }
277 if pollRes.HasAccess {
278 break
279 }
280 // Sleep and poll again
281 }
282
283 // Emit success telemetry
284 ch.Telemetry(ctx).RecordBehavioralLegacy(activity.BehavioralEventGithubConnectedSuccess)
285
286 // get orgs on which rill github app is installed with write permission
287 var candidateOrgs []string
288 if pollRes.UserInstallationPermission == adminv1.GithubPermission_GITHUB_PERMISSION_WRITE {
289 candidateOrgs = append(candidateOrgs, pollRes.Account)
290 }

Callers 1

ConnectGithubFlowFunction · 0.85

Calls 15

OpenFunction · 0.92
ConfirmPromptFunction · 0.92
SelectPromptFunction · 0.92
CommitAndPushFunction · 0.92
createGithubRepositoryFunction · 0.85
TelemetryMethod · 0.80
PrintMethod · 0.80
DoneMethod · 0.80
PrintfWarnMethod · 0.80
PrintfMethod · 0.80
GitSignatureMethod · 0.80

Tested by

no test coverage detected