Skip to content

Commit

Permalink
fix: Simplify rill deploy command and break up upload and github fl…
Browse files Browse the repository at this point in the history
…ows (#5534)

* Move common code to cmdutil.Helper

* Move upload and git-push commands

* Fill in the deploy command

* Rename gitpush => connect-githup

* Lockdown rill developer during rill deploy

* Revert locking down rill developer

* Remove deploy command

* Update some references to upload

* Lint
  • Loading branch information
AdityaHegde committed Sep 3, 2024
1 parent 2c4ab57 commit 836926a
Show file tree
Hide file tree
Showing 26 changed files with 1,187 additions and 1,154 deletions.
30 changes: 29 additions & 1 deletion cli/cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package auth

import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/rilldata/rill/cli/pkg/browser"
"github.com/rilldata/rill/cli/pkg/cmdutil"
"github.com/rilldata/rill/cli/pkg/deviceauth"
"github.com/rilldata/rill/cli/pkg/dotrill"
adminv1 "github.com/rilldata/rill/proto/gen/rill/admin/v1"
"github.com/rilldata/rill/runtime/pkg/activity"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -92,6 +96,30 @@ func Login(ctx context.Context, ch *cmdutil.Helper, redirectURL string) error {
return nil
}

func LoginWithTelemetry(ctx context.Context, ch *cmdutil.Helper, redirectURL string) error {
ch.PrintfBold("Please log in or sign up for Rill. Opening browser...\n")
time.Sleep(2 * time.Second)

ch.Telemetry(ctx).RecordBehavioralLegacy(activity.BehavioralEventLoginStart)

if err := Login(ctx, ch, redirectURL); err != nil {
if errors.Is(err, deviceauth.ErrAuthenticationTimedout) {
ch.PrintfWarn("Rill login has timed out as the code was not confirmed in the browser.\n")
ch.PrintfWarn("Run the command again.\n")
return nil
} else if errors.Is(err, deviceauth.ErrCodeRejected) {
ch.PrintfError("Login failed: Confirmation code rejected\n")
return nil
}
return fmt.Errorf("login failed: %w", err)
}

// The cmdutil.Helper automatically detects the login and will add the user's ID to the telemetry.
ch.Telemetry(ctx).RecordBehavioralLegacy(activity.BehavioralEventLoginSuccess)

return nil
}

func SelectOrgFlow(ctx context.Context, ch *cmdutil.Helper, interactive bool) error {
client, err := ch.Client()
if err != nil {
Expand All @@ -105,7 +133,7 @@ func SelectOrgFlow(ctx context.Context, ch *cmdutil.Helper, interactive bool) er

if len(res.Organizations) == 0 {
if interactive {
ch.PrintfWarn("You are not part of an org. Run `rill org create` or `rill deploy` to create one.\n")
ch.PrintfWarn("You are not part of an org. Run `rill org create` to create one.\n")
}
return nil
}
Expand Down
Loading

1 comment on commit 836926a

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.