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

Function DeployWithUploadFlow

cli/cmd/project/deploy.go:331–458  ·  view source on GitHub ↗
(ctx context.Context, ch *cmdutil.Helper, opts *DeployOpts)

Source from the content-addressed store, hash-verified

329}
330
331func DeployWithUploadFlow(ctx context.Context, ch *cmdutil.Helper, opts *DeployOpts) error {
332 localProjectPath := opts.LocalProjectPath()
333 // If no project name was provided, default to dir name
334 if opts.Name == "" {
335 opts.Name = filepath.Base(localProjectPath)
336 }
337
338 // Set a default org for the user if necessary
339 // (If user is not in an org, we'll create one based on their user name later in the flow.)
340 adminClient, err := ch.Client()
341 if err != nil {
342 return err
343 }
344 if ch.Org == "" {
345 if err := org.SetDefaultOrg(ctx, ch); err != nil {
346 return err
347 }
348 }
349
350 // If no default org is set, it means the user is not in an org yet.
351 // We create a default org based on the user name.
352 // TODO : Ask user prompt similar to UI instead of silently creating org based on email
353 if ch.Org == "" {
354 if !ch.Interactive {
355 return fmt.Errorf("--org flag is required when not running interactively")
356 }
357 err = createOrgFlow(ctx, ch)
358 if err != nil {
359 return fmt.Errorf("org creation failed with error: %w", err)
360 }
361 ch.PrintfSuccess("Created org %q. Run `rill org edit` to change name if required.\n\n", ch.Org)
362 } else {
363 ch.PrintfBold("Using org %q.\n\n", ch.Org)
364 }
365
366 // get repo for current project
367 repo, _, err := cmdutil.RepoForProjectPath(localProjectPath)
368 if err != nil {
369 return err
370 }
371 // Ensure gitignore is set up so that we don't upload files that should not be tracked by Git.
372 err = cmdutil.SetupGitIgnore(ctx, repo)
373 if err != nil {
374 return fmt.Errorf("failed to set up .gitignore: %w", err)
375 }
376
377 if opts.pushToProject != nil {
378 return redeployProject(ctx, ch, opts)
379 }
380
381 // Create a new project
382 req := &adminv1.CreateProjectRequest{
383 Org: ch.Org,
384 Project: opts.Name,
385 Description: opts.Description,
386 Provisioner: opts.Provisioner,
387 ProdVersion: opts.ProdVersion,
388 ProdSlots: int64(opts.Slots),

Callers 2

DeployCmdFunction · 0.92
DeployCmdFunction · 0.85

Calls 15

SetDefaultOrgFunction · 0.92
RepoForProjectPathFunction · 0.92
SetupGitIgnoreFunction · 0.92
UploadRepoFunction · 0.92
ParseDotenvFunction · 0.92
OpenFunction · 0.92
createOrgFlowFunction · 0.85
redeployProjectFunction · 0.85
LocalProjectPathMethod · 0.80
PrintfSuccessMethod · 0.80
PrintfBoldMethod · 0.80
PrintlnMethod · 0.80

Tested by

no test coverage detected