keyFor builds the bucket-level S3 key for a digest. Every tenant's objects live under a prefix derived from the requesting org carried in ctx, so two tenants pushing the same digest don't collide at the bucket layer. The function fails closed when the org is missing — same invariant the credentials
(ctx context.Context, digest string)
| 126 | // invariant the credentials provider enforces, just surfaced earlier |
| 127 | // with a clearer error. |
| 128 | func (b *Backend) keyFor(ctx context.Context, digest string) (string, error) { |
| 129 | claims, err := robotaccount.InfoFromAuth(ctx) |
| 130 | if err != nil { |
| 131 | return "", err |
| 132 | } |
| 133 | if claims.OrgID == "" { |
| 134 | return "", ErrMissingRequestingOrg |
| 135 | } |
| 136 | return fmt.Sprintf("%s/sha256:%s", claims.OrgID, digest), nil |
| 137 | } |
| 138 | |
| 139 | func (b *Backend) Exists(ctx context.Context, digest string) (bool, error) { |
| 140 | _, err := b.Describe(ctx, digest) |
no outgoing calls