@@ -147,7 +147,7 @@ type Repository struct {
147
147
// - https://www.rfc-editor.org/rfc/rfc7234#section-5.5
148
148
HandleWarning func (warning Warning )
149
149
150
- // NOTE: Must keep fields in sync with newRepositoryWithOptions function .
150
+ // NOTE: Must keep fields in sync with clone() .
151
151
152
152
// referrersState represents that if the repository supports Referrers API.
153
153
// default: referrersStateUnknown
@@ -186,16 +186,24 @@ func newRepositoryWithOptions(ref registry.Reference, opts *RepositoryOptions) (
186
186
if err := ref .ValidateRepository (); err != nil {
187
187
return nil , err
188
188
}
189
+ repo := (* Repository )(opts ).clone ()
190
+ repo .Reference = ref
191
+ return repo , nil
192
+ }
193
+
194
+ // clone makes a copy of the Repository being careful not to copy non-copyable fields (sync.Mutex and syncutil.Pool types)
195
+ func (r * Repository ) clone () * Repository {
189
196
return & Repository {
190
- Client : opts .Client ,
191
- Reference : ref ,
192
- PlainHTTP : opts .PlainHTTP ,
193
- SkipReferrersGC : opts .SkipReferrersGC ,
194
- ManifestMediaTypes : slices .Clone (opts .ManifestMediaTypes ),
195
- TagListPageSize : opts .TagListPageSize ,
196
- ReferrerListPageSize : opts .ReferrerListPageSize ,
197
- MaxMetadataBytes : opts .MaxMetadataBytes ,
198
- }, nil
197
+ Client : r .Client ,
198
+ Reference : r .Reference ,
199
+ PlainHTTP : r .PlainHTTP ,
200
+ ManifestMediaTypes : slices .Clone (r .ManifestMediaTypes ),
201
+ TagListPageSize : r .TagListPageSize ,
202
+ ReferrerListPageSize : r .ReferrerListPageSize ,
203
+ MaxMetadataBytes : r .MaxMetadataBytes ,
204
+ SkipReferrersGC : r .SkipReferrersGC ,
205
+ HandleWarning : r .HandleWarning ,
206
+ }
199
207
}
200
208
201
209
// SetReferrersCapability indicates the Referrers API capability of the remote
@@ -803,10 +811,10 @@ func (s *blobStore) Mount(ctx context.Context, desc ocispec.Descriptor, fromRepo
803
811
// sibling returns a blob store for another repository in the same
804
812
// registry.
805
813
func (s * blobStore ) sibling (otherRepoName string ) * blobStore {
806
- otherRepo := * s .repo
814
+ otherRepo := s .repo . clone ()
807
815
otherRepo .Reference .Repository = otherRepoName
808
816
return & blobStore {
809
- repo : & otherRepo ,
817
+ repo : otherRepo ,
810
818
}
811
819
}
812
820
0 commit comments