@@ -157,10 +157,11 @@ func (s *Store) Exists(ctx context.Context, target ocispec.Descriptor) (bool, er
157
157
158
158
// Delete deletes the content matching the descriptor from the store. Delete may
159
159
// fail on certain systems (i.e. NTFS), if there is a process (i.e. an unclosed
160
- // Reader) using target. If s.AutoGC is set to true, Delete will recursively
161
- // remove the dangling blobs caused by the current delete. If s.AutoDeleteReferrers
162
- // is set to true, Delete will recursively remove the referrers of the manifests
163
- // being deleted.
160
+ // Reader) using target.
161
+ // - If s.AutoGC is set to true, Delete will recursively
162
+ // remove the dangling blobs caused by the current delete.
163
+ // - If s.AutoDeleteReferrers is set to true, Delete will recursively remove
164
+ // the referrers of the manifests being deleted.
164
165
func (s * Store ) Delete (ctx context.Context , target ocispec.Descriptor ) error {
165
166
s .sync .Lock ()
166
167
defer s .sync .Unlock ()
@@ -220,8 +221,17 @@ func (s *Store) delete(ctx context.Context, target ocispec.Descriptor) ([]ocispe
220
221
return danglings , nil
221
222
}
222
223
223
- // Tag tags a descriptor with a reference string.
224
- // reference should be a valid tag (e.g. "latest").
224
+ // Tag associates a reference string (e.g. "latest") with the descriptor.
225
+ // The reference string is recorded in the "org.opencontainers.image.ref.name"
226
+ // annotation of the descriptor. When saved, the updated descriptor is persisted
227
+ // in the `index.json` file.
228
+ //
229
+ // - If the same reference string is tagged multiple times on different
230
+ // descriptors, the descriptor from the last call will be stored.
231
+ // - If the same descriptor is tagged multiple times with different reference
232
+ // strings, multiple copies of the descriptor with different reference tags
233
+ // will be stored in the `index.json` file.
234
+ //
225
235
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.1/image-layout.md#indexjson-file
226
236
func (s * Store ) Tag (ctx context.Context , desc ocispec.Descriptor , reference string ) error {
227
237
s .sync .RLock ()
@@ -260,11 +270,11 @@ func (s *Store) tag(ctx context.Context, desc ocispec.Descriptor, reference stri
260
270
return nil
261
271
}
262
272
263
- // Resolve resolves a reference to a descriptor. If the reference to be resolved
264
- // is a tag, the returned descriptor will be a full descriptor declared by
265
- // github.com/opencontainers/image-spec/specs-go/v1. If the reference is a
266
- // digest the returned descriptor will be a plain descriptor (containing only
267
- // the digest, media type and size).
273
+ // Resolve resolves a reference to a descriptor.
274
+ // - If the reference to be resolved is a tag, the returned descriptor will be
275
+ // a full descriptor declared by github.com/opencontainers/image-spec/specs-go/v1.
276
+ // - If the reference is a digest, the returned descriptor will be a
277
+ // plain descriptor (containing only the digest, media type and size).
268
278
func (s * Store ) Resolve (ctx context.Context , reference string ) (ocispec.Descriptor , error ) {
269
279
s .sync .RLock ()
270
280
defer s .sync .RUnlock ()
@@ -290,6 +300,13 @@ func (s *Store) Resolve(ctx context.Context, reference string) (ocispec.Descript
290
300
return desc , nil
291
301
}
292
302
303
+ // Untag disassociates a reference string from its descriptor.
304
+ // When saved, the descriptor entry cotanining the reference in the
305
+ // "org.opencontainers.image.ref.name" annotation is removed from the
306
+ // `index.json` file.
307
+ // The actual content identified by the descriptor is NOT deleted.
308
+ //
309
+ // Reference: https://github.com/opencontainers/image-spec/blob/v1.1.1/image-layout.md#indexjson-file
293
310
func (s * Store ) Untag (ctx context.Context , reference string ) error {
294
311
if reference == "" {
295
312
return errdef .ErrMissingReference
0 commit comments