fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

index: remove Options.{TenantID,RepoID} (#954)

These are duplicated with RepositoryDescription. There is exactly one
place we set these values, and in that case we set it in the repository
description as well.

Note: we update some the calls in builder.go for o.IndexOptions.RepoID
to be just o.RepoID. This is to make it consistent with how we access
TenantID. IndexOptions is embedded in that struct (indexArgs) which is
why we can do the shortcut.

Test Plan: go test is sufficient for this change. I will do a larger
round of manual tests soon with all my changes stacked.

+4 -18
+2 -5
cmd/zoekt-sourcegraph-indexserver/index.go
··· 110 110 // nothing needs to be done. 111 111 RepositoryDescription: zoekt.Repository{ 112 112 TenantID: o.TenantID, 113 - ID: o.IndexOptions.RepoID, 113 + ID: o.RepoID, 114 114 Name: o.Name, 115 115 Branches: o.Branches, 116 116 RawConfig: map[string]string{ 117 - "repoid": strconv.Itoa(int(o.IndexOptions.RepoID)), 117 + "repoid": strconv.Itoa(int(o.RepoID)), 118 118 "priority": strconv.FormatFloat(o.Priority, 'g', -1, 64), 119 119 "public": marshalBool(o.Public), 120 120 "fork": marshalBool(o.Fork), ··· 135 135 LanguageMap: o.LanguageMap, 136 136 137 137 ShardMerging: o.ShardMerging, 138 - 139 - TenantID: o.TenantID, 140 - RepoID: o.RepoID, 141 138 } 142 139 } 143 140
+2 -8
index/builder.go
··· 120 120 // 121 121 // Note: heap checking is "best effort", and it's possible for the process to OOM without triggering the heap profile. 122 122 HeapProfileTriggerBytes uint64 123 - 124 - // TenantID is the ID of the tenant this shard belongs to. 125 - TenantID int 126 - 127 - // RepoID is the ID of the repository this shard belongs to. 128 - RepoID uint32 129 123 } 130 124 131 125 // HashOptions contains only the options in Options that upon modification leads to IndexState of IndexStateMismatch during the next index building. ··· 343 337 var prefix string 344 338 345 339 // If tenant enforcement is enabled and we have tenant/repo IDs, use those to generate the prefix 346 - if o.TenantID != 0 && o.RepoID != 0 && tenant.EnforceTenant() { 347 - prefix = tenant.SrcPrefix(o.TenantID, o.RepoID) 340 + if o.RepositoryDescription.TenantID != 0 && o.RepositoryDescription.ID != 0 && tenant.EnforceTenant() { 341 + prefix = tenant.SrcPrefix(o.RepositoryDescription.TenantID, o.RepositoryDescription.ID) 348 342 } else { 349 343 prefix = o.RepositoryDescription.Name 350 344 }
-5
index/merge.go
··· 211 211 opts := Options{ 212 212 IndexDir: dstDir, 213 213 RepositoryDescription: ib.repoList[0], 214 - 215 - // TODO we should remove these fields from Options and just rely on them 216 - // being set by RepositoryDescription. 217 - TenantID: ib.repoList[0].TenantID, 218 - RepoID: ib.repoList[0].ID, 219 214 } 220 215 221 216 shardName := opts.shardNameVersion(ib.indexFormatVersion, 0)