Skip to content
quarry Artifact [f727e93cc1]
Login

Artifact [f727e93cc1]

Artifact f727e93cc14a6263c3d7a1a589cd1ab0025610aa2a401273be8997f4b51b016d:


package ops

import "context"

type ctxArchiveReaderKey struct{}

// WithArchiveReader marks a request as one a sync-scoped credential is
// reading a repository's archive on, and names that repository. The
// forge's door sets it only for the archive route itself, so a gate
// that finds it knows the credential reaches exactly that one route.
func WithArchiveReader(ctx context.Context, repo string) context.Context {
	return context.WithValue(ctx, ctxArchiveReaderKey{}, repo)
}

// ArchiveReaderOf is the repository WithArchiveReader named, or "".
func ArchiveReaderOf(ctx context.Context) string {
	r, _ := ctx.Value(ctxArchiveReaderKey{}).(string)
	return r
}