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

Function redeployProject

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

Source from the content-addressed store, hash-verified

458}
459
460func redeployProject(ctx context.Context, ch *cmdutil.Helper, opts *DeployOpts) error {
461 c, err := ch.Client()
462 if err != nil {
463 return err
464 }
465 proj := opts.pushToProject
466 if proj.ManagedGitId != "" {
467 err := ch.GitHelper(ch.Org, proj.Name, opts.LocalProjectPath()).PushToManagedRepo(ctx)
468 if err != nil {
469 return err
470 }
471 } else if proj.GitRemote != "" {
472 // Infer repo root and subpath for git operations
473 repoRoot, subpath, err := gitutil.InferRepoRootAndSubpath(opts.LocalProjectPath())
474 if err != nil {
475 return err
476 }
477 // Verify subpath matches the one stored in the project
478 if subpath != proj.Subpath {
479 return fmt.Errorf("current project subpath %q does not match the one stored in rill %q. Run rill cli from github repo root and pass explicit subpath using `rill deploy --subpath %s`", subpath, proj.Subpath, proj.Subpath)
480 }
481 config := &gitutil.Config{
482 Remote: opts.pushToProject.GitRemote,
483 DefaultBranch: opts.pushToProject.PrimaryBranch,
484 Subpath: subpath,
485 }
486 author, err := ch.GitSignature(ctx, repoRoot)
487 if err != nil {
488 return err
489 }
490 err = ch.CommitAndSafePush(ctx, repoRoot, config, "", author, "1")
491 if err != nil {
492 return err
493 }
494 } else {
495 // tarball flow
496 var updateProjReq *adminv1.UpdateProjectRequest
497 if opts.ArchiveUpload {
498 repo, _, err := cmdutil.RepoForProjectPath(opts.LocalProjectPath())
499 if err != nil {
500 return err
501 }
502 assetID, err := cmdutil.UploadRepo(ctx, repo, ch, ch.Org, opts.Name)
503 if err != nil {
504 return err
505 }
506 updateProjReq = &adminv1.UpdateProjectRequest{
507 Org: ch.Org,
508 Project: proj.Name,
509 ArchiveAssetId: &assetID,
510 }
511 } else {
512 // need to migrate to rill managed git
513 gitRepo, err := ch.GitHelper(ch.Org, opts.Name, opts.LocalProjectPath()).PushToNewManagedRepo(ctx, opts.PrimaryBranch)
514 if err != nil {
515 return err
516 }
517 updateProjReq = &adminv1.UpdateProjectRequest{

Callers 2

ConnectGithubFlowFunction · 0.85
DeployWithUploadFlowFunction · 0.85

Calls 15

InferRepoRootAndSubpathFunction · 0.92
RepoForProjectPathFunction · 0.92
UploadRepoFunction · 0.92
ParseDotenvFunction · 0.92
PushToManagedRepoMethod · 0.80
GitHelperMethod · 0.80
LocalProjectPathMethod · 0.80
GitSignatureMethod · 0.80
CommitAndSafePushMethod · 0.80
PushToNewManagedRepoMethod · 0.80
PrintfErrorMethod · 0.80
PrintfWarnMethod · 0.80

Tested by

no test coverage detected