@@ -11,6 +11,7 @@ import (
11
11
"github.com/mandelsoft/goutils/sliceutils"
12
12
"github.com/opencontainers/go-digest"
13
13
14
+ cfgctx "ocm.software/ocm/api/config"
14
15
"ocm.software/ocm/api/oci"
15
16
"ocm.software/ocm/api/oci/artdesc"
16
17
"ocm.software/ocm/api/oci/extensions/repositories/artifactset"
@@ -23,10 +24,13 @@ import (
23
24
"ocm.software/ocm/api/ocm/extensions/accessmethods/localociblob"
24
25
"ocm.software/ocm/api/ocm/extensions/accessmethods/ociartifact"
25
26
"ocm.software/ocm/api/ocm/extensions/accessmethods/ociblob"
27
+ "ocm.software/ocm/api/ocm/extensions/accessmethods/relativeociref"
26
28
"ocm.software/ocm/api/ocm/extensions/attrs/compatattr"
27
29
"ocm.software/ocm/api/ocm/extensions/attrs/keepblobattr"
28
30
"ocm.software/ocm/api/ocm/extensions/attrs/mapocirepoattr"
31
+ "ocm.software/ocm/api/ocm/extensions/attrs/preferrelativeattr"
29
32
storagecontext "ocm.software/ocm/api/ocm/extensions/blobhandler/handlers/oci"
33
+ "ocm.software/ocm/api/ocm/extensions/blobhandler/handlers/oci/ocirepo/config"
30
34
"ocm.software/ocm/api/utils/accessobj"
31
35
"ocm.software/ocm/api/utils/blobaccess/blobaccess"
32
36
)
@@ -226,6 +230,14 @@ func (b *artifactHandler) StoreBlob(blob cpi.BlobAccess, artType, hint string, g
226
230
227
231
keep := keepblobattr .Get (ctx .GetContext ())
228
232
233
+ opts , _ := cfgctx.GetConfigured [config.UploadOptions ](ctx .GetContext ())
234
+ if opts == nil {
235
+ opts = & config.UploadOptions {}
236
+ }
237
+ // this attribute (only if set) overrides the enabling set in the
238
+ // config.
239
+ preferrelativeattr .ApplyTo (ctx .GetContext (), & opts .PreferRelativeAccess )
240
+
229
241
if m , ok := blob .(blobaccess.AnnotatedBlobAccess [accspeccpi.AccessMethodView ]); ok {
230
242
// prepare for optimized point to point implementation
231
243
log .Debug ("oci artifact handler with ocm access source" ,
@@ -340,6 +352,10 @@ func (b *artifactHandler) StoreBlob(blob cpi.BlobAccess, artType, hint string, g
340
352
if tag != "" {
341
353
tag = ":" + tag
342
354
}
355
+ if opts .PreferRelativeAccessFor (base ) {
356
+ ref := namespace .GetNamespace () + tag + version
357
+ return relativeociref .New (ref ), nil
358
+ }
343
359
ref := scheme + path .Join (base , namespace .GetNamespace ()) + tag + version
344
360
return ociartifact .New (ref ), nil
345
361
}
0 commit comments