-
Notifications
You must be signed in to change notification settings - Fork 22
/
resource.go
34 lines (27 loc) · 1.3 KB
/
resource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
package npmaccess
import (
"github.com/open-component-model/ocm/pkg/contexts/ocm"
access "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/npm"
"github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc"
"github.com/open-component-model/ocm/pkg/contexts/ocm/cpi"
"github.com/open-component-model/ocm/pkg/contexts/ocm/elements/artifactaccess/genericaccess"
"github.com/open-component-model/ocm/pkg/contexts/ocm/resourcetypes"
)
const TYPE = resourcetypes.NPM_PACKAGE
func Access[M any, P compdesc.ArtifactMetaPointer[M]](ctx ocm.Context, meta P, registry, pkg, version string) cpi.ArtifactAccess[M] {
if meta.GetType() == "" {
meta.SetType(TYPE)
}
spec := access.New(registry, pkg, version)
// is global access, must work, otherwise there is an error in the lib.
return genericaccess.MustAccess(ctx, meta, spec)
}
func ResourceAccess(ctx ocm.Context, meta *cpi.ResourceMeta, registry, pkg, version string) cpi.ResourceAccess {
return Access(ctx, meta, registry, pkg, version)
}
func SourceAccess(ctx ocm.Context, meta *cpi.SourceMeta, registry, pkg, version string) cpi.SourceAccess {
return Access(ctx, meta, registry, pkg, version)
}