You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update registry cache to (ab)use Data field of Descriptor objects
This allows us to store full descriptors (necessary to implement `Resolve*`), but with a net decrease in the number of fields we have to juggle / keep in sync.
This does mean consumers need to be careful about how they use the `Descriptor` objects we return (esp. WRT `Data`), but it makes it easier for them to then have `Data` available if they want it (which is something I'd like to use in the future). This is a net win anyhow because the upstream objects might've contained `Data` fields so this forces us to deal with them in a sane way we're comfortable with instead of potentially just including them verbatim unintentionally. 🚀
mu sync.Mutex// TODO some kind of per-object/name/digest mutex so we don't request the same object from the upstream registry concurrently (on *top* of our maps mutex)?
36
-
hasmap[string]bool// "repo/name@digest" => true (whether a given repo has the given digest)
typesmap[ociregistry.Digest]string// digest => "mediaType" (most recent *storing* / "cache-miss" lookup wins, in the case of upstream/cross-repo ambiguity)
39
-
datamap[ociregistry.Digest][]byte// digest => data
34
+
mu sync.Mutex// TODO some kind of per-object/name/digest mutex so we don't request the same object from the upstream registry concurrently (on *top* of our maps mutex)?
35
+
hasmap[string]bool// "repo/name@digest" => true (whether a given repo has the given digest)
datamap[ociregistry.Digest]ociregistry.Descriptor// digest => mediaType+size(+data) (most recent *storing* / "cache-miss" lookup wins, in the case of upstream/cross-repo ambiguity)
// make sure we don't return any (big) data fields, now that we know we don't need them for sure (they might exist in the index we queried, but they're also used as an implementation detail in our registry cache code to store the original upstream data)
133
+
m.Data=nil
134
+
// }
135
+
130
136
index.Manifests[i] =m
131
137
seen[string(m.Digest)] =&index.Manifests[i]
132
138
i++
@@ -158,9 +164,13 @@ func normalizeManifestPlatform(ctx context.Context, m *ocispec.Descriptor, r oci
0 commit comments