Skip to content

Commit 31c3896

Browse files
committed
adjusted according to review comments
Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
1 parent 8ccd71f commit 31c3896

10 files changed

Lines changed: 45 additions & 70 deletions

File tree

api/config/utils.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

api/oci/interface.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ type (
3838
BlobAccess = internal.BlobAccess
3939
DataAccess = internal.DataAccess
4040
ConsumerIdentityProvider = internal.ConsumerIdentityProvider
41-
42-
UniformRepositorySpecProvider = internal.UniformRepositorySpecProvider
4341
)
4442

4543
func DefaultContext() internal.Context {

api/oci/internal/repotypes.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ type IntermediateRepositorySpecAspect interface {
2020
IsIntermediate() bool
2121
}
2222

23-
type UniformRepositorySpecProvider interface {
24-
UniformRepositorySpec() *UniformRepositorySpec
25-
}
26-
2723
type RepositorySpec interface {
2824
runtime.VersionedTypedObject
29-
UniformRepositorySpecProvider
3025

3126
Name() string
27+
UniformRepositorySpec() *UniformRepositorySpec
3228
Repository(Context, credentials.Credentials) (Repository, error)
3329

3430
Validate(Context, credentials.Credentials, ...credentials.UsageContext) error

api/ocm/extensions/accessmethods/relativeociref/method.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,10 @@ func (a *AccessSpec) GetOCIReference(cv accspeccpi.ComponentVersionAccess) (stri
8484
if o, ok := accspeccpi.GetAccessMethodImplementation(m).(ociartifact.OCIArtifactReferenceProvider); ok {
8585
im, err := o.GetOCIReference(cv)
8686
if err == nil {
87-
if s, ok := cv.Repository().GetSpecification().(oci.UniformRepositorySpecProvider); ok {
88-
host := s.UniformRepositorySpec().Host
89-
// not supported for fake repos
90-
if host != "" {
91-
im = host + "/" + im
92-
}
87+
spec := cv.Repository().GetSpecification().AsUniformSpec(cv.GetContext())
88+
// not supported for fake repos
89+
if spec.Host != "" {
90+
im = spec.Host + "/" + im
9391
}
9492
}
9593
return im, err

api/ocm/extensions/attrs/preferrelativeattr/attr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
)
99

1010
const (
11-
ATTR_KEY = "github.com/mandelsoft/ocm/preferrelativeaccess"
1211
ATTR_SHORT = "preferrelativeaccess"
12+
ATTR_KEY = "ocm.software/ocm/oci/" + ATTR_SHORT
1313
)
1414

1515
func init() {

api/ocm/extensions/blobhandler/handlers/oci/ocirepo/blobhandler.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/mandelsoft/goutils/sliceutils"
1212
"github.com/opencontainers/go-digest"
1313

14-
cfgctx "ocm.software/ocm/api/config"
14+
cfgcpi "ocm.software/ocm/api/config/cpi"
1515
"ocm.software/ocm/api/oci"
1616
"ocm.software/ocm/api/oci/artdesc"
1717
"ocm.software/ocm/api/oci/extensions/repositories/artifactset"
@@ -230,10 +230,11 @@ func (b *artifactHandler) StoreBlob(blob cpi.BlobAccess, artType, hint string, g
230230

231231
keep := keepblobattr.Get(ctx.GetContext())
232232

233-
opts, _ := cfgctx.GetConfigured[config.UploadOptions](ctx.GetContext())
234-
if opts == nil {
235-
opts = &config.UploadOptions{}
233+
opts := &config.UploadOptions{}
234+
if err := cfgcpi.NewUpdater(ctx.GetContext().ConfigContext(), opts).Update(); err != nil {
235+
return nil, err
236236
}
237+
237238
// this attribute (only if set) overrides the enabling set in the
238239
// config.
239240
preferrelativeattr.ApplyTo(ctx.GetContext(), &opts.PreferRelativeAccess)

api/ocm/extensions/blobhandler/handlers/oci/ocirepo/config/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
const (
11-
ConfigType = "local.oci.uploader" + cfgcpi.OCM_CONFIG_TYPE_SUFFIX
11+
ConfigType = "oci.uploader" + cfgcpi.OCM_CONFIG_TYPE_SUFFIX
1212
ConfigTypeV1 = ConfigType + runtime.VersionSeparator + "v1"
1313
)
1414

docs/reference/ocm.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,6 @@ The value can be a simple type or a JSON/YAML string for complex values
238238

239239
Directory to look for OCM plugin executables.
240240

241-
- <code>github.com/mandelsoft/ocm/preferrelativeaccess</code> [<code>preferrelativeaccess</code>]: *bool*
242-
243-
If an artifact blob is uploaded to the technical repository
244-
used as OCM repository, the uploader should prefer to return
245-
a relative access method.
246-
247241
- <code>github.com/mandelsoft/ocm/rootcerts</code> [<code>rootcerts</code>]: *JSON*
248242

249243
General root certificate settings given as JSON document with the following
@@ -312,6 +306,12 @@ The value can be a simple type or a JSON/YAML string for complex values
312306
the backend and descriptor updated will be persisted on AddVersion
313307
or closing a provided existing component version.
314308

309+
- <code>ocm.software/ocm/oci/preferrelativeaccess</code> [<code>preferrelativeaccess</code>]: *bool*
310+
311+
If an artifact blob is uploaded to the technical repository
312+
used as OCM repository, the uploader should prefer to return
313+
a relative access method.
314+
315315
- <code>ocm.software/signing/sigstore</code> [<code>sigstore</code>]: *sigstore config* Configuration to use for sigstore based signing.
316316

317317
The following fields are used.

docs/reference/ocm_attributes.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ OCM library:
130130

131131
Directory to look for OCM plugin executables.
132132

133-
- <code>github.com/mandelsoft/ocm/preferrelativeaccess</code> [<code>preferrelativeaccess</code>]: *bool*
134-
135-
If an artifact blob is uploaded to the technical repository
136-
used as OCM repository, the uploader should prefer to return
137-
a relative access method.
138-
139133
- <code>github.com/mandelsoft/ocm/rootcerts</code> [<code>rootcerts</code>]: *JSON*
140134

141135
General root certificate settings given as JSON document with the following
@@ -204,6 +198,12 @@ OCM library:
204198
the backend and descriptor updated will be persisted on AddVersion
205199
or closing a provided existing component version.
206200

201+
- <code>ocm.software/ocm/oci/preferrelativeaccess</code> [<code>preferrelativeaccess</code>]: *bool*
202+
203+
If an artifact blob is uploaded to the technical repository
204+
used as OCM repository, the uploader should prefer to return
205+
a relative access method.
206+
207207
- <code>ocm.software/signing/sigstore</code> [<code>sigstore</code>]: *sigstore config* Configuration to use for sigstore based signing.
208208

209209
The following fields are used.

docs/reference/ocm_configfile.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,6 @@ The following configuration types are supported:
168168

169169
At least the given values must be present in the certificate
170170
to be accepted for a successful signature validation.
171-
- <code>local.oci.uploader.config.ocm.software</code>
172-
The config type <code>local.oci.uploader.config.ocm.software</code> can be used to set some
173-
configurations for the implicit OCI artifact upload for OCI based OCM repositories.
174-
175-
<pre>
176-
type: local.oci.uploader.config.ocm.software
177-
preferRelativeAccess: true # use relative access methods for given target repositories.
178-
repositories:
179-
- localhost:5000
180-
</pre>
181-
182-
If <code>preferRelativeAccess</code> is set to <code>true</code> the
183-
OCI uploader for OCI based OCM repositories does not use the
184-
OCI repository to create absolute OCI access methods
185-
if the target repository is in the <code>repositories</code> list.
186-
Instead, a relative <code>relativeOciReference</code> access method
187-
is created.
188-
If this list is empty, all uploads are handled this way.
189-
190-
If the global attribute <code>preferrelativeaccess</code>
191-
is configured, it overrides the <code>preferRelativeAccess</code> setting.
192171
- <code>logging.config.ocm.software</code>
193172
The config type <code>logging.config.ocm.software</code> can be used to configure the logging
194173
aspect of a dedicated context type:
@@ -254,6 +233,27 @@ The following configuration types are supported:
254233
&lt;name>: &lt;OCI registry specification>
255234
...
256235
</pre>
236+
- <code>oci.uploader.config.ocm.software</code>
237+
The config type <code>oci.uploader.config.ocm.software</code> can be used to set some
238+
configurations for the implicit OCI artifact upload for OCI based OCM repositories.
239+
240+
<pre>
241+
type: oci.uploader.config.ocm.software
242+
preferRelativeAccess: true # use relative access methods for given target repositories.
243+
repositories:
244+
- localhost:5000
245+
</pre>
246+
247+
If <code>preferRelativeAccess</code> is set to <code>true</code> the
248+
OCI uploader for OCI based OCM repositories does not use the
249+
OCI repository to create absolute OCI access methods
250+
if the target repository is in the <code>repositories</code> list.
251+
Instead, a relative <code>relativeOciReference</code> access method
252+
is created.
253+
If this list is empty, all uploads are handled this way.
254+
255+
If the global attribute <code>preferrelativeaccess</code>
256+
is configured, it overrides the <code>preferRelativeAccess</code> setting.
257257
- <code>ocm.cmd.config.ocm.software</code>
258258
The config type <code>ocm.cmd.config.ocm.software</code> can be used to
259259
configure predefined aliases for dedicated OCM repositories and

0 commit comments

Comments
 (0)