From 9374b7ff77f0c0c91f5940261f1b63e42fdd905f Mon Sep 17 00:00:00 2001 From: Keegan Carruthers-Smith Date: Mon, 19 May 2025 15:56:39 +0200 Subject: [PATCH] index: inline tenant.SrcPrefix It had exactly one call site and the logic was super simple. So I think it is clearer to just inline the logic here. Test Plan: mechanical refactor so just CI. In a future PR I will be adding better test coverage just on this function. --- index/builder.go | 2 +- internal/tenant/shards.go | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 internal/tenant/shards.go diff --git a/index/builder.go b/index/builder.go index d02f531e9..47b8b3eed 100644 --- a/index/builder.go +++ b/index/builder.go @@ -338,7 +338,7 @@ func (o *Options) shardNameVersion(version, n int) string { // If tenant enforcement is enabled and we have tenant/repo IDs, use those to generate the prefix if o.RepositoryDescription.TenantID != 0 && o.RepositoryDescription.ID != 0 && tenant.EnforceTenant() { - prefix = tenant.SrcPrefix(o.RepositoryDescription.TenantID, o.RepositoryDescription.ID) + prefix = fmt.Sprintf("%09d_%09d", o.RepositoryDescription.TenantID, o.RepositoryDescription.ID) } else { prefix = o.RepositoryDescription.Name } diff --git a/internal/tenant/shards.go b/internal/tenant/shards.go deleted file mode 100644 index af4cbb103..000000000 --- a/internal/tenant/shards.go +++ /dev/null @@ -1,9 +0,0 @@ -package tenant - -import "fmt" - -// SrcPrefix returns the Sourcegraph prefix of a shard. We put it here to avoid -// circular dependencies. -func SrcPrefix(tenantID int, repoID uint32) string { - return fmt.Sprintf("%09d_%09d", tenantID, repoID) -}