(ctx context.Context, ch *cmdutil.Helper, opts *DeployOpts)
| 329 | } |
| 330 | |
| 331 | func 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), |
no test coverage detected