MCPcopy Index your code
hub / github.com/jetify-com/devbox / pullCmdFunc

Function pullCmdFunc

internal/boxcli/pull.go:52–113  ·  view source on GitHub ↗
(cmd *cobra.Command, url string, flags *pullCmdFlags)

Source from the content-addressed store, hash-verified

50}
51
52func 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{

Callers 1

pullCmdFunction · 0.85

Calls 8

OpenFunction · 0.92
GenSessionFunction · 0.92
NewFunction · 0.92
absolutizeIfLocalFunction · 0.85
pullErrorPromptFunction · 0.85
installCmdFuncFunction · 0.85
IsMethod · 0.80
PullMethod · 0.45

Tested by

no test coverage detected