ctf

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ArtefactDescriptorFileName = "artefact-descriptor.yaml"

ArtefactDescriptorFileName is the name of the artefact-descriptor file.

View Source
const BlobsDirectoryName = "blobs"

BlobsDirectoryName is the name of the blob directory in the tar.

View Source
const ComponentDescriptorFileName = "component-descriptor.yaml"

ComponentDescriptorFileName is the name of the component-descriptor file.

View Source
const ManifestFileName = "manifest.json"

ManifestFileName is the name of the manifest json file.

Variables

View Source
var ErrBlobResolverNotDefinedError = errors.New("BlobResolverNotDefined")
View Source
var ErrNotFoundError = errors.New("ComponentDescriptorNotFound")
View Source
var ErrUnsupportedResolveType = errors.New("UnsupportedResolveType")

Functions

func BlobPath

func BlobPath(name string) string

BlobPath returns the path to the blob for a given name.

func ExtractTarToFs

func ExtractTarToFs(fs vfs.FileSystem, in io.Reader) error

ExtractTarToFs writes a tar stream to a filesystem.

Types

type AggregatedBlobResolver

type AggregatedBlobResolver struct {
	// contains filtered or unexported fields
}

AggregatedBlobResolver combines multiple blob resolver. Is automatically picks the right resolver based on the resolvers type information. If multiple resolvers match, the first matching resolver is used.

func NewAggregatedBlobResolver

func NewAggregatedBlobResolver(resolvers ...BlobResolver) (*AggregatedBlobResolver, error)

NewAggregatedBlobResolver creates a new aggregated resolver. Note that only typed resolvers can be added. An error is thrown if a resolver does not implement the supported types.

func (*AggregatedBlobResolver) Add

func (a *AggregatedBlobResolver) Add(resolvers ...BlobResolver) error

Add adds multiple resolvers to the aggregator. Only typed resolvers can be added. An error is thrown if a resolver does not implement the supported types function.

func (*AggregatedBlobResolver) Info

func (*AggregatedBlobResolver) Resolve

func (a *AggregatedBlobResolver) Resolve(ctx context.Context, res v2.Resource, writer io.Writer) (*BlobInfo, error)

type ArchiveFormat

type ArchiveFormat string

ArchiveFormat describes the format of a component archive. A archive can currently be defined in a filesystem, as tar or as gzipped tar.

const (
	ArchiveFormatFilesystem ArchiveFormat = "fs"
	ArchiveFormatTar        ArchiveFormat = "tar"
	ArchiveFormatTarGzip    ArchiveFormat = "tgz"
)

type BlobInfo

type BlobInfo struct {
	// MediaType is the media type of the object this schema refers to.
	MediaType string `json:"mediaType,omitempty"`

	// Digest is the digest of the targeted content.
	Digest string `json:"digest"`

	// Size specifies the size in bytes of the blob.
	Size int64 `json:"size"`
}

BlobInfo describes a blob.

type BlobResolver

type BlobResolver interface {
	Info(ctx context.Context, res v2.Resource) (*BlobInfo, error)
	Resolve(ctx context.Context, res v2.Resource, writer io.Writer) (*BlobInfo, error)
}

BlobResolver defines a resolver that can fetch blobs in a specific context defined in a component descriptor.

func AggregateBlobResolvers

func AggregateBlobResolvers(a, b BlobResolver) (BlobResolver, error)

AggregateBlobResolvers aggregates two resolvers to one by using aggregated blob resolver.

type CTF

type CTF struct {
	// contains filtered or unexported fields
}

func NewCTF

func NewCTF(fs vfs.FileSystem, ctfPath string) (*CTF, error)

NewCTF reads a CTF archive from a file. The use should call "Close" to remove all temporary files

func (*CTF) AddComponentArchive

func (ctf *CTF) AddComponentArchive(ca *ComponentArchive, format ArchiveFormat) error

AddComponentArchive adds or updates a component archive in the ctf archive.

func (*CTF) AddComponentArchiveWithName

func (ctf *CTF) AddComponentArchiveWithName(filename string, ca *ComponentArchive, format ArchiveFormat) error

AddComponentArchiveWithName adds or updates a component archive in the ctf archive. The archive is added to the ctf with the given name

func (*CTF) Close

func (ctf *CTF) Close() error

Close closes the CTF that deletes all temporary files

func (*CTF) Walk

func (ctf *CTF) Walk(walkFunc WalkFunc) error

Walk traverses through all component archives that are included in the ctf.

func (*CTF) Write

func (ctf *CTF) Write() error

Write writes the current changes back to the original ctf.

type ComponentArchive

type ComponentArchive struct {
	ComponentDescriptor *v2.ComponentDescriptor

	BlobResolver
	// contains filtered or unexported fields
}

ComponentArchive is the go representation for a CTF component artefact

func ComponentArchiveFromCTF

func ComponentArchiveFromCTF(path string) (*ComponentArchive, error)

ComponentArchiveFromCTF creates a new componet archive from a CTF tar file.

func ComponentArchiveFromCompressedCTF

func ComponentArchiveFromCompressedCTF(path string) (*ComponentArchive, error)

ComponentArchiveFromCompressedCTF creates a new component archive from a zipped CTF tar.

func ComponentArchiveFromPath

func ComponentArchiveFromPath(path string) (*ComponentArchive, error)

ComponentArchiveFromPath creates a component archive from a path

func NewComponentArchive

func NewComponentArchive(cd *v2.ComponentDescriptor, fs vfs.FileSystem) *ComponentArchive

NewComponentArchive returns a new component descriptor with a filesystem

func NewComponentArchiveFromFilesystem

func NewComponentArchiveFromFilesystem(fs vfs.FileSystem, decodeOpts ...codec.DecodeOption) (*ComponentArchive, error)

NewComponentArchiveFromFilesystem creates a new component archive from a filesystem.

func NewComponentArchiveFromTarReader

func NewComponentArchiveFromTarReader(in io.Reader) (*ComponentArchive, error)

NewComponentArchiveFromTarReader creates a new manifest builder from a input reader. todo: make the fs configurable to also use a temporary filesystem

func (*ComponentArchive) AddResource

func (ca *ComponentArchive) AddResource(res *v2.Resource, info BlobInfo, reader io.Reader) error

AddResource adds a blob resource to the current archive. If the specified resource already exists it will be overwritten.

func (*ComponentArchive) AddResourceFromResolver

func (ca *ComponentArchive) AddResourceFromResolver(ctx context.Context, res *v2.Resource, resolver BlobResolver) error

AddResourceFromResolver adds a blob resource to the current archive. If the specified resource already exists it will be overwritten.

func (*ComponentArchive) AddSource

func (ca *ComponentArchive) AddSource(src *v2.Source, info BlobInfo, reader io.Reader) error

AddSource adds a blob source to the current archive. If the specified source already exists it will be overwritten.

func (*ComponentArchive) Digest

func (ca *ComponentArchive) Digest() (string, error)

Digest returns the digest of the component archive. The digest is computed serializing the included component descriptor into json and compute sha hash.

func (*ComponentArchive) WriteTar

func (ca *ComponentArchive) WriteTar(writer io.Writer) error

WriteTar tars the current components descriptor and its artifacts.

func (*ComponentArchive) WriteTarGzip

func (ca *ComponentArchive) WriteTarGzip(writer io.Writer) error

WriteTarGzip tars the current components descriptor and its artifacts.

func (*ComponentArchive) WriteToFilesystem

func (ca *ComponentArchive) WriteToFilesystem(fs vfs.FileSystem, path string) error

WriteToFilesystem writes the current component archive to a filesystem

type ComponentArchiveBlobResolver

type ComponentArchiveBlobResolver struct {
	// contains filtered or unexported fields
}

ComponentArchiveBlobResolver implements the BlobResolver interface for "LocalFilesystemBlob" access types.

func NewComponentArchiveBlobResolver

func NewComponentArchiveBlobResolver(fs vfs.FileSystem) *ComponentArchiveBlobResolver

NewComponentArchiveBlobResolver creates new ComponentArchive blob that can resolve local filesystem references. The filesystem is expected to have its root at the component archives root so that artifacts can be resolve in "/blobs".

func (*ComponentArchiveBlobResolver) CanResolve

func (ca *ComponentArchiveBlobResolver) CanResolve(res v2.Resource) bool

func (*ComponentArchiveBlobResolver) Info

func (*ComponentArchiveBlobResolver) Resolve

func (ca *ComponentArchiveBlobResolver) Resolve(ctx context.Context, res v2.Resource, writer io.Writer) (*BlobInfo, error)

Resolve fetches the blob for a given resource and writes it to the given tar.

type ComponentResolver

type ComponentResolver interface {
	Resolve(ctx context.Context, repoCtx v2.Repository, name, version string) (*v2.ComponentDescriptor, error)
	ResolveWithBlobResolver(ctx context.Context, repoCtx v2.Repository, name, version string) (*v2.ComponentDescriptor, BlobResolver, error)
}

ComponentResolver describes a general interface to resolve a component descriptor

type ListResolver

type ListResolver struct {
	List *cdv2.ComponentDescriptorList
	// contains filtered or unexported fields
}

ListResolver describes a ComponentResolver using a list of Component Descriptors

func NewListResolver

func NewListResolver(list *cdv2.ComponentDescriptorList, resolvers ...BlobResolver) (*ListResolver, error)

NewListResolver creates a new list resolver.

func (ListResolver) Resolve

func (l ListResolver) Resolve(_ context.Context, repoCtx cdv2.Repository, name, version string) (*cdv2.ComponentDescriptor, error)

func (ListResolver) ResolveWithBlobResolver

func (l ListResolver) ResolveWithBlobResolver(ctx context.Context, repoCtx cdv2.Repository, name, version string) (*cdv2.ComponentDescriptor, BlobResolver, error)

type TypedBlobResolver

type TypedBlobResolver interface {
	BlobResolver
	// CanResolve returns whether the resolver is able to resolve the
	// resource.
	CanResolve(resource v2.Resource) bool
}

TypedBlobResolver defines a blob resolver that is able to resolves a set of access types.

type WalkFunc

type WalkFunc = func(ca *ComponentArchive) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL