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

Function getWriteCacheURI

internal/devbox/cache.go:88–119  ·  view source on GitHub ↗
(
	ctx context.Context,
	w io.Writer,
)

Source from the content-addressed store, hash-verified

86}
87
88func getWriteCacheURI(
89 ctx context.Context,
90 w io.Writer,
91) (string, error) {
92 _, err := identity.GenSession(ctx)
93 if errors.Is(err, auth.ErrNotLoggedIn) {
94 return "",
95 usererr.New("You must be logged in to upload to a Nix cache.")
96 }
97 caches, err := nixcache.WriteCaches(ctx)
98 if err != nil {
99 return "", err
100 }
101
102 if len(caches) == 0 {
103 slug, err := identity.GetOrgSlug(ctx)
104 if err != nil {
105 return "", err
106 }
107 return "",
108 usererr.New(
109 "You don't have permission to write to any Nix caches. To configure cache, go to "+
110 "%s/teams/%s/devbox",
111 build.DashboardHostname(),
112 slug,
113 )
114 }
115 if len(caches) > 1 {
116 ux.Fwarningf(w, "Multiple caches available, using %s.\n", caches[0].GetUri())
117 }
118 return caches[0].GetUri(), nil
119}

Callers 2

UploadProjectToCacheMethod · 0.85
UploadInstallableToCacheFunction · 0.85

Calls 6

GenSessionFunction · 0.92
NewFunction · 0.92
WriteCachesFunction · 0.92
GetOrgSlugFunction · 0.92
FwarningfFunction · 0.92
IsMethod · 0.80

Tested by

no test coverage detected