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

Function cacheEnableCmd

internal/boxcli/cache.go:148–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

146}
147
148func cacheEnableCmd() *cobra.Command {
149 cmd := &cobra.Command{
150 Use: "enable",
151 Short: "Enable the Devbox Nix cache for your account",
152 Long: heredoc.Doc(`
153 Sign up or log in to a Jetify Cloud account and configure Nix to use the
154 account's Nix cache.
155
156 For more about how Devbox configures Nix, see "devbox cache configure -h".
157 `),
158 Args: cobra.ExactArgs(0),
159 RunE: func(cmd *cobra.Command, args []string) error {
160 auth, err := identity.AuthClient(identity.AuthRedirectCache)
161 if err != nil {
162 return err
163 }
164 sess, _ := auth.GetSessions()
165 needLogin := len(sess) == 0
166 if needLogin {
167 _, err = auth.LoginFlow()
168 if err != nil {
169 return err
170 }
171 }
172
173 needConfigure := !nixcache.IsConfigured(cmd.Context())
174 if needConfigure {
175 u, _ := user.Current()
176 err = nixcache.ConfigureReprompt(cmd.Context(), u.Username)
177 if err != nil {
178 return err
179 }
180 }
181
182 if !needConfigure && !needLogin {
183 fmt.Fprintln(cmd.OutOrStdout(), "The Devbox cache is already enabled for your account.")
184 }
185 return nil
186 },
187 }
188 return cmd
189}
190
191func cacheInfoCmd() *cobra.Command {
192 return &cobra.Command{

Callers 1

cacheCmdFunction · 0.85

Calls 3

AuthClientFunction · 0.92
IsConfiguredFunction · 0.92
ConfigureRepromptFunction · 0.92

Tested by

no test coverage detected