Documentation
¶
Index ¶
- Constants
- Variables
- func BlobPath(name string) string
- func ExtractTarToFs(fs vfs.FileSystem, in io.Reader) error
- type AggregatedBlobResolver
- type ArchiveFormat
- type BlobInfo
- type BlobResolver
- type CTF
- func (ctf *CTF) AddComponentArchive(ca *ComponentArchive, format ArchiveFormat) error
- func (ctf *CTF) AddComponentArchiveWithName(filename string, ca *ComponentArchive, format ArchiveFormat) error
- func (ctf *CTF) Close() error
- func (ctf *CTF) Walk(walkFunc WalkFunc) error
- func (ctf *CTF) Write() error
- type ComponentArchive
- func ComponentArchiveFromCTF(path string) (*ComponentArchive, error)
- func ComponentArchiveFromCompressedCTF(path string) (*ComponentArchive, error)
- func ComponentArchiveFromPath(path string) (*ComponentArchive, error)
- func NewComponentArchive(cd *v2.ComponentDescriptor, fs vfs.FileSystem) *ComponentArchive
- func NewComponentArchiveFromFilesystem(fs vfs.FileSystem, decodeOpts ...codec.DecodeOption) (*ComponentArchive, error)
- func NewComponentArchiveFromTarReader(in io.Reader) (*ComponentArchive, error)
- func (ca *ComponentArchive) AddResource(res *v2.Resource, info BlobInfo, reader io.Reader) error
- func (ca *ComponentArchive) AddResourceFromResolver(ctx context.Context, res *v2.Resource, resolver BlobResolver) error
- func (ca *ComponentArchive) AddSource(src *v2.Source, info BlobInfo, reader io.Reader) error
- func (ca *ComponentArchive) Digest() (string, error)
- func (ca *ComponentArchive) WriteTar(writer io.Writer) error
- func (ca *ComponentArchive) WriteTarGzip(writer io.Writer) error
- func (ca *ComponentArchive) WriteToFilesystem(fs vfs.FileSystem, path string) error
- type ComponentArchiveBlobResolver
- type ComponentResolver
- type ListResolver
- type TypedBlobResolver
- type WalkFunc
Constants ¶
const ArtefactDescriptorFileName = "artefact-descriptor.yaml"
ArtefactDescriptorFileName is the name of the artefact-descriptor file.
const BlobsDirectoryName = "blobs"
BlobsDirectoryName is the name of the blob directory in the tar.
const ComponentDescriptorFileName = "component-descriptor.yaml"
ComponentDescriptorFileName is the name of the component-descriptor file.
const ManifestFileName = "manifest.json"
ManifestFileName is the name of the manifest json file.
Variables ¶
var ErrBlobResolverNotDefinedError = errors.New("BlobResolverNotDefined")
var ErrNotFoundError = errors.New("ComponentDescriptorNotFound")
var ErrUnsupportedResolveType = errors.New("UnsupportedResolveType")
Functions ¶
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.
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
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 ¶
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 ¶
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
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