Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/config/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ toi
toiexecutor
toolset
transportarchive
transferhandler
typehandler
typename
unmarshaller
Expand Down
6 changes: 3 additions & 3 deletions api/credentials/cpi/repotypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func RegisterRepositoryTypeVersions(s RepositoryTypeVersionScheme) {
////////////////////////////////////////////////////////////////////////////////

func NewRepositoryType[I RepositorySpec](name string, opts ...RepositoryOption) RepositoryType {
return descriptivetype.NewTypedObjectTypeObject(runtime.NewVersionedTypedObjectType[RepositorySpec, I](name), opts...)
return descriptivetype.NewVersionedTypedObjectTypeObject(runtime.NewVersionedTypedObjectType[RepositorySpec, I](name), opts...)
}

func NewRepositoryTypeByConverter[I RepositorySpec, V runtime.TypedObject](name string, converter runtime.Converter[I, V], opts ...RepositoryOption) RepositoryType {
return descriptivetype.NewTypedObjectTypeObject(runtime.NewVersionedTypedObjectTypeByConverter[RepositorySpec, I](name, converter), opts...)
return descriptivetype.NewVersionedTypedObjectTypeObject(runtime.NewVersionedTypedObjectTypeByConverter[RepositorySpec, I](name, converter), opts...)
}

func NewRepositoryTypeByFormatVersion(name string, fmt runtime.FormatVersion[RepositorySpec], opts ...RepositoryOption) RepositoryType {
return descriptivetype.NewTypedObjectTypeObject(runtime.NewVersionedTypedObjectTypeByFormatVersion[RepositorySpec](name, fmt), opts...)
return descriptivetype.NewVersionedTypedObjectTypeObject(runtime.NewVersionedTypedObjectTypeByFormatVersion[RepositorySpec](name, fmt), opts...)
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
20 changes: 10 additions & 10 deletions api/credentials/internal/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package internal
import (
"github.com/mandelsoft/goutils/set"

common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

type Repository interface {
Expand All @@ -17,16 +17,16 @@ type Credentials interface {
ExistsProperty(name string) bool
GetProperty(name string) string
PropertyNames() set.Set[string]
Properties() common.Properties
Properties() misc.Properties
}

type DirectCredentials common.Properties
type DirectCredentials misc.Properties

var _ Credentials = (*DirectCredentials)(nil)

func NewCredentials(props common.Properties) DirectCredentials {
func NewCredentials(props misc.Properties) DirectCredentials {
if props == nil {
props = common.Properties{}
props = misc.Properties{}
} else {
props = props.Copy()
}
Expand All @@ -43,21 +43,21 @@ func (c DirectCredentials) GetProperty(name string) string {
}

func (c DirectCredentials) PropertyNames() set.Set[string] {
return common.Properties(c).Names()
return misc.Properties(c).Names()
}

func (c DirectCredentials) Properties() common.Properties {
return common.Properties(c).Copy()
func (c DirectCredentials) Properties() misc.Properties {
return misc.Properties(c).Copy()
}

func (c DirectCredentials) Credentials(Context, ...CredentialsSource) (Credentials, error) {
return c, nil
}

func (c DirectCredentials) Copy() DirectCredentials {
return DirectCredentials(common.Properties(c).Copy())
return DirectCredentials(misc.Properties(c).Copy())
}

func (c DirectCredentials) String() string {
return common.Properties(c).String()
return misc.Properties(c).String()
}
10 changes: 5 additions & 5 deletions api/credentials/internal/repotypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type RepositoryType interface {
descriptivetype.TypedObjectType[RepositorySpec]
descriptivetype.VersionedTypedObjectType[RepositorySpec]
}

type RepositorySpec interface {
Expand All @@ -28,22 +28,22 @@ type (
)

type RepositoryTypeScheme interface {
descriptivetype.TypeScheme[RepositorySpec, RepositoryType]
descriptivetype.VersionedTypeScheme[RepositorySpec, RepositoryType]
}

type _Scheme = descriptivetype.TypeScheme[RepositorySpec, RepositoryType]
type _Scheme = descriptivetype.VersionedTypeScheme[RepositorySpec, RepositoryType]

type repositoryTypeScheme struct {
_Scheme
}

func NewRepositoryTypeScheme(defaultDecoder RepositorySpecDecoder, base ...RepositoryTypeScheme) RepositoryTypeScheme {
scheme := descriptivetype.MustNewDefaultTypeScheme[RepositorySpec, RepositoryType, RepositoryTypeScheme]("Credential provider", nil, &UnknownRepositorySpec{}, true, defaultDecoder, utils.Optional(base...))
scheme := descriptivetype.MustNewDefaultVersionedTypeScheme[RepositorySpec, RepositoryType, RepositoryTypeScheme]("Credential provider", nil, &UnknownRepositorySpec{}, true, defaultDecoder, utils.Optional(base...))
return &repositoryTypeScheme{scheme}
}

func NewStrictRepositoryTypeScheme(base ...RepositoryTypeScheme) runtime.VersionedTypeRegistry[RepositorySpec, RepositoryType] {
scheme := descriptivetype.MustNewDefaultTypeScheme[RepositorySpec, RepositoryType, RepositoryTypeScheme]("Credential provider", nil, nil, false, nil, utils.Optional(base...))
scheme := descriptivetype.MustNewDefaultVersionedTypeScheme[RepositorySpec, RepositoryType, RepositoryTypeScheme]("Credential provider", nil, nil, false, nil, utils.Optional(base...))
return &repositoryTypeScheme{scheme}
}

Expand Down
8 changes: 6 additions & 2 deletions api/oci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ func AsTags(tag string) []string {
}

func StandardOCIRef(host, repository, version string) string {
return fmt.Sprintf("%s%s%s", host, grammar.RepositorySeparator, RelativeOCIRef(repository, version))
}

func RelativeOCIRef(repository, version string) string {
sep := grammar.TagSeparator
i := strings.Index(version, grammar.DigestSeparator)
if i > 1 {
return fmt.Sprintf("%s%s%s%s%s", host, grammar.RepositorySeparator, repository, sep, version)
return fmt.Sprintf("%s%s%s", repository, sep, version)
}
if ok, _ := artdesc.IsDigest(version); ok {
sep = grammar.DigestSeparator
if strings.HasPrefix(version, sep) {
sep = ""
}
}
return fmt.Sprintf("%s%s%s%s%s", host, grammar.RepositorySeparator, repository, sep, version)
return fmt.Sprintf("%s%s%s", repository, sep, version)
}

func IsIntermediate(spec RepositorySpec) bool {
Expand Down
6 changes: 3 additions & 3 deletions api/ocm/cpi/accspeccpi/accesstypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func MustNewAccessSpecMultiFormatVersion(kind string, formats AccessSpecFormatVe
}

func NewAccessSpecType[I AccessSpec](name string, opts ...AccessSpecTypeOption) AccessType {
return flagsetscheme.NewTypedObjectTypeObject[AccessSpec](runtime.NewVersionedTypedObjectType[AccessSpec, I](name), opts...)
return flagsetscheme.NewVersionedTypedObjectTypeObject[AccessSpec](runtime.NewVersionedTypedObjectType[AccessSpec, I](name), opts...)
}

func NewAccessSpecTypeByConverter[I AccessSpec, V runtime.VersionedTypedObject](name string, converter runtime.Converter[I, V], opts ...AccessSpecTypeOption) AccessType {
return flagsetscheme.NewTypedObjectTypeObject[AccessSpec](runtime.NewVersionedTypedObjectTypeByConverter[AccessSpec, I, V](name, converter), opts...)
return flagsetscheme.NewVersionedTypedObjectTypeObject[AccessSpec](runtime.NewVersionedTypedObjectTypeByConverter[AccessSpec, I, V](name, converter), opts...)
}

func NewAccessSpecTypeByFormatVersion(name string, fmt runtime.FormatVersion[AccessSpec], opts ...AccessSpecTypeOption) AccessType {
return flagsetscheme.NewTypedObjectTypeObject[AccessSpec](runtime.NewVersionedTypedObjectTypeByFormatVersion[AccessSpec](name, fmt), opts...)
return flagsetscheme.NewVersionedTypedObjectTypeObject[AccessSpec](runtime.NewVersionedTypedObjectTypeByFormatVersion[AccessSpec](name, fmt), opts...)
}
9 changes: 5 additions & 4 deletions api/ocm/cpi/accspeccpi/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ type (

AccessType = internal.AccessType

AccessMethodImpl = internal.AccessMethodImpl
AccessMethod = internal.AccessMethod
AccessSpec = internal.AccessSpec
AccessSpecRef = internal.AccessSpecRef
AccessMethodImpl = internal.AccessMethodImpl
AccessMethod = internal.AccessMethod
UniformAccessSpecInfo = internal.UniformAccessSpecInfo
AccessSpec = internal.AccessSpec
AccessSpecRef = internal.AccessSpecRef

HintProvider = internal.HintProvider
GlobalAccessProvider = internal.GlobalAccessProvider
Expand Down
3 changes: 3 additions & 0 deletions api/ocm/cpi/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type (
ComponentLister = internal.ComponentLister
ComponentAccess = internal.ComponentAccess
ComponentVersionAccess = internal.ComponentVersionAccess
UniformAccessSpecInfo = internal.UniformAccessSpecInfo
AccessSpec = internal.AccessSpec
AccessSpecDecoder = internal.AccessSpecDecoder
GenericAccessSpec = internal.GenericAccessSpec
Expand Down Expand Up @@ -183,6 +184,8 @@ func ToGenericRepositorySpec(spec RepositorySpec) (*GenericRepositorySpec, error

type AccessSpecRef = internal.AccessSpecRef

var _ AccessSpec = &AccessSpecRef{}

func NewAccessSpecRef(spec AccessSpec) *AccessSpecRef {
return internal.NewAccessSpecRef(spec)
}
Expand Down
6 changes: 6 additions & 0 deletions api/ocm/extensions/accessmethods/compose/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return fmt.Sprintf("Composition blob %s", a.Id)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
}
}

func (_ *AccessSpec) IsLocal(accspeccpi.Context) bool {
return true
}
Expand Down
14 changes: 14 additions & 0 deletions api/ocm/extensions/accessmethods/github/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return fmt.Sprintf("GitHub commit %s[%s]", a.RepoURL, a.Commit)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
u, err := url.Parse(a.RepoURL)
if err != nil {
u = &url.URL{}
}
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Host: u.Hostname(),
Port: u.Port(),
Path: u.Path,
Info: a.Commit,
}
}

func (_ *AccessSpec) IsLocal(accspeccpi.Context) bool {
return false
}
Expand Down
15 changes: 15 additions & 0 deletions api/ocm/extensions/accessmethods/helm/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package helm
import (
"fmt"
"io"
"net/url"
"strings"
"sync"

Expand Down Expand Up @@ -63,6 +64,20 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return fmt.Sprintf("Helm chart %s:%s in repository %s", a.GetChartName(), a.GetVersion(), a.HelmRepository)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
u, err := url.Parse(a.HelmRepository)
if err != nil {
u = &url.URL{}
}
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Host: u.Hostname(),
Port: u.Port(),
Path: u.Path,
Info: a.HelmChart,
}
}

func (a *AccessSpec) IsLocal(ctx accspeccpi.Context) bool {
return false
}
Expand Down
7 changes: 7 additions & 0 deletions api/ocm/extensions/accessmethods/localblob/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return fmt.Sprintf("Local blob %s[%s]", a.LocalReference, a.ReferenceName)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Info: a.LocalReference,
}
}

func (a *AccessSpec) IsLocal(accspeccpi.Context) bool {
return true
}
Expand Down
15 changes: 15 additions & 0 deletions api/ocm/extensions/accessmethods/maven/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package maven

import (
"fmt"
"net/url"

"github.com/mandelsoft/goutils/optionutils"

Expand Down Expand Up @@ -78,6 +79,20 @@ func (a *AccessSpec) Describe(_ accspeccpi.Context) string {
return fmt.Sprintf("Maven package '%s' in repository '%s' path '%s'", a.Coordinates.String(), a.RepoUrl, a.Coordinates.FilePath())
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
u, err := url.Parse(a.RepoUrl)
if err != nil {
u = &url.URL{}
}
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Host: u.Hostname(),
Port: u.Port(),
Path: u.Path,
Info: a.Coordinates.String(),
}
}

func (_ *AccessSpec) IsLocal(accspeccpi.Context) bool {
return false
}
Expand Down
6 changes: 6 additions & 0 deletions api/ocm/extensions/accessmethods/none/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return "none"
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
}
}

func (s *AccessSpec) IsLocal(context accspeccpi.Context) bool {
return false
}
Expand Down
15 changes: 15 additions & 0 deletions api/ocm/extensions/accessmethods/npm/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package npm

import (
"fmt"
"net/url"

"ocm.software/ocm/api/ocm/cpi/accspeccpi"
"ocm.software/ocm/api/utils/blobaccess/blobaccess"
Expand Down Expand Up @@ -49,6 +50,20 @@ func (a *AccessSpec) Describe(_ accspeccpi.Context) string {
return fmt.Sprintf("NPM package %s:%s in registry %s", a.Package, a.Version, a.Registry)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
u, err := url.Parse(a.Registry)
if err != nil {
u = &url.URL{}
}
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Host: u.Hostname(),
Port: u.Port(),
Path: u.Path,
Info: a.GetReferenceHint(nil),
}
}

func (_ *AccessSpec) IsLocal(accspeccpi.Context) bool {
return false
}
Expand Down
19 changes: 19 additions & 0 deletions api/ocm/extensions/accessmethods/ociartifact/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return fmt.Sprintf("OCI artifact %s", a.ImageReference)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
ref, _ := oci.ParseRef(a.ImageReference)
host, port := ref.HostPort()

r := ref.Repository
if ref.Tag != nil {
r += ":" + *ref.Tag
}
if ref.Digest != nil {
r += "@" + ref.Digest.String()
}
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Host: host,
Port: port,
Info: r,
}
}

func (_ *AccessSpec) IsLocal(accspeccpi.Context) bool {
return false
}
Expand Down
17 changes: 17 additions & 0 deletions api/ocm/extensions/accessmethods/ociblob/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ociblob
import (
"fmt"
"io"
"strings"
"sync"

"github.com/mandelsoft/goutils/errors"
Expand Down Expand Up @@ -62,6 +63,22 @@ func (a *AccessSpec) Describe(ctx accspeccpi.Context) string {
return fmt.Sprintf("OCI blob %s in repository %s", a.Digest, a.Reference)
}

func (a *AccessSpec) Info(ctx accspeccpi.Context) *accspeccpi.UniformAccessSpecInfo {
segs := strings.Split(a.Reference, "/")
comps := strings.Split(segs[0], ":")
port := ""
if len(comps) > 1 {
port = comps[1]
}
return &accspeccpi.UniformAccessSpecInfo{
Kind: Type,
Host: comps[0],
Port: port,
Path: strings.Join(segs[1:], "/"),
Info: a.Digest.String(),
}
}

func (s *AccessSpec) IsLocal(context accspeccpi.Context) bool {
return false
}
Expand Down
Loading
Loading