Documentation
¶
Overview ¶
Package catalog provides artifact storage and retrieval for scafctl.
The catalog system manages solutions, providers, and auth handlers as OCI artifacts, enabling versioned storage, distribution, and dependency management.
Catalog Types ¶
There are two types of catalogs:
- Local catalog: Built-in catalog stored at XDG data path, always available
- Remote catalog: OCI registry-based catalog for distribution
Built-in Local Catalog ¶
The local catalog is always available and is first in resolution order. It uses the XDG-compliant path from paths.CatalogDir():
- Linux: ~/.local/share/scafctl/catalog/
- macOS: ~/.local/share/scafctl/catalog/
- Windows: %LOCALAPPDATA%\scafctl\catalog\
The local catalog stores artifacts as OCI artifacts in OCI Image Layout format, providing content-addressable storage with full OCI compatibility.
Registry ¶
The Registry manages multiple catalogs with a defined resolution order:
- Built-in local catalog (always first)
- Configured remote catalogs (in config order)
This enables seamless artifact resolution across local and remote sources.
Artifact Types ¶
Currently supported artifact types:
- Solutions: YAML configuration files (application/vnd.scafctl.solution.v1+yaml)
- Providers: go-plugin binaries exposing providers (application/vnd.scafctl.provider.v1+binary)
- Auth Handlers: go-plugin binaries exposing auth handlers (application/vnd.scafctl.auth-handler.v1+binary)
Example Usage ¶
// Create a registry with the built-in local catalog
reg, err := catalog.NewRegistry(logger)
if err != nil {
return err
}
// Build a solution into the local catalog
ref := catalog.Reference{
Kind: catalog.ArtifactKindSolution,
Name: "my-solution",
Version: semver.MustParse("1.0.0"),
}
info, err := reg.Local().Store(ctx, ref, content, nil, annotations, false)
// Resolve an artifact (checks local first, then configured catalogs)
content, info, err := reg.Fetch(ctx, ref)
Index ¶
- Constants
- Variables
- func ConfigMediaTypeForKind(kind ArtifactKind) string
- func GetTags(annotations map[string]string) []string
- func IsArtifactNotFoundError(err error) bool
- func IsExists(err error) bool
- func IsInvalidReference(err error) bool
- func IsNotFound(err error) bool
- func IsValidDigest(digest string) bool
- func IsValidName(name string) bool
- func MediaTypeForKind(kind ArtifactKind) string
- func NormalizeRegistryHost(host string) string
- type AnnotationBuilder
- type ArtifactExistsError
- type ArtifactInfo
- type ArtifactKind
- type ArtifactNotFoundError
- type Catalog
- type CopyOptions
- type CredentialStore
- type InvalidReferenceError
- type LoadResult
- type LocalCatalog
- func (c *LocalCatalog) Delete(ctx context.Context, ref Reference) error
- func (c *LocalCatalog) Exists(ctx context.Context, ref Reference) (bool, error)
- func (c *LocalCatalog) Fetch(ctx context.Context, ref Reference) ([]byte, ArtifactInfo, error)
- func (c *LocalCatalog) FetchDedup(ctx context.Context, ref Reference) (solutionYAML, manifestJSON []byte, ...)
- func (c *LocalCatalog) FetchWithBundle(ctx context.Context, ref Reference) ([]byte, []byte, ArtifactInfo, error)
- func (c *LocalCatalog) List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
- func (c *LocalCatalog) Load(ctx context.Context, inputPath string, force bool) (LoadResult, error)
- func (c *LocalCatalog) Name() string
- func (c *LocalCatalog) Path() string
- func (c *LocalCatalog) Prune(ctx context.Context) (PruneResult, error)
- func (c *LocalCatalog) Resolve(ctx context.Context, ref Reference) (ArtifactInfo, error)
- func (c *LocalCatalog) Save(ctx context.Context, name, version, outputPath string) (SaveResult, error)
- func (c *LocalCatalog) Store(ctx context.Context, ref Reference, content, bundleData []byte, ...) (ArtifactInfo, error)
- func (c *LocalCatalog) StoreDedup(ctx context.Context, ref Reference, ...) (ArtifactInfo, error)
- func (c *LocalCatalog) Tag(ctx context.Context, ref Reference, alias string) error
- type OCITarReader
- type OCITarWriter
- type PruneResult
- type Reference
- type Registry
- func (r *Registry) AddCatalog(catalog Catalog)
- func (r *Registry) Catalogs() []Catalog
- func (r *Registry) Fetch(ctx context.Context, ref Reference) ([]byte, ArtifactInfo, error)
- func (r *Registry) FetchWithBundle(ctx context.Context, ref Reference) ([]byte, []byte, ArtifactInfo, error)
- func (r *Registry) List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
- func (r *Registry) Local() *LocalCatalog
- func (r *Registry) Resolve(ctx context.Context, ref Reference) (ArtifactInfo, error)
- type RemoteCatalog
- func (c *RemoteCatalog) CopyFrom(ctx context.Context, source *LocalCatalog, ref Reference, opts CopyOptions) (ArtifactInfo, error)
- func (c *RemoteCatalog) CopyTo(ctx context.Context, ref Reference, target *LocalCatalog, opts CopyOptions) (ArtifactInfo, error)
- func (c *RemoteCatalog) Delete(ctx context.Context, ref Reference) error
- func (c *RemoteCatalog) Exists(ctx context.Context, ref Reference) (bool, error)
- func (c *RemoteCatalog) Fetch(ctx context.Context, ref Reference) ([]byte, ArtifactInfo, error)
- func (c *RemoteCatalog) FetchWithBundle(ctx context.Context, ref Reference) ([]byte, []byte, ArtifactInfo, error)
- func (c *RemoteCatalog) List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
- func (c *RemoteCatalog) Name() string
- func (c *RemoteCatalog) Registry() string
- func (c *RemoteCatalog) Repository() string
- func (c *RemoteCatalog) Resolve(ctx context.Context, ref Reference) (ArtifactInfo, error)
- func (c *RemoteCatalog) Store(ctx context.Context, ref Reference, content, bundleData []byte, ...) (ArtifactInfo, error)
- func (c *RemoteCatalog) Tag(ctx context.Context, ref Reference, alias string) error
- type RemoteCatalogConfig
- type RemoteReference
- type SaveResult
- type SolutionResolver
Constants ¶
const ( // AnnotationTitle is the human-readable title. AnnotationTitle = "org.opencontainers.image.title" // AnnotationDescription is a longer description. AnnotationDescription = "org.opencontainers.image.description" // AnnotationVersion is the version (semver). AnnotationVersion = "org.opencontainers.image.version" // AnnotationCreated is the creation timestamp (RFC 3339). AnnotationCreated = "org.opencontainers.image.created" // AnnotationAuthors is the contact for the image. AnnotationAuthors = "org.opencontainers.image.authors" // AnnotationSource is the URL to get source code. AnnotationSource = "org.opencontainers.image.source" // AnnotationDocumentation is the URL for documentation. AnnotationDocumentation = "org.opencontainers.image.documentation" // AnnotationVendor is the vendor name. AnnotationVendor = "org.opencontainers.image.vendor" // AnnotationArtifactType is the scafctl artifact type ("solution", "provider", or "auth-handler"). AnnotationArtifactType = "dev.scafctl.artifact.type" // AnnotationArtifactName is the artifact name. AnnotationArtifactName = "dev.scafctl.artifact.name" // AnnotationCategory is the solution category. AnnotationCategory = "dev.scafctl.solution.category" // AnnotationTags is a comma-separated list of tags. AnnotationTags = "dev.scafctl.solution.tags" // AnnotationMaintainers is a JSON array of maintainer objects. AnnotationMaintainers = "dev.scafctl.solution.maintainers" // AnnotationRequires is the dependency specifications (future). AnnotationRequires = "dev.scafctl.solution.requires" // AnnotationDisplayName is the human-friendly display name. AnnotationDisplayName = "dev.scafctl.solution.displayName" // AnnotationProviders is a comma-separated list of provider names (provider artifacts only). AnnotationProviders = "dev.scafctl.plugin.providers" // AnnotationPlatform is the target platform (provider/auth-handler artifacts only, e.g., "linux/amd64"). AnnotationPlatform = "dev.scafctl.plugin.platform" )
OCI annotation keys.
const ( // MediaTypeSolutionManifest is the manifest media type for solution artifacts. MediaTypeSolutionManifest = "application/vnd.oci.image.manifest.v1+json" // MediaTypeSolutionContent is the content layer media type for solution YAML. MediaTypeSolutionContent = "application/vnd.scafctl.solution.v1+yaml" // MediaTypeSolutionConfig is the config blob media type for solution metadata. MediaTypeSolutionConfig = "application/vnd.scafctl.solution.config.v1+json" // MediaTypeSolutionBundle is the content layer media type for solution bundle tar archives. MediaTypeSolutionBundle = "application/vnd.scafctl.solution.bundle.v1+tar" // MediaTypeSolutionBundleManifest is the media type for deduplicated bundle manifests (v2). MediaTypeSolutionBundleManifest = "application/vnd.scafctl.solution.bundle-manifest.v2+json" // MediaTypeSolutionBundleBlob is the media type for individual file blobs in deduplicated bundles (v2). MediaTypeSolutionBundleBlob = "application/vnd.scafctl.solution.bundle-blob.v2+octet-stream" // MediaTypeSolutionBundleSmallTar is the media type for grouped small files in deduplicated bundles (v2). MediaTypeSolutionBundleSmallTar = "application/vnd.scafctl.solution.bundle-small.v2+tar" // MediaTypeProviderManifest is the manifest media type for provider artifacts. MediaTypeProviderManifest = "application/vnd.oci.image.manifest.v1+json" // MediaTypeProviderBinary is the content layer media type for provider binaries. MediaTypeProviderBinary = "application/vnd.scafctl.provider.v1+binary" // MediaTypeProviderConfig is the config blob media type for provider metadata. MediaTypeProviderConfig = "application/vnd.scafctl.provider.config.v1+json" // MediaTypeAuthHandlerManifest is the manifest media type for auth handler artifacts. MediaTypeAuthHandlerManifest = "application/vnd.oci.image.manifest.v1+json" // MediaTypeAuthHandlerBinary is the content layer media type for auth handler binaries. MediaTypeAuthHandlerBinary = "application/vnd.scafctl.auth-handler.v1+binary" // MediaTypeAuthHandlerConfig is the config blob media type for auth handler metadata. MediaTypeAuthHandlerConfig = "application/vnd.scafctl.auth-handler.config.v1+json" )
OCI media types for scafctl artifacts.
const (
// LocalCatalogName is the name of the built-in local catalog.
LocalCatalogName = "local"
)
const OCILayoutVersion = "1.0.0"
OCILayoutVersion is the OCI image layout version.
Variables ¶
var ErrArtifactExists = errors.New("artifact already exists")
ErrArtifactExists is returned when storing an artifact that already exists.
var ErrArtifactNotFound = errors.New("artifact not found")
ErrArtifactNotFound is returned when an artifact cannot be found.
var ErrInvalidReference = errors.New("invalid reference")
ErrInvalidReference is returned when a reference is malformed.
Functions ¶
func ConfigMediaTypeForKind ¶
func ConfigMediaTypeForKind(kind ArtifactKind) string
ConfigMediaTypeForKind returns the config media type for an artifact kind.
func IsArtifactNotFoundError ¶
IsArtifactNotFoundError is an alias for IsNotFound.
func IsInvalidReference ¶
IsInvalidReference returns true if the error indicates an invalid reference.
func IsNotFound ¶
IsNotFound returns true if the error indicates an artifact was not found.
func IsValidDigest ¶
IsValidDigest checks if a string is a valid OCI digest.
func IsValidName ¶
IsValidName checks if a name follows the naming convention. Names must be lowercase alphanumeric with hyphens, starting with a letter.
func MediaTypeForKind ¶
func MediaTypeForKind(kind ArtifactKind) string
MediaTypeForKind returns the content media type for an artifact kind.
func NormalizeRegistryHost ¶
NormalizeRegistryHost normalizes common registry hostnames.
Types ¶
type AnnotationBuilder ¶
type AnnotationBuilder struct {
// contains filtered or unexported fields
}
AnnotationBuilder helps construct annotation maps.
func NewAnnotationBuilder ¶
func NewAnnotationBuilder() *AnnotationBuilder
NewAnnotationBuilder creates a new annotation builder.
func (*AnnotationBuilder) Build ¶
func (b *AnnotationBuilder) Build() map[string]string
Build returns the annotation map.
func (*AnnotationBuilder) Set ¶
func (b *AnnotationBuilder) Set(key, value string) *AnnotationBuilder
Set adds an annotation if the value is non-empty.
func (*AnnotationBuilder) SetTags ¶
func (b *AnnotationBuilder) SetTags(tags []string) *AnnotationBuilder
SetTags adds tags as a comma-separated annotation.
type ArtifactExistsError ¶
ArtifactExistsError provides details about a duplicate artifact.
func (*ArtifactExistsError) Error ¶
func (e *ArtifactExistsError) Error() string
Error implements the error interface.
func (*ArtifactExistsError) Unwrap ¶
func (e *ArtifactExistsError) Unwrap() error
Unwrap returns the base error for errors.Is support.
type ArtifactInfo ¶
type ArtifactInfo struct {
// Reference is the artifact identifier.
Reference Reference `json:"reference" yaml:"reference" doc:"Artifact reference"`
// Digest is the content digest (sha256:...).
Digest string `json:"digest" yaml:"digest" doc:"Content digest"`
// CreatedAt is when the artifact was stored.
CreatedAt time.Time `json:"createdAt" yaml:"createdAt" doc:"Storage timestamp"`
// Size is the artifact size in bytes.
Size int64 `json:"size" yaml:"size" doc:"Size in bytes"`
// Annotations are OCI annotations from the manifest.
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty" doc:"OCI annotations"`
// Catalog is the name of the catalog this artifact came from.
Catalog string `json:"catalog" yaml:"catalog" doc:"Source catalog name"`
}
ArtifactInfo contains metadata about a stored artifact.
type ArtifactKind ¶
type ArtifactKind string
ArtifactKind represents the type of artifact stored in the catalog.
const ( // ArtifactKindSolution represents a solution artifact. ArtifactKindSolution ArtifactKind = "solution" // ArtifactKindProvider represents a provider artifact (go-plugin binary exposing providers). ArtifactKindProvider ArtifactKind = "provider" // ArtifactKindAuthHandler represents an auth handler artifact (go-plugin binary exposing auth handlers). ArtifactKindAuthHandler ArtifactKind = "auth-handler" )
func ParseArtifactKind ¶
func ParseArtifactKind(s string) (ArtifactKind, bool)
ParseArtifactKind parses a string into an ArtifactKind. Returns empty string and false if the input is not a valid kind.
func ParseArtifactKindFromPlural ¶
func ParseArtifactKindFromPlural(s string) (ArtifactKind, bool)
ParseArtifactKindFromPlural parses a pluralized path segment into an ArtifactKind. E.g., "solutions" -> ArtifactKindSolution, "providers" -> ArtifactKindProvider
func (ArtifactKind) IsValid ¶
func (k ArtifactKind) IsValid() bool
IsValid returns true if the artifact kind is valid.
func (ArtifactKind) Plural ¶
func (k ArtifactKind) Plural() string
Plural returns the pluralized form of the artifact kind (for repository paths).
func (ArtifactKind) String ¶
func (k ArtifactKind) String() string
String returns the string representation of the artifact kind.
type ArtifactNotFoundError ¶
type ArtifactNotFoundError struct {
Reference Reference
Catalog string // Optional: which catalog was checked
}
ArtifactNotFoundError provides details about a missing artifact.
func (*ArtifactNotFoundError) Error ¶
func (e *ArtifactNotFoundError) Error() string
Error implements the error interface.
func (*ArtifactNotFoundError) Unwrap ¶
func (e *ArtifactNotFoundError) Unwrap() error
Unwrap returns the base error for errors.Is support.
type Catalog ¶
type Catalog interface {
// Name returns the catalog identifier (e.g., "local", "company-registry").
Name() string
// Store saves an artifact to the catalog.
// For solutions with bundled files, bundleData contains the tar archive.
// If bundleData is nil, only the primary content layer is stored.
// Returns ErrArtifactExists if the version already exists (use force to overwrite).
Store(ctx context.Context, ref Reference, content, bundleData []byte, annotations map[string]string, force bool) (ArtifactInfo, error)
// Fetch retrieves an artifact's primary content from the catalog.
// Returns ErrArtifactNotFound if the artifact doesn't exist.
Fetch(ctx context.Context, ref Reference) ([]byte, ArtifactInfo, error)
// FetchWithBundle retrieves an artifact's primary content and bundle layer.
// The bundle layer contains bundled files as a tar archive.
// If the artifact has no bundle layer, bundleData is nil.
// Returns ErrArtifactNotFound if the artifact doesn't exist.
FetchWithBundle(ctx context.Context, ref Reference) (content, bundleData []byte, info ArtifactInfo, err error)
// Resolve finds the best matching version for a reference.
// If no version is specified, returns the highest semver version.
// Returns ErrArtifactNotFound if no matching artifact exists.
Resolve(ctx context.Context, ref Reference) (ArtifactInfo, error)
// List returns all artifacts matching the criteria.
// If name is empty, returns all artifacts of the specified kind.
List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
// Exists checks if an artifact exists in the catalog.
Exists(ctx context.Context, ref Reference) (bool, error)
// Delete removes an artifact from the catalog.
// Returns ErrArtifactNotFound if the artifact doesn't exist.
Delete(ctx context.Context, ref Reference) error
}
Catalog defines the interface for artifact storage. Both local and remote catalogs implement this interface.
type CopyOptions ¶
type CopyOptions struct {
// TargetName overrides the artifact name in the target catalog
TargetName string
// Force overwrites existing artifacts
Force bool
// OnProgress reports copy progress
OnProgress func(desc ocispec.Descriptor)
}
CopyOptions configures a copy operation between catalogs.
type CredentialStore ¶
type CredentialStore struct {
// contains filtered or unexported fields
}
CredentialStore provides OCI registry credentials from docker config. It supports both static credentials and docker credential helpers.
func NewCredentialStore ¶
func NewCredentialStore(logger logr.Logger) (*CredentialStore, error)
NewCredentialStore creates a credential store from the default docker config. It looks for config in the following order: 1. $DOCKER_CONFIG/config.json 2. ~/.docker/config.json 3. $XDG_RUNTIME_DIR/containers/auth.json (podman rootless) 4. ~/.config/containers/auth.json (podman) 5. /run/containers/$UID/auth.json (podman rootless fallback)
func (*CredentialStore) Credential ¶
func (c *CredentialStore) Credential(ctx context.Context, host string) (auth.Credential, error)
Credential returns the auth credential for a registry host. This implements the auth.CredentialFunc signature for oras-go.
func (*CredentialStore) CredentialFunc ¶
func (c *CredentialStore) CredentialFunc() auth.CredentialFunc
CredentialFunc returns an auth.CredentialFunc for use with oras-go.
type InvalidReferenceError ¶
InvalidReferenceError provides details about an invalid reference.
func (*InvalidReferenceError) Error ¶
func (e *InvalidReferenceError) Error() string
Error implements the error interface.
func (*InvalidReferenceError) Unwrap ¶
func (e *InvalidReferenceError) Unwrap() error
Unwrap returns the base error for errors.Is support.
type LoadResult ¶
type LoadResult struct {
// Reference is the artifact that was loaded.
Reference Reference `json:"reference" yaml:"reference"`
// Digest is the manifest digest.
Digest string `json:"digest" yaml:"digest"`
// Size is the artifact content size in bytes.
Size int64 `json:"size" yaml:"size"`
// CreatedAt is when the artifact was originally created.
CreatedAt time.Time `json:"createdAt" yaml:"createdAt"`
}
LoadResult contains information about the load operation.
type LocalCatalog ¶
type LocalCatalog struct {
// contains filtered or unexported fields
}
LocalCatalog implements Catalog using a local OCI layout store.
func NewLocalCatalog ¶
func NewLocalCatalog(logger logr.Logger) (*LocalCatalog, error)
NewLocalCatalog creates a catalog at the XDG data path. The path is determined by paths.CatalogDir().
func NewLocalCatalogAt ¶
func NewLocalCatalogAt(path string, logger logr.Logger) (*LocalCatalog, error)
NewLocalCatalogAt creates a catalog at a custom path. Use this for testing or custom installations.
func (*LocalCatalog) Delete ¶
func (c *LocalCatalog) Delete(ctx context.Context, ref Reference) error
Delete removes an artifact from the catalog.
func (*LocalCatalog) Fetch ¶
func (c *LocalCatalog) Fetch(ctx context.Context, ref Reference) ([]byte, ArtifactInfo, error)
Fetch retrieves an artifact from the catalog.
func (*LocalCatalog) FetchDedup ¶
func (c *LocalCatalog) FetchDedup(ctx context.Context, ref Reference) (solutionYAML, manifestJSON []byte, layerFetcher func(layer int) ([]byte, error), info ArtifactInfo, err error)
FetchDedup retrieves a deduplicated (v2) bundle by fetching all layers. Returns the solution YAML, bundle manifest JSON, and a layer fetcher that can retrieve individual layers by index.
func (*LocalCatalog) FetchWithBundle ¶
func (c *LocalCatalog) FetchWithBundle(ctx context.Context, ref Reference) ([]byte, []byte, ArtifactInfo, error)
FetchWithBundle retrieves an artifact's primary content and bundle layer. If the artifact has no bundle layer, bundleData is nil.
func (*LocalCatalog) List ¶
func (c *LocalCatalog) List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
List returns all artifacts matching the criteria.
func (*LocalCatalog) Load ¶
func (c *LocalCatalog) Load(ctx context.Context, inputPath string, force bool) (LoadResult, error)
Load imports an artifact from an OCI Image Layout tar archive. Returns ErrArtifactExists if artifact already exists and force is false.
func (*LocalCatalog) Path ¶
func (c *LocalCatalog) Path() string
Path returns the catalog directory path.
func (*LocalCatalog) Prune ¶
func (c *LocalCatalog) Prune(ctx context.Context) (PruneResult, error)
Prune removes orphaned blobs and manifests from the catalog. Orphaned content is any blob or manifest not referenced by a tagged artifact.
func (*LocalCatalog) Resolve ¶
func (c *LocalCatalog) Resolve(ctx context.Context, ref Reference) (ArtifactInfo, error)
Resolve finds the best matching version for a reference.
func (*LocalCatalog) Save ¶
func (c *LocalCatalog) Save(ctx context.Context, name, version, outputPath string) (SaveResult, error)
Save exports an artifact to an OCI Image Layout tar archive. If version is empty, exports the latest version.
func (*LocalCatalog) Store ¶
func (c *LocalCatalog) Store(ctx context.Context, ref Reference, content, bundleData []byte, annotations map[string]string, force bool) (ArtifactInfo, error)
Store saves an artifact to the catalog. For solutions with bundled files, bundleData contains the tar archive. If bundleData is nil, only the primary content layer is stored.
func (*LocalCatalog) StoreDedup ¶
func (c *LocalCatalog) StoreDedup(ctx context.Context, ref Reference, solutionYAML, manifestJSON, smallTar []byte, blobLayers [][]byte, annotations map[string]string, force bool) (ArtifactInfo, error)
StoreDedup saves a solution with content-addressable deduplicated layers. manifestJSON is the bundle manifest (v2), smallTar is grouped small files, and blobLayers are individual large file blobs with their media types.
type OCITarReader ¶
type OCITarReader struct {
// contains filtered or unexported fields
}
OCITarReader reads OCI Image Layout format from a tar archive.
func NewOCITarReader ¶
func NewOCITarReader(r io.Reader) (*OCITarReader, error)
NewOCITarReader reads an OCI tar archive into memory.
func (*OCITarReader) Blobs ¶
func (r *OCITarReader) Blobs() map[string][]byte
Blobs returns all blobs in the archive.
func (*OCITarReader) GetBlob ¶
func (r *OCITarReader) GetBlob(digest string) ([]byte, bool)
GetBlob returns a specific blob by digest.
func (*OCITarReader) HasValidLayout ¶
func (r *OCITarReader) HasValidLayout() bool
HasValidLayout returns true if the archive has a valid oci-layout file.
type OCITarWriter ¶
type OCITarWriter struct {
// contains filtered or unexported fields
}
OCITarWriter writes OCI Image Layout format to a tar archive.
func NewOCITarWriter ¶
func NewOCITarWriter(w io.Writer) *OCITarWriter
NewOCITarWriter creates a new OCI tar writer.
func (*OCITarWriter) WriteBlob ¶
func (w *OCITarWriter) WriteBlob(digestStr string, data []byte) error
WriteBlob writes a blob to the blobs/sha256/ directory.
func (*OCITarWriter) WriteIndex ¶
func (w *OCITarWriter) WriteIndex(index ocispec.Index) error
WriteIndex writes the index.json file.
func (*OCITarWriter) WriteOCILayout ¶
func (w *OCITarWriter) WriteOCILayout() error
WriteOCILayout writes the oci-layout file.
type PruneResult ¶
type PruneResult struct {
// RemovedManifests is the number of orphaned manifests removed
RemovedManifests int `json:"removedManifests" yaml:"removedManifests"`
// RemovedBlobs is the number of orphaned blobs removed
RemovedBlobs int `json:"removedBlobs" yaml:"removedBlobs"`
// ReclaimedBytes is the total bytes freed
ReclaimedBytes int64 `json:"reclaimedBytes" yaml:"reclaimedBytes"`
}
PruneResult contains statistics from a prune operation.
type Reference ¶
type Reference struct {
// Kind is the type of artifact (solution, provider, or auth-handler).
Kind ArtifactKind `json:"kind" yaml:"kind" doc:"Artifact type"`
// Name is the artifact identifier (e.g., "my-solution").
Name string `json:"name" yaml:"name" doc:"Artifact name"`
// Version is the semantic version (e.g., 1.2.3). Nil means "latest".
Version *semver.Version `json:"version,omitempty" yaml:"version,omitempty" doc:"Semantic version"`
// Digest is the content digest for pinning (e.g., "sha256:abc123...").
// If set, takes precedence over Version for resolution.
Digest string `json:"digest,omitempty" yaml:"digest,omitempty" doc:"Content digest for pinning"`
}
Reference uniquely identifies an artifact in the catalog.
func MustParseReference ¶
func MustParseReference(kind ArtifactKind, input string) Reference
MustParseReference parses a reference string and panics on error. Only use in tests or with known-valid input.
func ParseReference ¶
func ParseReference(kind ArtifactKind, input string) (Reference, error)
ParseReference parses a reference string into a Reference struct. Supported formats:
- "name" - artifact name only (version resolved to latest)
- "name@1.2.3" - artifact with specific version
- "name@sha256:abc..." - artifact with specific digest
func (Reference) HasVersion ¶
HasVersion returns true if the reference has a version specified.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages multiple catalogs and provides unified access. The local catalog is always first in resolution order.
func NewRegistry ¶
NewRegistry creates a registry with the built-in local catalog.
func NewRegistryWithLocal ¶
func NewRegistryWithLocal(local *LocalCatalog, logger logr.Logger) *Registry
NewRegistryWithLocal creates a registry with a custom local catalog. Use for testing with a custom catalog directory.
func (*Registry) AddCatalog ¶
AddCatalog adds a catalog to the registry. Catalogs are searched in the order they are added (after local).
func (*Registry) FetchWithBundle ¶
func (r *Registry) FetchWithBundle(ctx context.Context, ref Reference) ([]byte, []byte, ArtifactInfo, error)
FetchWithBundle retrieves an artifact with its bundle layer from the first catalog that has it.
func (*Registry) List ¶
func (r *Registry) List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
List returns all artifacts matching the criteria from all catalogs.
func (*Registry) Local ¶
func (r *Registry) Local() *LocalCatalog
Local returns the built-in local catalog.
type RemoteCatalog ¶
type RemoteCatalog struct {
// contains filtered or unexported fields
}
RemoteCatalog implements Catalog interface for OCI registries.
func NewRemoteCatalog ¶
func NewRemoteCatalog(cfg RemoteCatalogConfig) (*RemoteCatalog, error)
NewRemoteCatalog creates a remote catalog client.
func (*RemoteCatalog) CopyFrom ¶
func (c *RemoteCatalog) CopyFrom(ctx context.Context, source *LocalCatalog, ref Reference, opts CopyOptions) (ArtifactInfo, error)
CopyFrom copies an artifact from a local catalog to this remote catalog.
func (*RemoteCatalog) CopyTo ¶
func (c *RemoteCatalog) CopyTo(ctx context.Context, ref Reference, target *LocalCatalog, opts CopyOptions) (ArtifactInfo, error)
CopyTo copies an artifact from this remote catalog to a local catalog.
func (*RemoteCatalog) Delete ¶
func (c *RemoteCatalog) Delete(ctx context.Context, ref Reference) error
Delete removes an artifact from the catalog.
func (*RemoteCatalog) Fetch ¶
func (c *RemoteCatalog) Fetch(ctx context.Context, ref Reference) ([]byte, ArtifactInfo, error)
Fetch retrieves an artifact from the remote catalog.
func (*RemoteCatalog) FetchWithBundle ¶
func (c *RemoteCatalog) FetchWithBundle(ctx context.Context, ref Reference) ([]byte, []byte, ArtifactInfo, error)
FetchWithBundle retrieves an artifact's primary content and bundle layer. If the artifact has no bundle layer, bundleData is nil.
func (*RemoteCatalog) List ¶
func (c *RemoteCatalog) List(ctx context.Context, kind ArtifactKind, name string) ([]ArtifactInfo, error)
List returns all artifacts matching the criteria.
func (*RemoteCatalog) Name ¶
func (c *RemoteCatalog) Name() string
Name returns the catalog identifier.
func (*RemoteCatalog) Registry ¶
func (c *RemoteCatalog) Registry() string
Registry returns the registry address.
func (*RemoteCatalog) Repository ¶
func (c *RemoteCatalog) Repository() string
Repository returns the base repository path.
func (*RemoteCatalog) Resolve ¶
func (c *RemoteCatalog) Resolve(ctx context.Context, ref Reference) (ArtifactInfo, error)
Resolve finds the best matching version for a reference.
func (*RemoteCatalog) Store ¶
func (c *RemoteCatalog) Store(ctx context.Context, ref Reference, content, bundleData []byte, annotations map[string]string, force bool) (ArtifactInfo, error)
Store saves an artifact to the remote catalog. For solutions with bundled files, bundleData contains the tar archive. If bundleData is nil, only the primary content layer is stored.
type RemoteCatalogConfig ¶
type RemoteCatalogConfig struct {
// Name is the catalog identifier (e.g., "company-registry")
Name string
// RegistryURL is the registry address (e.g., "ghcr.io", "registry.example.com")
Registry string
// Repository is the base repository path (e.g., "myorg/scafctl")
Repository string
// CredentialStore provides authentication credentials
CredentialStore *CredentialStore
// Insecure allows HTTP connections (for testing)
Insecure bool
// Logger for logging operations
Logger logr.Logger
}
RemoteCatalogConfig holds configuration for creating a remote catalog.
type RemoteReference ¶
type RemoteReference struct {
// Registry is the registry host (e.g., "ghcr.io", "docker.io")
Registry string
// Repository is the repository path (e.g., "myorg/scafctl")
Repository string
// Kind is the artifact kind (solution, provider, or auth-handler)
Kind ArtifactKind
// Name is the artifact name
Name string
// Tag is the version tag or digest
Tag string
}
RemoteReference represents a parsed remote registry reference.
func ParseRemoteReference ¶
func ParseRemoteReference(input string) (*RemoteReference, error)
ParseRemoteReference parses a full remote reference URL. Supported formats:
- "ghcr.io/myorg/scafctl/solutions/my-solution@1.0.0"
- "oci://ghcr.io/myorg/scafctl/solutions/my-solution@1.0.0"
- "docker.io/myorg/my-solution:1.0.0" (Docker Hub style)
Returns the registry, repository, name, and version/tag.
func (*RemoteReference) String ¶
func (r *RemoteReference) String() string
String returns the full remote reference string.
func (*RemoteReference) ToReference ¶
func (r *RemoteReference) ToReference() (Reference, error)
ToReference converts a RemoteReference to a Reference.
type SaveResult ¶
type SaveResult struct {
// Reference is the artifact that was saved.
Reference Reference `json:"reference" yaml:"reference"`
// OutputPath is the path to the created archive.
OutputPath string `json:"outputPath" yaml:"outputPath"`
// Size is the size of the archive in bytes.
Size int64 `json:"size" yaml:"size"`
// Digest is the manifest digest.
Digest string `json:"digest" yaml:"digest"`
}
SaveResult contains information about the save operation.
type SolutionResolver ¶
type SolutionResolver struct {
// contains filtered or unexported fields
}
SolutionResolver wraps a Catalog to provide solution fetching by name[@version]. It implements the CatalogResolver interface from pkg/solution/get.
func NewSolutionResolver ¶
func NewSolutionResolver(catalog Catalog, logger logr.Logger) *SolutionResolver
NewSolutionResolver creates a resolver that fetches solutions from the given catalog.
func (*SolutionResolver) FetchSolution ¶
func (r *SolutionResolver) FetchSolution(ctx context.Context, nameWithVersion string) ([]byte, error)
FetchSolution retrieves a solution from the catalog by name[@version]. The input format is "name" or "name@version" (e.g., "my-solution" or "my-solution@1.2.3"). Returns the solution content as bytes.
func (*SolutionResolver) FetchSolutionWithBundle ¶
func (r *SolutionResolver) FetchSolutionWithBundle(ctx context.Context, nameWithVersion string) ([]byte, []byte, error)
FetchSolutionWithBundle retrieves a solution and its bundle from the catalog by name[@version]. The input format is "name" or "name@version" (e.g., "my-solution" or "my-solution@1.2.3"). Returns the solution content bytes, bundle tar bytes (nil if no bundle), and any error.