Skip to content

Commit

Permalink
Merge branch 'main' into docs/release-process
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf authored Jan 29, 2025
2 parents 82e65ec + f8470dd commit 377aca3
Show file tree
Hide file tree
Showing 46 changed files with 196 additions and 80 deletions.
2 changes: 2 additions & 0 deletions api/helper/builder/ocm_comparch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"ocm.software/ocm/api/utils/accessobj"
)

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
const T_COMPARCH = "component archive"

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (b *Builder) ComponentArchive(path string, fmt accessio.FileFormat, name, vers string, f ...func()) {
r, err := comparch.Open(b.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, path, 0o777, accessio.PathFileSystem(b.FileSystem()))
b.failOn(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ import (
common "ocm.software/ocm/api/utils/misc"
)

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func init() {
cpi.RegisterBlobHandler(NewBlobHandler(), cpi.ForRepo(cpi.CONTEXT_TYPE, comparch.Type))
}

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// blobHandler is the default handling to store local blobs as local blobs.
type blobHandler struct{}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func NewBlobHandler() cpi.BlobHandler {
return &blobHandler{}
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (b *blobHandler) StoreBlob(blob cpi.BlobAccess, artType, hint string, global cpi.AccessSpec, ctx cpi.StorageContext) (cpi.AccessSpec, error) {
ocmctx, ok := ctx.(storagecontext.StorageContext)
if !ok {
Expand Down
30 changes: 30 additions & 0 deletions api/ocm/extensions/repositories/comparch/componentarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
type _componentVersionAccess = cpi.ComponentVersionAccess

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// ComponentArchive is the go representation for a component artifact.
type ComponentArchive struct {
_componentVersionAccess
Expand All @@ -31,6 +33,7 @@ type ComponentArchive struct {
nonref cpi.Repository
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// New returns a new representation based element.
func New(ctx cpi.Context, acc accessobj.AccessMode, fs vfs.FileSystem, setup accessobj.Setup, closer accessobj.Closer, mode vfs.FileMode) (*ComponentArchive, error) {
obj, err := accessobj.NewAccessObject(accessObjectInfo, acc, fs, setup, closer, mode)
Expand All @@ -41,6 +44,7 @@ func New(ctx cpi.Context, acc accessobj.AccessMode, fs vfs.FileSystem, setup acc
return _Wrap(ctx, obj, spec, err)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func _Wrap(ctx cpi.ContextProvider, obj *accessobj.AccessObject, spec *RepositorySpec, err error) (*ComponentArchive, error) {
if err != nil {
return nil, err
Expand All @@ -67,41 +71,50 @@ func _Wrap(ctx cpi.ContextProvider, obj *accessobj.AccessObject, spec *Repositor

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
var _ cpi.ComponentVersionAccess = &ComponentArchive{}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *ComponentArchive) Close() error {
return c.main.Close()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *ComponentArchive) IsReadOnly() bool {
return c.container.IsReadOnly()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *ComponentArchive) SetReadOnly() {
c.container.SetReadOnly()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// Repository returns a non referencing repository which does not
// close the archive.
func (c *ComponentArchive) Repository() cpi.Repository {
return c.nonref
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// AsRepository returns a repository view closing the archive.
func (c *ComponentArchive) AsRepository() cpi.Repository {
return c.main
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *ComponentArchive) SetName(n string) {
c.GetDescriptor().Name = n
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *ComponentArchive) SetVersion(v string) {
c.GetDescriptor().Version = v
}

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
type componentArchiveContainer struct {
ctx cpi.Context
base repocpi.ComponentVersionAccessBridge
Expand All @@ -110,42 +123,52 @@ type componentArchiveContainer struct {
repo cpi.Repository
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
var _ repocpi.ComponentVersionAccessImpl = (*componentArchiveContainer)(nil)

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) SetBridge(base repocpi.ComponentVersionAccessBridge) {
c.base = base
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) GetParentBridge() repocpi.ComponentAccessBridge {
return nil
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) Close() error {
var list errors.ErrorList
_, err := c.Update()
return list.Add(err, c.fsacc.Close()).Result()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) GetContext() cpi.Context {
return c.ctx
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) Repository() cpi.Repository {
return c.repo
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) IsReadOnly() bool {
return c.fsacc.IsReadOnly()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) SetReadOnly() {
c.fsacc.SetReadOnly()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) Update() (bool, error) {
return c.fsacc.Update()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) SetDescriptor(cd *compdesc.ComponentDescriptor) (bool, error) {
if c.fsacc.IsReadOnly() {
return false, accessobj.ErrReadOnly
Expand All @@ -155,25 +178,30 @@ func (c *componentArchiveContainer) SetDescriptor(cd *compdesc.ComponentDescript
return c.fsacc.Update()
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) GetDescriptor() *compdesc.ComponentDescriptor {
if c.fsacc.IsReadOnly() {
return c.fsacc.GetState().GetOriginalState().(*compdesc.ComponentDescriptor)
}
return c.fsacc.GetState().GetState().(*compdesc.ComponentDescriptor)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) GetBlob(name string) (cpi.DataAccess, error) {
return c.fsacc.GetBlobDataByName(name)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) GetStorageContext() cpi.StorageContext {
return ocmhdlr.New(c.Repository(), c.base.GetName(), &BlobSink{c.fsacc}, Type)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
type BlobSink struct {
Sink ocicpi.BlobSink
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (s *BlobSink) AddBlob(blob blobaccess.BlobAccess) (string, error) {
err := s.Sink.AddBlob(blob)
if err != nil {
Expand All @@ -182,6 +210,7 @@ func (s *BlobSink) AddBlob(blob blobaccess.BlobAccess) (string, error) {
return blob.Digest().String(), nil
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) AddBlob(blob cpi.BlobAccess, refName string, global cpi.AccessSpec) (cpi.AccessSpec, error) {
if blob == nil {
return nil, errors.New("a resource has to be defined")
Expand All @@ -193,6 +222,7 @@ func (c *componentArchiveContainer) AddBlob(blob cpi.BlobAccess, refName string,
return localblob.New(common.DigestToFileName(blob.Digest()), refName, blob.MimeType(), global), nil
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (c *componentArchiveContainer) AccessMethod(a cpi.AccessSpec, cv refmgmt.ExtendedAllocatable) (cpi.AccessMethod, error) {
if a.GetKind() == localblob.Type || a.GetKind() == localfsblob.Type {
accessSpec, err := c.GetContext().AccessSpecForSpec(a)
Expand Down
17 changes: 17 additions & 0 deletions api/ocm/extensions/repositories/comparch/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ import (
"ocm.software/ocm/api/utils/accessobj"
)

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// ComponentDescriptorFileName is the name of the component-descriptor file.
const ComponentDescriptorFileName = compdesc.ComponentDescriptorFileName

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// BlobsDirectoryName is the name of the blob directory in the tar.
const BlobsDirectoryName = "blobs"

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
var accessObjectInfo = &accessobj.DefaultAccessObjectInfo{
DescriptorFileName: ComponentDescriptorFileName,
ObjectTypeName: "component archive",
Expand All @@ -28,13 +31,16 @@ var accessObjectInfo = &accessobj.DefaultAccessObjectInfo{
DescriptorValidator: validateDescriptor,
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func validateDescriptor(data []byte) error {
_, err := compdesc.Decode(data)
return err
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
type Object = ComponentArchive

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
type FormatHandler interface {
accessio.Option

Expand All @@ -45,10 +51,12 @@ type FormatHandler interface {
Write(obj *Object, path string, opts accessio.Options, mode vfs.FileMode) error
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
type formatHandler struct {
accessobj.FormatHandler
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
var (
FormatDirectory = RegisterFormat(accessobj.FormatDirectory)
FormatTAR = RegisterFormat(accessobj.FormatTAR)
Expand All @@ -57,11 +65,13 @@ var (

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
var (
fileFormats = map[accessio.FileFormat]*formatHandler{}
lock sync.RWMutex
)

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func RegisterFormat(f accessobj.FormatHandler) *formatHandler {
lock.Lock()
defer lock.Unlock()
Expand All @@ -70,12 +80,14 @@ func RegisterFormat(f accessobj.FormatHandler) *formatHandler {
return h
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func GetFormats() []string {
lock.RLock()
defer lock.RUnlock()
return accessio.GetFormatsFor(fileFormats)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func GetFormat(name accessio.FileFormat) FormatHandler {
lock.RLock()
defer lock.RUnlock()
Expand All @@ -88,6 +100,7 @@ func GetFormat(name accessio.FileFormat) FormatHandler {

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func Open(ctx cpi.ContextProvider, acc accessobj.AccessMode, path string, mode vfs.FileMode, olist ...accessio.Option) (*Object, error) {
opts, err := accessio.AccessOptions(&accessio.StandardOptions{PathFileSystem: vfsattr.Get(ctx.OCMContext())}, olist...)
if err != nil {
Expand All @@ -107,6 +120,7 @@ func Open(ctx cpi.ContextProvider, acc accessobj.AccessMode, path string, mode v
return h.Open(ctx, acc, path, o)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func Create(ctx cpi.ContextProvider, acc accessobj.AccessMode, path string, mode vfs.FileMode, opts ...accessio.Option) (*Object, error) {
o, err := accessio.AccessOptions(nil, opts...)
if err != nil {
Expand All @@ -122,6 +136,7 @@ func Create(ctx cpi.ContextProvider, acc accessobj.AccessMode, path string, mode

////////////////////////////////////////////////////////////////////////////////

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (h *formatHandler) Open(ctx cpi.ContextProvider, acc accessobj.AccessMode, path string, opts accessio.Options) (*Object, error) {
obj, err := h.FormatHandler.Open(accessObjectInfo, acc, path, opts)
if err != nil {
Expand All @@ -131,6 +146,7 @@ func (h *formatHandler) Open(ctx cpi.ContextProvider, acc accessobj.AccessMode,
return _Wrap(ctx, obj, spec, err)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
func (h *formatHandler) Create(ctx cpi.ContextProvider, path string, opts accessio.Options, mode vfs.FileMode) (*Object, error) {
obj, err := h.FormatHandler.Create(accessObjectInfo, path, opts, mode)
if err != nil {
Expand All @@ -140,6 +156,7 @@ func (h *formatHandler) Create(ctx cpi.ContextProvider, path string, opts access
return _Wrap(ctx, obj, spec, err)
}

// Deprecated: Component Archive (CA) - https://kubernetes.slack.com/archives/C05UWBE8R1D/p1734357630853489
// WriteToFilesystem writes the current object to a filesystem.
func (h *formatHandler) Write(obj *Object, path string, opts accessio.Options, mode vfs.FileMode) error {
return h.FormatHandler.Write(obj.container.fsacc.Access(), path, opts, mode)
Expand Down
Loading

0 comments on commit 377aca3

Please sign in to comment.