package runnersetup import ( "amadan.net/oficina/equipo/internal/runnerproto" "context" "errors" "time" "amadan.net/oficina/equipo/internal/runner/provider" ) // RunAccountLogin belongs to the interactive subcommand only. func RunAccountLogin(ctx context.Context, l *AccountLogin, id string) error { if _, err := l.Begin(ctx, id); err != nil { return err } defer func() { if l.active != nil && !l.Saved() { cleanup, stop := context.WithTimeout(context.Background(), 5*time.Second) defer stop() _ = l.Cancel(cleanup) } }() delay := time.Second timer := time.NewTimer(delay) defer timer.Stop() retries := 0 for { select { case <-ctx.Done(): return context.Canceled case <-timer.C: out, err := l.Poll(ctx) if err != nil { if errors.Is(err, runnerproto.ErrTransient) && l.active != nil && time.Now().Before(l.active.challenge.ExpiresAt) { delay = min(delay*2, 30*time.Second) timer.Reset(delay) continue } if l.Saved() && retries < 3 { retries++ timer.Reset(min(time.Duration(1<