( ctx context.Context, w io.Writer, )
| 86 | } |
| 87 | |
| 88 | func 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 | } |
no test coverage detected