(cmd *cobra.Command, url string, flags *pullCmdFlags)
| 50 | } |
| 51 | |
| 52 | func pullCmdFunc(cmd *cobra.Command, url string, flags *pullCmdFlags) error { |
| 53 | box, err := devbox.Open(&devopt.Opts{ |
| 54 | Dir: flags.config.path, |
| 55 | Environment: flags.config.environment, |
| 56 | Stderr: cmd.ErrOrStderr(), |
| 57 | }) |
| 58 | if err != nil { |
| 59 | return errors.WithStack(err) |
| 60 | } |
| 61 | |
| 62 | pullPath, err := absolutizeIfLocal(url) |
| 63 | if err != nil { |
| 64 | return errors.WithStack(err) |
| 65 | } |
| 66 | |
| 67 | var creds devopt.Credentials |
| 68 | t, err := identity.GenSession(cmd.Context()) |
| 69 | if err != nil && !errors.Is(err, auth.ErrNotLoggedIn) { |
| 70 | return errors.WithStack(err) |
| 71 | } else if t != nil && err == nil { |
| 72 | creds = devopt.Credentials{ |
| 73 | IDToken: t.IDToken, |
| 74 | Email: t.IDClaims().Email, |
| 75 | Sub: t.IDClaims().Subject, |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | err = box.Pull(cmd.Context(), devopt.PullboxOpts{ |
| 80 | URL: pullPath, |
| 81 | Overwrite: flags.force, |
| 82 | Credentials: creds, |
| 83 | }) |
| 84 | if prompt := pullErrorPrompt(err); prompt != "" { |
| 85 | prompt := &survey.Confirm{Message: prompt} |
| 86 | if err = survey.AskOne(prompt, &flags.force); err != nil { |
| 87 | return errors.WithStack(err) |
| 88 | } |
| 89 | if !flags.force { |
| 90 | return nil |
| 91 | } |
| 92 | err = box.Pull(cmd.Context(), devopt.PullboxOpts{ |
| 93 | URL: pullPath, |
| 94 | Overwrite: flags.force, |
| 95 | Credentials: creds, |
| 96 | }) |
| 97 | } |
| 98 | if errors.Is(err, s3.ErrProfileNotFound) { |
| 99 | return usererr.New( |
| 100 | "Profile not found. Use `devbox global push` to create a new profile.", |
| 101 | ) |
| 102 | } |
| 103 | if err != nil { |
| 104 | return err |
| 105 | } |
| 106 | |
| 107 | return installCmdFunc( |
| 108 | cmd, |
| 109 | installCmdFlags{ |
no test coverage detected