Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/main' into release-0.48
Browse files Browse the repository at this point in the history
  • Loading branch information
nishantmonu51 committed Aug 8, 2024
2 parents 8741ce9 + 32593f9 commit 6b076d2
Show file tree
Hide file tree
Showing 39 changed files with 1,299 additions and 435 deletions.
4 changes: 2 additions & 2 deletions admin/worker/reset_all_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package worker

import (
"context"
"fmt"

"github.com/rilldata/rill/admin/database"
"github.com/rilldata/rill/runtime/pkg/observability"
Expand Down Expand Up @@ -50,7 +49,8 @@ func (w *Worker) resetAllDeploymentsForProject(ctx context.Context, proj *databa
// Make sure the deployment provisioner is in the current provisioner set
_, ok := w.admin.ProvisionerSet[depl.Provisioner]
if !ok {
return fmt.Errorf("reset all deployments: %q is not in the provisioner set", depl.Provisioner)
w.logger.Error("reset all deployments: provisioner is not in the provisioner set", zap.String("provisioner", depl.Provisioner), zap.String("deployment_id", depl.ID), observability.ZapCtx(ctx))
continue
}

w.logger.Info("reset all deployments: redeploying deployment", zap.String("deployment_id", depl.ID), observability.ZapCtx(ctx))
Expand Down
35 changes: 20 additions & 15 deletions cli/cmd/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func StartCmd(ch *cmdutil.Helper) *cobra.Command {
var logFormat string
var env []string
var vars []string
var allowedOrigins []string
var tlsCertPath string
var tlsKeyPath string

Expand Down Expand Up @@ -143,22 +144,25 @@ func StartCmd(ch *cmdutil.Helper) *cobra.Command {
}
localURL := fmt.Sprintf("%s://localhost:%d", scheme, httpPort)

allowedOrigins = append(allowedOrigins, localURL)

app, err := local.NewApp(cmd.Context(), &local.AppOptions{
Version: ch.Version,
Verbose: verbose,
Debug: debug,
Reset: reset,
Environment: environment,
OlapDriver: olapDriver,
OlapDSN: olapDSN,
ProjectPath: projectPath,
LogFormat: parsedLogFormat,
Variables: varsMap,
Activity: ch.Telemetry(cmd.Context()),
AdminURL: ch.AdminURL,
AdminToken: ch.AdminToken(),
CMDHelper: ch,
LocalURL: localURL,
Version: ch.Version,
Verbose: verbose,
Debug: debug,
Reset: reset,
Environment: environment,
OlapDriver: olapDriver,
OlapDSN: olapDSN,
ProjectPath: projectPath,
LogFormat: parsedLogFormat,
Variables: varsMap,
Activity: ch.Telemetry(cmd.Context()),
AdminURL: ch.AdminURL,
AdminToken: ch.AdminToken(),
CMDHelper: ch,
LocalURL: localURL,
AllowedOrigins: allowedOrigins,
})
if err != nil {
return err
Expand Down Expand Up @@ -192,6 +196,7 @@ func StartCmd(ch *cmdutil.Helper) *cobra.Command {
// --env was previously used for variables, but is now used to set the environment name. We maintain backwards compatibility by keeping --env as a slice var, and setting any value containing an equals sign as a variable.
startCmd.Flags().StringSliceVarP(&env, "env", "e", []string{}, `Environment name (default "dev")`)
startCmd.Flags().StringSliceVarP(&vars, "var", "v", []string{}, "Set project variables")
startCmd.Flags().StringSliceVarP(&allowedOrigins, "allowed-origins", "", []string{}, "add additional allowed-origins")

// We have deprecated the ability configure the OLAP database via the CLI. This should now be done via rill.yaml.
// Keeping these for backwards compatibility for a while.
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/sudo/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func cloneCmd(ch *cmdutil.Helper) *cobra.Command {

fmt.Println("Clone command:")
if res.ArchiveDownloadUrl != "" {
fmt.Printf("\tcurl -o %s__%s.tar.gz %s\n\n", args[0], args[1], res.ArchiveDownloadUrl)
fmt.Printf("\tcurl -o %s__%s.tar.gz '%s'\n\n", args[0], args[1], res.ArchiveDownloadUrl)
return nil
}

Expand Down
35 changes: 19 additions & 16 deletions cli/pkg/local/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,26 @@ type App struct {
pkceAuthenticators map[string]*pkce.Authenticator // map of state to pkce authenticators
ch *cmdutil.Helper
localURL string
allowedOrigins []string
}

type AppOptions struct {
Version cmdutil.Version
Verbose bool
Debug bool
Reset bool
Environment string
OlapDriver string
OlapDSN string
ProjectPath string
LogFormat LogFormat
Variables map[string]string
Activity *activity.Client
AdminURL string
AdminToken string
CMDHelper *cmdutil.Helper
LocalURL string
Version cmdutil.Version
Verbose bool
Debug bool
Reset bool
Environment string
OlapDriver string
OlapDSN string
ProjectPath string
LogFormat LogFormat
Variables map[string]string
Activity *activity.Client
AdminURL string
AdminToken string
CMDHelper *cmdutil.Helper
LocalURL string
AllowedOrigins []string
}

func NewApp(ctx context.Context, opts *AppOptions) (*App, error) {
Expand Down Expand Up @@ -300,6 +302,7 @@ func NewApp(ctx context.Context, opts *AppOptions) (*App, error) {
pkceAuthenticators: make(map[string]*pkce.Authenticator),
ch: opts.CMDHelper,
localURL: opts.LocalURL,
allowedOrigins: opts.AllowedOrigins,
}

// Collect and emit information about connectors at start time
Expand Down Expand Up @@ -377,7 +380,7 @@ func (a *App) Serve(httpPort, grpcPort int, enableUI, openBrowser, readonly bool
GRPCPort: grpcPort,
TLSCertPath: tlsCertPath,
TLSKeyPath: tlsKeyPath,
AllowedOrigins: []string{"*"},
AllowedOrigins: a.allowedOrigins,
ServePrometheus: true,
}
runtimeServer, err := runtimeserver.NewServer(ctx, opts, a.Runtime, runtimeServerLogger, ratelimit.NewNoop(), a.activity)
Expand Down
60 changes: 60 additions & 0 deletions cli/pkg/local/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (s *Server) GetMetadata(ctx context.Context, r *connect.Request[localv1.Get
AnalyticsEnabled: s.metadata.AnalyticsEnabled,
Readonly: s.metadata.Readonly,
GrpcPort: int32(s.metadata.GRPCPort),
LoginUrl: s.app.localURL + "/auth",
}), nil
}

Expand Down Expand Up @@ -674,13 +675,72 @@ func (s *Server) GetCurrentUser(ctx context.Context, r *connect.Request[localv1.
return nil, errors.New("failed to get current user")
}

// get rill user orgs
resp, err := c.ListOrganizations(ctx, &adminv1.ListOrganizationsRequest{})
if err != nil {
return nil, err
}

userOrgs := make([]string, 0, len(resp.Organizations))
for _, org := range resp.Organizations {
userOrgs = append(userOrgs, org.Name)
}

return connect.NewResponse(&localv1.GetCurrentUserResponse{
User: &adminv1.User{
Id: userResp.User.Id,
Email: userResp.User.Email,
DisplayName: userResp.User.DisplayName,
PhotoUrl: userResp.User.PhotoUrl,
},
RillUserOrgs: userOrgs,
}), nil
}

func (s *Server) GetCurrentProject(ctx context.Context, r *connect.Request[localv1.GetCurrentProjectRequest]) (*connect.Response[localv1.GetCurrentProjectResponse], error) {
localProjectName := filepath.Base(s.app.ProjectPath)

if !s.app.ch.IsAuthenticated() {
// user should be logged in first
return connect.NewResponse(&localv1.GetCurrentProjectResponse{
LocalProjectName: localProjectName,
}), nil
}
// Get admin client
c, err := client.New(s.app.adminURL, s.app.ch.AdminTokenDefault, "Rill Localhost")
if err != nil {
return nil, err
}

rc, err := dotrillcloud.GetAll(s.app.ProjectPath, s.app.adminURL)
if err != nil {
return nil, err
}
if rc == nil {
return connect.NewResponse(&localv1.GetCurrentProjectResponse{
LocalProjectName: localProjectName,
}), nil
}

var project *adminv1.Project
proj, err := c.GetProjectByID(ctx, &adminv1.GetProjectByIDRequest{
Id: rc.ProjectID,
})
if err != nil {
// unset if project doesnt exist
if errors.Is(err, database.ErrNotFound) {
err = dotrillcloud.Delete(s.app.ProjectPath, s.app.adminURL)
if err != nil {
return nil, err
}
}
} else {
project = proj.Project
}

return connect.NewResponse(&localv1.GetCurrentProjectResponse{
LocalProjectName: localProjectName,
Project: project,
}), nil
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "npm run build -w web-local",
"dev": "sh -c 'npm run dev-runtime & npm run dev-web & wait'",
"dev-web": "npm run dev -w web-local",
"dev-runtime": "go run cli/main.go start dev-project --no-ui",
"dev-runtime": "go run cli/main.go start dev-project --no-ui --allowed-origins http://localhost:3000",
"clean": "rm -rf dev-project",
"test": "npm run test -w web-common & npm run test -w web-auth & PLAYWRIGHT_TEST=true make cli && npm run test -w web-local"
},
Expand Down
Loading

2 comments on commit 6b076d2

@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.

@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.

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://66b6044c11461b62248f63f9--rill-ui.netlify.app

Please sign in to comment.